first commit
This commit is contained in:
368
api/controller/groupController.go
Normal file
368
api/controller/groupController.go
Normal file
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user