You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

package api
import (
"regexp"
"shop-api/api/sys"
"shop-api/global"
"shop-api/model/request"
"shop-api/model/response"
"shop-api/service"
"shop-api/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// @Summary 购买申诉[v1.0.0]
// @Security Bearer
// @Description
// @Tags user
// @Param data body request.UserAppeal true "respon"
// @Success 200 {string} string "{"code": 0, "data": [...]}"
// @Success 200 {string} string "{"code": 1, "message": ""}"
// @Router /user/appeal [post]
func UserAppeal(c *gin.Context) {
var a request.UserAppeal
_ = c.ShouldBindJSON(&a)
if err := utils.Verify(a, utils.UserAppealVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
if err := service.UserAppeal(&a, sys.GetUserUuid(c)); err != nil {
global.MG_LOG.Error("Appeal failed!", zap.Any("err", err))
response.FailWithMessage("Appeal failed", c)
return
}
response.OkWithMessage("Appeal successful", c)
}
// @Summary 绑定邮箱[v1.0.0]
// @Security Bearer
// @Description
// @Tags user
// @Param data body request.UserEmail true "email"
// @Success 200 {string} string "{"code": 0, "data": [...]}"
// @Success 200 {string} string "{"code": 1, "message": ""}"
// @Router /user/email [put]
func BandUserEmail(c *gin.Context) {
var a request.UserEmail
_ = c.ShouldBindJSON(&a)
if err := utils.Verify(a, utils.UserEmailVerify); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
//校验邮箱格式
if ok, _ := regexp.MatchString(utils.RegEmailNumber, a.Email); !ok {
response.FailWithMessage("邮箱格式不合法", c)
return
}
if err := service.UserEmail(&a, sys.GetUserUuid(c), sys.GetUserAppid(c)); err != nil {
global.MG_LOG.Error("Band failed!", zap.Any("err", err))
response.FailWithMessage("Band failed", c)
return
}
response.OkWithMessage("Band successful", c)
}