Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-09-08 18:50:04 +08:00
commit eb7235281f
2 changed files with 23 additions and 10 deletions

View File

@ -124,11 +124,10 @@ func (l *UserLogoListLogic) UserLogoList(req *types.UserLogoListReq, userinfo *a
}
list, err := userMaterialModel.FindList(l.ctx, userMaterialRSB, nil, "")
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "data not found")
if !errors.Is(err, gorm.ErrRecordNotFound) {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get data list")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get data list")
}
var isDefaul bool = false
if len(list) > 0 {

View File

@ -109,11 +109,11 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
}
}
var module = "profile"
if req.SetLogoSelected == 1 {
var userInfo = &gmodel.FsUserInfo{}
BuilderDB := tx.Model(&gmodel.FsUserInfo{}).Where("module = ?", "profile")
BuilderDB := tx.Model(&gmodel.FsUserInfo{}).Where("module = ?", module)
if userId > 0 {
BuilderDB.Where("user_id=?", userId)
} else {
@ -122,7 +122,7 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
userInfoFirstRes := BuilderDB.First(userInfo)
err = userInfoFirstRes.Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
if !errors.Is(err, gorm.ErrRecordNotFound) {
logc.Errorf(l.ctx, "userInfo First err%+v", err)
return err
}
@ -149,9 +149,23 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
return err
}
userInfo.Metadata = &metadataBUserInfo
userInfo.Utime = &nowTime
resUpdates := tx.Model(&userInfo).Select("metadata").Where("id = ?", userInfo.Id).Updates(&userInfo)
err = resUpdates.Error
if userInfo.Id == 0 {
// 新增
userInfo.Module = &module
userInfo.Ctime = &nowTime
userInfo.Utime = &nowTime
userInfo.UserId = &userId
userInfo.GuestId = &guestId
resCreate := tx.Model(&userInfo).Create(&userInfo)
err = resCreate.Error
} else {
// 更新
userInfo.Utime = &nowTime
resUpdates := tx.Model(&userInfo).Select("metadata").Where("id = ?", userInfo.Id).Updates(&userInfo)
err = resUpdates.Error
}
if err != nil {
if err != gorm.ErrRecordNotFound {
logc.Errorf(l.ctx, "FsUserInfo Updates err%+v", err)