2023-11-30 17:31:50 +08:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2023-11-30 23:12:38 +08:00
|
|
|
"go-wechat/service"
|
2023-11-30 17:31:50 +08:00
|
|
|
"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
|
|
|
|
}
|
|
|
|
// 查询数据
|
2023-11-30 23:12:38 +08:00
|
|
|
records, err := service.GetGroupUsersByGroupId(p.GroupId)
|
|
|
|
if err != nil {
|
|
|
|
ctx.String(http.StatusInternalServerError, "查询失败: %s", err.Error())
|
2023-11-30 17:31:50 +08:00
|
|
|
return
|
|
|
|
}
|
2024-07-11 15:46:49 +08:00
|
|
|
|
|
|
|
result := map[string]any{
|
|
|
|
"records": records,
|
|
|
|
}
|
|
|
|
// 循环数据,统计健在成员
|
|
|
|
var isOkCount int
|
|
|
|
for _, record := range records {
|
|
|
|
if record.IsMember {
|
|
|
|
isOkCount++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result["isOkCount"] = isOkCount
|
|
|
|
|
2023-11-30 17:31:50 +08:00
|
|
|
// 暂时先就这样写着,跑通了再改
|
2024-07-11 15:46:49 +08:00
|
|
|
ctx.JSON(http.StatusOK, result)
|
2023-11-30 17:31:50 +08:00
|
|
|
}
|