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