Эх сурвалжийг харах

添加了拦截器,修改了部分代码问题

Administrator 2 жил өмнө
parent
commit
6e8f79f0ec

+ 2 - 8
.test/req.http

@@ -1,10 +1,4 @@
-#GET http://localhost:8080/api/goods/all
-#Accept: application/json
-
-###
-PUT http://localhost:8080/api/user/name?name=666
-Content-Type: application/json
-Auth-Sign:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTQ5Nzc1MDcsImlzcyI6IjEifQ.Ez8HbEJICdLBy_rDep7dA-CB1k77hTTfwx_7LOFACZc
-
+GET http://localhost:8182/api/test/get
+Accept: application/json
 
 ###

+ 1 - 7
data/dao/Login.go

@@ -7,7 +7,7 @@ import (
 	"fmt"
 )
 
-func Logins(username, password string) (domain.ManageUser, error) {
+func BackLogins(username, password string) (domain.ManageUser, error) {
 	user := domain.ManageUser{}
 	var err error
 	fmt.Println("username", username, "password", password)
@@ -23,9 +23,3 @@ func Logins(username, password string) (domain.ManageUser, error) {
 	}
 	return domain.ManageUser{}, err
 }
-
-func Md5_KKC(str string) string {
-	hash := md5.New()
-	hash.Write([]byte("kkc-" + str))
-	return fmt.Sprintf("%x", hash.Sum(nil))
-}

+ 4 - 4
user/userdao.go → data/dao/Userdao.go

@@ -1,4 +1,4 @@
-package user
+package dao
 
 import (
 	"crypto/md5"
@@ -9,7 +9,7 @@ import (
 	"strconv"
 )
 
-func logins(username, password, t string) (configs.User, error) {
+func Logins(username, password, t string) (configs.User, error) {
 	user := configs.User{}
 	var err error
 	fmt.Println("username", username, "password", password)
@@ -30,7 +30,7 @@ func logins(username, password, t string) (configs.User, error) {
 	}
 	return configs.User{}, err
 }
-func sendSms(matched bool, username string) string {
+func SendSms(matched bool, username string) string {
 	mins := big.NewInt(100000)
 	maxs := big.NewInt(999999)
 	randomNum := share.RandomInt(mins, maxs)
@@ -67,7 +67,7 @@ func GetUserByPhoneOrEmail(phone, email string) (bool, error) {
 }
 
 // 判断手机号数量
-func existsPhone(phone string) (bool, error) {
+func ExistsPhone(phone string) (bool, error) {
 	count, err := configs.Engine.Table("user").Where("phone = ?", phone).Count()
 	if err != nil {
 		return false, err


BIN
file.zip


BIN
file/resources/avatar.jpg


+ 1 - 9
main.go

@@ -3,8 +3,6 @@ package main
 import (
 	"demo/configs"
 	"demo/router"
-	"demo/share"
-	"demo/user"
 	"github.com/gin-gonic/gin"
 )
 
@@ -14,16 +12,10 @@ func init() {
 func main() {
 	runGin()
 }
+
 func runGin() {
 	Router := gin.Default()
-
 	apiGroup := Router.Group("/api")
-
-	user.UserRouth(apiGroup)
-
 	router.InitRouter(apiGroup)
-	apiGroup.GET("/ping", share.JwtMiddleware(), func(context *gin.Context) {
-		context.String(200, "pong")
-	})
 	Router.Run(":8182")
 }

+ 10 - 36
router/BackRouter.go

@@ -18,17 +18,19 @@ import (
 func BackRouter(engine *gin.RouterGroup) {
 	user := engine.Group("/back")
 	{
-		user.POST("/login", login)
-		user.GET("/code", VerificationCode)
-		user.GET("/state", GetBackUserState)
+		user.POST("/login", BackLogin)
+		user.GET("/code", VerificationBackCode)
+	}
+	user.Use(LoginInterceptor())
+	{
 		//获取用户信息
-
+		user.GET("/state", GetBackUserState)
 	}
 }
 
 var ctx = context.Background()
 
-func login(c *gin.Context) {
+func BackLogin(c *gin.Context) {
 	data := share.GetJsonAnyParam(c)
 	username, _ := data("username")
 	password, _ := data("password")
@@ -41,7 +43,7 @@ func login(c *gin.Context) {
 		return
 	}
 	// 定义正则表达式
-	user, err := dao.Logins(cast.ToString(username), cast.ToString(password))
+	user, err := dao.BackLogins(cast.ToString(username), cast.ToString(password))
 
 	if err == nil && user.Id != 0 {
 		fmt.Println("用户登录成功!!!")
@@ -57,37 +59,9 @@ func login(c *gin.Context) {
 		c.JSON(http.StatusOK, CreateResultError(401, "用户密码错误!!!"))
 	}
 }
-func isLogin(c *gin.Context) {
-	data := share.GetJsonAnyParam(c)
-	username, _ := data("username")
-	password, _ := data("password")
-	code, _ := data("code")
-	codeMap := cast.ToStringMapString(code)
-	//判断验证码是否正确
-	redisCode := configs.RedisDb.Get(ctx, fmt.Sprint("VerificationCode_", codeMap["id"])).String()
-	if redisCode != codeMap["value"] {
-		c.JSON(http.StatusOK, CreateResultError(400, "验证码错误!!!"))
-		return
-	}
-	// 定义正则表达式
-	user, err := dao.Logins(cast.ToString(username), cast.ToString(password))
-	fmt.Println("user:", user)
-	if err == nil && user.Id != 0 {
-		fmt.Println("用户登录成功!!!")
-		token, err := share.GenerateToken("back_" + cast.ToString(user.Id))
-		if err == nil {
-			c.Header("auth-sign", token)
-			c.JSON(http.StatusOK, CreateResultData(map[string]string{"token": token}))
-		} else {
-			c.JSON(http.StatusOK, CreateResultError(400, "生成token失败!!!"))
-		}
-	} else {
-		fmt.Println("用户登录失败!!!")
-		c.JSON(http.StatusOK, CreateResultError(401, "用户密码错误!!!"))
-	}
-}
 
-func VerificationCode(c *gin.Context) {
+// VerificationBackCode 获取后台验证码登录
+func VerificationBackCode(c *gin.Context) {
 	// 配置
 	driver := base64Captcha.NewDriverDigit(80, 240, 4, 0.5, 80)
 	store := base64Captcha.DefaultMemStore

+ 2 - 0
router/DetailRouter.go

@@ -9,10 +9,12 @@ import (
 func DetailRouter(engine *gin.RouterGroup) {
 	user := engine.Group("/detail")
 	{
+		//获取文章详情
 		user.GET("/:id", GetDetailData)
 	}
 }
 
+// GetDetailData 获取文章详情
 func GetDetailData(c *gin.Context) {
 	id, err2 := strconv.Atoi(c.Param("id"))
 	if err2 != nil {

+ 2 - 1
router/FileRouter.go

@@ -14,10 +14,11 @@ var (
 )
 
 func FileRouter(engine *gin.RouterGroup) {
-	//文件静态资源
+	//文件静态资源,可以直接访问静态资源文件
 	engine.StaticFS("/static", http.Dir("file/resources"))
 	user := engine.Group("/file")
 	{
+		//文章上传
 		user.POST("/upload.bat", uploadHandler)
 	}
 }

+ 26 - 0
router/Interceptor.go

@@ -0,0 +1,26 @@
+package router
+
+import (
+	"fmt"
+	"github.com/gin-gonic/gin"
+)
+
+func LoginInterceptor() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		id := GetUserIdByToken(c)
+		fmt.Println("拦截器", id)
+		if id == 0 {
+			fmt.Println("拦截器:用户未登录")
+			//这里终止后续请求访问
+			c.Abort()
+			return
+		}
+	}
+}
+func LogInterceptor() gin.HandlerFunc {
+	return func(c *gin.Context) {
+		fmt.Println("日志系统")
+		c.Next()
+		fmt.Println("日志系统666")
+	}
+}

+ 1 - 0
router/OrderRouter.go

@@ -15,6 +15,7 @@ import (
 func OrderRouter(engine *gin.RouterGroup) {
 	order := engine.Group("/order")
 	{
+		//根据用户登录id获取用户登录信息
 		order.POST("/submit", GetOrderData)
 	}
 }

+ 9 - 1
router/Router.go

@@ -5,10 +5,18 @@ import (
 )
 
 func InitRouter(apiGroup *gin.RouterGroup) {
+	apiGroup.Use(LogInterceptor())
+	//用户,包含用户后台
+	UserRouth(apiGroup)
+	//文章详情页
 	DetailRouter(apiGroup)
+	//文件上传下载
 	FileRouter(apiGroup)
+	//测试
 	TestRouth(apiGroup)
-	UserRouth(apiGroup)
+	//订单,支付
 	OrderRouter(apiGroup)
+	//-------------------
+	//后台管理系统
 	BackRouter(apiGroup)
 }

+ 5 - 1
router/TestRouter.go

@@ -1,9 +1,12 @@
 package router
 
-import "github.com/gin-gonic/gin"
+import (
+	"github.com/gin-gonic/gin"
+)
 
 func TestRouth(engine *gin.RouterGroup) {
 	user := engine.Group("/test")
+	user.Use(LoginInterceptor())
 	{
 		user.GET("/get", testGet)
 		user.POST("/post", testPost)
@@ -11,6 +14,7 @@ func TestRouth(engine *gin.RouterGroup) {
 		user.DELETE("/delete", testDelete)
 
 	}
+
 }
 
 func testGet(c *gin.Context) {

+ 348 - 5
router/UserRouter.go

@@ -4,20 +4,44 @@ import (
 	"demo/configs"
 	"demo/data/dao"
 	"demo/data/dao/manage"
+	"demo/data/domain"
 	"demo/data/domain/vo"
 	"demo/share"
+	"demo/util"
 	"fmt"
 	"github.com/gin-gonic/gin"
+	"github.com/mojocn/base64Captcha"
 	"github.com/spf13/cast"
+	"log"
+	"math/big"
+	"net/http"
+	"regexp"
+	"strconv"
+	"time"
 )
 
 func UserRouth(engine *gin.RouterGroup) {
 	user := engine.Group("/user")
 	{
+		//获取用户基本信息
 		user.GET("/info", GetUserInfo)
-		user.GET("/wallet", GetUserPurse)
+		//获取用户钱包
+		user.GET("/wallet", GetUserWallet)
+		//修改名字
 		user.PUT("/name", SetNameValue)
+		//获取用户的订单信息
 		user.POST("/order", GetUserOrder)
+		//用户登录
+		user.POST("/login", login)
+		//注册
+		user.POST("/register", register)
+
+		//发送邮箱注册验证码
+		user.POST("/registerCode", registerCode)
+		//发送验证码
+		user.POST("/sendSms", SendVerificationCode)
+		//图片验证码
+		user.GET("/captcha", VerificationCode)
 	}
 }
 
@@ -39,12 +63,10 @@ func GetUserInfo(c *gin.Context) {
 		c.JSON(200, CreateResultError(401, "用户未登录"))
 		return
 	}
-	c.JSON(200, CreateResultData(map[string]any{
-		"info": userInfo,
-	}))
+	c.JSON(200, CreateResultData(userInfo))
 }
 
-func GetUserPurse(c *gin.Context) {
+func GetUserWallet(c *gin.Context) {
 	id := GetUserIdByToken(c)
 	if id == 0 {
 		return
@@ -97,3 +119,324 @@ func GetUserOrder(c *gin.Context) {
 	}
 	c.JSON(200, CreateResultData(vo))
 }
+
+////
+
+func VerificationCode(c *gin.Context) {
+	// 配置
+	driver := base64Captcha.NewDriverDigit(80, 240, 4, 0.5, 80)
+	store := base64Captcha.DefaultMemStore
+	captcha := base64Captcha.NewCaptcha(driver, store)
+
+	// 生成验证码
+	id, b64s, answer, err := captcha.Generate()
+	if err != nil {
+		c.JSON(500, gin.H{"error": err.Error()})
+		return
+	}
+	fmt.Println(answer)
+	err = configs.RedisDb.Set(ctx, "VerificationCode_"+id, answer, 0).Err()
+	if err != nil {
+		fmt.Println(err)
+	}
+	err = configs.RedisDb.Expire(ctx, "VerificationCode_"+id, 60*time.Second).Err()
+	if err != nil {
+		panic(err)
+	}
+	// 返回验证码图片
+	c.JSON(200, gin.H{
+		"message": "获取成功!!!",
+		"expires": time.Now().Add(time.Minute * 5).Unix(),
+		"code":    200,
+		"data":    map[string]string{"id": id, "image": b64s},
+	})
+
+}
+
+func login(c *gin.Context) {
+	data := share.GetJsonAnyParam(c)
+	var user configs.User
+	var err error
+	username, _ := data("username")
+	password, _ := data("password")
+	t, _ := data("type")
+	// 定义正则表达式
+
+	if cast.ToString(t) == "email" {
+		regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
+		// 编译正则表达式
+		reg, err := regexp.Compile(regexPattern)
+		if err != nil {
+			fmt.Println("编译正则表达式时出错:", err)
+			return
+		}
+		//判断是否为邮箱格式
+		matched := reg.MatchString(cast.ToString(username))
+
+		if !matched {
+			fmt.Println("无效的电子邮件格式.")
+			c.JSON(http.StatusOK, CreateResultError(400, "邮箱格式错误!!!"))
+			return
+		}
+	} else if cast.ToString(t) == "phone" {
+		regexPattern := `^1[3-9]\d{9}$`
+		// 编译正则表达式
+		reg, err := regexp.Compile(regexPattern)
+		if err != nil {
+			fmt.Println("编译正则表达式时出错:", err)
+			return
+		}
+		//判断是否为邮箱格式
+		matched := reg.MatchString(cast.ToString(username))
+
+		if !matched {
+			fmt.Println("无效的手机号格式.")
+			c.JSON(http.StatusOK, CreateResultError(400, "手机格式错误!!!"))
+			return
+		}
+	}
+
+	user, err = dao.Logins(cast.ToString(username), cast.ToString(password), cast.ToString(t))
+
+	if err == nil && user.Id != 0 {
+		fmt.Println("用户登录成功!!!")
+		token, err := share.GenerateToken(cast.ToString(user.Id))
+		if err == nil {
+			c.Header("auth-sign", token)
+			c.JSON(http.StatusOK, CreateResultData(map[string]string{"token": token}))
+		} else {
+			c.JSON(http.StatusOK, CreateResultError(400, "生成token失败!!!"))
+		}
+	} else {
+		fmt.Println("用户登录失败!!!")
+		c.JSON(http.StatusOK, CreateResultError(401, "用户密码错误!!!"))
+	}
+}
+
+func registerCode(c *gin.Context) {
+	data := share.GetJsonAnyParam(c)
+	phone, _ := data("phone")
+	//判断是否为手机格式
+	if !checkPhone(c, cast.ToString(phone)) {
+		return
+	}
+	//判断是否已经注册
+	b, err := dao.ExistsPhone(cast.ToString(phone))
+	if err != nil {
+		fmt.Println(err)
+		c.JSON(http.StatusOK, CreateResultError(200, "数据库错误!!!"))
+		return
+	}
+	if b {
+		c.JSON(http.StatusOK, CreateResultError(200, "手机号已注册!!!"))
+		return
+	}
+	//判断是否重复注册
+	get := configs.RedisDb.Exists(ctx, "PhoneVerificationCodeTime_"+cast.ToString(phone))
+	if get.Val() == 1 {
+		c.JSON(http.StatusOK, CreateResultError(200, "验证码已经发送,请等待"))
+		return
+	}
+
+	//发送短信
+	//sms := sendSms(b, cast.ToString(phone))
+	//TODO 模拟发送短信
+	sms := testSendSms()
+	fmt.Println("发送成功!!!:验证码为:", sms)
+	configs.RedisDb.Set(ctx, "PhoneVerificationCode_"+cast.ToString(phone), sms, 60*5*time.Second)
+	configs.RedisDb.Set(ctx, "PhoneVerificationCodeTime_"+cast.ToString(phone), time.Now(), 60*time.Second)
+	c.JSON(http.StatusOK, CreateResult())
+
+}
+
+func testSendSms() string {
+	mins := big.NewInt(100000)
+	maxs := big.NewInt(999999)
+	randomNum := share.RandomInt(mins, maxs)
+	//if matched {
+	//	//bools, err = configs.Engine.Table("user").Where("username = ?", username).Exist(&user)
+	//
+	//	share.SendMail(username, strconv.Itoa(int(randomNum.Int64())))
+	//
+	//} else {
+	//	share.SendSms(strconv.Itoa(int(randomNum.Int64())), username)
+	//}
+	return randomNum.String()
+}
+
+func register(c *gin.Context) {
+
+	data := share.GetJsonAnyParam(c)
+
+	username, _ := data("username")
+	password, _ := data("password")
+	code, _ := data("code")
+	phone, _ := data("phone")
+
+	if !checkEmail(c, cast.ToString(username)) {
+		return
+	}
+	if !checkPhone(c, cast.ToString(phone)) {
+		return
+	}
+	if !checkCode(c, cast.ToString(code)) {
+		return
+	}
+	if !checkPassword(c, cast.ToString(password)) {
+		return
+	}
+	// 验证验证码
+	get := configs.RedisDb.Get(ctx, "PhoneVerificationCode_"+cast.ToString(phone))
+	fmt.Println(code, get.Val())
+	if code != get.Val() {
+		c.JSON(http.StatusOK, CreateResultError(400, "验证码错误!"))
+		return
+	}
+	configs.RedisDb.Del(ctx, "PhoneVerificationCode_"+cast.ToString(phone))
+
+	//判断是否已经注册
+	b, err := dao.GetUserByPhoneOrEmail(cast.ToString(phone), cast.ToString(username))
+	if err != nil {
+		c.JSON(http.StatusOK, CreateResultError(400, "验证手机号及用户名,数据错误"))
+		return
+	}
+	if b {
+		c.JSON(http.StatusOK, CreateResultError(400, "手机号或邮箱已注册!!!"))
+		return
+	}
+
+	timestamp := time.Now().Unix()
+	user := configs.User{
+		Username:      cast.ToString(username),
+		Password:      cast.ToString(password),
+		Creation_time: int(timestamp),
+		Status:        0,
+		Role_id:       2,
+		Phone:         cast.ToString(phone),
+		Email:         cast.ToString(username),
+		Name:          cast.ToString(username),
+		RecommendCode: fmt.Sprint(strconv.FormatInt(timestamp, 16), util.RandomArrays(13, 62)),
+	}
+
+	user, err = dao.SaveNewUser(user)
+	if err != nil {
+		fmt.Println(err)
+		c.JSON(http.StatusOK, CreateResultError(400, "数据库错误!!!"))
+		return
+	}
+	if user.Id != 0 {
+		fmt.Println("用户注册成功!!!")
+		c.JSON(http.StatusOK, CreateResultData(map[string]any{"user": user}))
+		//用户钱包添加
+		manage.SaveUserWallet(&domain.UserWallet{UserId: user.Id})
+
+		return
+	} else {
+		fmt.Println("用户注册失败!!!")
+		c.JSON(http.StatusOK, CreateResultError(400, "用户注册失败!!!"))
+		return
+	}
+}
+
+func checkEmail(c *gin.Context, email string) bool {
+	//// 定义正则表达式
+	regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
+	reg, err := regexp.Compile(regexPattern)
+	if err != nil {
+		fmt.Println("Error compiling regex:", err)
+		c.JSON(500, CreateResultError(500, "邮箱格式错误!!!"))
+		return false
+	}
+	//判断是否为邮箱格式
+	matched := reg.MatchString(cast.ToString(email))
+	if !matched {
+		fmt.Println("Error compiling regex:", err)
+		c.JSON(500, CreateResultError(500, "邮箱格式错误!!!"))
+		return false
+	}
+	return true
+}
+func checkPhone(c *gin.Context, phone string) bool {
+	//// 定义正则表达式
+	regexPattern := `^1[3-9]\d{9}$`
+	reg, err := regexp.Compile(regexPattern)
+	if err != nil {
+		fmt.Println("1 Error compiling regex:", err)
+		c.JSON(200, CreateResultError(500, "手机号格式错误!!!"))
+		return false
+	}
+	matched := reg.MatchString(cast.ToString(phone))
+	if !matched {
+		fmt.Println("2 Error compiling regex:", err)
+		c.JSON(200, CreateResultError(500, "手机号格式错误!!!"))
+		return false
+	}
+	return true
+}
+func checkPassword(c *gin.Context, email string) bool {
+	//// 定义正则表达式
+	regexPattern := `^[a-zA-Z0-9,./<>?;'\\:"|\[\]{}~!@#$%^&*()_+=-]{6,32}$`
+	reg, err := regexp.Compile(regexPattern)
+	if err != nil {
+		fmt.Println("Error compiling regex:", err)
+		c.JSON(500, CreateResultError(500, "密码格式错误!!!"))
+		return false
+	}
+	//判断是否为邮箱格式
+	matched := reg.MatchString(cast.ToString(email))
+	if !matched {
+		fmt.Println("Error compiling regex:", err)
+		c.JSON(500, CreateResultError(500, "密码格式错误!!!"))
+		return false
+	}
+	return true
+}
+func checkCode(c *gin.Context, code string) bool {
+	//// 定义正则表达式
+	regexPattern := `^\d{6}$`
+	reg, err := regexp.Compile(regexPattern)
+	if err != nil {
+		fmt.Println("Error compiling regex:", err)
+		c.JSON(500, CreateResultError(500, "验证码格式错误!!!"))
+		return false
+	}
+	//判断是否为邮箱格式
+	matched := reg.MatchString(cast.ToString(code))
+	if !matched {
+		fmt.Println("Error compiling regex:", err)
+		c.JSON(500, CreateResultError(500, "验证码格式错误!!!"))
+		return false
+	}
+
+	return true
+}
+
+// SendVerificationCode 发送验证码
+func SendVerificationCode(c *gin.Context) {
+	data := share.GetJsonAnyParam(c)
+	var err error
+	username, _ := data("username")
+	code, _ := data("code")
+	codeId, _ := data("codeId")
+	val, err := configs.RedisDb.Get(ctx, cast.ToString(codeId)).Result()
+	if err != nil {
+		log.Fatal(err)
+	}
+	if val != cast.ToString(code) {
+		c.JSON(200, gin.H{"code": 400, "message": "验证码错误!!!"})
+		c.Abort()
+		return
+	}
+	// 定义正则表达式
+	regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
+
+	// 编译正则表达式
+	reg, err := regexp.Compile(regexPattern)
+	if err != nil {
+		fmt.Println("Error compiling regex:", err)
+		return
+	}
+	matched := reg.MatchString(cast.ToString(username))
+	dao.SendSms(matched, cast.ToString(username))
+	c.JSON(200, gin.H{"code": 200, "message": "发送成功!!!"})
+}

+ 355 - 0
user/UserRouter.go

@@ -0,0 +1,355 @@
+package user
+
+//
+//import (
+//	"context"
+//	"demo/configs"
+//	"demo/data/dao/manage"
+//	"demo/data/domain"
+//	"demo/router"
+//	"demo/share"
+//	"demo/util"
+//	"fmt"
+//	"github.com/gin-gonic/gin"
+//	"github.com/mojocn/base64Captcha"
+//	"github.com/spf13/cast"
+//	"log"
+//	"math/big"
+//	"net/http"
+//	"regexp"
+//	"strconv"
+//	"time"
+//)
+//
+//var ctx = context.Background()
+//
+//func UserRouth(engine *gin.RouterGroup) {
+//	user := engine.Group("/user")
+//	{
+//		user.POST("/login", login)
+//		user.POST("/register", register)
+//		user.POST("/registerCode", registerCode)
+//
+//		user.POST("/sendSms", SendVerificationCode)
+//		user.GET("/captcha", VerificationCode)
+//	}
+//}
+//
+//func VerificationCode(c *gin.Context) {
+//	// 配置
+//	driver := base64Captcha.NewDriverDigit(80, 240, 4, 0.5, 80)
+//	store := base64Captcha.DefaultMemStore
+//	captcha := base64Captcha.NewCaptcha(driver, store)
+//
+//	// 生成验证码
+//	id, b64s, answer, err := captcha.Generate()
+//	if err != nil {
+//		c.JSON(500, gin.H{"error": err.Error()})
+//		return
+//	}
+//	fmt.Println(answer)
+//	err = configs.RedisDb.Set(ctx, "VerificationCode_"+id, answer, 0).Err()
+//	if err != nil {
+//		fmt.Println(err)
+//	}
+//	err = configs.RedisDb.Expire(ctx, "VerificationCode_"+id, 60*time.Second).Err()
+//	if err != nil {
+//		panic(err)
+//	}
+//	// 返回验证码图片
+//	c.JSON(200, gin.H{
+//		"message": "获取成功!!!",
+//		"expires": time.Now().Add(time.Minute * 5).Unix(),
+//		"code":    200,
+//		"data":    map[string]string{"id": id, "image": b64s},
+//	})
+//
+//}
+//
+//func login(c *gin.Context) {
+//	data := share.GetJsonAnyParam(c)
+//	var user configs.User
+//	var err error
+//	username, _ := data("username")
+//	password, _ := data("password")
+//	t, _ := data("type")
+//	// 定义正则表达式
+//
+//	if cast.ToString(t) == "email" {
+//		regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
+//		// 编译正则表达式
+//		reg, err := regexp.Compile(regexPattern)
+//		if err != nil {
+//			fmt.Println("编译正则表达式时出错:", err)
+//			return
+//		}
+//		//判断是否为邮箱格式
+//		matched := reg.MatchString(cast.ToString(username))
+//
+//		if !matched {
+//			fmt.Println("无效的电子邮件格式.")
+//			c.JSON(http.StatusOK, router.CreateResultError(400, "邮箱格式错误!!!"))
+//			return
+//		}
+//	} else if cast.ToString(t) == "phone" {
+//		regexPattern := `^1[3-9]\d{9}$`
+//		// 编译正则表达式
+//		reg, err := regexp.Compile(regexPattern)
+//		if err != nil {
+//			fmt.Println("编译正则表达式时出错:", err)
+//			return
+//		}
+//		//判断是否为邮箱格式
+//		matched := reg.MatchString(cast.ToString(username))
+//
+//		if !matched {
+//			fmt.Println("无效的手机号格式.")
+//			c.JSON(http.StatusOK, router.CreateResultError(400, "手机格式错误!!!"))
+//			return
+//		}
+//	}
+//
+//	user, err = logins(cast.ToString(username), cast.ToString(password), cast.ToString(t))
+//
+//	if err == nil && user.Id != 0 {
+//		fmt.Println("用户登录成功!!!")
+//		token, err := share.GenerateToken(cast.ToString(user.Id))
+//		if err == nil {
+//			c.Header("auth-sign", token)
+//			c.JSON(http.StatusOK, router.CreateResultData(map[string]string{"token": token}))
+//		} else {
+//			c.JSON(http.StatusOK, router.CreateResultError(400, "生成token失败!!!"))
+//		}
+//	} else {
+//		fmt.Println("用户登录失败!!!")
+//		c.JSON(http.StatusOK, router.CreateResultError(401, "用户密码错误!!!"))
+//	}
+//}
+//
+//func registerCode(c *gin.Context) {
+//	data := share.GetJsonAnyParam(c)
+//	phone, _ := data("phone")
+//	//判断是否为手机格式
+//	if !checkPhone(c, cast.ToString(phone)) {
+//		return
+//	}
+//	//判断是否已经注册
+//	b, err := existsPhone(cast.ToString(phone))
+//	if err != nil {
+//		fmt.Println(err)
+//		c.JSON(http.StatusOK, router.CreateResultError(200, "数据库错误!!!"))
+//		return
+//	}
+//	if b {
+//		c.JSON(http.StatusOK, router.CreateResultError(200, "手机号已注册!!!"))
+//		return
+//	}
+//	//判断是否重复注册
+//	get := configs.RedisDb.Exists(ctx, "PhoneVerificationCodeTime_"+cast.ToString(phone))
+//	if get.Val() == 1 {
+//		c.JSON(http.StatusOK, router.CreateResultError(200, "验证码已经发送,请等待"))
+//		return
+//	}
+//
+//	//发送短信
+//	//sms := sendSms(b, cast.ToString(phone))
+//	//TODO 模拟发送短信
+//	sms := testSendSms()
+//	fmt.Println("发送成功!!!:验证码为:", sms)
+//	configs.RedisDb.Set(ctx, "PhoneVerificationCode_"+cast.ToString(phone), sms, 60*5*time.Second)
+//	configs.RedisDb.Set(ctx, "PhoneVerificationCodeTime_"+cast.ToString(phone), time.Now(), 60*time.Second)
+//	c.JSON(http.StatusOK, router.CreateResult())
+//
+//}
+//
+//func testSendSms() string {
+//	mins := big.NewInt(100000)
+//	maxs := big.NewInt(999999)
+//	randomNum := share.RandomInt(mins, maxs)
+//	//if matched {
+//	//	//bools, err = configs.Engine.Table("user").Where("username = ?", username).Exist(&user)
+//	//
+//	//	share.SendMail(username, strconv.Itoa(int(randomNum.Int64())))
+//	//
+//	//} else {
+//	//	share.SendSms(strconv.Itoa(int(randomNum.Int64())), username)
+//	//}
+//	return randomNum.String()
+//}
+//
+//func register(c *gin.Context) {
+//
+//	data := share.GetJsonAnyParam(c)
+//
+//	username, _ := data("username")
+//	password, _ := data("password")
+//	code, _ := data("code")
+//	phone, _ := data("phone")
+//
+//	if !checkEmail(c, cast.ToString(username)) {
+//		return
+//	}
+//	if !checkPhone(c, cast.ToString(phone)) {
+//		return
+//	}
+//	if !checkCode(c, cast.ToString(code)) {
+//		return
+//	}
+//	if !checkPassword(c, cast.ToString(password)) {
+//		return
+//	}
+//	// 验证验证码
+//	get := configs.RedisDb.Get(ctx, "PhoneVerificationCode_"+cast.ToString(phone))
+//	fmt.Println(code, get.Val())
+//	if code != get.Val() {
+//		c.JSON(http.StatusOK, router.CreateResultError(400, "验证码错误!"))
+//		return
+//	}
+//	configs.RedisDb.Del(ctx, "PhoneVerificationCode_"+cast.ToString(phone))
+//
+//	//判断是否已经注册
+//	b, err := GetUserByPhoneOrEmail(cast.ToString(phone), cast.ToString(username))
+//	if err != nil {
+//		c.JSON(http.StatusOK, router.CreateResultError(400, "验证手机号及用户名,数据错误"))
+//		return
+//	}
+//	if b {
+//		c.JSON(http.StatusOK, router.CreateResultError(400, "手机号或邮箱已注册!!!"))
+//		return
+//	}
+//
+//	timestamp := time.Now().Unix()
+//	user := configs.User{
+//		Username:      cast.ToString(username),
+//		Password:      cast.ToString(password),
+//		Creation_time: int(timestamp),
+//		Status:        0,
+//		Role_id:       2,
+//		Phone:         cast.ToString(phone),
+//		Email:         cast.ToString(username),
+//		Name:          cast.ToString(username),
+//		RecommendCode: fmt.Sprint(strconv.FormatInt(timestamp, 16), util.RandomArrays(13, 62)),
+//	}
+//
+//	user, err = SaveNewUser(user)
+//	if err != nil {
+//		fmt.Println(err)
+//		c.JSON(http.StatusOK, router.CreateResultError(400, "数据库错误!!!"))
+//		return
+//	}
+//	if user.Id != 0 {
+//		fmt.Println("用户注册成功!!!")
+//		c.JSON(http.StatusOK, router.CreateResultData(map[string]any{"user": user}))
+//		//用户钱包添加
+//		manage.SaveUserWallet(&domain.UserWallet{UserId: user.Id})
+//
+//		return
+//	} else {
+//		fmt.Println("用户注册失败!!!")
+//		c.JSON(http.StatusOK, router.CreateResultError(400, "用户注册失败!!!"))
+//		return
+//	}
+//}
+//
+//func checkEmail(c *gin.Context, email string) bool {
+//	//// 定义正则表达式
+//	regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
+//	reg, err := regexp.Compile(regexPattern)
+//	if err != nil {
+//		fmt.Println("Error compiling regex:", err)
+//		c.JSON(500, router.CreateResultError(500, "邮箱格式错误!!!"))
+//		return false
+//	}
+//	//判断是否为邮箱格式
+//	matched := reg.MatchString(cast.ToString(email))
+//	if !matched {
+//		fmt.Println("Error compiling regex:", err)
+//		c.JSON(500, router.CreateResultError(500, "邮箱格式错误!!!"))
+//		return false
+//	}
+//	return true
+//}
+//func checkPhone(c *gin.Context, phone string) bool {
+//	//// 定义正则表达式
+//	regexPattern := `^1[3-9]\d{9}$`
+//	reg, err := regexp.Compile(regexPattern)
+//	if err != nil {
+//		fmt.Println("1 Error compiling regex:", err)
+//		c.JSON(200, router.CreateResultError(500, "手机号格式错误!!!"))
+//		return false
+//	}
+//	matched := reg.MatchString(cast.ToString(phone))
+//	if !matched {
+//		fmt.Println("2 Error compiling regex:", err)
+//		c.JSON(200, router.CreateResultError(500, "手机号格式错误!!!"))
+//		return false
+//	}
+//	return true
+//}
+//func checkPassword(c *gin.Context, email string) bool {
+//	//// 定义正则表达式
+//	regexPattern := `^[a-zA-Z0-9,./<>?;'\\:"|\[\]{}~!@#$%^&*()_+=-]{6,32}$`
+//	reg, err := regexp.Compile(regexPattern)
+//	if err != nil {
+//		fmt.Println("Error compiling regex:", err)
+//		c.JSON(500, router.CreateResultError(500, "密码格式错误!!!"))
+//		return false
+//	}
+//	//判断是否为邮箱格式
+//	matched := reg.MatchString(cast.ToString(email))
+//	if !matched {
+//		fmt.Println("Error compiling regex:", err)
+//		c.JSON(500, router.CreateResultError(500, "密码格式错误!!!"))
+//		return false
+//	}
+//	return true
+//}
+//func checkCode(c *gin.Context, code string) bool {
+//	//// 定义正则表达式
+//	regexPattern := `^\d{6}$`
+//	reg, err := regexp.Compile(regexPattern)
+//	if err != nil {
+//		fmt.Println("Error compiling regex:", err)
+//		c.JSON(500, router.CreateResultError(500, "验证码格式错误!!!"))
+//		return false
+//	}
+//	//判断是否为邮箱格式
+//	matched := reg.MatchString(cast.ToString(code))
+//	if !matched {
+//		fmt.Println("Error compiling regex:", err)
+//		c.JSON(500, router.CreateResultError(500, "验证码格式错误!!!"))
+//		return false
+//	}
+//
+//	return true
+//}
+//
+//// SendVerificationCode 发送验证码
+//func SendVerificationCode(c *gin.Context) {
+//	data := share.GetJsonAnyParam(c)
+//	var err error
+//	username, _ := data("username")
+//	code, _ := data("code")
+//	codeId, _ := data("codeId")
+//	val, err := configs.RedisDb.Get(ctx, cast.ToString(codeId)).Result()
+//	if err != nil {
+//		log.Fatal(err)
+//	}
+//	if val != cast.ToString(code) {
+//		c.JSON(200, gin.H{"code": 400, "message": "验证码错误!!!"})
+//		c.Abort()
+//		return
+//	}
+//	// 定义正则表达式
+//	regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
+//
+//	// 编译正则表达式
+//	reg, err := regexp.Compile(regexPattern)
+//	if err != nil {
+//		fmt.Println("Error compiling regex:", err)
+//		return
+//	}
+//	matched := reg.MatchString(cast.ToString(username))
+//	sendSms(matched, cast.ToString(username))
+//	c.JSON(200, gin.H{"code": 200, "message": "发送成功!!!"})
+//}

+ 0 - 354
user/user.go

@@ -1,354 +0,0 @@
-package user
-
-import (
-	"context"
-	"demo/configs"
-	"demo/data/dao/manage"
-	"demo/data/domain"
-	"demo/router"
-	"demo/share"
-	"demo/util"
-	"fmt"
-	"github.com/gin-gonic/gin"
-	"github.com/mojocn/base64Captcha"
-	"github.com/spf13/cast"
-	"log"
-	"math/big"
-	"net/http"
-	"regexp"
-	"strconv"
-	"time"
-)
-
-var ctx = context.Background()
-
-func UserRouth(engine *gin.RouterGroup) {
-	user := engine.Group("/user")
-	{
-		user.POST("/login", login)
-		user.POST("/register", register)
-		user.POST("/registerCode", registerCode)
-
-		user.POST("/sendSms", SendVerificationCode)
-		user.GET("/captcha", VerificationCode)
-	}
-}
-
-func VerificationCode(c *gin.Context) {
-	// 配置
-	driver := base64Captcha.NewDriverDigit(80, 240, 4, 0.5, 80)
-	store := base64Captcha.DefaultMemStore
-	captcha := base64Captcha.NewCaptcha(driver, store)
-
-	// 生成验证码
-	id, b64s, answer, err := captcha.Generate()
-	if err != nil {
-		c.JSON(500, gin.H{"error": err.Error()})
-		return
-	}
-	fmt.Println(answer)
-	err = configs.RedisDb.Set(ctx, "VerificationCode_"+id, answer, 0).Err()
-	if err != nil {
-		fmt.Println(err)
-	}
-	err = configs.RedisDb.Expire(ctx, "VerificationCode_"+id, 60*time.Second).Err()
-	if err != nil {
-		panic(err)
-	}
-	// 返回验证码图片
-	c.JSON(200, gin.H{
-		"message": "获取成功!!!",
-		"expires": time.Now().Add(time.Minute * 5).Unix(),
-		"code":    200,
-		"data":    map[string]string{"id": id, "image": b64s},
-	})
-
-}
-
-func login(c *gin.Context) {
-	data := share.GetJsonAnyParam(c)
-	var user configs.User
-	var err error
-	username, _ := data("username")
-	password, _ := data("password")
-	t, _ := data("type")
-	// 定义正则表达式
-
-	if cast.ToString(t) == "email" {
-		regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
-		// 编译正则表达式
-		reg, err := regexp.Compile(regexPattern)
-		if err != nil {
-			fmt.Println("编译正则表达式时出错:", err)
-			return
-		}
-		//判断是否为邮箱格式
-		matched := reg.MatchString(cast.ToString(username))
-
-		if !matched {
-			fmt.Println("无效的电子邮件格式.")
-			c.JSON(http.StatusOK, router.CreateResultError(400, "邮箱格式错误!!!"))
-			return
-		}
-	} else if cast.ToString(t) == "phone" {
-		regexPattern := `^1[3-9]\d{9}$`
-		// 编译正则表达式
-		reg, err := regexp.Compile(regexPattern)
-		if err != nil {
-			fmt.Println("编译正则表达式时出错:", err)
-			return
-		}
-		//判断是否为邮箱格式
-		matched := reg.MatchString(cast.ToString(username))
-
-		if !matched {
-			fmt.Println("无效的手机号格式.")
-			c.JSON(http.StatusOK, router.CreateResultError(400, "手机格式错误!!!"))
-			return
-		}
-	}
-
-	user, err = logins(cast.ToString(username), cast.ToString(password), cast.ToString(t))
-
-	if err == nil && user.Id != 0 {
-		fmt.Println("用户登录成功!!!")
-		token, err := share.GenerateToken(cast.ToString(user.Id))
-		if err == nil {
-			c.Header("auth-sign", token)
-			c.JSON(http.StatusOK, router.CreateResultData(map[string]string{"token": token}))
-		} else {
-			c.JSON(http.StatusOK, router.CreateResultError(400, "生成token失败!!!"))
-		}
-	} else {
-		fmt.Println("用户登录失败!!!")
-		c.JSON(http.StatusOK, router.CreateResultError(401, "用户密码错误!!!"))
-	}
-}
-
-func registerCode(c *gin.Context) {
-	data := share.GetJsonAnyParam(c)
-	phone, _ := data("phone")
-	//判断是否为手机格式
-	if !checkPhone(c, cast.ToString(phone)) {
-		return
-	}
-	//判断是否已经注册
-	b, err := existsPhone(cast.ToString(phone))
-	if err != nil {
-		fmt.Println(err)
-		c.JSON(http.StatusOK, router.CreateResultError(200, "数据库错误!!!"))
-		return
-	}
-	if b {
-		c.JSON(http.StatusOK, router.CreateResultError(200, "手机号已注册!!!"))
-		return
-	}
-	//判断是否重复注册
-	get := configs.RedisDb.Exists(ctx, "PhoneVerificationCodeTime_"+cast.ToString(phone))
-	if get.Val() == 1 {
-		c.JSON(http.StatusOK, router.CreateResultError(200, "验证码已经发送,请等待"))
-		return
-	}
-
-	//发送短信
-	//sms := sendSms(b, cast.ToString(phone))
-	//TODO 模拟发送短信
-	sms := testSendSms()
-	fmt.Println("发送成功!!!:验证码为:", sms)
-	configs.RedisDb.Set(ctx, "PhoneVerificationCode_"+cast.ToString(phone), sms, 60*5*time.Second)
-	configs.RedisDb.Set(ctx, "PhoneVerificationCodeTime_"+cast.ToString(phone), time.Now(), 60*time.Second)
-	c.JSON(http.StatusOK, router.CreateResult())
-
-}
-
-func testSendSms() string {
-	mins := big.NewInt(100000)
-	maxs := big.NewInt(999999)
-	randomNum := share.RandomInt(mins, maxs)
-	//if matched {
-	//	//bools, err = configs.Engine.Table("user").Where("username = ?", username).Exist(&user)
-	//
-	//	share.SendMail(username, strconv.Itoa(int(randomNum.Int64())))
-	//
-	//} else {
-	//	share.SendSms(strconv.Itoa(int(randomNum.Int64())), username)
-	//}
-	return randomNum.String()
-}
-
-func register(c *gin.Context) {
-
-	data := share.GetJsonAnyParam(c)
-
-	username, _ := data("username")
-	password, _ := data("password")
-	code, _ := data("code")
-	phone, _ := data("phone")
-
-	if !checkEmail(c, cast.ToString(username)) {
-		return
-	}
-	if !checkPhone(c, cast.ToString(phone)) {
-		return
-	}
-	if !checkCode(c, cast.ToString(code)) {
-		return
-	}
-	if !checkPassword(c, cast.ToString(password)) {
-		return
-	}
-	// 验证验证码
-	get := configs.RedisDb.Get(ctx, "PhoneVerificationCode_"+cast.ToString(phone))
-	fmt.Println(code, get.Val())
-	if code != get.Val() {
-		c.JSON(http.StatusOK, router.CreateResultError(400, "验证码错误!"))
-		return
-	}
-	configs.RedisDb.Del(ctx, "PhoneVerificationCode_"+cast.ToString(phone))
-
-	//判断是否已经注册
-	b, err := GetUserByPhoneOrEmail(cast.ToString(phone), cast.ToString(username))
-	if err != nil {
-		c.JSON(http.StatusOK, router.CreateResultError(400, "验证手机号及用户名,数据错误"))
-		return
-	}
-	if b {
-		c.JSON(http.StatusOK, router.CreateResultError(400, "手机号或邮箱已注册!!!"))
-		return
-	}
-
-	timestamp := time.Now().Unix()
-	user := configs.User{
-		Username:      cast.ToString(username),
-		Password:      cast.ToString(password),
-		Creation_time: int(timestamp),
-		Status:        0,
-		Role_id:       2,
-		Phone:         cast.ToString(phone),
-		Email:         cast.ToString(username),
-		Name:          cast.ToString(username),
-		RecommendCode: fmt.Sprint(strconv.FormatInt(timestamp, 16), util.RandomArrays(13, 62)),
-	}
-
-	user, err = SaveNewUser(user)
-	if err != nil {
-		fmt.Println(err)
-		c.JSON(http.StatusOK, router.CreateResultError(400, "数据库错误!!!"))
-		return
-	}
-	if user.Id != 0 {
-		fmt.Println("用户注册成功!!!")
-		c.JSON(http.StatusOK, router.CreateResultData(map[string]any{"user": user}))
-		//用户钱包添加
-		manage.SaveUserWallet(&domain.UserWallet{UserId: user.Id})
-
-		return
-	} else {
-		fmt.Println("用户注册失败!!!")
-		c.JSON(http.StatusOK, router.CreateResultError(400, "用户注册失败!!!"))
-		return
-	}
-}
-
-func checkEmail(c *gin.Context, email string) bool {
-	//// 定义正则表达式
-	regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
-	reg, err := regexp.Compile(regexPattern)
-	if err != nil {
-		fmt.Println("Error compiling regex:", err)
-		c.JSON(500, router.CreateResultError(500, "邮箱格式错误!!!"))
-		return false
-	}
-	//判断是否为邮箱格式
-	matched := reg.MatchString(cast.ToString(email))
-	if !matched {
-		fmt.Println("Error compiling regex:", err)
-		c.JSON(500, router.CreateResultError(500, "邮箱格式错误!!!"))
-		return false
-	}
-	return true
-}
-func checkPhone(c *gin.Context, phone string) bool {
-	//// 定义正则表达式
-	regexPattern := `^1[3-9]\d{9}$`
-	reg, err := regexp.Compile(regexPattern)
-	if err != nil {
-		fmt.Println("1 Error compiling regex:", err)
-		c.JSON(200, router.CreateResultError(500, "手机号格式错误!!!"))
-		return false
-	}
-	matched := reg.MatchString(cast.ToString(phone))
-	if !matched {
-		fmt.Println("2 Error compiling regex:", err)
-		c.JSON(200, router.CreateResultError(500, "手机号格式错误!!!"))
-		return false
-	}
-	return true
-}
-func checkPassword(c *gin.Context, email string) bool {
-	//// 定义正则表达式
-	regexPattern := `^[a-zA-Z0-9,./<>?;'\\:"|\[\]{}~!@#$%^&*()_+=-]{6,32}$`
-	reg, err := regexp.Compile(regexPattern)
-	if err != nil {
-		fmt.Println("Error compiling regex:", err)
-		c.JSON(500, router.CreateResultError(500, "密码格式错误!!!"))
-		return false
-	}
-	//判断是否为邮箱格式
-	matched := reg.MatchString(cast.ToString(email))
-	if !matched {
-		fmt.Println("Error compiling regex:", err)
-		c.JSON(500, router.CreateResultError(500, "密码格式错误!!!"))
-		return false
-	}
-	return true
-}
-func checkCode(c *gin.Context, code string) bool {
-	//// 定义正则表达式
-	regexPattern := `^\d{6}$`
-	reg, err := regexp.Compile(regexPattern)
-	if err != nil {
-		fmt.Println("Error compiling regex:", err)
-		c.JSON(500, router.CreateResultError(500, "验证码格式错误!!!"))
-		return false
-	}
-	//判断是否为邮箱格式
-	matched := reg.MatchString(cast.ToString(code))
-	if !matched {
-		fmt.Println("Error compiling regex:", err)
-		c.JSON(500, router.CreateResultError(500, "验证码格式错误!!!"))
-		return false
-	}
-
-	return true
-}
-
-// SendVerificationCode 发送验证码
-func SendVerificationCode(c *gin.Context) {
-	data := share.GetJsonAnyParam(c)
-	var err error
-	username, _ := data("username")
-	code, _ := data("code")
-	codeId, _ := data("codeId")
-	val, err := configs.RedisDb.Get(ctx, cast.ToString(codeId)).Result()
-	if err != nil {
-		log.Fatal(err)
-	}
-	if val != cast.ToString(code) {
-		c.JSON(200, gin.H{"code": 400, "message": "验证码错误!!!"})
-		c.Abort()
-		return
-	}
-	// 定义正则表达式
-	regexPattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
-
-	// 编译正则表达式
-	reg, err := regexp.Compile(regexPattern)
-	if err != nil {
-		fmt.Println("Error compiling regex:", err)
-		return
-	}
-	matched := reg.MatchString(cast.ToString(username))
-	sendSms(matched, cast.ToString(username))
-	c.JSON(200, gin.H{"code": 200, "message": "发送成功!!!"})
-}