feat: 初次启动

This commit is contained in:
Blizzard
2026-04-27 21:23:13 +08:00
parent e515f6a287
commit bb8ad4d515
148 changed files with 8602 additions and 5678 deletions
@@ -1,13 +1,11 @@
// Code scaffolded by goctl. Safe to edit.
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"
plantModel "sundynix-micro-go/app/plant/model"
"sundynix-micro-go/app/plant/rpc/plant"
)
type UpdatePlantLogic struct {
@@ -21,32 +19,10 @@ func NewUpdatePlantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Updat
}
func (l *UpdatePlantLogic) UpdatePlant(req *types.UpdatePlantReq) error {
updates := map[string]interface{}{}
if req.Name != "" {
updates["name"] = req.Name
}
if req.Status > 0 {
updates["status"] = req.Status
}
if req.Placement != "" {
updates["placement"] = req.Placement
}
if req.PotMaterial != "" {
updates["pot_material"] = req.PotMaterial
}
if req.PotSize != "" {
updates["pot_size"] = req.PotSize
}
if req.Sunlight != "" {
updates["sunlight"] = req.Sunlight
}
if req.PlantingMaterial != "" {
updates["planting_material"] = req.PlantingMaterial
}
if len(updates) > 0 {
if err := l.svcCtx.DB.Model(&plantModel.SundynixMyPlant{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
return fmt.Errorf("更新植物失败")
}
}
return nil
_, err := l.svcCtx.PlantRpc.UpdatePlant(l.ctx, &plant.UpdatePlantReq{
Id: req.Id, Name: req.Name, Status: int32(req.Status), Placement: req.Placement,
PotMaterial: req.PotMaterial, PotSize: req.PotSize, Sunlight: req.Sunlight,
PlantingMaterial: req.PlantingMaterial, ImgIds: req.ImgIds,
})
return err
}