44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
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{
|
|
StoreId: req.StoreId,
|
|
Name: req.Name,
|
|
RewardTypeId: req.RewardTypeId,
|
|
GameId: req.GameId,
|
|
Img: req.RewardImg,
|
|
QQGoodsId: req.QQGoodsId,
|
|
QQGoodsIdStr: req.QQGoodsIdStr,
|
|
Status: req.Status,
|
|
OperatorId: operatorId,
|
|
OperatorRole: operatorRole,
|
|
ExpireType: req.ExpireType,
|
|
ExpireDays: req.ExpireDays,
|
|
ValidFrom: req.ValidFrom,
|
|
ValidTo: req.ValidTo,
|
|
DailyTotalLimit: int64(req.DailyTotalLimit),
|
|
TotalLimit: int64(req.TotalLimit),
|
|
UserDailyLimit: int64(req.UserDailyLimit),
|
|
UserTotalLimit: int64(req.UserTotalLimit),
|
|
GrantQuantity: int64(req.GrantQuantity),
|
|
Source: req.Source,
|
|
})
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.CreateRes{Success: out.Success}, nil
|
|
}
|