Compare commits
No commits in common. "be15d42d9349a35eac6ab625b624184c69924ddd" and "450857dee83f51ba000977011be5b3d12cd93ac1" have entirely different histories.
be15d42d93
...
450857dee8
@ -85,29 +85,6 @@ func ChangeEnableWelcomeStatus(ctx *gin.Context) {
|
||||
ctx.String(http.StatusOK, "操作成功")
|
||||
}
|
||||
|
||||
// ChangeEnableCommandStatus
|
||||
// @description: 修改是否开启指令
|
||||
// @param ctx
|
||||
func ChangeEnableCommandStatus(ctx *gin.Context) {
|
||||
var p changeStatusParam
|
||||
if err := ctx.ShouldBindJSON(&p); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
log.Printf("待修改的群Id:%s", p.WxId)
|
||||
|
||||
err := client.MySQL.Model(&entity.Friend{}).
|
||||
Where("wxid = ?", p.WxId).
|
||||
Update("`enable_command`", gorm.Expr(" !`enable_command`")).Error
|
||||
if err != nil {
|
||||
log.Printf("修改指令启用状态失败:%s", err)
|
||||
ctx.String(http.StatusInternalServerError, "操作失败: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.String(http.StatusOK, "操作成功")
|
||||
}
|
||||
|
||||
// ChangeSkipGroupRankStatus
|
||||
// @description: 修改是否跳过水群排行榜
|
||||
// @param ctx
|
||||
|
@ -31,7 +31,6 @@ 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"` // 是否跳过聊天排行
|
||||
|
@ -23,7 +23,6 @@ func Init(g *gin.Engine) {
|
||||
api := g.Group("/api")
|
||||
api.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态
|
||||
api.PUT("/welcome/status", app.ChangeEnableWelcomeStatus) // 修改是否开启迎新状态
|
||||
api.PUT("/command/status", app.ChangeEnableCommandStatus) // 修改是否开启指令状态
|
||||
api.PUT("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜状态
|
||||
api.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态
|
||||
api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表
|
||||
|
@ -155,7 +155,6 @@ 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 {
|
||||
@ -169,7 +168,6 @@ 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
|
||||
|
@ -37,7 +37,6 @@
|
||||
<th>最后活跃时间</th>
|
||||
<th>是否在通讯录</th>
|
||||
<th>是否启用AI</th>
|
||||
<th>是否启用指令</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -68,14 +67,6 @@
|
||||
<label class="swap swap-flip {{ checkSwap .EnableAi }}">
|
||||
<input type="checkbox" onclick="changeAiEnableStatus({{.Wxid}})"/>
|
||||
|
||||
<div class="swap-on">✔️已启用</div>
|
||||
<div class="swap-off">❌已禁用</div>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label class="swap swap-flip {{ checkSwap .EnableCommand }}">
|
||||
<input type="checkbox" onclick="changeCommandEnableStatus({{.Wxid}})"/>
|
||||
|
||||
<div class="swap-on">✔️已启用</div>
|
||||
<div class="swap-off">❌已禁用</div>
|
||||
</label>
|
||||
@ -100,7 +91,6 @@
|
||||
<th>是否启用AI</th>
|
||||
<th>是否启用水群排行榜</th>
|
||||
<th>是否启用迎新</th>
|
||||
<th>是否启用指令</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -153,14 +143,6 @@
|
||||
<div class="swap-off">❌已禁用</div>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label class="swap swap-flip {{ checkSwap .EnableCommand }}">
|
||||
<input type="checkbox" onclick="changeCommandEnableStatus({{.Wxid}})"/>
|
||||
|
||||
<div class="swap-on">✔️已启用</div>
|
||||
<div class="swap-off">❌已禁用</div>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-link" onclick="getGroupUsers({{.Wxid}}, {{.Nickname}})">查看群成员</button>
|
||||
</td>
|
||||
@ -201,7 +183,6 @@
|
||||
<th>微信Id</th>
|
||||
<th>昵称</th>
|
||||
<th>是否群成员</th>
|
||||
<th>是否群主</th>
|
||||
<th>加群时间</th>
|
||||
<th>最后活跃时间</th>
|
||||
<th>退群时间</th>
|
||||
|
@ -51,22 +51,6 @@ function changeWelcomeEnableStatus(wxId) {
|
||||
})
|
||||
}
|
||||
|
||||
// 修改指令权限启用状态
|
||||
function changeCommandEnableStatus(wxId) {
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/command/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
})
|
||||
}
|
||||
|
||||
// 修改群成员是否参与排行榜状态
|
||||
function changeUserGroupRankSkipStatus(groupId, userId) {
|
||||
console.log("修改水群排行榜开启状态: ", groupId, userId)
|
||||
@ -112,20 +96,43 @@ function getGroupUsers(groupId, groupName) {
|
||||
// 渲染群成员列表
|
||||
const groupUsers = response.data
|
||||
// 循环渲染数据
|
||||
groupUsers.forEach((groupUser, i) => {
|
||||
const { wxid, nickname, isMember, isAdmin, joinTime, lastActiveTime, leaveTime, skipChatRank } = groupUser;
|
||||
for (let i = 0; i < groupUsers.length; i++) {
|
||||
const groupUser = groupUsers[i]
|
||||
|
||||
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}')" />`;
|
||||
});
|
||||
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}\')" />`;
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
}).finally(function () {
|
||||
|
@ -15,7 +15,6 @@ type FriendItem struct {
|
||||
EnableAi bool // 是否使用AI
|
||||
EnableChatRank bool // 是否使用聊天排行
|
||||
EnableWelcome bool // 是否使用迎新
|
||||
EnableCommand bool // 是否启用指令
|
||||
IsOk bool // 是否还在通讯库(群聊是要还在群里也算)
|
||||
LastActiveTime types.DateTime // 最后活跃时间
|
||||
}
|
||||
@ -28,7 +27,6 @@ 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"` // 离开时间
|
||||
|
Loading…
Reference in New Issue
Block a user