Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
454b5f0980 | ||
|
|
2af0719f51 | ||
|
|
699f10e854 | ||
|
|
0430c2203e | ||
|
|
917e96b332 | ||
|
|
e80fe2a7a0 |
10
Dockerfile
10
Dockerfile
@@ -6,8 +6,8 @@ COPY . .
|
||||
#ENV GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
RUN go version
|
||||
RUN go mod download && go build -o app
|
||||
RUN ls -lh && chmod +x ./app
|
||||
RUN go mod download && go build -o wxhelper
|
||||
RUN ls -lh && chmod -R +x ./*
|
||||
|
||||
FROM code.hyxc1.com/open/alpine:3.16.0 as runner
|
||||
LABEL org.opencontainers.image.authors="lxh@cxh.cn"
|
||||
@@ -16,6 +16,6 @@ EXPOSE 19099
|
||||
EXPOSE 8080
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /builder/app ./app
|
||||
COPY ./views ./views
|
||||
CMD ./app
|
||||
COPY --from=builder /builder/wxhelper ./wxhelper
|
||||
COPY --from=builder /builder/views ./views
|
||||
CMD ./wxhelper
|
||||
87
app/friend.go
Normal file
87
app/friend.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// changeStatusParam
|
||||
// @description: 修改状态用的参数集
|
||||
type changeStatusParam struct {
|
||||
WxId string `json:"wxId" binding:"required"`
|
||||
UserId string `json:"userId"`
|
||||
}
|
||||
|
||||
// ChangeEnableAiStatus
|
||||
// @description: 修改是否开启AI
|
||||
// @param ctx
|
||||
func ChangeEnableAiStatus(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_ai`", gorm.Expr(" !`enable_ai`")).Error
|
||||
if err != nil {
|
||||
log.Printf("修改是否开启AI失败:%s", err)
|
||||
ctx.String(http.StatusInternalServerError, "操作失败: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.String(http.StatusOK, "操作成功")
|
||||
}
|
||||
|
||||
// ChangeEnableGroupRankStatus
|
||||
// @description: 修改是否开启水群排行榜
|
||||
// @param ctx
|
||||
func ChangeEnableGroupRankStatus(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_chat_rank`", gorm.Expr(" !`enable_chat_rank`")).Error
|
||||
if err != nil {
|
||||
log.Printf("修改开启水群排行榜失败:%s", err)
|
||||
ctx.String(http.StatusInternalServerError, "操作失败: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.String(http.StatusOK, "操作成功")
|
||||
}
|
||||
|
||||
// ChangeSkipGroupRankStatus
|
||||
// @description: 修改是否跳过水群排行榜
|
||||
// @param ctx
|
||||
func ChangeSkipGroupRankStatus(ctx *gin.Context) {
|
||||
var p changeStatusParam
|
||||
if err := ctx.ShouldBindJSON(&p); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
log.Printf("待修改的群Id:%s -> %s", p.WxId, p.UserId)
|
||||
|
||||
err := client.MySQL.Model(&entity.GroupUser{}).
|
||||
Where("group_id = ?", p.WxId).
|
||||
Where("wxid = ?", p.UserId).
|
||||
Update("`skip_chat_rank`", gorm.Expr(" !`skip_chat_rank`")).Error
|
||||
if err != nil {
|
||||
log.Printf("修改跳过水群排行榜失败:%s", err)
|
||||
ctx.String(http.StatusInternalServerError, "操作失败: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.String(http.StatusOK, "操作成功")
|
||||
}
|
||||
30
app/group.go
Normal file
30
app/group.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-wechat/service"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type getGroupUser struct {
|
||||
GroupId string `json:"groupId" form:"groupId" binding:"required"` // 群Id
|
||||
}
|
||||
|
||||
// GetGroupUsers
|
||||
// @description: 获取群成员列表
|
||||
// @param ctx
|
||||
func GetGroupUsers(ctx *gin.Context) {
|
||||
var p getGroupUser
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
// 查询数据
|
||||
records, err := service.GetGroupUsersByGroupId(p.GroupId)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusInternalServerError, "查询失败: %s", err.Error())
|
||||
return
|
||||
}
|
||||
// 暂时先就这样写着,跑通了再改
|
||||
ctx.JSON(http.StatusOK, records)
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func (dt DateTime) Value() (dv driver.Value, err error) {
|
||||
|
||||
// 用于 fmt.Println 和后续验证场景
|
||||
func (dt DateTime) String() string {
|
||||
return dt.Format(dateTimeFormat)
|
||||
return dt.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
// Format 格式化
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Friend
|
||||
// @description: 好友列表
|
||||
type Friend struct {
|
||||
Wxid string `json:"wxid"` // 微信原始Id
|
||||
CustomAccount string `json:"customAccount"` // 微信号
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
Pinyin string `json:"pinyin"` // 昵称拼音大写首字母
|
||||
PinyinAll string `json:"pinyinAll"` // 昵称全拼
|
||||
Wxid string `json:"wxid"` // 微信原始Id
|
||||
EnableAi bool `json:"enableAI" gorm:"type:tinyint(1) default 0 not null"` // 是否使用AI
|
||||
EnableChatRank bool `json:"enableChatRank" gorm:"type:tinyint(1) default 0 not null"` // 是否使用聊天排行
|
||||
IsOk bool `json:"isOk" gorm:"type:tinyint(1) default 0 not null"` // 是否正常
|
||||
@@ -23,11 +25,12 @@ func (Friend) TableName() string {
|
||||
// @description: 群成员
|
||||
type GroupUser struct {
|
||||
GroupId string `json:"groupId"` // 群Id
|
||||
Wxid string `json:"wxid"` // 微信Id
|
||||
Account string `json:"account"` // 账号
|
||||
HeadImage string `json:"headImage"` // 头像
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
Wxid string `json:"wxid"` // 微信Id
|
||||
IsMember bool `json:"isMember" 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
main.go
23
main.go
@@ -8,7 +8,10 @@ import (
|
||||
"go-wechat/tasks"
|
||||
"go-wechat/tcpserver"
|
||||
"go-wechat/utils"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -30,14 +33,32 @@ func main() {
|
||||
|
||||
// 启动HTTP服务
|
||||
app := gin.Default()
|
||||
|
||||
// 自定义模板引擎函数
|
||||
app.SetFuncMap(template.FuncMap{
|
||||
"checkSwap": func(flag bool) string {
|
||||
if flag {
|
||||
return "swap-active"
|
||||
}
|
||||
return ""
|
||||
},
|
||||
})
|
||||
|
||||
app.LoadHTMLGlob("views/*.html")
|
||||
app.Static("/assets", "./views/assets")
|
||||
app.Static("/assets", "./views/static")
|
||||
app.StaticFile("/favicon.ico", "./views/wechat.ico")
|
||||
// 404返回数据
|
||||
app.NoRoute(func(ctx *gin.Context) {
|
||||
if strings.HasPrefix(ctx.Request.URL.Path, "/api") {
|
||||
ctx.String(404, "接口不存在")
|
||||
return
|
||||
}
|
||||
// 404直接跳转到首页
|
||||
ctx.Redirect(302, "/index.html")
|
||||
})
|
||||
app.NoMethod(func(ctx *gin.Context) {
|
||||
ctx.String(http.StatusMethodNotAllowed, "不支持的请求方式")
|
||||
})
|
||||
// 初始化路由
|
||||
router.Init(app)
|
||||
if err := app.Run(":8080"); err != nil {
|
||||
|
||||
@@ -18,4 +18,11 @@ func Init(g *gin.Engine) {
|
||||
g.GET("/test.html", func(ctx *gin.Context) {
|
||||
ctx.HTML(200, "test.html", nil)
|
||||
})
|
||||
|
||||
// 接口
|
||||
api := g.Group("/api")
|
||||
api.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态
|
||||
api.PUT("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜状态
|
||||
api.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态
|
||||
api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表
|
||||
}
|
||||
|
||||
25
service/group.go
Normal file
25
service/group.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/vo"
|
||||
)
|
||||
|
||||
// GetGroupUsersByGroupId
|
||||
// @description: 根据群Id取出群成员列表
|
||||
// @param groupId
|
||||
// @return records
|
||||
// @return err
|
||||
func GetGroupUsersByGroupId(groupId string) (records []vo.GroupUserItem, err error) {
|
||||
err = client.MySQL.
|
||||
Table("t_group_user AS tgu").
|
||||
Joins("LEFT JOIN t_message AS tm ON tm.from_user = tgu.group_id AND tm.group_user = tgu.wxid").
|
||||
//Select("tgu.wxid", "tgu.nickname", "tgu.head_image", "tgu.is_member", "tgu.leave_time",
|
||||
// "tgu.skip_chat_rank", "MAX(tm.create_at) AS last_active_time").
|
||||
Select("tgu.*", "MAX(tm.create_at) AS last_active_time").
|
||||
Where("tgu.group_id = ?", groupId).
|
||||
Group("tgu.group_id, tgu.wxid").
|
||||
Order("tgu.join_time DESC").
|
||||
Find(&records).Error
|
||||
return
|
||||
}
|
||||
@@ -154,6 +154,7 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
|
||||
Nickname: cp.Nickname,
|
||||
Wxid: cp.Wxid,
|
||||
IsMember: true,
|
||||
JoinTime: time.Now().Local(),
|
||||
}).Error
|
||||
if err != nil {
|
||||
log.Printf("新增群成员失败: %s", err.Error())
|
||||
|
||||
235
views/index.html
235
views/index.html
@@ -4,8 +4,12 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>水群助手</title>
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.4.14/dist/full.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- <link href="https://cdn.jsdelivr.net/npm/daisyui@4.4.14/dist/full.min.css" rel="stylesheet" type="text/css" />-->
|
||||
<link href="assets/css/daisyui-4.4.14-full.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="assets/css/index.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.min.js"></script>
|
||||
|
||||
<script src="assets/js/index.js"></script>
|
||||
</head>
|
||||
@@ -19,92 +23,159 @@
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="collapse collapse-arrow bg-base-200">
|
||||
<input type="radio" name="my-accordion-2" checked="checked" />
|
||||
<div class="collapse-title text-xl font-medium">
|
||||
好友列表
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
<div role="tablist" class="tabs tabs-bordered">
|
||||
<input type="radio" name="friend_tab" role="tab" class="tab" aria-label="好友列表" checked />
|
||||
<div role="tabpanel" class="tab-content p-6">
|
||||
<!-- 循环好友列表 -->
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-zebra">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>微信Id</th>
|
||||
<th>微信号</th>
|
||||
<th>昵称</th>
|
||||
<th>最后活跃时间</th>
|
||||
<th>是否在通讯录</th>
|
||||
<th>是否启用AI</th>
|
||||
<th>是否启用水群排行榜</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .friends }}
|
||||
<tr>
|
||||
<td>{{ .Wxid }}</td>
|
||||
<td>{{ .CustomAccount }}</td>
|
||||
<td>{{ .Nickname }}</td>
|
||||
<td>
|
||||
{{ if eq .LastActiveTime.IsNil true }}
|
||||
无数据
|
||||
{{ else }}
|
||||
{{ .LastActiveTime }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>{{ .IsOk }}</td>
|
||||
<td>{{ .EnableAi }}</td>
|
||||
<td>{{ .EnableChatRank }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<table class="table table-zebra">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>微信Id</th>
|
||||
<th>微信号</th>
|
||||
<th>昵称</th>
|
||||
<th>最后活跃时间</th>
|
||||
<th>是否在通讯录</th>
|
||||
<th>是否启用AI</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .friends }}
|
||||
<tr>
|
||||
<td>{{ .Wxid }}</td>
|
||||
<td>{{ .CustomAccount }}</td>
|
||||
<td>{{ .Nickname }}</td>
|
||||
<td>
|
||||
{{ if eq .LastActiveTime.IsNil true }}
|
||||
无数据
|
||||
{{ else }}
|
||||
{{ .LastActiveTime }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>
|
||||
{{ if eq .IsOk true }}
|
||||
<div class="badge badge-info gap-2">
|
||||
是
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="badge badge-error gap-2">
|
||||
否
|
||||
</div>
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>
|
||||
<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>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse collapse-arrow bg-base-200">
|
||||
<input type="radio" name="my-accordion-2" />
|
||||
<div class="collapse-title text-xl font-medium">
|
||||
群列表
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
|
||||
<input type="radio" name="friend_tab" role="tab" class="tab" aria-label="群列表" />
|
||||
<div role="tabpanel" class="tab-content p-6">
|
||||
<!-- 循环群列表 -->
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-zebra">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>群Id</th>
|
||||
<th>昵称</th>
|
||||
<th>最后活跃时间</th>
|
||||
<th>是否在通讯录</th>
|
||||
<th>是否启用AI</th>
|
||||
<th>是否启用水群排行榜</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .groups }}
|
||||
<tr>
|
||||
<td>{{ .Wxid }}</td>
|
||||
<td>{{ .Nickname }}</td>
|
||||
<td>
|
||||
{{ if eq .LastActiveTime.IsNil true }}
|
||||
无数据
|
||||
{{ else }}
|
||||
{{ .LastActiveTime }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>{{ .IsOk }}</td>
|
||||
<td>{{ .EnableAi }}</td>
|
||||
<td>{{ .EnableChatRank }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<table class="table table-zebra">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>群Id</th>
|
||||
<th>昵称</th>
|
||||
<th>最后活跃时间</th>
|
||||
<th>是否在通讯录</th>
|
||||
<th>是否启用AI</th>
|
||||
<th>是否启用水群排行榜</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .groups }}
|
||||
<tr>
|
||||
<td>{{ .Wxid }}</td>
|
||||
<td>{{ .Nickname }}</td>
|
||||
<td>
|
||||
{{ if eq .LastActiveTime.IsNil true }}
|
||||
无数据
|
||||
{{ else }}
|
||||
{{ .LastActiveTime }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>
|
||||
{{ if eq .IsOk true }}
|
||||
<div class="badge badge-info gap-2">
|
||||
是
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="badge badge-error gap-2">
|
||||
否
|
||||
</div>
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>
|
||||
<!-- EnableAi -->
|
||||
<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>
|
||||
<!-- EnableChatRank -->
|
||||
<label class="swap swap-flip {{ checkSwap .EnableChatRank }}">
|
||||
<input type="checkbox" onclick="changeGroupRankEnableStatus({{.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>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<dialog id="groupUserModal" class="modal">
|
||||
<div class="modal-box w-11/12 max-w-7xl">
|
||||
<!-- <form method="dialog">-->
|
||||
<!-- <button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button>-->
|
||||
<!-- </form>-->
|
||||
<h3 class="font-bold text-lg" id="groupUserModalName">我是群名称</h3>
|
||||
<!-- 加载动画 -->
|
||||
|
||||
|
||||
<div class="divider divider-warning">成员列表</div>
|
||||
<!-- 好友列表 -->
|
||||
<table class="table table-zebra">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th>微信Id</th>
|
||||
<th>昵称</th>
|
||||
<th>是否群成员</th>
|
||||
<th>加群时间</th>
|
||||
<th>最后活跃时间</th>
|
||||
<th>退群时间</th>
|
||||
<th>是否跳过水群排行榜</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="groupUsers"></tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</dialog>
|
||||
</body>
|
||||
</html>
|
||||
20
views/static/css/daisyui-4.4.14-full.min.css
vendored
Normal file
20
views/static/css/daisyui-4.4.14-full.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
4
views/static/css/index.css
Normal file
4
views/static/css/index.css
Normal file
@@ -0,0 +1,4 @@
|
||||
/* 隐藏滚动条 */
|
||||
::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
@@ -1 +1,127 @@
|
||||
console.log("打开首页")
|
||||
console.log("打开首页")
|
||||
|
||||
// 改变AI开启状态
|
||||
function changeAiEnableStatus(wxId) {
|
||||
// console.log("修改AI开启状态: ", wxId)
|
||||
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/ai/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
})
|
||||
}
|
||||
|
||||
// 修改水群排行榜状态
|
||||
function changeGroupRankEnableStatus(wxId) {
|
||||
// console.log("修改水群排行榜开启状态: ", wxId)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/grouprank/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)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/grouprank/skip',
|
||||
data: {
|
||||
wxId: groupId,
|
||||
userId: userId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
})
|
||||
}
|
||||
|
||||
// 获取群成员列表
|
||||
function getGroupUsers(groupId, groupName) {
|
||||
// 获取表格的tbody部分,以便稍后向其中添加行
|
||||
var tbody = document.getElementById("groupUsers");
|
||||
tbody.innerHTML = ""
|
||||
|
||||
// 打开模态框
|
||||
const modal = document.getElementById("groupUserModal");
|
||||
modal.showModal()
|
||||
|
||||
// 设置群名称
|
||||
const groupNameTag = document.getElementById("groupUserModalName");
|
||||
groupNameTag.innerHTML = '<span class="loading loading-dots loading-lg"></span>'
|
||||
|
||||
// 显示加载框
|
||||
// const loading = document.getElementById("groupUserDataLoading");
|
||||
// loading.style.display = "block"
|
||||
|
||||
axios.get('/api/group/users', {
|
||||
params: {
|
||||
groupId: groupId
|
||||
}
|
||||
}).then(function (response) {
|
||||
// console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
// 渲染群成员列表
|
||||
const groupUsers = response.data
|
||||
// 循环渲染数据
|
||||
for (let i = 0; i < groupUsers.length; i++) {
|
||||
const groupUser = groupUsers[i]
|
||||
|
||||
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 () {
|
||||
// 隐藏加载框
|
||||
// loading.style.display = "none"
|
||||
groupNameTag.innerHTML = groupName
|
||||
})
|
||||
}
|
||||
14
vo/friend.go
14
vo/friend.go
@@ -17,3 +17,17 @@ type FriendItem struct {
|
||||
IsOk bool // 是否还在通讯库(群聊是要还在群里也算)
|
||||
LastActiveTime types.DateTime // 最后活跃时间
|
||||
}
|
||||
|
||||
// GroupUserItem
|
||||
// @description: 群成员列表数据
|
||||
type GroupUserItem struct {
|
||||
Wxid string `json:"wxid"` // 微信Id
|
||||
Account string `json:"account"` // 账号
|
||||
HeadImage string `json:"headImage"` // 头像
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
IsMember bool `json:"isMember" ` // 是否群成员
|
||||
JoinTime types.DateTime `json:"joinTime"` // 加入时间
|
||||
LastActiveTime types.DateTime `json:"lastActiveTime"` // 最后活跃时间
|
||||
LeaveTime types.DateTime `json:"leaveTime"` // 离开时间
|
||||
SkipChatRank bool `json:"skipChatRank" ` // 是否跳过聊天排行
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user