Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 40s
feat(pay): 添加支付API基础结构 feat(miniapp): 创建支付测试小程序页面与配置 feat(wechatpay): 配置微信支付参数与证书 fix(guild): 修复成员列表查询条件 docs: 更新代码规范文档与需求文档 style: 统一前后端枚举显示与注释格式 refactor(admin): 重构用户奖励发放接口参数处理 test(title): 添加称号效果参数验证测试
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package activity
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"bindbox-game/internal/repository/mysql/model"
|
|
)
|
|
|
|
// ModifyIssueReward 修改期奖励
|
|
// 参数: rewardID 奖励ID, in 修改输入
|
|
// 返回: 错误信息
|
|
func (s *service) ModifyIssueReward(ctx context.Context, rewardID int64, in ModifyRewardInput) error {
|
|
item, err := s.readDB.ActivityRewardSettings.WithContext(ctx).Where(s.readDB.ActivityRewardSettings.ID.Eq(rewardID)).First()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if in.ProductID != nil {
|
|
item.ProductID = *in.ProductID
|
|
}
|
|
if in.Name != "" {
|
|
item.Name = in.Name
|
|
}
|
|
if in.Weight != nil {
|
|
item.Weight = *in.Weight
|
|
}
|
|
if in.Quantity != nil {
|
|
item.Quantity = *in.Quantity
|
|
}
|
|
if in.OriginalQty != nil {
|
|
item.OriginalQty = *in.OriginalQty
|
|
}
|
|
if in.Level != nil {
|
|
item.Level = *in.Level
|
|
}
|
|
if in.Sort != nil {
|
|
item.Sort = *in.Sort
|
|
}
|
|
if in.IsBoss != nil {
|
|
item.IsBoss = *in.IsBoss
|
|
}
|
|
item.UpdatedAt = time.Now()
|
|
return s.writeDB.ActivityRewardSettings.WithContext(ctx).Save(item)
|
|
}
|
|
|
|
// DeleteIssueReward 删除期奖励
|
|
// 参数: rewardID 奖励ID
|
|
// 返回: 错误信息
|
|
func (s *service) DeleteIssueReward(ctx context.Context, rewardID int64) error {
|
|
_, err := s.writeDB.ActivityRewardSettings.WithContext(ctx).Where(s.writeDB.ActivityRewardSettings.ID.Eq(rewardID)).Delete(&model.ActivityRewardSettings{})
|
|
return err
|
|
}
|