1
0
Fork 0

🆕 页面新增迎新开关实现

This commit is contained in:
李寻欢 2023-12-04 14:24:30 +08:00
parent 14d407eff1
commit 89c504d019
5 changed files with 50 additions and 0 deletions

View File

@ -62,6 +62,29 @@ func ChangeEnableGroupRankStatus(ctx *gin.Context) {
ctx.String(http.StatusOK, "操作成功")
}
// ChangeEnableWelcomeStatus
// @description: 修改是否开启迎新
// @param ctx
func ChangeEnableWelcomeStatus(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_welcome`", gorm.Expr(" !`enable_welcome`")).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

@ -22,6 +22,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("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜状态
api.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态
api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表

View File

@ -90,6 +90,7 @@
<th>是否在通讯录</th>
<th>是否启用AI</th>
<th>是否启用水群排行榜</th>
<th>是否启用迎新</th>
<th>操作</th>
</tr>
</thead>
@ -134,6 +135,14 @@
<div class="swap-off">❌已禁用</div>
</label>
</td>
<td>
<label class="swap swap-flip {{ checkSwap .EnableWelcome }}">
<input type="checkbox" onclick="changeWelcomeEnableStatus({{.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

@ -35,6 +35,22 @@ function changeGroupRankEnableStatus(wxId) {
})
}
// 修改欢迎语开启状态
function changeWelcomeEnableStatus(wxId) {
axios({
method: 'put',
url: '/api/welcome/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

@ -14,6 +14,7 @@ type FriendItem struct {
Wxid string // 微信原始Id
EnableAi bool // 是否使用AI
EnableChatRank bool // 是否使用聊天排行
EnableWelcome bool // 是否使用迎新
IsOk bool // 是否还在通讯库(群聊是要还在群里也算)
LastActiveTime types.DateTime // 最后活跃时间
}