return at least one chat role for getUserRoles API

This commit is contained in:
RockYang 2024-09-14 05:54:55 +08:00
parent 1960a85ead
commit 96b8121210
2 changed files with 5 additions and 2 deletions

View File

@ -269,7 +269,7 @@ func (h *UserHandler) Remove(c *gin.Context) {
} }
} }
if err != nil { if err != nil {
resp.ERROR(c, "删除失败") resp.ERROR(c, err.Error())
tx.Rollback() tx.Rollback()
return return
} }

View File

@ -69,8 +69,11 @@ func (h *ChatRoleHandler) ListByUser(c *gin.Context) {
resp.ERROR(c, "角色解析失败!") resp.ERROR(c, "角色解析失败!")
return return
} }
// 保证用户至少有一个角色可用
if len(roleKeys) > 0 {
session = session.Where("marker IN ?", roleKeys) session = session.Where("marker IN ?", roleKeys)
} }
}
if id > 0 { if id > 0 {
session = session.Or("id", id) session = session.Or("id", id)