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
@@ -5,9 +5,12 @@ package userProfile
import (
"context"
"fmt"
"sundynix-micro-go/app/plant/api/internal/svc"
"sundynix-micro-go/app/plant/api/internal/types"
"sundynix-micro-go/app/plant/rpc/plant"
systemPb "sundynix-micro-go/app/system/rpc/system"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +31,27 @@ func NewUpdateUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *UpdateUserProfileLogic) UpdateUserProfile(req *types.UpdateProfileReq) error {
// todo: add your logic here and delete this line
userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
// 1. 更新植物用户资料(昵称、头像)
if _, err := l.svcCtx.PlantRpc.UpdateUserProfile(l.ctx, &plant.UpdateProfileReq{
UserId: userId,
NickName: req.Nickname,
AvatarId: req.AvatarId,
}); err != nil {
return err
}
// 2. 同步更新系统 user 表(与旧项目保持一致:name + avatar_id 双写)
if req.Nickname != "" || req.AvatarId != "" {
if _, err := l.svcCtx.UserRpc.UpdateUser(l.ctx, &systemPb.UpdateUserReq{
Id: userId,
NickName: req.Nickname,
AvatarId: req.AvatarId,
}); err != nil {
// 非致命错误,记录日志但不回滚(植物资料已更新)
l.Logger.Errorf("sync system user failed: %v", err)
}
}
return nil
}