网页管理基本功能完成

This commit is contained in:
李寻欢
2023-11-30 23:12:38 +08:00
parent 699f10e854
commit 2af0719f51
7 changed files with 157 additions and 47 deletions

View File

@@ -2,6 +2,9 @@ package app
import (
"github.com/gin-gonic/gin"
"go-wechat/client"
"go-wechat/entity"
"gorm.io/gorm"
"log"
"net/http"
)
@@ -24,6 +27,15 @@ func ChangeEnableAiStatus(ctx *gin.Context) {
}
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, "操作成功")
}
@@ -38,6 +50,15 @@ func ChangeEnableGroupRankStatus(ctx *gin.Context) {
}
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, "操作成功")
}
@@ -52,5 +73,15 @@ func ChangeSkipGroupRankStatus(ctx *gin.Context) {
}
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, "操作成功")
}

View File

@@ -2,8 +2,7 @@ package app
import (
"github.com/gin-gonic/gin"
"go-wechat/client"
"go-wechat/entity"
"go-wechat/service"
"net/http"
)
@@ -21,11 +20,11 @@ func GetGroupUsers(ctx *gin.Context) {
return
}
// 查询数据
var users []entity.GroupUser
if err := client.MySQL.Where("group_id = ?", p.GroupId).Find(&users).Error; err != nil {
ctx.String(http.StatusInternalServerError, "查询数据失败")
records, err := service.GetGroupUsersByGroupId(p.GroupId)
if err != nil {
ctx.String(http.StatusInternalServerError, "查询失败: %s", err.Error())
return
}
// 暂时先就这样写着,跑通了再改
ctx.JSON(http.StatusOK, users)
ctx.JSON(http.StatusOK, records)
}