This commit is contained in:
laodaming 2023-09-20 18:06:21 +08:00
parent 82a8dfa953
commit d4b1d78201
2 changed files with 3 additions and 18 deletions

View File

@ -142,16 +142,7 @@ func (m *FsUserMaterialModel) GetListByUser(ctx context.Context, userId, guestId
Where(cond).Order("id DESC").Limit(limit).Find(&resp).Error
return resp, err
}
func (m *FsUserMaterialModel) FindOneByUserAndLogoUrl(ctx context.Context, userId, guestId int64, logoResourceId string) (resp *FsUserMaterial, err error) {
var cond string
if userId != 0 {
cond = fmt.Sprintf("user_id = %d", userId)
} else if guestId != 0 {
cond = fmt.Sprintf("guest_id = %d", guestId)
} else {
cond = fmt.Sprintf("user_id = %d and guest_id = %d", userId, guestId)
}
err = m.db.WithContext(ctx).Model(&FsUserMaterial{}).Where("`resource_id` = ?", logoResourceId).
Where(cond).Order("id DESC").Take(&resp).Error
func (m *FsUserMaterialModel) FindOneByLogoResourceId(ctx context.Context, logoResourceId string) (resp *FsUserMaterial, err error) {
err = m.db.WithContext(ctx).Model(&FsUserMaterial{}).Where("`resource_id` = ?", logoResourceId).Take(&resp).Error
return resp, err
}

View File

@ -59,13 +59,7 @@ func (l *GetTemplateTagColorLogic) GetTemplateTagColor(req *types.GetTemplateTag
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tag info")
}
//游客或者用户
if userinfo.IsUser() || userinfo.IsGuest() {
userMaterial, err = l.svcCtx.AllModels.FsUserMaterial.FindOneByUserAndLogoUrl(l.ctx, userinfo.UserId, userinfo.GuestId, resourceId)
} else {
//白板用户
userMaterial, err = l.svcCtx.AllModels.FsUserMaterial.FindOneById(l.ctx, 0)
}
userMaterial, err = l.svcCtx.AllModels.FsUserMaterial.FindOneByLogoResourceId(l.ctx, resourceId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the logo is not found")