Files
wechat_ipad_pro/api/controller/labelController.go
2026-02-17 13:06:23 +08:00

100 lines
2.5 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"
)
// 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)
}