feat: 长文本语音合成

This commit is contained in:
Blizzard
2026-03-06 17:39:52 +08:00
parent 2583b5f302
commit dda4d2e1d6
24 changed files with 975 additions and 52 deletions
+10 -5
View File
@@ -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)
}