feat: create chat app list page, build the layout of page

This commit is contained in:
RockYang
2023-10-13 18:05:40 +08:00
parent ead8dbbaa5
commit ebdec4fa44
7 changed files with 95 additions and 31 deletions

View File

@@ -24,6 +24,7 @@ func NewChatRoleHandler(app *core.AppServer, db *gorm.DB) *ChatRoleHandler {
// List get user list
func (h *ChatRoleHandler) List(c *gin.Context) {
all := h.GetBool(c, "all")
var roles []model.ChatRole
res := h.db.Where("enable", true).Order("sort_num ASC").Find(&roles)
if res.Error != nil {
@@ -31,6 +32,22 @@ func (h *ChatRoleHandler) List(c *gin.Context) {
return
}
// 获取所有角色
if all {
// 转成 vo
var roleVos = make([]vo.ChatRole, 0)
for _, r := range roles {
var v vo.ChatRole
err := utils.CopyObject(r, &v)
if err == nil {
v.Id = r.Id
roleVos = append(roleVos, v)
}
}
resp.SUCCESS(c, roleVos)
return
}
user, err := utils.GetLoginUser(c, h.db)
if err != nil {
resp.NotAuth(c)