3 Star 1 Fork 906

高煜涛/gin-vue-admin

forked from pixel/gin-vue-admin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fd_article.go 3.27 KB
一键复制 编辑 原始数据 按行查看 历史
高煜涛 提交于 2024-09-18 21:11 . 24/9/18
package hierarchy
import (
"gitee.com/g-qs/gin-vue-admin/server/global"
"gitee.com/g-qs/gin-vue-admin/server/model/common/response"
"gitee.com/g-qs/gin-vue-admin/server/service"
"gitee.com/g-qs/gin-vue-admin/server/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
type FdArticleApi struct {
}
var fdArticleService = service.ServiceGroupApp.HierarchyServiceGroup.FdArticleService
// GetArticle 获取文章
// @Tags FdArticleAudio
// @Summary 创建FdArticleAudio
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body hierarchy.FdArticleAudio true "创建FdArticleAudio"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fdArticle/getArticle [get]
func (fdArticleApi *FdArticleApi) GetArticle(c *gin.Context) {
level := c.Query("level")
id := c.Query("id")
userID := utils.GetUserID(c)
if articleList, err := fdArticleService.GetArticle(level, id, userID); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithData(articleList, c)
}
}
// GetHotArticle 搜索文章&获取热门搜索文章列表
// @Tags FdArticleAudio
// @Summary 搜索文章&获取热门搜索文章列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body hierarchy.FdArticleAudio true "创建FdArticleAudio"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fdArticle/getHotArticle [get]
func (fdArticleApi *FdArticleApi) GetHotArticle(c *gin.Context) {
title := c.Query("title")
userID := utils.GetUserID(c)
if articleList, err := fdArticleService.GetHotArticle(userID, title); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithData(articleList, c)
}
}
// GetMyCollect 获取我的收藏文章
// @Tags FdArticleAudio
// @Summary 搜索文章&获取热门搜索文章列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body hierarchy.FdArticleAudio true "创建FdArticleAudio"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fdArticle/getMyCollect [get]
func (fdArticleApi *FdArticleApi) GetMyCollect(c *gin.Context) {
userID := utils.GetUserID(c)
if articleList, err := fdArticleService.GetMyCollect(userID); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithData(articleList, c)
}
}
// ForwardArticle 转发文章
// @Tags FdArticleAudio
// @Summary 转发文章
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body hierarchy.FdArticleAudio true "创建FdArticleAudio"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /fdArticle/forwardArticle [put]
func (fdArticleApi *FdArticleApi) ForwardArticle(c *gin.Context) {
types := c.Query("types")
id := c.Query("id")
if err := fdArticleService.ForwardArticle(types, id); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("转发失败", c)
} else {
response.Result(200, "", "转发成功", c)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/g-qs/gin-vue-admin.git
git@gitee.com:g-qs/gin-vue-admin.git
g-qs
gin-vue-admin
gin-vue-admin
a5c0f301b910

搜索帮助