Files
sundynix-micro-be/app/plant/rpc/internal/logic/createLevelConfigLogic.go
T
2026-05-23 13:55:05 +08:00

28 lines
878 B
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 CreateLevelConfigLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateLevelConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLevelConfigLogic {
return &CreateLevelConfigLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
}
func (l *CreateLevelConfigLogic) CreateLevelConfig(in *plant.CreateLevelConfigReq) (*plant.CommonResp, error) {
cfg := plantModel.LevelConfig{Level: int(in.Level), Title: in.Title, MinSunlight: in.MinSunlight, Perks: in.Perks}
if err := l.svcCtx.DB.Create(&cfg).Error; err != nil {
return nil, err
}
return &plant.CommonResp{Code: 0, Msg: "ok"}, nil
}