31 lines
948 B
Go
31 lines
948 B
Go
package myPlant
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"sundynix-micro-go/app/plant/api/internal/svc"
|
|
"sundynix-micro-go/app/plant/api/internal/types"
|
|
"sundynix-micro-go/app/plant/rpc/plant"
|
|
)
|
|
|
|
type CreatePlantLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewCreatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePlantLogic {
|
|
return &CreatePlantLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
|
}
|
|
|
|
func (l *CreatePlantLogic) CreatePlant(req *types.CreatePlantReq) error {
|
|
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
|
|
_, err := l.svcCtx.PlantRpc.CreatePlant(l.ctx, &plant.CreatePlantReq{
|
|
UserId: userId, Name: req.Name, PlantTime: req.PlantTime, Placement: req.Placement,
|
|
PotMaterial: req.PotMaterial, PotSize: req.PotSize, Sunlight: req.Sunlight,
|
|
PlantingMaterial: req.PlantingMaterial, ImgIds: req.ImgIds,
|
|
})
|
|
return err
|
|
}
|