feat: improve group owner and status display

This commit is contained in:
richjohnrambo
2026-09-09 11:10:59 +08:00
parent 964746c19b
commit da60b52be2
5 changed files with 70 additions and 28 deletions
+8
View File
@@ -70,10 +70,14 @@ func (s *sSysImGroup) List(ctx context.Context, in *sysin.ImGroupListInp) (list
func (s *sSysImGroup) groupModel(ctx context.Context, db gdb.DB) *gdb.Model { func (s *sSysImGroup) groupModel(ctx context.Context, db gdb.DB) *gdb.Model {
return db.Model("im_topics t").Safe().Ctx(ctx). return db.Model("im_topics t").Safe().Ctx(ctx).
LeftJoin("im_group_settings gs", "gs.topic = t.name"). LeftJoin("im_group_settings gs", "gs.topic = t.name").
LeftJoin("im_users owner", "owner.id = COALESCE(gs.owner_user_id, t.owner)").
LeftJoin("im_user_profiles owner_profile", "owner_profile.user_id = COALESCE(gs.owner_user_id, t.owner)").
Fields( Fields(
"t.name topic", "t.name topic",
"t.state", "t.state",
"COALESCE(gs.owner_user_id, t.owner) owner_id", "COALESCE(gs.owner_user_id, t.owner) owner_id",
"COALESCE(NULLIF(owner_profile.nickname, ''), owner.username, '') owner_nickname",
"COALESCE(owner.username, '') owner_username",
"t.seqid seq_id", "t.seqid seq_id",
"t.delid del_id", "t.delid del_id",
"t.subcnt sub_cnt", "t.subcnt sub_cnt",
@@ -137,10 +141,14 @@ func (s *sSysImGroup) View(ctx context.Context, in *sysin.ImGroupViewInp) (res *
err = db.Model("im_topics t").Safe().Ctx(ctx). err = db.Model("im_topics t").Safe().Ctx(ctx).
LeftJoin("im_group_settings gs", "gs.topic = t.name"). LeftJoin("im_group_settings gs", "gs.topic = t.name").
LeftJoin("im_users owner", "owner.id = COALESCE(gs.owner_user_id, t.owner)").
LeftJoin("im_user_profiles owner_profile", "owner_profile.user_id = COALESCE(gs.owner_user_id, t.owner)").
Fields( Fields(
"t.name topic", "t.name topic",
"t.state", "t.state",
"COALESCE(gs.owner_user_id, t.owner) owner_id", "COALESCE(gs.owner_user_id, t.owner) owner_id",
"COALESCE(NULLIF(owner_profile.nickname, ''), owner.username, '') owner_nickname",
"COALESCE(owner.username, '') owner_username",
"t.seqid seq_id", "t.seqid seq_id",
"t.delid del_id", "t.delid del_id",
"t.subcnt sub_cnt", "t.subcnt sub_cnt",
+17 -15
View File
@@ -30,21 +30,23 @@ func (in *ImGroupListInp) Filter(ctx context.Context) (err error) {
} }
type ImGroupListModel struct { type ImGroupListModel struct {
TenantId int64 `json:"tenantId" dc:"租户ID"` TenantId int64 `json:"tenantId" dc:"租户ID"`
TenantName string `json:"tenantName" dc:"租户名称"` TenantName string `json:"tenantName" dc:"租户名称"`
Topic string `json:"topic" dc:"Topic"` Topic string `json:"topic" dc:"Topic"`
State int `json:"state" dc:"状态"` State int `json:"state" dc:"状态"`
OwnerId int64 `json:"ownerId" dc:"群主ID"` OwnerId int64 `json:"ownerId" dc:"群主ID"`
SeqId int `json:"seqId" dc:"最新消息序号"` OwnerNickname string `json:"ownerNickname" dc:"群主昵称"`
DelId int `json:"delId" dc:"删除序号"` OwnerUsername string `json:"ownerUsername" dc:"群主用户名"`
SubCnt int `json:"subCnt" dc:"成员数"` SeqId int `json:"seqId" dc:"最新消息序号"`
TouchedAt *gtime.Time `json:"touchedAt" dc:"活跃时间"` DelId int `json:"delId" dc:"删除序号"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` SubCnt int `json:"subCnt" dc:"成员数"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"` TouchedAt *gtime.Time `json:"touchedAt" dc:"活跃时间"`
PublicJson string `json:"publicJson" dc:"公开资料"` CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
TrustedJson string `json:"trustedJson" dc:"可信资料"` UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
TagsJson string `json:"tagsJson" dc:"标签"` PublicJson string `json:"publicJson" dc:"公开资料"`
AuxJson string `json:"auxJson" dc:"辅助资料"` TrustedJson string `json:"trustedJson" dc:"可信资料"`
TagsJson string `json:"tagsJson" dc:"标签"`
AuxJson string `json:"auxJson" dc:"辅助资料"`
GroupName string `json:"groupName" dc:"群名称"` GroupName string `json:"groupName" dc:"群名称"`
AvatarFileId string `json:"avatarFileId" dc:"头像文件ID"` AvatarFileId string `json:"avatarFileId" dc:"头像文件ID"`
@@ -89,3 +89,13 @@ WHERE NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imGroupMemberRem
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`)
SELECT NULL, @groupListId, '转让群主', 'imGroupOwnerTransfer', '', '', '3', '', '/imGroup/ownerTransfer', '', '', '1', '', '0', '0', '', '0', '1', '0', '4', CONCAT('tr_', @imRootId, ' tr_', @groupDirId, ' tr_', @groupListId, ' '), '160', '', '1', @now, @now SELECT NULL, @groupListId, '转让群主', 'imGroupOwnerTransfer', '', '', '3', '', '/imGroup/ownerTransfer', '', '', '1', '', '0', '0', '', '0', '1', '0', '4', CONCAT('tr_', @imRootId, ' tr_', @groupDirId, ' tr_', @groupListId, ' '), '160', '', '1', @now, @now
WHERE NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imGroupOwnerTransfer'); WHERE NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imGroupOwnerTransfer');
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`)
SELECT NULL, @groupListId, '解散群', 'imGroupDissolve', '', '', '3', '', '/imGroup/dissolve', '', '', '1', '', '0', '0', '', '0', '1', '0', '4', CONCAT('tr_', @imRootId, ' tr_', @groupDirId, ' tr_', @groupListId, ' '), '170', '', '1', @now, @now
WHERE NOT EXISTS (SELECT 1 FROM `hg_admin_menu` WHERE `name` = 'imGroupDissolve');
INSERT IGNORE INTO `hg_admin_role_menu` (`role_id`, `menu_id`)
SELECT source_role.`role_id`, dissolve_menu.`id`
FROM `hg_admin_role_menu` source_role
JOIN `hg_admin_menu` governance_update ON governance_update.`id` = source_role.`menu_id` AND governance_update.`name` = 'imGroupGovernanceUpdate'
JOIN `hg_admin_menu` dissolve_menu ON dissolve_menu.`name` = 'imGroupDissolve';
+29 -12
View File
@@ -1,4 +1,5 @@
import { computed, ref } from 'vue'; import { computed, h, ref } from 'vue';
import { NTag } from 'naive-ui';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { FormSchema } from '@/components/Form'; import { FormSchema } from '@/components/Form';
import { defRangeShortcuts } from '@/utils/dateUtil'; import { defRangeShortcuts } from '@/utils/dateUtil';
@@ -15,6 +16,8 @@ export class State {
public topic = ''; // Topic public topic = ''; // Topic
public state = 0; // 状态 public state = 0; // 状态
public ownerId = 0; // 群主ID public ownerId = 0; // 群主ID
public ownerNickname = ''; // 群主昵称
public ownerUsername = ''; // 群主用户名
public seqId = 0; // 最新消息序号 public seqId = 0; // 最新消息序号
public delId = 0; // 删除序号 public delId = 0; // 删除序号
public subCnt = 0; // 成员数 public subCnt = 0; // 成员数
@@ -183,10 +186,10 @@ export const schemas = ref<FormSchema[]>([
// 表格列 // 表格列
export const columns = [ export const columns = [
{ {
title: 'Topic', title: '群名称',
key: 'topic', key: 'groupName',
align: 'left', align: 'left',
width: 220, width: 180,
}, },
{ {
title: '状态', title: '状态',
@@ -194,7 +197,12 @@ export const columns = [
align: 'left', align: 'left',
width: 110, width: 110,
render(row: State) { render(row: State) {
return dict.getLabel('ImGroupStateOptions', row.state); const label = dict.getLabel('ImGroupStateOptions', row.state) || '-';
return h(
NTag,
{ type: dict.getType('ImGroupStateOptions', row.state), bordered: true },
() => label
);
}, },
}, },
{ {
@@ -203,20 +211,29 @@ export const columns = [
align: 'left', align: 'left',
width: 110, width: 110,
render(row: State) { render(row: State) {
return dict.getLabel('ImGroupStatusOptions', row.groupStatus) || '-'; const dictName = row.groupStatus ? 'ImGroupStatusOptions' : 'ImGroupStateOptions';
const value = row.groupStatus || row.state;
const label = dict.getLabel(dictName, value) || '-';
return h(NTag, { type: dict.getType(dictName, value), bordered: true }, () => label);
}, },
}, },
{ {
title: '群名称', title: 'Topic',
key: 'groupName', key: 'topic',
align: 'left', align: 'left',
width: 160, width: 220,
}, },
{ {
title: '群主ID', title: '群主昵称',
key: 'ownerId', key: 'ownerNickname',
align: 'left', align: 'left',
width: 120, width: 150,
},
{
title: '群主用户名',
key: 'ownerUsername',
align: 'left',
width: 160,
}, },
{ {
title: '成员数', title: '成员数',
+6 -1
View File
@@ -15,7 +15,12 @@
<n-descriptions-item label="租户">{{ formValue.tenantName }}</n-descriptions-item> <n-descriptions-item label="租户">{{ formValue.tenantName }}</n-descriptions-item>
<n-descriptions-item label="Topic">{{ formValue.topic }}</n-descriptions-item> <n-descriptions-item label="Topic">{{ formValue.topic }}</n-descriptions-item>
<n-descriptions-item label="状态">{{ stateLabel }}</n-descriptions-item> <n-descriptions-item label="状态">{{ stateLabel }}</n-descriptions-item>
<n-descriptions-item label="群主ID">{{ formValue.ownerId }}</n-descriptions-item> <n-descriptions-item label="群主昵称">{{
formValue.ownerNickname || '-'
}}</n-descriptions-item>
<n-descriptions-item label="群主用户名">{{
formValue.ownerUsername || '-'
}}</n-descriptions-item>
<n-descriptions-item label="业务状态">{{ groupStatusLabel }}</n-descriptions-item> <n-descriptions-item label="业务状态">{{ groupStatusLabel }}</n-descriptions-item>
<n-descriptions-item label="群名称">{{ <n-descriptions-item label="群名称">{{
formValue.groupName || '-' formValue.groupName || '-'