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 {
return db.Model("im_topics t").Safe().Ctx(ctx).
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(
"t.name topic",
"t.state",
"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.delid del_id",
"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).
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(
"t.name topic",
"t.state",
"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.delid del_id",
"t.subcnt sub_cnt",