feat: 用户中心

This commit is contained in:
Blizzard
2026-02-11 14:33:00 +08:00
parent 4ccab96ca2
commit 112a1f439c
17 changed files with 1571 additions and 138 deletions
+29
View File
@@ -0,0 +1,29 @@
package plant
import (
"sundynix-go/global"
"sundynix-go/model/plant"
plantReq "sundynix-go/model/plant/request"
)
type UserProfileService struct{}
// UpdateProfile 修改用户信息
func (s *UserProfileService) UpdateProfile(req plantReq.UpdateProfile, userId string) error {
updateMap := map[string]interface{}{
"nick_name": req.Nickname,
"avatar_id": req.AvatarId,
}
return global.DB.Model(&plant.UserProfile{}).Where("user_id = ?", userId).Updates(updateMap).Error
}
// ProfileDetail 获取用户详情
func (s *UserProfileService) ProfileDetail(userId string) (plant.UserProfile, error) {
var res plant.UserProfile
err := global.DB.Where("user_id = ?", userId).Preload("Avatar").Preload("Level").First(&res).Error
if err != nil {
return res, err
}
return res, nil
}