From b024600ef06b67f6b2a9ec02bc085476b28d0242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Tue, 18 Jun 2024 16:23:09 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20=E4=BF=AE=E6=94=B9=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=B8=BA=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/friend.go | 30 ++++++ router/router.go | 1 + views/components.html | 4 +- views/group.html | 200 ++++++++++++++++++++----------------- views/static/css/index.css | 12 ++- views/static/js/index.js | 30 ++++++ 6 files changed, 180 insertions(+), 97 deletions(-) diff --git a/app/friend.go b/app/friend.go index 3849f2b..71a4212 100644 --- a/app/friend.go +++ b/app/friend.go @@ -23,6 +23,13 @@ type changeUseAiModelParam struct { Model string `json:"model" binding:"required"` // 模型代码 } +// autoClearMembers +// @description: 自动清理群成员 +type autoClearMembers struct { + WxId string `json:"wxid" binding:"required"` // 群Id + Days int `json:"days"` // 多少天未发言 +} + // ChangeEnableAiStatus // @description: 修改是否开启AI // @param ctx @@ -227,3 +234,26 @@ func ChangeEnableNewsStatus(ctx *gin.Context) { ctx.String(http.StatusOK, "操作成功") } + +// AutoClearMembers +// @description: 自动清理群成员 +// @param ctx +func AutoClearMembers(ctx *gin.Context) { + var p autoClearMembers + 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("`clear_member`", p.Days).Error + if err != nil { + log.Printf("修改自动清理群成员阈值失败:%s", err) + ctx.String(http.StatusInternalServerError, "操作失败: %s", err) + return + } + + ctx.String(http.StatusOK, "操作成功") +} diff --git a/router/router.go b/router/router.go index 3b606c2..950d9c4 100644 --- a/router/router.go +++ b/router/router.go @@ -32,4 +32,5 @@ func Init(g *gin.Engine) { api.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态 api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表 api.PUT("/summary/status", app.ChangeEnableSummaryStatus) // 修改是否开启群聊总结状态 + api.PUT("/clearmembers", app.AutoClearMembers) // 自动清理群成员 } diff --git a/views/components.html b/views/components.html index a25cbce..96ebc1e 100644 --- a/views/components.html +++ b/views/components.html @@ -197,9 +197,9 @@ {{define "flagTag"}} {{ if eq . true }} + class="inline-flex items-center rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">在通讯录 {{ else }} + class="inline-flex items-center rounded-md bg-red-50 px-2 py-1 text-xs font-medium text-red-700 ring-1 ring-inset ring-red-600/20">不在通讯录 {{ end }} {{end}} diff --git a/views/group.html b/views/group.html index 5d41d94..05f0c2a 100644 --- a/views/group.html +++ b/views/group.html @@ -21,101 +21,113 @@
- - - - - - - - - - - - - - - - - +
    {{ range .groups }} -
- - - - - - - - - - - - - {{ end }} - -
群名称 - - 最后活跃时间 - - 是否在通讯录 - - AI - - 排行榜 - - 总结 - - 迎新 - - 早报 - - 指令 - - 末位淘汰(天) - - 操作 -
-
{{ .Nickname }}
-
{{ .Wxid }}
-
- {{ if eq .LastActive.IsNil true }} - 无数据 - {{ else }} - {{ .LastActive }} - {{ end }} - - {{ template "flagTag" .IsOk }} - - {{ template "ai" . }} - - {{ if eq .EnableAi true }} - - {{ end }} - - {{ template "chatRank" . }} - - {{ template "summary" . }} - - {{ template "welcome" . }} - - {{ template "news" . }} - - {{ template "command" . }} - - {{ .ClearMember }} - - -
+
  • +
    + Tuple +
    +
    {{ .Nickname }}
    +
    {{ .Wxid }}
    + {{ template "flagTag" .IsOk }} + +
    +
    + +
    + +
    +
    最后活跃时间
    +
    + {{ if eq .LastActive.IsNil true }} + 无活跃数据 + {{ else }} + + {{ end }} +
    +
    + +
    +
    AI
    +
    +
    + {{ template "ai" . }} +
    + {{ if eq .EnableAi true }} +
    + +
    + {{ end }} +
    +
    + +
    +
    水群排行榜
    +
    + {{ template "chatRank" . }} +
    +
    + +
    +
    群聊总结
    +
    + {{ template "summary" . }} +
    +
    + +
    +
    迎新
    +
    + {{ template "welcome" . }} +
    +
    + +
    +
    早报
    +
    + {{ template "news" . }} +
    +
    + +
    +
    迎新
    +
    + {{ template "command" . }} +
    +
    + +
    +
    末位淘汰
    +
    +
    + +
    + +
    +
    +
    +
    +
    + {{ end }} +
  • diff --git a/views/static/css/index.css b/views/static/css/index.css index 0e725a8..09ecab4 100644 --- a/views/static/css/index.css +++ b/views/static/css/index.css @@ -1,4 +1,14 @@ /* 隐藏滚动条 */ ::-webkit-scrollbar { display: none; -} \ No newline at end of file +} + +/* 隐藏input输入数字时的箭头 */ +input[type=number]::-webkit-inner-spin-button, +input[type=number]::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} +input[type=number] { + -moz-appearance:textfield; +} diff --git a/views/static/js/index.js b/views/static/js/index.js index 688936f..ee7014c 100644 --- a/views/static/js/index.js +++ b/views/static/js/index.js @@ -236,3 +236,33 @@ function aiAssistantChange(event, wxid) { window.location.reload(); }) } + +// 修改清理群成员值 +function changeClearMember(wxid, oldVal, newVal) { + oldVal = Number(oldVal) + newVal = Number(newVal) + + if (oldVal === newVal) { + return + } + if (newVal < 0) { + alert('不活跃天数的值不能小于0') + } + // 请求接口 + axios({ + method: 'put', + url: '/api/clearmembers', + data: { + wxid: wxid, + days: Number(newVal) + } + }).then(function (response) { + console.log(`返回结果: ${JSON.stringify(response)}`); + alert(`${response.data}`) + }).catch(function (error) { + console.log(`错误信息: ${error}`); + alert("修改失败") + }).finally(function () { + window.location.reload(); + }) +}