feat: 迁移plant

This commit is contained in:
Blizzard
2026-05-23 13:55:05 +08:00
parent a93477ea8e
commit ae6d03d351
228 changed files with 25296 additions and 917 deletions
@@ -3,6 +3,7 @@ package logic
import (
"context"
plantModel "sundynix-micro-go/app/plant/model"
"sundynix-micro-go/app/plant/rpc/internal/svc"
"sundynix-micro-go/app/plant/rpc/plant"
@@ -23,9 +24,30 @@ func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
}
}
// 用户Profile
// 获取用户资料 (首次访问自动初始化)
func (l *GetUserProfileLogic) GetUserProfile(in *plant.GetProfileReq) (*plant.PlantUserProfile, error) {
// todo: add your logic here and delete this line
return &plant.PlantUserProfile{}, nil
var profile plantModel.UserProfile
err := l.svcCtx.DB.Where("user_id = ?", in.UserId).FirstOrCreate(&profile, plantModel.UserProfile{
UserID: in.UserId,
}).Error
if err != nil {
return nil, err
}
return &plant.PlantUserProfile{
Id: profile.ID,
UserId: profile.UserID,
NickName: profile.NickName,
AvatarId: profile.AvatarID,
LevelId: profile.LevelID,
CurrentSunlight: profile.CurrentSunlight,
TotalSunlight: profile.TotalSunlight,
PlantCount: profile.PlantCount,
CareCount: profile.CareCount,
PostCount: profile.PostCount,
WaterCount: profile.WaterCount,
FertilizeCount: profile.FertilizeCount,
RepotCount: profile.RepotCount,
PruneCount: profile.PruneCount,
PhotoCount: profile.PhotoCount,
}, nil
}