🆕 群成员新增是否群主

This commit is contained in:
李寻欢 2024-01-12 22:26:06 +08:00
parent 01051ff606
commit 6a879cbef6
5 changed files with 19 additions and 37 deletions

View File

@ -31,6 +31,7 @@ type GroupUser struct {
HeadImage string `json:"headImage"` // 头像
Nickname string `json:"nickname"` // 昵称
IsMember bool `json:"isMember" gorm:"type:tinyint(1) default 0 not null"` // 是否群成员
IsAdmin bool `json:"isAdmin" gorm:"type:tinyint(1) default 0 not null"` // 是否群主
JoinTime time.Time `json:"joinTime"` // 加入时间
LeaveTime *time.Time `json:"leaveTime"` // 离开时间
SkipChatRank bool `json:"skipChatRank" gorm:"type:tinyint(1) default 0 not null"` // 是否跳过聊天排行

View File

@ -155,6 +155,7 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
Nickname: cp.Nickname,
Wxid: cp.Wxid,
IsMember: true,
IsAdmin: wxid == baseResp.Data.Admin,
JoinTime: time.Now().Local(),
}).Error
if err != nil {
@ -168,6 +169,7 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
"head_image": cp.HeadImage,
"nickname": cp.Nickname,
"is_member": true,
"is_admin": wxid == baseResp.Data.Admin,
"leave_time": nil,
}
err = tx.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Where("wxid = ?", wxid).Updates(pm).Error

View File

@ -100,7 +100,7 @@
<th>是否启用AI</th>
<th>是否启用水群排行榜</th>
<th>是否启用迎新</th>
<th>是否启用l指令</th>
<th>是否启用指令</th>
<th>操作</th>
</tr>
</thead>
@ -201,6 +201,7 @@
<th>微信Id</th>
<th>昵称</th>
<th>是否群成员</th>
<th>是否群主</th>
<th>加群时间</th>
<th>最后活跃时间</th>
<th>退群时间</th>

View File

@ -112,43 +112,20 @@ function getGroupUsers(groupId, groupName) {
// 渲染群成员列表
const groupUsers = response.data
// 循环渲染数据
for (let i = 0; i < groupUsers.length; i++) {
const groupUser = groupUsers[i]
groupUsers.forEach((groupUser, i) => {
const { wxid, nickname, isMember, isAdmin, joinTime, lastActiveTime, leaveTime, skipChatRank } = groupUser;
let row = tbody.insertRow(i); // 插入新行
// 微信Id
let wxId = row.insertCell(0);
wxId.innerHTML = groupUser.wxid;
// 昵称
let nickname = row.insertCell(1);
nickname.innerHTML = groupUser.nickname;
// 是否群成员
let isMember = row.insertCell(2);
if (groupUser.isMember) {
isMember.innerHTML = '<div class="badge badge-info gap-2">是</div>';
} else {
isMember.innerHTML = '<div class="badge badge-error gap-2">否</div>';
}
// 加群时间
let joinTime = row.insertCell(3);
joinTime.innerHTML = groupUser.joinTime;
// 最后活跃时间
let lastActiveTime = row.insertCell(4);
lastActiveTime.innerHTML = groupUser.lastActiveTime;
// 退群时间
let leaveTime = row.insertCell(5);
leaveTime.innerHTML = groupUser.leaveTime;
// 是否跳过水群排行榜
let skipChatRank = row.insertCell(6);
skipChatRank.innerHTML = `<input type="checkbox" class="toggle toggle-error" ${groupUser.skipChatRank ? 'checked' : ''} onclick="changeUserGroupRankSkipStatus(\'${groupId}\', \'${groupUser.wxid}\')" />`;
}
let row = tbody.insertRow(i);
// Insert data into cells
row.insertCell(0).innerHTML = wxid;
row.insertCell(1).innerHTML = nickname;
row.insertCell(2).innerHTML = `<div class="badge badge-${isMember ? 'info' : 'error'} gap-2">${isMember ? '是' : '否'}</div>`;
row.insertCell(3).innerHTML = `<div class="badge badge-${isAdmin ? 'info' : 'error'} gap-2">${isAdmin ? '是' : '否'}</div>`;
row.insertCell(4).innerHTML = joinTime;
row.insertCell(5).innerHTML = lastActiveTime;
row.insertCell(6).innerHTML = leaveTime;
row.insertCell(7).innerHTML = `<input type="checkbox" class="toggle toggle-error" ${skipChatRank ? 'checked' : ''} onclick="changeUserGroupRankSkipStatus('${groupId}', '${wxid}')" />`;
});
}).catch(function (error) {
console.log(`错误信息: ${error}`);
}).finally(function () {

View File

@ -28,6 +28,7 @@ type GroupUserItem struct {
HeadImage string `json:"headImage"` // 头像
Nickname string `json:"nickname"` // 昵称
IsMember bool `json:"isMember" ` // 是否群成员
IsAdmin bool `json:"isAdmin"` // 是否群主
JoinTime types.DateTime `json:"joinTime"` // 加入时间
LastActiveTime types.DateTime `json:"lastActiveTime"` // 最后活跃时间
LeaveTime types.DateTime `json:"leaveTime"` // 离开时间