376 lines
11 KiB
Go
376 lines
11 KiB
Go
package controller
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
"xiawan/wx/api/req"
|
|
"xiawan/wx/api/service"
|
|
"xiawan/wx/api/vo"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 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)
|
|
}
|