获取app用户数据时,用户姓名新增默认name数据
This commit is contained in:
parent
997ca33dc4
commit
fc4e40f49b
@ -377,7 +377,9 @@ func (r *UserService) GetAppUserInfo(tx *gorm.DB, user *model.User, userInfo *mo
|
||||
}
|
||||
|
||||
// 姓名
|
||||
if appUserInfo.Data.Name != "" {
|
||||
if appUserInfo.Data.Name == "" {
|
||||
appUserInfo.Data.Name = "GDXZ_" + utils.GenerateRandomString(4)
|
||||
}
|
||||
if user.UserName != "" {
|
||||
if appUserInfo.Data.Name != user.UserName {
|
||||
userData["user_name"] = appUserInfo.Data.Name
|
||||
@ -385,7 +387,6 @@ func (r *UserService) GetAppUserInfo(tx *gorm.DB, user *model.User, userInfo *mo
|
||||
} else {
|
||||
userData["user_name"] = appUserInfo.Data.Name
|
||||
}
|
||||
}
|
||||
|
||||
// 头像
|
||||
if appUserInfo.Data.Photo != "" && user.Avatar == "" {
|
||||
|
||||
@ -2,7 +2,9 @@ package utils
|
||||
|
||||
import (
|
||||
"hepa-calc-api/config"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RemoveOssDomain 去除oss地址中的前缀
|
||||
@ -20,3 +22,15 @@ func AddOssDomain(url string) string {
|
||||
}
|
||||
return config.C.Oss.OssCustomDomainName + url
|
||||
}
|
||||
|
||||
// GenerateRandomString 生成随机字母字符串
|
||||
func GenerateRandomString(n int) string {
|
||||
letters := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数种子
|
||||
b := make([]byte, n) // 创建长度为 n 的字节切片
|
||||
for i := range b {
|
||||
b[i] = letters[r.Intn(len(letters))] // 从字母列表中随机选择字符
|
||||
}
|
||||
return string(b) // 转换为字符串返回
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user