33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
plantModel "sundynix-micro-go/app/plant/model"
|
|
"sundynix-micro-go/app/plant/rpc/internal/svc"
|
|
"sundynix-micro-go/app/plant/rpc/plant"
|
|
)
|
|
|
|
type UpdateBadgeConfigLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewUpdateBadgeConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBadgeConfigLogic {
|
|
return &UpdateBadgeConfigLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
|
|
}
|
|
|
|
func (l *UpdateBadgeConfigLogic) UpdateBadgeConfig(in *plant.UpdateBadgeConfigReq) (*plant.CommonResp, error) {
|
|
updates := map[string]interface{}{
|
|
"name": in.Name, "description": in.Description, "dimension": in.Dimension,
|
|
"group_id": in.GroupId, "tier": in.Tier, "target_action": in.TargetAction,
|
|
"threshold": in.Threshold, "reward_sunlight": in.RewardSunlight,
|
|
"icon_id": in.IconId, "sort": in.Sort,
|
|
}
|
|
if err := l.svcCtx.DB.Model(&plantModel.BadgeConfig{}).Where("id = ?", in.Id).Updates(updates).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &plant.CommonResp{Code: 0, Msg: "ok"}, nil
|
|
}
|