31 lines
768 B
Go
31 lines
768 B
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) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
|
|
fromCtx := g.RequestFromCtx(ctx)
|
|
operatorId := fromCtx.GetCtxVar("id").Int64()
|
|
operatorRole := fromCtx.GetCtxVar("role").String()
|
|
out, err := service.Reward().Update(ctx, &model.RewardUpdateIn{
|
|
Id: req.Id,
|
|
Name: req.Name,
|
|
Description: req.Description,
|
|
Value: req.Value,
|
|
OperatorId: operatorId,
|
|
OperatorRole: operatorRole,
|
|
StoreId: req.StoreId,
|
|
Status: req.Status,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.UpdateRes{Success: out.Success}, nil
|
|
}
|