feat: 植物识别
This commit is contained in:
@@ -8,6 +8,7 @@ type ApiGroup struct {
|
||||
PostApi
|
||||
WikiClassApi
|
||||
WikiApi
|
||||
OcrApi
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -16,4 +17,5 @@ var (
|
||||
postService = service.GroupApp.PlantServiceGroup.PostService
|
||||
wikiClassService = service.GroupApp.PlantServiceGroup.WikiClassService
|
||||
wikiService = service.GroupApp.PlantServiceGroup.WikiService
|
||||
ocrService = service.GroupApp.PlantServiceGroup.OcrService
|
||||
)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package plant
|
||||
|
||||
import (
|
||||
"sundynix-go/global"
|
||||
"sundynix-go/model/commom/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type OcrApi struct{}
|
||||
|
||||
// ClassifyPlant
|
||||
// @tags 识别相关
|
||||
// @Summary base64植物识别
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param file formData file true "植物识别"
|
||||
// @Success 200 {object} response.Response{msg=string} "文件OCR"
|
||||
// @router /ocr/base64 [post]
|
||||
func (o *OcrApi) ClassifyPlant(c *gin.Context) {
|
||||
multipartFile, header, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
global.Logger.Error("接收文件失败!", zap.Error(err))
|
||||
response.FailWithMsg("接收文件失败!", c)
|
||||
return
|
||||
}
|
||||
res, err := ocrService.ClassifyPlant(multipartFile, header)
|
||||
if err != nil {
|
||||
global.Logger.Error("植物识别识别!", zap.Error(err))
|
||||
response.FailWithMsg("植物识别失败!", c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(res, c)
|
||||
}
|
||||
@@ -70,6 +70,37 @@ func (a *PostApi) PostPage(c *gin.Context) {
|
||||
}, c)
|
||||
}
|
||||
|
||||
// MyPost 我的发布
|
||||
// @Tags 帖子
|
||||
// @Summary 我的发布
|
||||
// @Security BearerAuth
|
||||
// @accept json
|
||||
// @Produce application/json
|
||||
// @Param data body plantReq.PostPage true "分页获取帖子列表"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /post/myPost [post]
|
||||
func (a *PostApi) MyPost(c *gin.Context) {
|
||||
var req plantReq.PostPage
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
response.FailWithMsg("请求参数错误", c)
|
||||
return
|
||||
}
|
||||
userId := auth.GetUserId(c)
|
||||
posts, total, err := postService.MyPost(req, userId)
|
||||
if err != nil {
|
||||
global.Logger.Error("获取帖子列表失败", zap.Error(err))
|
||||
response.FailWithMsg("获取帖子列表失败", c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(response.PageResult{
|
||||
List: posts,
|
||||
Total: total,
|
||||
Page: req.Current,
|
||||
PageSize: req.PageSize,
|
||||
}, c)
|
||||
}
|
||||
|
||||
// LikePost 点赞帖子
|
||||
// @Tags 帖子
|
||||
// @Summary 点赞帖子
|
||||
|
||||
@@ -42,7 +42,7 @@ func (a *WikiClassApi) AddClass(c *gin.Context) {
|
||||
// @Security BearerAuth
|
||||
// @accept json
|
||||
// @Produce application/json
|
||||
// @Param data body lantReq.UpdateWikiClass true "修改分类"
|
||||
// @Param data body plantReq.UpdateWikiClass true "修改分类"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发布成功"}"
|
||||
// @Router /wiki-class/update [post]
|
||||
func (a *WikiClassApi) UpdateClass(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user