1
0
Fork 0

🆕 网页新增控制是否打开指令功能

This commit is contained in:
李寻欢 2024-01-12 22:20:14 +08:00
parent 77c5a96c76
commit 01051ff606
5 changed files with 59 additions and 0 deletions

View File

@ -85,6 +85,29 @@ 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

View File

@ -23,6 +23,7 @@ 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) // 获取群成员列表

View File

@ -37,6 +37,7 @@
<th>最后活跃时间</th>
<th>是否在通讯录</th>
<th>是否启用AI</th>
<th>是否启用指令</th>
</tr>
</thead>
<tbody>
@ -67,6 +68,14 @@
<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>
@ -91,6 +100,7 @@
<th>是否启用AI</th>
<th>是否启用水群排行榜</th>
<th>是否启用迎新</th>
<th>是否启用l指令</th>
<th>操作</th>
</tr>
</thead>
@ -143,6 +153,14 @@
<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>

View File

@ -51,6 +51,22 @@ 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)

View File

@ -15,6 +15,7 @@ type FriendItem struct {
EnableAi bool // 是否使用AI
EnableChatRank bool // 是否使用聊天排行
EnableWelcome bool // 是否使用迎新
EnableCommand bool // 是否启用指令
IsOk bool // 是否还在通讯库(群聊是要还在群里也算)
LastActiveTime types.DateTime // 最后活跃时间
}