fix bug: free model not record the chat history

This commit is contained in:
RockYang
2024-06-06 15:01:32 +08:00
parent c02661ea29
commit b8de15d66e
7 changed files with 41 additions and 29 deletions

View File

@@ -109,7 +109,6 @@ func (h *UserHandler) Register(c *gin.Context) {
user := model.User{
Username: data.Username,
Password: utils.GenPassword(data.Password, salt),
Nickname: fmt.Sprintf("极客学长@%d", utils.RandomNumber(6)),
Avatar: "/images/avatar/user.png",
Salt: salt,
Status: true,
@@ -118,6 +117,16 @@ func (h *UserHandler) Register(c *gin.Context) {
Power: h.App.SysConfig.InitPower,
}
// 被邀请人也获得赠送算力
if data.InviteCode != "" {
user.Power += h.App.SysConfig.InvitePower
}
if h.licenseService.GetLicense().Configs.DeCopy {
user.Username = fmt.Sprintf("用户@%d", utils.RandomNumber(6))
} else {
user.Nickname = fmt.Sprintf("极客学长@%d", utils.RandomNumber(6))
}
res = h.DB.Create(&user)
if res.Error != nil {
resp.ERROR(c, "保存数据失败")