first commit
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
"xiawan/wx/srv/srvconfig"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func IsValidAdminKey(key string) (bool, vo.DTO) {
|
||||
if key == srvconfig.GlobalSetting.AdminKey {
|
||||
return true, vo.NewSuccess(gin.H{}, "")
|
||||
}
|
||||
return false, vo.NewFail("软件授权 ADMIN_KEY 错误")
|
||||
}
|
||||
|
||||
// GenAuthKey1 生成授权码(新设备)
|
||||
func GenAuthKey1(ctx *gin.Context) {
|
||||
reqModel := new(req.GenAuthKeyModel)
|
||||
key, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(key)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
|
||||
_ = ctx.ShouldBindJSON(&reqModel)
|
||||
result := service.GenAuthKeyService(reqModel.Count, reqModel.Days)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GenAuthKey2 生成授权码(新设备)
|
||||
func GenAuthKey2(ctx *gin.Context) {
|
||||
key, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(key)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
|
||||
reqModel := new(req.GenAuthKeyModel)
|
||||
_ = ctx.BindQuery(&reqModel)
|
||||
|
||||
result := service.GenAuthKeyService(reqModel.Count, reqModel.Days)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GenAuthKey3 生成授权码(1-日 7-周 30-月 90-季 180-半年 365-年 30000-永久)此key不使用无过期时间
|
||||
func GenAuthKey3(ctx *gin.Context) {
|
||||
reqModel := new(req.GenAuthKeyTypeModel)
|
||||
|
||||
key, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(key)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
|
||||
_ = ctx.ShouldBindJSON(&reqModel)
|
||||
|
||||
result := service.GenAuthKeyService3(reqModel.Count, reqModel.Type)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// 西柚云授权码延期
|
||||
func DelayAuthKeyNew(ctx *gin.Context) {
|
||||
reqModel := new(req.DelayAuthKeyModelNew)
|
||||
_ = ctx.ShouldBindJSON(&reqModel)
|
||||
|
||||
key, _ := ctx.GetQuery("key")
|
||||
_, err := service.CheckKey(key)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
_, err = service.CheckKey(reqModel.KeyUse)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
result := service.DelayAuthKeyServiceNew(key, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// 西柚云解绑授权码
|
||||
func UnbindAuthKey(ctx *gin.Context) {
|
||||
key, _ := ctx.GetQuery("key")
|
||||
_, err := service.CheckKey(key)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
result := service.UnbindAuthKeyService(key)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// 西柚云查看配置
|
||||
func GetConfig(ctx *gin.Context) {
|
||||
key, _ := ctx.GetQuery("key")
|
||||
_, err := service.CheckKey(key)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
result := service.GetConfigService(key)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DelayAuthKey 授权码延期
|
||||
func DelayAuthKey(ctx *gin.Context) {
|
||||
reqModel := new(req.DelayAuthKeyModel)
|
||||
key, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(key)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
_ = ctx.ShouldBindJSON(&reqModel)
|
||||
|
||||
// 延期授权码 AuthKey
|
||||
result := service.DelayAuthKeyService(*reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DeleteAuthKey 删除授权码
|
||||
func DeleteAuthKey(ctx *gin.Context) {
|
||||
reqModel := new(req.DeleteAuthKeyModel)
|
||||
key, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(key)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
_ = ctx.ShouldBindJSON(&reqModel)
|
||||
|
||||
// 删除授权码 AuthKey
|
||||
result := service.DeleteAuthKeyService(*reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// 禁用授权码
|
||||
func DisableAuthKey(ctx *gin.Context) {
|
||||
reqModel := new(req.BannedAuthKeyModel)
|
||||
key, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(key)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
_ = ctx.ShouldBindJSON(&reqModel)
|
||||
|
||||
// 禁用授权码 AuthKey
|
||||
result := service.BannedAuthKeyService(*reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// HttpSyncLicenseKey 同步卡密激活状态, HTTP-轮询方式
|
||||
func HttpSyncLicenseKey(ctx *gin.Context) {
|
||||
key, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(key)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
|
||||
result := service.HttpSyncLicenseKeyService()
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetLicenseKey 查询卡密有效期
|
||||
func GetLicenseKey(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.GetLicenseKeyService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetActiveLicenseKeys 查询所有激活状态的卡密
|
||||
func GetActiveLicenseKeys(ctx *gin.Context) {
|
||||
adminKey, _ := ctx.GetQuery("key")
|
||||
flag, errRes := IsValidAdminKey(adminKey)
|
||||
if !flag {
|
||||
ctx.JSON(http.StatusOK, errRes)
|
||||
return
|
||||
}
|
||||
|
||||
result := service.GetActiveLicenseKeysService()
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetA8KeyApi 授权链接
|
||||
func GetA8KeyApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetA8KeyRequestModel)
|
||||
|
||||
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.GetA8KeyService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// JSLoginApi 授权小程序(返回授权后的code)
|
||||
func JSLoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.AppletModel)
|
||||
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.JsLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// JSOperateWxDataApi 小程序云函数操作
|
||||
func JSOperateWxDataApi(ctx *gin.Context) {
|
||||
reqModel := new(req.AppletModel)
|
||||
reqModel.Opt = 1
|
||||
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 len(strings.TrimSpace(reqModel.Data)) == 0 {
|
||||
reqModel.Data = "{\"with_credentials\":true,\"from_component\":true,\"data\":{\"lang\":\"zh_CN\"},\"api_name\":\"webapi_getuserinfo\"}"
|
||||
}
|
||||
|
||||
var js json.RawMessage
|
||||
err := json.Unmarshal([]byte(reqModel.Data), &js)
|
||||
if err != nil {
|
||||
// 要执行的 小程序云函数 Data 数据不合法
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("小程序云函数 Data 数据不是合法 JSON"))
|
||||
return
|
||||
}
|
||||
|
||||
result := service.JSOperateWxDataService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SdkOauthAuthorizeApi app 应用授权
|
||||
func SdkOauthAuthorizeApi(ctx *gin.Context) {
|
||||
reqModel := new(req.AppletModel)
|
||||
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.SdkOauthAuthorizeService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QRConnectAuthorizeApi 二维码授权请求
|
||||
func QRConnectAuthorizeApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QRConnectAuthorizeModel)
|
||||
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.QRConnectAuthorizeService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QRConnectAuthorizeConfirmApi 二维码授权确认
|
||||
func QRConnectAuthorizeConfirmApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QRConnectAuthorizeModel)
|
||||
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.QRConnectAuthorizeConfirmService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetMpA8KeyApi 授权链接
|
||||
func GetMpA8KeyApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetMpA8KeyModel)
|
||||
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.GetMpA8Service(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AuthMpLoginApi 授权公众号登录
|
||||
func AuthMpLoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetMpA8KeyModel)
|
||||
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.AuthMpLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// 获取公众号历史消息
|
||||
func GetMpHistoryMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetMpHistoryMsgModel)
|
||||
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.GetAppletHistoryMsg(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetAppMsgExtApi 阅读公众号文章
|
||||
func GetAppMsgExtApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ReadParam)
|
||||
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.GetAppMsgExtService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetAppMsgReadCountApi 获取公众号文章阅读数
|
||||
func GetAppMsgReadCountApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ReadParam)
|
||||
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.GetAppMsgReadCountService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetAppMsgExtLikeApi 点赞公众号文章
|
||||
func GetAppMsgExtLikeApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ReadParam)
|
||||
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.GetAppMsgExtLikeService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ChannelsLoginApi 视频号助手扫码登录
|
||||
func ChannelsLoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ChannelsLoginModel)
|
||||
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.ChannelsLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ShopLoginConfirmApi 微信小店确认登录
|
||||
func ShopLoginConfirmApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ShopLoginConfirmModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
|
||||
result := service.ShopLoginConfirmService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func ScanQrcodeEventReportApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ShopLoginConfirmModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.ScanQrcodeEventReportService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func ExtDeviceLoginConfirmGetApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ShopLoginConfirmModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.ShopLoginConfirmGetService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func ExtDeviceLoginConfirmOkApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ShopLoginConfirmModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.ShopLoginConfirmOkService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func validateData(ctx *gin.Context, model interface{}) bool {
|
||||
// ShouldBindJSON
|
||||
err := ctx.ShouldBindJSON(&model)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.DTO{
|
||||
Code: vo.FAIL_DATA,
|
||||
Data: nil,
|
||||
Text: "\"提交数据错误!\"",
|
||||
})
|
||||
ctx.Abort()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/vo"
|
||||
"xiawan/wx/db"
|
||||
"xiawan/wx/db/table"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// SetCallbackApi 设置消息回调配置
|
||||
func SetCallbackApi(ctx *gin.Context) {
|
||||
config := new(req.MessageCallbackConfigModel)
|
||||
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, &config) {
|
||||
return
|
||||
}
|
||||
|
||||
// 使用传入的queryKey作为UUID
|
||||
configInDB := table.MessageCallbackConfig{
|
||||
UUID: queryKey,
|
||||
CallbackURL: config.CallbackURL,
|
||||
Enabled: config.Enabled,
|
||||
}
|
||||
|
||||
// 保存配置到数据库
|
||||
err := db.SaveMessageCallbackConfig(&configInDB)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("保存消息回调配置失败: "+err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, vo.NewSuccess(gin.H{}, "设置消息回调成功"))
|
||||
}
|
||||
|
||||
// GetCallbackApi 获取消息回调配置
|
||||
func GetCallbackApi(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
|
||||
}
|
||||
|
||||
// 查询数据库获取回调配置
|
||||
config, err := db.GetMessageCallbackConfig(queryKey)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("获取消息回调配置失败: "+err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if config == nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("未找到消息回调配置"))
|
||||
return
|
||||
}
|
||||
|
||||
// 转换为响应模型
|
||||
response := req.MessageCallbackConfigModel{
|
||||
CallbackURL: config.CallbackURL,
|
||||
Enabled: config.Enabled,
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, vo.NewSuccessObj(response, "获取消息回调配置成功"))
|
||||
}
|
||||
|
||||
// DeleteCallbackApi 删除消息回调配置
|
||||
func DeleteCallbackApi(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
|
||||
}
|
||||
|
||||
// 从数据库删除回调配置
|
||||
err := db.DeleteMessageCallbackConfig(queryKey)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("删除消息回调配置失败: "+err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, vo.NewSuccess(gin.H{}, "删除消息回调配置成功"))
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// AutoRedApi 自动抢红包
|
||||
func AutoRedApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.AutoRedRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealAutoRed(¶ms)
|
||||
// 调用服务逻辑处理
|
||||
result := service.AutoRedRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// TransferApi 自动接收转账
|
||||
func TransferApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.AutoTransferRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealTransfer(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.TransferRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DelayRedApi 延迟领取红包
|
||||
func DelayRedApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.DelayRedRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealDelayRed(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.DelayRedRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DelayTransferApi 延迟接收转账
|
||||
func DelayTransferApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.DelayAutoTransferRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealDelayTransfer(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.DelayTransferRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// KeywordAvoidanceApi 关键字包不抢
|
||||
func KeywordAvoidanceApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.KeywordAvoidanceRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealKeywordAvoidance(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.KeywordAvoidanceRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AutoLikeApi 自动点赞
|
||||
func AutoLikeApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.AutoLikeRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealAutoLike(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.AutoLikeRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AutoForwardApi 朋友圈跟随转发
|
||||
func AutoForwardApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.AutoForwardRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealAutoForward(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.AutoForwardRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// FavoriteForwardApi 朋友圈收藏转发
|
||||
func FavoriteForwardApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.FavoriteForwardRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealFavoriteForward(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.FavoriteForwardRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AutoCommentApi 朋友圈自动评论
|
||||
func AutoCommentApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.AutoCommentRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealAutoComment(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.AutoCommentRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// MomentsApi 定时发朋友圈
|
||||
func MomentsApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.MomentsRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealMoments(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.MomentsRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// MomentsPostApi 发大视频朋友圈
|
||||
func MomentsPostApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.MomentsPostRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealMomentsPost(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.MomentsPostRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// WelcomeNewMemberApi 欢迎新人入群
|
||||
func WelcomeNewMemberApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.WelcomeNewMemberRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealWelcomeNewMember(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.WelcomeNewMemberRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// KeywordKickApi 关键词自动踢人
|
||||
func KeywordKickApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.KeywordKickRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealKeywordKick(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.KeywordKickRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// KeywordAutoReplyApi 关键词自动回复
|
||||
func KeywordAutoReplyApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.KeywordAutoReplyRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealKeywordAutoReply(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.KeywordAutoReplyRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// MessageForwardingApi 万群同步
|
||||
func MessageForwardingApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.MessageForwardingRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealMessageForwarding(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.MessageForwardingRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AutoApproveApi 自动通过好友
|
||||
func AutoApproveApi(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
|
||||
}
|
||||
|
||||
// 定义请求模型并绑定参数
|
||||
var params req.AutoApproveRequestModel
|
||||
if err := ctx.ShouldBindJSON(¶ms); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "参数解析错误",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 参数完整性、安全性处理
|
||||
req.DealAutoApprove(¶ms)
|
||||
|
||||
// 调用服务逻辑处理
|
||||
result := service.AutoApproveRequestService(queryKey, params)
|
||||
|
||||
// 返回处理结果
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetFinderSearchApi 视频号搜索
|
||||
func GetFinderSearchApi(ctx *gin.Context) {
|
||||
reqModel := new(req.FinderSearchModel)
|
||||
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.GetFinderSearchService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// FinderUserPrepareApi 视频号中心
|
||||
func FinderUserPrepareApi(ctx *gin.Context) {
|
||||
reqModel := new(req.FinderUserPrepareModel)
|
||||
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.FinderUserPrepareService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// FinderFollowApi 关注取消
|
||||
func FinderFollowApi(ctx *gin.Context) {
|
||||
reqModel := new(req.FinderFollowModel)
|
||||
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.FinderFollowService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// FavSyncApi 同步收藏
|
||||
func FavSyncApi(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.FavSyncService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetFavListApi 获取收藏list
|
||||
func GetFavListApi(ctx *gin.Context) {
|
||||
reqModel := new(req.FavInfoModel)
|
||||
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.GetFavListService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetFavInfoApi 获取收藏信息
|
||||
func GetFavInfoApi(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.GetFavInfoService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// BatchDelFavItemApi 删除收藏
|
||||
func BatchDelFavItemApi(ctx *gin.Context) {
|
||||
reqModel := new(req.FavInfoModel)
|
||||
|
||||
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.BatchDelFavItemService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// BatchGetFavItemApi 获取收藏详细
|
||||
func BatchGetFavItemApi(ctx *gin.Context) {
|
||||
reqModel := new(req.FavInfoModel)
|
||||
|
||||
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.BatchGetFavItemService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// UploadAppAttachApi 上传文件
|
||||
func UploadAppAttachApi(ctx *gin.Context) {
|
||||
reqModel := new(req.UploadAppAttachModel)
|
||||
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.UploadAppAttachService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetContactListApi 获取全部联系人
|
||||
func GetContactListApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetContactListModel)
|
||||
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.GetContactListService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetFriendListApi 获取好友列表
|
||||
func GetFriendListApi(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.GetFriendListService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetGroupListApi 获取保存的群聊列表
|
||||
func GetGroupListApi(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.GetGroupListService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetGHListApi 获取关注的公众号列表
|
||||
func GetGHListApi(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.GetGHListService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// FollowGHApi 关注公众号
|
||||
func FollowGHApi(ctx *gin.Context) {
|
||||
|
||||
reqModel := new(req.FollowGHModel)
|
||||
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.FollowGHService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// UploadMContactApi 上传手机通讯录好友
|
||||
func UploadMContactApi(ctx *gin.Context) {
|
||||
reqModel := new(req.UploadMContactModel)
|
||||
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.UploadMContactService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetMFriendApi 获取手机通讯录好友
|
||||
func GetMFriendApi(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.GetMFriendService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetContactContactApi 获取联系人详情
|
||||
func GetContactContactApi(ctx *gin.Context) {
|
||||
reqModel := new(req.BatchGetContactModel)
|
||||
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.GetContactContactService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetFriendRelationApi 获取好友关系
|
||||
func GetFriendRelationApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetFriendRelationModel)
|
||||
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.GetFriendRelationService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SearchContactRequestApi 搜索联系人
|
||||
func SearchContactRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SearchContactRequestModel)
|
||||
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.SearchContactRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// VerifyUserRequestApi 验证好友/添加好友
|
||||
func VerifyUserRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.VerifyUserRequestModel)
|
||||
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.VerifyUserRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AgreeAddApi 同意好友请求
|
||||
func AgreeAddApi(ctx *gin.Context) {
|
||||
reqModel := new(req.VerifyUserRequestModel)
|
||||
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.Scene == 0 {
|
||||
reqModel.Scene = 0x06
|
||||
}
|
||||
result := service.VerifyUserRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DetectDeadFans 检测僵死粉
|
||||
func DetectDeadFans(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.StartFriendTaskService(queryKey, 1) // 1表示检测僵死粉任务
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CleanDeadFans 清理僵死粉
|
||||
func CleanDeadFans(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.StartFriendTaskService(queryKey, 2) // 2表示清理僵死粉任务
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetChatroomQrCode 获取群二维码
|
||||
func GetChatroomQrCode(ctx *gin.Context) {
|
||||
reqModel := new(req.GetChatroomQrCodeModel)
|
||||
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 !strings.HasSuffix(reqModel.ChatRoomName, "@chatroom") {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("非法的 ChatRoomId!"))
|
||||
return
|
||||
}
|
||||
|
||||
result := service.GetChatroomQrCodeService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SetChatroomAnnouncementApi 设置群公告
|
||||
func SetChatroomAnnouncementApi(ctx *gin.Context) {
|
||||
reqModel := new(req.UpdateChatroomAnnouncementModel)
|
||||
|
||||
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.SetChatroomAnnouncementService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetChatroomMemberDetailApi 获取群成员详细
|
||||
func GetChatroomMemberDetailApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetChatroomMemberDetailModel)
|
||||
|
||||
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.GetChatroomMemberDetailService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetQuitChatroomApi 退出群聊
|
||||
func GetQuitChatroomApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetChatroomMemberDetailModel)
|
||||
|
||||
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.QuitChatroomService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CreateChatRoomApi 创建群请求
|
||||
func CreateChatRoomApi(ctx *gin.Context) {
|
||||
reqModel := new(req.CreateChatRoomModel)
|
||||
|
||||
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.CreateChatRoomService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// InviteChatroomMembersApi 邀请群成员
|
||||
func InviteChatroomMembersApi(ctx *gin.Context) {
|
||||
reqModel := new(req.InviteChatroomMembersModel)
|
||||
|
||||
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.InviteChatroomMembersService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AddChatRoomMembersApi 添加群成员
|
||||
func AddChatRoomMembersApi(ctx *gin.Context) {
|
||||
reqModel := new(req.InviteChatroomMembersModel)
|
||||
|
||||
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.AddChatRoomMemberService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ScanIntoUrlGroupApi 扫码入群
|
||||
func ScanIntoUrlGroupApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ScanIntoUrlGroupModel)
|
||||
|
||||
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.ScanIntoUrlGroupService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendAddChatRoomMemberApi 添加好友进群
|
||||
func SendAddChatRoomMemberApi(ctx *gin.Context) {
|
||||
reqModel := new(req.InviteChatroomMembersModel)
|
||||
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.AddChatRoomMemberService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendDelDelChatRoomMemberApi 删除群成员
|
||||
func SendDelDelChatRoomMemberApi(ctx *gin.Context) {
|
||||
reqModel := new(req.InviteChatroomMembersModel)
|
||||
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.SendDelDelChatRoomMemberService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendTransferGroupOwnerApi 转让群
|
||||
func SendTransferGroupOwnerApi(ctx *gin.Context) {
|
||||
reqModel := new(req.TransferGroupOwnerModel)
|
||||
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.SendTransferGroupOwnerService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ConsentToJoinGroupApi 同意入群
|
||||
func ConsentToJoinGroupApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ConsentToJoinGroupModel)
|
||||
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.ConsentToJoinGroupService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SetGetChatRoomInfoDetailApi 获取群公告
|
||||
func SetGetChatRoomInfoDetailApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetChatroomMemberDetailModel)
|
||||
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.SetGetChatRoomInfoDetailService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetChatRoomInfoApi 获取群详情
|
||||
func GetChatRoomInfoApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ChatRoomWxIdListModel)
|
||||
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.GetChatRoomInfoService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// MoveToContractApi 获取群聊
|
||||
func MoveToContractApi(ctx *gin.Context) {
|
||||
reqModel := new(req.MoveContractModel)
|
||||
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.MoveToContractService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SetChatroomAccessVerifyApi 设置群聊邀请开关
|
||||
func SetChatroomAccessVerifyApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SetChatroomAccessVerifyModel)
|
||||
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.SetChatroomAccessVerifyService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AddChatroomAdminApi 添加群管理员
|
||||
func AddChatroomAdminApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ChatroomMemberModel)
|
||||
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.AddChatroomAdminService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DelChatroomAdminApi 删除群管理员
|
||||
func DelChatroomAdminApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ChatroomMemberModel)
|
||||
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.DelChatroomAdminService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SetChatroomNameApi 设置群昵称
|
||||
func SetChatroomNameApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ChatroomNameModel)
|
||||
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.SetChatroomNameService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendPatApi 群拍一拍功能
|
||||
func SendPatApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendPatModel)
|
||||
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.SendPatService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GroupListApi 获取群列表
|
||||
func GroupListApi(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.NewSyncHistoryMessageService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetContactLabelListApi 获取标签列表
|
||||
func GetContactLabelListApi(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.GetContactLabelListRequestService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AddContactLabelRequestApi 添加列表
|
||||
func AddContactLabelRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.LabelModel)
|
||||
|
||||
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.AddContactLabelRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DelContactLabelRequestApi 删除标签
|
||||
func DelContactLabelRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.LabelModel)
|
||||
|
||||
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.DelContactLabelRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ModifyLabelRequestApi 修改标签
|
||||
func ModifyLabelRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.LabelModel)
|
||||
|
||||
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.ModifyLabelRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetWXFriendListByLabelIDApi 获取标签下所有好友
|
||||
func GetWXFriendListByLabelIDApi(ctx *gin.Context) {
|
||||
reqModel := new(req.LabelModel)
|
||||
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.GetWXFriendListByLabelIDService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,437 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
"xiawan/wx/clientsdk/baseutils"
|
||||
"xiawan/wx/db"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gogf/guuid"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
// 检查请求参数 key 对应的 license 是否可用
|
||||
func checkLicense(ctx *gin.Context) (string, error) {
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
errMsg := fmt.Sprintf("%s 该 key 无效! 请 检查正确性 或 联系管理员生成", queryKey)
|
||||
if !isExist || len(strings.TrimSpace(queryKey)) == 0 {
|
||||
// 请求参数中没有携带 license 或者 license 为空
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
has, err := db.HasLicense(queryKey)
|
||||
if has == nil || err != nil {
|
||||
// MySQL 数据库没有该 license
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
if db.CheckExpiry(has.ExpiryDate, has.Type) {
|
||||
// MySQL 数据库中的该 license 已过期
|
||||
return "", errors.New(fmt.Sprintf("%s 该 key 已过期!", queryKey))
|
||||
}
|
||||
|
||||
// license 可用
|
||||
return queryKey, nil
|
||||
}
|
||||
|
||||
// GetLoginQrCodeTempShow HTML展示登录二维码
|
||||
func GetLoginQrCodeTempShow(ctx *gin.Context) {
|
||||
queryKey, err := checkLicense(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
//获取二维码
|
||||
qrcodeResponse, dto := service.GetLoginQrCodeShow(queryKey)
|
||||
|
||||
// 二维码写入到文件
|
||||
baseutils.WriteToFile(qrcodeResponse.GetQrcode().GetSrc(), "static/qrcode/"+qrcodeResponse.GetUuid()+".png")
|
||||
// 延时删除图片
|
||||
go func() {
|
||||
time.Sleep(time.Second * 10)
|
||||
err := os.Remove("static/qrcode/" + qrcodeResponse.GetUuid() + ".png")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
if dto.Code == vo.SUCCESS {
|
||||
ctx.HTML(http.StatusOK, "login.tmpl", gin.H{"img": qrcodeResponse.GetUuid()})
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, "err.tmpl", gin.H{"showlog": dto})
|
||||
}
|
||||
}
|
||||
|
||||
// GetLoginQrCodeNewApi 获取登录二维码-iPad(异地IP必须用代理! socks5://username:password@ipv4:port)
|
||||
func GetLoginQrCodeNewApi(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.GetLoginQrCodeNewService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetLoginQrCodeNewApi 获取登录二维码-直登(异地IP必须用代理! socks5://username:password@ipv4:port)
|
||||
func GetLoginQrCodeNewApiDirect(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.GetLoginQrCodeNewServiceDirect(queryKey, *reqModel, reqModel.IpadOrmac)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// WxBindOpMobileForRegApi 获取验证码
|
||||
func WxBindOpMobileForRegApi(ctx *gin.Context) {
|
||||
reqModel := new(req.WxBindOpMobileForModel)
|
||||
queryKey, err := checkLicense(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.WxBindOpMobileForRegService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// Get62DataApi 提取62数据
|
||||
func Get62DataApi(ctx *gin.Context) {
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist {
|
||||
queryKey = guuid.New().String()
|
||||
}
|
||||
result := service.Get62DataService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// PhoneDeviceLoginApi 辅助新手机登录
|
||||
func PhoneDeviceLoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.PhoneLoginModel)
|
||||
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.PhoneDeviceLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DeviceIdLoginApi 62账号密码登录
|
||||
func DeviceIdLoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DeviceIdLoginModel)
|
||||
queryKey, err := checkLicense(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.DeviceIdLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SmsLoginApi 短信登录
|
||||
func SmsLoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DeviceIdLoginModel)
|
||||
queryKey, err := checkLicense(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
reqModel.Password = "strdm@," + reqModel.Password
|
||||
result := service.SmsLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// A16LoginApi A16数据登录
|
||||
func A16LoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DeviceIdLoginModel)
|
||||
queryKey, err := checkLicense(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.A16LoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// LoginNewApi 62LoginNew新疆号登录
|
||||
func LoginNewApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DeviceIdLoginModel)
|
||||
queryKey, err := checkLicense(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
reqModel.Type = 1
|
||||
result := service.A16LoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CheckLoginStatusApi 检测扫码状态
|
||||
func CheckLoginStatusApi(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.CheckLoginQrCodeStatusService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetInItStatusApi 初始化状态
|
||||
func GetInItStatusApi(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.GetInItStatusService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// WakeUpLoginApi 唤醒登录(只限扫码登录)
|
||||
func WakeUpLoginApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetLoginQrCodeModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
result := service.WakeUpLoginService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetLoginStatusApi 获取在线状态
|
||||
func GetLoginStatusApi(ctx *gin.Context) {
|
||||
autoLogin := true
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
isAutoLogin, isExist := ctx.GetQuery("autoLogin")
|
||||
if isExist {
|
||||
if strings.Contains(isAutoLogin, "false") {
|
||||
autoLogin = false
|
||||
}
|
||||
}
|
||||
|
||||
result := service.GetLoginStatusService(queryKey, false, autoLogin)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetSafetyInfoApi 获取安全设备列表
|
||||
func GetSafetyInfoApi(ctx *gin.Context) {
|
||||
queryKey, _ := ctx.GetQuery("key")
|
||||
result := service.GetSafetyInfoService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DelSafeDeviceApi 删除安全设备
|
||||
func DelSafeDeviceApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DelSafeDeviceModel)
|
||||
queryKey, _ := ctx.GetQuery("key")
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.DelSafeDeviceService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetBoundHardDevice 获取硬件设备情况
|
||||
func GetBoundHardDevice(ctx *gin.Context) {
|
||||
queryKey, _ := ctx.GetQuery("key")
|
||||
result := service.GetBoundHardDeviceService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CheckCanSetAliasApi 检测微信登录环境
|
||||
func CheckCanSetAliasApi(ctx *gin.Context) {
|
||||
queryKey, _ := ctx.GetQuery("key")
|
||||
result := service.CheckCanSetAliasService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// IWXConnectMgrApi 打印链接数量
|
||||
func IWXConnectMgrApi(ctx *gin.Context) {
|
||||
result := service.IWXConnectMgrService()
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetConnectInfo 打印链接信息
|
||||
func GetConnectInfo(ctx *gin.Context) {
|
||||
result := service.GetConnectInfo()
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// LogOutRequestApi 退出登录
|
||||
func LogOutRequestApi(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.LogOutService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// MacLoginApi 获取Mac登录二维码 (异地IP必须用代理 socks5://username:password@ipv4:port)
|
||||
func MacLoginApi(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.MacLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// AndroidPadLoginApi 获取安卓平板登录二维码 (异地IP必须用代理 socks5://username:password@ipv4:port)
|
||||
func AndroidPadLoginApi(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.AndroidPadLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CarLoginApi 获取车载登录二维码 (异地IP必须用代理 socks5://username:password@ipv4:port)
|
||||
func CarLoginApi(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.CarLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// VerifyCodeApi 验证码验证(输入iPad登录验证码)
|
||||
func VerifyCodeApi(ctx *gin.Context) {
|
||||
reqModel := new(req.VerifyCodeModel)
|
||||
queryKey, err := checkLicense(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
|
||||
param := req.VerifyCodeModel{
|
||||
Code: reqModel.Code,
|
||||
Data62: reqModel.Data62,
|
||||
Ticket: reqModel.Ticket,
|
||||
}
|
||||
result := service.Verificationcode2(param, queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// VerifyCodeSlideApi 过mac滑块验证
|
||||
func VerifyCodeApiSlide(ctx *gin.Context) {
|
||||
reqModel := new(req.SlideTicketModel)
|
||||
queryKey, _ := ctx.GetQuery("key")
|
||||
if queryKey != "1234520" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("key错误"))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
param := req.SlideTicketModel{
|
||||
Data62: reqModel.Data62,
|
||||
Ticket: reqModel.Ticket,
|
||||
RandStr: reqModel.RandStr,
|
||||
SlideTicket: reqModel.SlideTicket,
|
||||
}
|
||||
result := service.VerificationcodeSlide(param)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// WinLoginService win登录
|
||||
func WinLoginService(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.WinLoginService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,479 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
req "xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
// AddMessageMgrApi 添加要发送的文本消息进入管理器
|
||||
func AddMessageMgrApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendMessageModel)
|
||||
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.AddMessageMgrService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
var (
|
||||
upgrader = websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
}
|
||||
)
|
||||
|
||||
// GetSyncMsgApi 同步消息,ws协议; 下面有【同步消息-HTTP-轮询方式】
|
||||
// GetSyncMsgApi 处理同步消息的 API 请求。
|
||||
// 它从请求中获取查询参数 "key",如果不存在或为空,则返回 400 错误和相应的错误信息。
|
||||
// 如果 "key" 有效,则调用 WebSocketHandler 进行后续处理。
|
||||
func GetSyncMsgApi(ctx *gin.Context) {
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": "无效的key",
|
||||
})
|
||||
return
|
||||
}
|
||||
service.WebSocketHandler(ctx, queryKey)
|
||||
return
|
||||
}
|
||||
|
||||
// HttpSyncMsg 同步消息, HTTP-轮询方式
|
||||
func HttpSyncMsg(ctx *gin.Context) {
|
||||
reqModel := new(req.SyncMessageModel)
|
||||
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(queryKey))
|
||||
return
|
||||
}
|
||||
|
||||
_ = ctx.ShouldBindJSON(&reqModel)
|
||||
if reqModel.Count < 0 {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("Count参数错误"))
|
||||
return
|
||||
}
|
||||
|
||||
result := service.HttpSyncMsg(queryKey, reqModel.Count)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendImageMessageApi 发送图片消息
|
||||
func SendImageMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendMessageModel)
|
||||
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(queryKey))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.SendImageMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendImageNewMessageApi 发送图片消息(New)
|
||||
func SendImageNewMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendMessageModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Keys
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.SendImageNewMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendTextMessageApi 发送文本消息
|
||||
func SendTextMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendMessageModel)
|
||||
|
||||
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.SendTextMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ShareCardMessageApi 分享名片消息
|
||||
func ShareCardMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ShareCardParam)
|
||||
|
||||
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.ShareCardMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendTextMessageNoShow 不显示会话(不删聊天记录)
|
||||
func SendTextMessageNoShow(ctx *gin.Context) {
|
||||
reqModel := new(req.MessageNoShowParam)
|
||||
|
||||
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.SendTextMessageNoShowService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ForwardImageMessageApi 转发图片
|
||||
func ForwardImageMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ForwardMessageModel)
|
||||
|
||||
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.ForwardImageMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ForwardVideoMessageApi 转发视频
|
||||
func ForwardVideoMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ForwardMessageModel)
|
||||
|
||||
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.ForwardVideoMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendEmojiMessageApi 发送表情
|
||||
func SendEmojiMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendEmojiMessageModel)
|
||||
|
||||
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.SendEmojiMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ForwardEmojiApi 转发表情,包含动图
|
||||
func ForwardEmojiApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendEmojiMessageModel)
|
||||
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.ForwardEmojiService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendAppMessageApi 发送App消息
|
||||
func SendAppMessageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.AppMessageModel)
|
||||
|
||||
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.SendAppMessageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// RevokeMsgApi 撤销消息
|
||||
func RevokeMsgApi(ctx *gin.Context) {
|
||||
reqModel := new(req.RevokeMsgModel)
|
||||
|
||||
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.RevokeMsgService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// RevokeMsgNewApi 撤回消息(New)
|
||||
func RevokeMsgNewApi(ctx *gin.Context) {
|
||||
reqModel := new(req.RevokeMsgModel)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 检查是否有ClientImgIdStr字段,如果有则是图片消息
|
||||
if reqModel.ClientImgIdStr != "" {
|
||||
reqModel.IsImage = true
|
||||
log.Printf("尝试撤回图片消息: NewMsgId=%s, ClientMsgId=%d, CreateTime=%d, ClientImgIdStr=%s",
|
||||
reqModel.NewMsgId, reqModel.ClientMsgId, reqModel.CreateTime, reqModel.ClientImgIdStr)
|
||||
}
|
||||
|
||||
result := service.RevokeMsgNewService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// UploadVoiceRequestApi 发送语音
|
||||
func UploadVoiceRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendUploadVoiceRequestModel)
|
||||
|
||||
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.UploadVoiceRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CdnUploadVideoRequestApi 上传视频
|
||||
func CdnUploadVideoRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.CdnUploadVideoRequest)
|
||||
|
||||
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.SendCdnUploadVideoRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendCdnDownloadApi 下载 请求
|
||||
func SendCdnDownloadApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DownMediaModel)
|
||||
|
||||
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.SendCdnDownloadService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetMsgBigImgApi 获取图片(高清图片下载)
|
||||
func GetMsgBigImgApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DownloadParam)
|
||||
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.GetMsgBigImgService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetMsgVideoApi 获取视频(视频数据下载)
|
||||
func GetMsgVideoApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DownloadParam)
|
||||
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.GetMsgVideoService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// NewSyncHistoryMessageApi 同步历史消息
|
||||
func NewSyncHistoryMessageApi(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.NewSyncHistoryMessageService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GroupMassMsgTextApi 群发接口
|
||||
func GroupMassMsgTextApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GroupMassMsgTextModel)
|
||||
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.GroupMassMsgTextService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GroupMassMsgImageApi 群发图片
|
||||
func GroupMassMsgImageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GroupMassMsgImageModel)
|
||||
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.GroupMassMsgImageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetMsgVoiceApi 下载语音消息
|
||||
func GetMsgVoiceApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DownloadVoiceModel)
|
||||
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.GetMsgVoiceService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// DownloadEmojiGifApi 下载表情
|
||||
func DownloadEmojiGifApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DownloadEmojiModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(queryKey))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
|
||||
result := service.DownloadEmojiGifService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// UploadImageToCDNApi 纯CDN图片上传接口
|
||||
func UploadImageToCDNApi(ctx *gin.Context) {
|
||||
reqModel := new(req.UploadImageToCDNModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
|
||||
result := service.UploadImageToCDNService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetMyQrCode 获取我的二维码
|
||||
func GetMyQrCode(ctx *gin.Context) {
|
||||
reqModel := new(req.GetQrCodeModel)
|
||||
|
||||
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.GetMyQrCodeService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetPeopleNearbyApi 查看附近的人
|
||||
func GetPeopleNearbyApi(ctx *gin.Context) {
|
||||
reqModel := new(req.PeopleNearbyModel)
|
||||
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.GetPeopleNearbyService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// UpdateCmdStatusApi 更新指令状态, key 为指令 id,Value 为指令状态 0|1,ValueStr 为字符串值
|
||||
func UpdateCmdStatusApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ModifyCmdStatusModelNew)
|
||||
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.UpdateCmdStatusService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetProjectFullPathApi 获取项目完整路径
|
||||
func GetProjectFullPathApi(ctx *gin.Context) {
|
||||
execPath, err := os.Executable() // 获取可执行文件的路径
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get executable path: %v", err)
|
||||
ctx.JSON(http.StatusNotFound, "")
|
||||
return
|
||||
}
|
||||
execPath, err = filepath.EvalSymlinks(execPath) // 解析符号链接,获取真实路径
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to evaluate symlinks: %v", err)
|
||||
ctx.JSON(http.StatusNotFound, "")
|
||||
return
|
||||
}
|
||||
// 获取可执行文件所在目录
|
||||
dir := filepath.Dir(execPath)
|
||||
ctx.JSON(http.StatusOK, dir)
|
||||
}
|
||||
|
||||
// 企微图片下载
|
||||
func QWImageDownloadApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DownloadQWImageModel)
|
||||
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
|
||||
// 解析XML,提取 AesKey / FileURL / FileType
|
||||
type imageXML struct {
|
||||
XMLName xml.Name `xml:"msg"`
|
||||
Img struct {
|
||||
AESKey string `xml:"aeskey,attr"`
|
||||
CdnMidImgURL string `xml:"cdnmidimgurl,attr"`
|
||||
CdnThumbURL string `xml:"cdnthumburl,attr"`
|
||||
TpURL string `xml:"tpurl,attr"`
|
||||
TpThumbAESKey string `xml:"tpthumbaeskey,attr"`
|
||||
} `xml:"img"`
|
||||
}
|
||||
|
||||
var parsed imageXML
|
||||
if err := xml.Unmarshal([]byte(reqModel.Xml), &parsed); err != nil {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("XML解析失败:"+err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
aesKey := strings.TrimSpace(parsed.Img.AESKey)
|
||||
if aesKey == "" {
|
||||
aesKey = strings.TrimSpace(parsed.Img.TpThumbAESKey)
|
||||
}
|
||||
|
||||
fileURL := ""
|
||||
tpurl := strings.TrimSpace(parsed.Img.TpURL)
|
||||
if tpurl != "" {
|
||||
if u, err := url.Parse(tpurl); err == nil {
|
||||
f := u.Query().Get("f")
|
||||
if f != "" {
|
||||
fileURL = f
|
||||
} else {
|
||||
// 回退为完整tpurl(如果缺少f参数)
|
||||
fileURL = tpurl
|
||||
}
|
||||
} else {
|
||||
fileURL = tpurl
|
||||
}
|
||||
} else {
|
||||
fileURL = strings.TrimSpace(parsed.Img.CdnMidImgURL)
|
||||
if fileURL == "" {
|
||||
fileURL = strings.TrimSpace(parsed.Img.CdnThumbURL)
|
||||
}
|
||||
}
|
||||
|
||||
if aesKey == "" || fileURL == "" {
|
||||
ctx.JSON(http.StatusOK, vo.NewFail("参数错误:无法从XML提取必要字段(AesKey或FileURL)"))
|
||||
return
|
||||
}
|
||||
|
||||
model := req.DownMediaModel{
|
||||
AesKey: aesKey,
|
||||
FileURL: fileURL,
|
||||
FileType: 1, // 默认 1
|
||||
}
|
||||
|
||||
result := service.SendCdnDownloadService(queryKey, model)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
"xiawan/wx/clientsdk/baseinfo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetBandCardListApi 获取银行卡信息
|
||||
func GetBandCardListApi(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.GetBandCardListService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GeneratePayQCodeApi 生成自定义收款二维码
|
||||
func GeneratePayQCodeApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GeneratePayQCodeModel)
|
||||
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.GeneratePayQCodeService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CollectMoneyApi 确定收款
|
||||
func CollectMoneyApi(ctx *gin.Context) {
|
||||
reqModel := new(req.CollectmoneyModel)
|
||||
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.CollectMoneyService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// WXCreateRedPacketApi 创建红包
|
||||
func WXCreateRedPacketApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.RedPacket)
|
||||
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.WXCreateRedPacketService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// OpenRedEnvelopesApi 拆红包
|
||||
func OpenRedEnvelopesApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.HongBaoItem)
|
||||
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.OpenRedEnvelopesService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QueryRedEnvelopesDetailApi 查看红包详情
|
||||
func QueryRedEnvelopesDetailApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.HongBaoItem)
|
||||
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.QueryRedEnvelopesDetailService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetRedPacketListApi 查看红包领取列表
|
||||
func GetRedPacketListApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.GetRedPacketList)
|
||||
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.GetRedPacketListService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CreatePreTransferApi 创建转账
|
||||
func CreatePreTransferApi(ctx *gin.Context) {
|
||||
reqModel := new(req.CreatePreTransfer)
|
||||
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.CreatePreTransferService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ConfirmPreTransferApi 确认转账(客户端版本过低会无法转账)
|
||||
func ConfirmPreTransferApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ConfirmPreTransfer)
|
||||
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.ConfirmPreTransferService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"xiawan/wx/api/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetProxyMappingList 获取代理映射列表
|
||||
func GetProxyMappingList(ctx *gin.Context) {
|
||||
list, err := service.GetProxyMappingList()
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{
|
||||
"code": -1,
|
||||
"msg": err.Error(),
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"msg": "success",
|
||||
"data": list,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// QWContactApi 提取企业 wx 详情
|
||||
func QWContactApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWContactModel)
|
||||
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.QWContactService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWSyncContactApi 提取全部的企业通讯录
|
||||
func QWSyncContactApi(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.QWSyncContactService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWRemarkApi 备注企业 wxid
|
||||
func QWRemarkApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWRemarkModel)
|
||||
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.QWRemarkService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWCreateChatRoomApi 创建企业群
|
||||
func QWCreateChatRoomApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWCreateModel)
|
||||
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.QWCreateChatRoomService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWSearchContactApi 搜手机或企业对外名片链接提取验证
|
||||
func QWSearchContactApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SearchContactModel)
|
||||
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.QWSearchContactService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWApplyAddContactApi 向企业微信打招呼
|
||||
func QWApplyAddContactApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWApplyAddContactModel)
|
||||
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.QWApplyAddContactService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWAddContactApi 单向加企业微信
|
||||
func QWAddContactApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWApplyAddContactModel)
|
||||
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.QWAddContactService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWSyncChatRoomApi 提取全部企业微信群-
|
||||
func QWSyncChatRoomApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWSyncChatRoomModel)
|
||||
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.QWSyncChatRoomService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWChatRoomTransferOwnerApi 转让企业群
|
||||
func QWChatRoomTransferOwnerApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWChatRoomTransferOwnerModel)
|
||||
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.QWChatRoomTransferOwnerService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWAddChatRoomMemberApi 直接拉朋友进企业群
|
||||
func QWAddChatRoomMemberApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWAddChatRoomMemberService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWInviteChatRoomMemberApi 发送群邀请链接
|
||||
func QWInviteChatRoomMemberApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWInviteChatRoomMemberService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWDelChatRoomMemberApi 删除企业群成员
|
||||
func QWDelChatRoomMemberApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWDelChatRoomMemberService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWGetChatRoomMemberApi 提取企业群全部成员
|
||||
func QWGetChatRoomMemberApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWGetChatRoomMemberService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWGetChatroomInfoApi 提取企业群名称公告设定等信息
|
||||
func QWGetChatroomInfoApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWGetChatroomInfoService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWGetChatRoomQRApi 提取企业群二维码
|
||||
func QWGetChatRoomQRApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWGetChatRoomQRService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWAppointChatRoomAdminApi 增加企业管理员
|
||||
func QWAppointChatRoomAdminApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWAppointChatRoomAdminService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWDelChatRoomAdminApi 移除群管理员
|
||||
func QWDelChatRoomAdminApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAddChatRoomMemberModel)
|
||||
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.QWDelChatRoomAdminService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWAcceptChatRoomRequestApi 同意进企业群
|
||||
func QWAcceptChatRoomRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAcceptChatRoomModel)
|
||||
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.QWAcceptChatRoomRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWAdminAcceptJoinChatRoomSetApi 设定企业群管理审核进群
|
||||
func QWAdminAcceptJoinChatRoomSetApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWAdminAcceptJoinChatRoomSetModel)
|
||||
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.QWAdminAcceptJoinChatRoomSetService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWModChatRoomNameApi 修改企业群名称
|
||||
func QWModChatRoomNameApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWModChatRoomNameModel)
|
||||
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.QWModChatRoomNameService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWModChatRoomMemberNickApi 修改成员在群中呢称
|
||||
func QWModChatRoomMemberNickApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWModChatRoomNameModel)
|
||||
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.QWModChatRoomMemberNickService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWChatRoomAnnounceApi 发布企业群公告
|
||||
func QWChatRoomAnnounceApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWModChatRoomNameModel)
|
||||
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.QWChatRoomAnnounceService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QWDelChatRoomApi 删除企业群
|
||||
func QWDelChatRoomApi(ctx *gin.Context) {
|
||||
reqModel := new(req.QWModChatRoomNameModel)
|
||||
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.SendQWDelChatRoomService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
"xiawan/wx/clientsdk/baseinfo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// DownloadMediaApi 下载朋友圈视频
|
||||
func DownloadMediaApi(ctx *gin.Context) {
|
||||
reqModel := new(req.DownloadMediaModel)
|
||||
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.DownloadMediaService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SetFriendCircleDaysApi 设置朋友圈可见天数
|
||||
func SetFriendCircleDaysApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SetFriendCircleDaysModel)
|
||||
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.SetFriendCircleDaysService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendFriendCircleApi 发送朋友圈
|
||||
func SendFriendCircleApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SnsPostItemModel)
|
||||
|
||||
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.SendFriendCircleService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendFriendCircleByXMlApi 发送朋友圈XML结构
|
||||
func SendFriendCircleByXMlApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.TimelineObject)
|
||||
|
||||
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.SendFriendCircleByXMlService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// UploadFriendCircleImageApi 上传图片信息
|
||||
func UploadFriendCircleImageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.UploadFriendCircleModel)
|
||||
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, " ") == "" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
|
||||
result := service.UploadFriendCircleImageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendSnsCommentRequestApi 点赞评论
|
||||
func SendSnsCommentRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendSnsCommentRequestModel)
|
||||
|
||||
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.SendSnsCommentRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendSnsObjectOpRequestApi 朋友圈操作
|
||||
func SendSnsObjectOpRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendSnsObjectOpRequestModel)
|
||||
|
||||
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.SendSnsObjectOpRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendSnsTimeLineRequestApi 获取朋友圈主页
|
||||
func SendSnsTimeLineRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetSnsInfoModel)
|
||||
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.SendSnsTimeLineRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendSnsUserPageRequestApi 获取指定人朋友圈
|
||||
func SendSnsUserPageRequestApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetSnsInfoModel)
|
||||
|
||||
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.SendSnsUserPageRequestService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendSnsObjectDetailByIdApi 获取指定id朋友圈
|
||||
func SendSnsObjectDetailByIdApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetIdDetailModel)
|
||||
|
||||
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.SendSnsObjectDetailByIdService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SetBackgroundImageApi 设置朋友圈背景图片
|
||||
func SetBackgroundImageApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SetBackgroundImageModel)
|
||||
|
||||
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.SetBackgroundImageService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendFavItemCircleApi 转发收藏朋友圈id
|
||||
func SendFavItemCircleApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendFavItemCircle)
|
||||
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.SendFavItemCircleService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// SendOneIdCircleApi 一键转发朋友圈
|
||||
func SendOneIdCircleApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GetIdDetailModel)
|
||||
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.SendOneIdCircleService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetCollectCircleApi 获取收藏朋友圈详情
|
||||
func GetCollectCircleApi(ctx *gin.Context) {
|
||||
reqModel := new(req.SendFavItemCircle)
|
||||
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.GetCollectCircleService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetSnsSync 同步朋友圈
|
||||
func GetSnsSync(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.GetSnsSyncService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CdnSnsVideoUploadApi 上传CDN朋友圈视频
|
||||
func CdnSnsVideoUploadApi(ctx *gin.Context) {
|
||||
reqModel := new(req.CdnSnsVideoUploadModel)
|
||||
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.CdnSnsVideoUploadService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
@@ -0,0 +1,549 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user