feat: 长文本语音合成
This commit is contained in:
@@ -100,7 +100,7 @@ func (userService *UserService) ChangePassword(id string, pwd string) (err error
|
||||
return global.DB.Model(&system.User{}).Where("id = ?", id).Update("password", utils.BcryptHash(pwd)).Error
|
||||
}
|
||||
|
||||
func (userService *UserService) MiniLogin(code string) (result *system.User, err error) {
|
||||
func (userService *UserService) MiniLogin(code, ip string) (result *system.User, err error) {
|
||||
//构建参数
|
||||
params := url2.Values{}
|
||||
params.Set("appid", global.Config.MiniProgram.AppId)
|
||||
@@ -150,9 +150,10 @@ func (userService *UserService) MiniLogin(code string) (result *system.User, err
|
||||
err = global.DB.Transaction(func(tx *gorm.DB) error {
|
||||
// 创建新用户
|
||||
newUser := system.User{
|
||||
Name: uniqueid.GenerateRadioUsername(),
|
||||
OpenId: wxResp.Openid,
|
||||
SessionKey: wxResp.SessionKey,
|
||||
Name: uniqueid.GenerateRadioUsername(),
|
||||
OpenId: wxResp.Openid,
|
||||
SessionKey: wxResp.SessionKey,
|
||||
LastLoginIp: ip,
|
||||
}
|
||||
if err := tx.Create(&newUser).Error; err != nil {
|
||||
return err
|
||||
@@ -170,7 +171,11 @@ func (userService *UserService) MiniLogin(code string) (result *system.User, err
|
||||
}
|
||||
if err == nil && user.Id != "" {
|
||||
// UpdateColumn:只更新字段,不触发模型钩子,比Update更高效
|
||||
if err = global.DB.Model(&user).UpdateColumn("session_key", wxResp.SessionKey).Error; err != nil {
|
||||
updateData := map[string]interface{}{
|
||||
"session_key": wxResp.SessionKey,
|
||||
"last_login_ip": ip,
|
||||
}
|
||||
if err = global.DB.Model(&user).Updates(updateData).Error; err != nil {
|
||||
global.Logger.Error("更新session_key失败", zap.Error(err))
|
||||
return nil, fmt.Errorf("更新session_key失败: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user