实现了门店奖励的增删改查
This commit is contained in:
31
internal/controller/reward/reward_v1_create.go
Normal file
31
internal/controller/reward/reward_v1_create.go
Normal file
@ -0,0 +1,31 @@
|
||||
package reward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/reward/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
|
||||
fromCtx := g.RequestFromCtx(ctx)
|
||||
operatorId := fromCtx.GetCtxVar("id").Int64()
|
||||
operatorRole := fromCtx.GetCtxVar("role").String()
|
||||
out, err := service.Reward().Create(ctx, &model.RewardCreateIn{
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
Value: req.Value,
|
||||
Status: req.Status,
|
||||
OperatorId: operatorId,
|
||||
OperatorRole: operatorRole,
|
||||
StoreId: req.StoreId,
|
||||
RewardTypeId: req.RewardTypeId,
|
||||
Source: req.Source,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CreateRes{Id: out.Id}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user