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.
41 lines
1014 B
41 lines
1014 B
package couponusers
|
|
|
|
import (
|
|
"CouponBackendGo/api/v1/couponusers"
|
|
"CouponBackendGo/internal/model/dto"
|
|
"CouponBackendGo/internal/service"
|
|
"CouponBackendGo/utility"
|
|
"github.com/gogf/gf/v2/net/ghttp"
|
|
)
|
|
|
|
type CouponUsers struct{}
|
|
|
|
func NewCouponUsers() *CouponUsers {
|
|
return &CouponUsers{}
|
|
}
|
|
|
|
// 添加用户选择武器记录
|
|
func (c *CouponUsers) AddRecord(r *ghttp.Request) {
|
|
var req *couponusers.AddRecordReq
|
|
if err := r.Parse(&req); err != nil {
|
|
r.Response.WriteJsonExit(dto.Error(err.Error()))
|
|
}
|
|
//解析token,获取jwcode
|
|
token := r.Header.Get("token")
|
|
if token == "" {
|
|
r.Response.WriteJsonExit(dto.Error("token为空"))
|
|
}
|
|
|
|
jwcode, err := utility.GetJwcodeJSON(token)
|
|
if err != nil {
|
|
r.Response.WriteJsonExit(dto.Error(err.Error()))
|
|
}
|
|
|
|
err = service.CouponUsers().AddRecord(r.Context(), jwcode, req.CouponId, req.Name)
|
|
//错误处理
|
|
if err != nil {
|
|
r.Response.WriteJsonExit(dto.Error(err.Error()))
|
|
}
|
|
//成功处理
|
|
r.Response.WriteJsonExit(dto.SuccessWithMsg("记录成功"))
|
|
}
|