feat: swagger format
This commit is contained in:
@@ -15,7 +15,7 @@ type LevelConfigApi struct{}
|
|||||||
// @Tags 等级配置
|
// @Tags 等级配置
|
||||||
// @Summary 添加等级配置
|
// @Summary 添加等级配置
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreateLevelConf true "添加等级配置"
|
// @Param data body plantReq.CreateLevelConf true "添加等级配置"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
||||||
@@ -40,7 +40,7 @@ func (a *LevelConfigApi) AddLevelConfig(c *gin.Context) {
|
|||||||
// @Tags 等级配置
|
// @Tags 等级配置
|
||||||
// @Summary 修改等级配置
|
// @Summary 修改等级配置
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.UpdateLevelConf true "修改等级配置"
|
// @Param data body plantReq.UpdateLevelConf true "修改等级配置"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type MyPlantApi struct{}
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 添加植物
|
// @Summary 添加植物
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreateMyPlant true "创建植物"
|
// @Param data body plantReq.CreateMyPlant true "创建植物"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
||||||
@@ -43,7 +43,7 @@ func (a *MyPlantApi) AddPlant(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 植物列表
|
// @Summary 植物列表
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.PageInfo true "分页获取植物列表"
|
// @Param data body request.PageInfo true "分页获取植物列表"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||||
@@ -92,7 +92,7 @@ func (a *MyPlantApi) PlantDetail(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 修改ById植物
|
// @Summary 修改ById植物
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.UpdateMyPlant true "修改ById植物"
|
// @Param data body plantReq.UpdateMyPlant true "修改ById植物"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改ById成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改ById成功"}"
|
||||||
@@ -117,7 +117,7 @@ func (a *MyPlantApi) UpdatePlant(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 今日任务
|
// @Summary 今日任务
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||||
// @Router /plant/todayTask [get]
|
// @Router /plant/todayTask [get]
|
||||||
@@ -138,7 +138,7 @@ func (a *MyPlantApi) TodayTask(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 完成任务
|
// @Summary 完成任务
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CompleteTask true "完成任务"
|
// @Param data body plantReq.CompleteTask true "完成任务"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"完成任务"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"完成任务"}"
|
||||||
@@ -163,7 +163,7 @@ func (a *MyPlantApi) CompleteTask(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 删除植物
|
// @Summary 删除植物
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.IdsReq true "删除植物"
|
// @Param data body request.IdsReq true "删除植物"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||||
@@ -187,7 +187,7 @@ func (a *MyPlantApi) DeletePlants(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 删除任务
|
// @Summary 删除任务
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.IdsReq true "删除植物"
|
// @Param data body request.IdsReq true "删除植物"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||||
@@ -211,7 +211,7 @@ func (a *MyPlantApi) DeletePlans(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 添加养护事项
|
// @Summary 添加养护事项
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreateCarePlan true "添加养护事项"
|
// @Param data body plantReq.CreateCarePlan true "添加养护事项"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
||||||
@@ -255,7 +255,7 @@ func (a *MyPlantApi) DeletePlan(c *gin.Context) {
|
|||||||
// @Tags 我的植物
|
// @Tags 我的植物
|
||||||
// @Summary 添加成长记录
|
// @Summary 添加成长记录
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreateGrowthRecord true "添加成长记录"
|
// @Param data body plantReq.CreateGrowthRecord true "添加成长记录"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"添加成功"}"
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ func (o *OcrApi) ClassifyPlant(c *gin.Context) {
|
|||||||
// @tags 识别相关
|
// @tags 识别相关
|
||||||
// @Summary 我的植物识别记录
|
// @Summary 我的植物识别记录
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.PageInfo true "分页"
|
// @Param data body request.PageInfo true "分页"
|
||||||
// @Success 200 {object} response.Response{msg=string} "识别记录"
|
// @Success 200 {object} response.Response{msg=string} "识别记录"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type PostApi struct{}
|
|||||||
// @Tags 帖子
|
// @Tags 帖子
|
||||||
// @Summary 发布帖子
|
// @Summary 发布帖子
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreatePost true "发布帖子"
|
// @Param data body plantReq.CreatePost true "发布帖子"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
||||||
@@ -43,7 +43,7 @@ func (a *PostApi) PublishPost(c *gin.Context) {
|
|||||||
// @Tags 帖子
|
// @Tags 帖子
|
||||||
// @Summary 帖子列表
|
// @Summary 帖子列表
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.PostPage true "分页获取帖子列表"
|
// @Param data body plantReq.PostPage true "分页获取帖子列表"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||||
@@ -74,7 +74,7 @@ func (a *PostApi) PostPage(c *gin.Context) {
|
|||||||
// @Tags 帖子
|
// @Tags 帖子
|
||||||
// @Summary 我的发布
|
// @Summary 我的发布
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.PostPage true "分页获取帖子列表"
|
// @Param data body plantReq.PostPage true "分页获取帖子列表"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||||
@@ -127,7 +127,7 @@ func (a *PostApi) LikePost(c *gin.Context) {
|
|||||||
// @Tags 帖子
|
// @Tags 帖子
|
||||||
// @Summary 评论帖子
|
// @Summary 评论帖子
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreateComment true "评论帖子"
|
// @Param data body plantReq.CreateComment true "评论帖子"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"评论成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"评论成功"}"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type TopicApi struct{}
|
|||||||
// @Tags 帖子话题
|
// @Tags 帖子话题
|
||||||
// @Summary 发布话题
|
// @Summary 发布话题
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreateTopic true "发布话题"
|
// @Param data body plantReq.CreateTopic true "发布话题"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
||||||
@@ -40,7 +40,7 @@ func (a *TopicApi) AddTopic(c *gin.Context) {
|
|||||||
// @Tags 帖子话题
|
// @Tags 帖子话题
|
||||||
// @Summary 修改话题
|
// @Summary 修改话题
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.UpdateTopic true "修改话题"
|
// @Param data body plantReq.UpdateTopic true "修改话题"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
||||||
@@ -64,14 +64,15 @@ func (a *TopicApi) UpdateTopic(c *gin.Context) {
|
|||||||
// @Tags 帖子话题
|
// @Tags 帖子话题
|
||||||
// @Summary 话题分页
|
// @Summary 话题分页
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.PageInfo true "分页获取话题列表"
|
// @Param data body request.PageInfo true "分页获取话题列表"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||||
// @Router /topic/page [post]
|
// @Router /topic/page [post]
|
||||||
func (a *TopicApi) TopicPage(c *gin.Context) {
|
func (a *TopicApi) TopicPage(c *gin.Context) {
|
||||||
var req request.PageInfo
|
var req request.PageInfo
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
err := c.ShouldBindJSON(&req)
|
||||||
|
if err != nil {
|
||||||
response.FailWithMsg("请求参数错误", c)
|
response.FailWithMsg("请求参数错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type UserProfileApi struct{}
|
|||||||
// @Tags 个人中心
|
// @Tags 个人中心
|
||||||
// @Summary 修改用户信息
|
// @Summary 修改用户信息
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.UpdateProfile true "修改用户信息"
|
// @Param data body request.UpdateProfile true "修改用户信息"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
||||||
|
|||||||
@@ -22,11 +22,12 @@ type WikiApi struct{}
|
|||||||
// @Router /wiki/add [post]
|
// @Router /wiki/add [post]
|
||||||
func (a *WikiApi) CreateWiki(c *gin.Context) {
|
func (a *WikiApi) CreateWiki(c *gin.Context) {
|
||||||
var req plantReq.CreateWiki
|
var req plantReq.CreateWiki
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
err := c.ShouldBind(&req)
|
||||||
|
if err != nil {
|
||||||
response.FailWithMsg("请求参数错误", c)
|
response.FailWithMsg("请求参数错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := wikiService.CreateWiki(req)
|
err = wikiService.CreateWiki(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.Logger.Error("添加百科失败", zap.Error(err))
|
global.Logger.Error("添加百科失败", zap.Error(err))
|
||||||
response.FailWithMsg("添加百科失败", c)
|
response.FailWithMsg("添加百科失败", c)
|
||||||
@@ -46,11 +47,12 @@ func (a *WikiApi) CreateWiki(c *gin.Context) {
|
|||||||
// @Router /wiki/update [post]
|
// @Router /wiki/update [post]
|
||||||
func (a *WikiApi) UpdateWiki(c *gin.Context) {
|
func (a *WikiApi) UpdateWiki(c *gin.Context) {
|
||||||
var req plantReq.UpdateWiki
|
var req plantReq.UpdateWiki
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
err := c.ShouldBind(&req)
|
||||||
|
if err != nil {
|
||||||
response.FailWithMsg("请求参数错误", c)
|
response.FailWithMsg("请求参数错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := wikiService.UpdateWiki(req)
|
err = wikiService.UpdateWiki(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.Logger.Error("修改百科失败", zap.Error(err))
|
global.Logger.Error("修改百科失败", zap.Error(err))
|
||||||
response.FailWithMsg("修改百科失败", c)
|
response.FailWithMsg("修改百科失败", c)
|
||||||
@@ -71,7 +73,8 @@ func (a *WikiApi) UpdateWiki(c *gin.Context) {
|
|||||||
// @Router /wiki/page [post]
|
// @Router /wiki/page [post]
|
||||||
func (a *WikiApi) WikiPage(c *gin.Context) {
|
func (a *WikiApi) WikiPage(c *gin.Context) {
|
||||||
var req plantReq.WikiPage
|
var req plantReq.WikiPage
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
err := c.ShouldBind(&req)
|
||||||
|
if err != nil {
|
||||||
response.FailWithMsg("请求参数错误", c)
|
response.FailWithMsg("请求参数错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,18 +16,19 @@ type WikiClassApi struct{}
|
|||||||
// @Tags 百科分类
|
// @Tags 百科分类
|
||||||
// @Summary 添加分类
|
// @Summary 添加分类
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.CreateWikiClass true "添加分类"
|
// @Param data body plantReq.CreateWikiClass true "添加分类"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
||||||
// @Router /wiki-class/add [post]
|
// @Router /wiki-class/add [post]
|
||||||
func (a *WikiClassApi) AddClass(c *gin.Context) {
|
func (a *WikiClassApi) AddClass(c *gin.Context) {
|
||||||
var req plantReq.CreateWikiClass
|
var req plantReq.CreateWikiClass
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
err := c.ShouldBindJSON(&req)
|
||||||
|
if err != nil {
|
||||||
response.FailWithMsg("请求参数错误", c)
|
response.FailWithMsg("请求参数错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := wikiClassService.AddClass(req)
|
err = wikiClassService.AddClass(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.Logger.Error("添加百科分类失败", zap.Error(err))
|
global.Logger.Error("添加百科分类失败", zap.Error(err))
|
||||||
response.FailWithMsg("添加百科分类失败", c)
|
response.FailWithMsg("添加百科分类失败", c)
|
||||||
@@ -40,18 +41,19 @@ func (a *WikiClassApi) AddClass(c *gin.Context) {
|
|||||||
// @Tags 百科分类
|
// @Tags 百科分类
|
||||||
// @Summary 修改分类(可直接传入ossId修改图片)
|
// @Summary 修改分类(可直接传入ossId修改图片)
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body plantReq.UpdateWikiClass true "修改分类"
|
// @Param data body plantReq.UpdateWikiClass true "修改分类"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
||||||
// @Router /wiki-class/update [post]
|
// @Router /wiki-class/update [post]
|
||||||
func (a *WikiClassApi) UpdateClass(c *gin.Context) {
|
func (a *WikiClassApi) UpdateClass(c *gin.Context) {
|
||||||
var req plantReq.UpdateWikiClass
|
var req plantReq.UpdateWikiClass
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
err := c.ShouldBindJSON(&req)
|
||||||
|
if err != nil {
|
||||||
response.FailWithMsg("请求参数错误", c)
|
response.FailWithMsg("请求参数错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := wikiClassService.UpdateClass(req)
|
err = wikiClassService.UpdateClass(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.Logger.Error("修改百科分类失败", zap.Error(err))
|
global.Logger.Error("修改百科分类失败", zap.Error(err))
|
||||||
response.FailWithMsg("修改百科失败", c)
|
response.FailWithMsg("修改百科失败", c)
|
||||||
@@ -64,14 +66,15 @@ func (a *WikiClassApi) UpdateClass(c *gin.Context) {
|
|||||||
// @Tags 百科分类
|
// @Tags 百科分类
|
||||||
// @Summary 分类分页
|
// @Summary 分类分页
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.PageInfo true "分页获取分类列表"
|
// @Param data body request.PageInfo true "分页获取分类列表"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||||
// @Router /wiki-class/page [post]
|
// @Router /wiki-class/page [post]
|
||||||
func (a *WikiClassApi) ClassPage(c *gin.Context) {
|
func (a *WikiClassApi) ClassPage(c *gin.Context) {
|
||||||
var req request.PageInfo
|
var req request.PageInfo
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
err := c.ShouldBindQuery(&req)
|
||||||
|
if err != nil {
|
||||||
response.FailWithMsg("请求参数错误", c)
|
response.FailWithMsg("请求参数错误", c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -93,7 +96,7 @@ func (a *WikiClassApi) ClassPage(c *gin.Context) {
|
|||||||
// @Tags 百科分类
|
// @Tags 百科分类
|
||||||
// @Summary 删除分类
|
// @Summary 删除分类
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @accept json
|
// @accept application/json
|
||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Param data body request.IdsReq true "删除分类"
|
// @Param data body request.IdsReq true "删除分类"
|
||||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type Post struct {
|
|||||||
CommentCount int `json:"commentCount" form:"commentCount" gorm:"default:0;column:comment_count;comment:评论次数"`
|
CommentCount int `json:"commentCount" form:"commentCount" gorm:"default:0;column:comment_count;comment:评论次数"`
|
||||||
LikeCount int `json:"likeCount" form:"likeCount" gorm:"default:0;column:like_count;comment:点赞次数"`
|
LikeCount int `json:"likeCount" form:"likeCount" gorm:"default:0;column:like_count;comment:点赞次数"`
|
||||||
Location string `json:"location" form:"location" gorm:"column:location;size:100;comment:位置"`
|
Location string `json:"location" form:"location" gorm:"column:location;size:100;comment:位置"`
|
||||||
HasReviewed int `json:"hasReviewed" form:"hasReviewed" gorm:"column:has_reviewed;comment:是否审核通过"`
|
HasReviewed int `json:"hasReviewed" form:"hasReviewed" gorm:"column:has_reviewed;default:0;comment:是否审核通过"`
|
||||||
HasLiked int `json:"hasLiked" form:"hasLiked" gorm:"-"`
|
HasLiked int `json:"hasLiked" form:"hasLiked" gorm:"-"`
|
||||||
//图片
|
//图片
|
||||||
ImgList []*system.Oss `json:"imgList" form:"imgList" gorm:"many2many:post_oss;comment:图片列表"`
|
ImgList []*system.Oss `json:"imgList" form:"imgList" gorm:"many2many:post_oss;comment:图片列表"`
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
type Topic struct {
|
type Topic struct {
|
||||||
global.BaseModel
|
global.BaseModel
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
StartTime time.Time `json:"start_time" gorm:"column:start_time;"`
|
StartTime time.Time `json:"startTime" gorm:"type:date;column:start_time;"`
|
||||||
EndTime time.Time `json:"end_time" gorm:"column:end_time;"`
|
EndTime time.Time `json:"endTime" gorm:"type:date;column:end_time;"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type UpdatePost struct {
|
|||||||
type PostPage struct {
|
type PostPage struct {
|
||||||
common.PageInfo
|
common.PageInfo
|
||||||
Title string `json:"title"` // 标题
|
Title string `json:"title"` // 标题
|
||||||
HasReviewed int `json:"hasReviewed"` //是否审核通过
|
HasReviewed *int `json:"hasReviewed"` //是否审核通过
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateComment 创建评论
|
// CreateComment 创建评论
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ package request
|
|||||||
|
|
||||||
type CreateTopic struct {
|
type CreateTopic struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
StartTime string `json:"start_time"`
|
StartTime string `json:"startTime"`
|
||||||
EndTime string `json:"end_time"`
|
EndTime string `json:"endTime"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateTopic struct {
|
type UpdateTopic struct {
|
||||||
Id int `json:"id" binding:"required"`
|
Id int `json:"id" binding:"required"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
StartTime string `json:"start_time"`
|
StartTime string `json:"startTime"`
|
||||||
EndTime string `json:"end_time"`
|
EndTime string `json:"endTime"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ func (s *PostService) PostPage(req plantReq.PostPage, userId string) (list inter
|
|||||||
if req.Title != "" {
|
if req.Title != "" {
|
||||||
db = db.Where("title like ?", "%"+req.Title+"%")
|
db = db.Where("title like ?", "%"+req.Title+"%")
|
||||||
}
|
}
|
||||||
|
if req.HasReviewed != nil {
|
||||||
|
db = db.Where("has_reviewed = ?", *req.HasReviewed)
|
||||||
|
}
|
||||||
//todo 审核帖子
|
//todo 审核帖子
|
||||||
err = db.Count(&total).Error
|
err = db.Count(&total).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (s *TopicService) TopicPage(req common.PageInfo) (list interface{}, total i
|
|||||||
limit := req.PageSize
|
limit := req.PageSize
|
||||||
offset := req.PageSize * (req.Current - 1)
|
offset := req.PageSize * (req.Current - 1)
|
||||||
db := global.DB.Model(&plant.Topic{})
|
db := global.DB.Model(&plant.Topic{})
|
||||||
var topics []*plant.Topic
|
var topics []plant.Topic
|
||||||
err = db.Count(&total).Error
|
err = db.Count(&total).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user