89 lines
2.3 KiB
Go
89 lines
2.3 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"
|
|
)
|
|
|
|
// FavSyncApi 同步收藏
|
|
func FavSyncApi(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.FavSyncService(queryKey)
|
|
ctx.JSON(http.StatusOK, result)
|
|
}
|
|
|
|
// GetFavListApi 获取收藏list
|
|
func GetFavListApi(ctx *gin.Context) {
|
|
reqModel := new(req.FavInfoModel)
|
|
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.GetFavListService(queryKey, *reqModel)
|
|
ctx.JSON(http.StatusOK, result)
|
|
}
|
|
|
|
// GetFavInfoApi 获取收藏信息
|
|
func GetFavInfoApi(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.GetFavInfoService(queryKey)
|
|
ctx.JSON(http.StatusOK, result)
|
|
}
|
|
|
|
// BatchDelFavItemApi 删除收藏
|
|
func BatchDelFavItemApi(ctx *gin.Context) {
|
|
reqModel := new(req.FavInfoModel)
|
|
|
|
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.BatchDelFavItemService(queryKey, *reqModel)
|
|
ctx.JSON(http.StatusOK, result)
|
|
}
|
|
|
|
// BatchGetFavItemApi 获取收藏详细
|
|
func BatchGetFavItemApi(ctx *gin.Context) {
|
|
reqModel := new(req.FavInfoModel)
|
|
|
|
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.BatchGetFavItemService(queryKey, *reqModel)
|
|
ctx.JSON(http.StatusOK, result)
|
|
}
|