550 lines
15 KiB
Go
550 lines
15 KiB
Go
|
|
package controller
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
"strings"
|
||
|
|
"xiawan/wx/api/req"
|
||
|
|
"xiawan/wx/api/service"
|
||
|
|
"xiawan/wx/api/vo"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
// GetRedisSyncMsgApi 获取缓存在redis中的消息
|
||
|
|
func GetRedisSyncMsgApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
// reqModel := new(req.GetSyncMsgModel)
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
//if !validateData(ctx, &reqModel) {
|
||
|
|
// return
|
||
|
|
//}
|
||
|
|
result := service.GetRedisSyncMsgService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetOnlineInfoApi 获取在线设备信息
|
||
|
|
func GetOnlineInfoApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.OnlineInfoService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetProfileApi 获取个人资料信息
|
||
|
|
func GetProfileApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.GetProfileService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// DelContactApi 删除好友
|
||
|
|
func DelContactApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.DelContactModel)
|
||
|
|
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.SendDelContactService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ModifyUserInfoRequestApi 修改资料
|
||
|
|
func ModifyUserInfoRequestApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.ModifyUserInfo)
|
||
|
|
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.SendModifyUserInfoRequestService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UpdateNickNameApi 修改名称
|
||
|
|
func UpdateNickNameApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UpdateNickNameModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.UpdateNickNameService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetNickNameApi 设置昵称
|
||
|
|
func SetNickNameApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UpdateNickNameModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
reqModel.Scene = 1
|
||
|
|
result := service.SetNickNameService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetSexApi 修改性别
|
||
|
|
func SetSexApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UpdateSexModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetSexService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ResetGenderApi 重置性别
|
||
|
|
func ResetGenderApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
reqModel := &req.ModifyUserInfo{
|
||
|
|
City: "",
|
||
|
|
Country: "",
|
||
|
|
InitFlag: 0,
|
||
|
|
NickName: "",
|
||
|
|
Province: "",
|
||
|
|
Sex: 0,
|
||
|
|
Signature: "",
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.SendModifyUserInfoRequestService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetSignatureApi 修改签名
|
||
|
|
func SetSignatureApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UpdateNickNameModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
reqModel.Scene = 2
|
||
|
|
result := service.SetNickNameService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ChangePwdRequestRequestApi 更改密码
|
||
|
|
func ChangePwdRequestRequestApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SendChangePwdRequestModel)
|
||
|
|
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// 判断 旧密码
|
||
|
|
if reqModel.OldPass == "" {
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFail("旧密码不能为空"))
|
||
|
|
ctx.Abort()
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// 判断 旧密码
|
||
|
|
if reqModel.OldPass == reqModel.NewPass {
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFail("新旧密码不能相同"))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.SendChangePwdRequestService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UploadHeadImageApi 上传头像
|
||
|
|
func UploadHeadImageApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UploadHeadImageModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.UploadHeadImageService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UpdateAutoPassApi 修改加好友需要验证属性
|
||
|
|
func UpdateAutoPassApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UpdateAutopassModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.UpdateAutoPassService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SendModifyRemarkRequestApi 修改备注
|
||
|
|
func SendModifyRemarkRequestApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SendModifyRemarkRequestModel)
|
||
|
|
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
result := service.SendModifyRemarkRequestService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetWechatApi 设置微信号
|
||
|
|
func SetWechatApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.AlisaModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetWechatService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UpdateStepNumberApi 修改步数
|
||
|
|
func UpdateStepNumberApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UpdateStepNumberModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.UpdateStepNumberService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetUserRankLikeCountApi 获取步数排行数据列表
|
||
|
|
func GetUserRankLikeCountApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.UserRankLikeModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.GetUserRankLikeCountService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetFunctionSwitchApi 设置添加我的方式
|
||
|
|
func SetFunctionSwitchApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.WxFunctionSwitchModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetFunctionSwitchService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetSendPatApi 设置拍一拍名称
|
||
|
|
func SetSendPatApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SetSendPatModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetSendPatService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetProxyApi 修改Socks5代理 socks5://username:password@ipv4:port
|
||
|
|
func SetProxyApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.GetLoginQrCodeModel)
|
||
|
|
queryKey, err := checkLicense(ctx)
|
||
|
|
if err != nil {
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetProxyService(queryKey, *reqModel)
|
||
|
|
if result.Code != vo.SUCCESS {
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if !reqModel.Check { // 无需发送检测代理请求
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// 设置代理成功; 请求获取登录状态 及 在线设备信息
|
||
|
|
|
||
|
|
// 触发 AutoLogin 自动二次登录
|
||
|
|
loginStatus := service.GetLoginStatusService(queryKey, false, true)
|
||
|
|
|
||
|
|
if loginStatus.Code != vo.SUCCESS { // 登录失效
|
||
|
|
ctx.JSON(http.StatusOK, vo.DTO{
|
||
|
|
Code: vo.FAIL,
|
||
|
|
Data: gin.H{
|
||
|
|
"proxyInfo": result.Data,
|
||
|
|
},
|
||
|
|
Text: loginStatus.Text,
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// 获取当前在线设备信息
|
||
|
|
onlineInfo := service.OnlineInfoService(queryKey)
|
||
|
|
|
||
|
|
if onlineInfo.Code != vo.SUCCESS { // 登录失效
|
||
|
|
ctx.JSON(http.StatusOK, vo.DTO{
|
||
|
|
Code: vo.FAIL,
|
||
|
|
Data: gin.H{
|
||
|
|
"proxyInfo": result.Data,
|
||
|
|
"loginStatus": loginStatus.Data,
|
||
|
|
},
|
||
|
|
Text: onlineInfo.Text,
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
ctx.JSON(http.StatusOK, vo.DTO{
|
||
|
|
Code: vo.SUCCESS,
|
||
|
|
Data: gin.H{
|
||
|
|
"proxyInfo": result.Data,
|
||
|
|
"loginStatus": loginStatus.Data,
|
||
|
|
"onlineInfo": onlineInfo.Data,
|
||
|
|
},
|
||
|
|
Text: "",
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetKeywordReplyApi 设置关键词自动回复
|
||
|
|
func SetKeywordReplyApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SetKeywordReplyModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetKeywordReplyService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetKeywordReplyApi 获取关键词自动回复配置
|
||
|
|
func GetKeywordReplyApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.GetKeywordReplyService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetWelcomeApi 设置欢迎词配置
|
||
|
|
func SetWelcomeApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SetWelcomeModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetWelcomeService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetWelcomeApi 获取欢迎词配置
|
||
|
|
func GetWelcomeApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.GetWelcomeService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetAdminKeywordApi 设置管理员关键词配置
|
||
|
|
func SetAdminKeywordApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SetAdminKeywordModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetAdminKeywordService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetAdminKeywordApi 获取管理员关键词配置
|
||
|
|
func GetAdminKeywordApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.GetAdminKeywordService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetKickKeywordApi 设置踢人关键词配置
|
||
|
|
func SetKickKeywordApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SetKickKeywordModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetKickKeywordService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetKickKeywordApi 获取踢人关键词配置
|
||
|
|
func GetKickKeywordApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.GetKickKeywordService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetInviteKeywordApi 设置关键词邀请入群配置
|
||
|
|
func SetInviteKeywordApi(ctx *gin.Context) {
|
||
|
|
reqModel := new(req.SetInviteKeywordModel)
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if !validateData(ctx, &reqModel) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.SetInviteKeywordService(queryKey, *reqModel)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetInviteKeywordApi 获取关键词邀请入群配置
|
||
|
|
func GetInviteKeywordApi(ctx *gin.Context) {
|
||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||
|
|
//确保每次都有Key
|
||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||
|
|
return
|
||
|
|
}
|
||
|
|
result := service.GetInviteKeywordService(queryKey)
|
||
|
|
ctx.JSON(http.StatusOK, result)
|
||
|
|
}
|