first commit
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user