f
This commit is contained in:
@@ -34,6 +34,14 @@ func (l *AdminCreateFeatureLogic) AdminCreateFeature(req *types.AdminCreateFeatu
|
||||
ApiId: req.ApiId,
|
||||
Name: req.Name,
|
||||
}
|
||||
// 设置白名单屏蔽价格
|
||||
if req.WhitelistPrice != nil {
|
||||
data.WhitelistPrice = *req.WhitelistPrice
|
||||
}
|
||||
// 设置成本价
|
||||
if req.CostPrice != nil {
|
||||
data.CostPrice = *req.CostPrice
|
||||
}
|
||||
|
||||
// 2. 数据库操作
|
||||
result, err := l.svcCtx.FeatureModel.Insert(l.ctx, nil, data)
|
||||
|
||||
@@ -36,7 +36,7 @@ func (l *AdminUpdateFeatureLogic) AdminUpdateFeature(req *types.AdminUpdateFeatu
|
||||
record, err := l.svcCtx.FeatureModel.FindOne(l.ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR),
|
||||
"查找功能失败, err: %v, id: %d", err, req.Id)
|
||||
"查找功能失败, err: %v, id: %s", err, req.Id)
|
||||
}
|
||||
|
||||
// 3. 直接更新record的字段(只更新非空字段)
|
||||
@@ -46,12 +46,18 @@ func (l *AdminUpdateFeatureLogic) AdminUpdateFeature(req *types.AdminUpdateFeatu
|
||||
if req.Name != nil && *req.Name != "" {
|
||||
record.Name = *req.Name
|
||||
}
|
||||
if req.WhitelistPrice != nil {
|
||||
record.WhitelistPrice = *req.WhitelistPrice
|
||||
}
|
||||
if req.CostPrice != nil {
|
||||
record.CostPrice = *req.CostPrice
|
||||
}
|
||||
|
||||
// 4. 执行更新操作
|
||||
err = l.svcCtx.FeatureModel.UpdateWithVersion(l.ctx, nil, record)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR),
|
||||
"更新功能失败, err: %v, id: %d", err, req.Id)
|
||||
"更新功能失败, err: %v, id: %s", err, req.Id)
|
||||
}
|
||||
|
||||
// 5. 返回成功结果
|
||||
|
||||
Reference in New Issue
Block a user