30 lines
794 B
Go
30 lines
794 B
Go
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
|
|
}
|