feat: 迁移plant
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sundynix-micro-go/app/plant/api/internal/svc"
|
||||
"sundynix-micro-go/app/plant/api/internal/types"
|
||||
plantPb "sundynix-micro-go/app/plant/rpc/plant"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateWikiLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 创建百科
|
||||
func NewCreateWikiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWikiLogic {
|
||||
return &CreateWikiLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateWikiLogic) CreateWiki(req *types.CreateWikiReq) error {
|
||||
classID := req.ClassId
|
||||
if classID == "" && len(req.ClassIds) > 0 {
|
||||
classID = req.ClassIds[0]
|
||||
}
|
||||
_, err := l.svcCtx.PlantRpc.CreateWiki(l.ctx, &plantPb.CreateWikiReq{
|
||||
Name: req.Name,
|
||||
LatinName: req.LatinName,
|
||||
Aliases: req.Aliases,
|
||||
Genus: req.Genus,
|
||||
Difficulty: int32(req.Difficulty),
|
||||
IsHot: int32(req.IsHot),
|
||||
GrowthHabit: req.GrowthHabit,
|
||||
LightIntensity: req.LightIntensity,
|
||||
OptimalTempPeriod: req.OptimalTempPeriod,
|
||||
ClassId: classID,
|
||||
DistributionArea: req.DistributionArea,
|
||||
LifeCycle: req.LifeCycle,
|
||||
ClassIds: req.ClassIds,
|
||||
OssIds: req.OssIds,
|
||||
RelatedWikiIds: req.RelatedWikiIds,
|
||||
ReproductionMethod: req.ReproductionMethod,
|
||||
PestsDiseases: req.PestsDiseases,
|
||||
LightType: req.LightType,
|
||||
Stem: req.Stem,
|
||||
Fruit: req.Fruit,
|
||||
FoliageType: req.FoliageType,
|
||||
FoliageColor: req.FoliageColor,
|
||||
FoliageShape: req.FoliageShape,
|
||||
Height: int32(req.Height),
|
||||
FloweringPeriod: req.FloweringPeriod,
|
||||
FloweringColor: req.FloweringColor,
|
||||
FloweringShape: req.FloweringShape,
|
||||
FloweringDiameter: int32(req.FlowerDiameter),
|
||||
})
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user