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,14 +1,11 @@
// Code scaffolded by goctl. Safe to edit.
package myPlant
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
"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 GetPlantDetailLogic struct {
@@ -22,24 +19,9 @@ func NewGetPlantDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
}
func (l *GetPlantDetailLogic) GetPlantDetail(req *types.IdPathReq) (resp interface{}, err error) {
var plant plantModel.SundynixMyPlant
if err := l.svcCtx.DB.Where("id = ?", req.Id).First(&plant).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return nil, fmt.Errorf("植物不存在")
}
return nil, fmt.Errorf("查询植物失败")
result, err := l.svcCtx.PlantRpc.GetPlantDetail(l.ctx, &plant.IdReq{Id: req.Id})
if err != nil {
return nil, err
}
// 查询关联图片ID
var ossIds []string
l.svcCtx.DB.Model(&plantModel.SundynixMyPlantOss{}).Where("sundynix_my_plant_id = ?", plant.ID).Pluck("sundynix_oss_id", &ossIds)
// 查询养护计划
var plans []plantModel.SundynixCarePlan
l.svcCtx.DB.Where("plant_id = ?", plant.ID).Find(&plans)
// 查询成长记录
var records []plantModel.SundynixGrowthRecord
l.svcCtx.DB.Where("plant_id = ?", plant.ID).Order("created_at DESC").Limit(10).Find(&records)
return map[string]interface{}{
"plant": plant, "imgIds": ossIds, "carePlans": plans, "growthRecords": records,
}, nil
return result, nil
}