feat: 迁移plant
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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 UpdateLevelConfigLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewUpdateLevelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLevelConfigLogic {
|
||||
return &UpdateLevelConfigLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
|
||||
}
|
||||
|
||||
func (l *UpdateLevelConfigLogic) UpdateLevelConfig(in *plant.UpdateLevelConfigReq) (*plant.CommonResp, error) {
|
||||
updates := map[string]interface{}{"level": in.Level, "title": in.Title, "min_sunlight": in.MinSunlight, "perks": in.Perks}
|
||||
if err := l.svcCtx.DB.Model(&plantModel.LevelConfig{}).Where("id = ?", in.Id).Updates(updates).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &plant.CommonResp{Code: 0, Msg: "ok"}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user