feat: 植物识别

This commit is contained in:
Blizzard
2026-02-10 12:35:46 +08:00
parent e612234c91
commit 556ab6baff
24 changed files with 2745 additions and 11473 deletions
+2
View File
@@ -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
)
+36
View File
@@ -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)
}
+31
View File
@@ -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 点赞帖子
+1 -1
View File
@@ -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) {
+8 -1
View File
@@ -137,7 +137,14 @@ func (m *MenuApi) GetAllMenuTree(c *gin.Context) {
// @Success 200 {object} response.Response{data=[]system.Menu,msg=string} "用户菜单数据"
// @Router /menu/getUserMenuTree [get]
func (m *MenuApi) GetUserMenuTree(c *gin.Context) {
userId := auth.GetUserId(c)
routes, err := menuService.GetUserRoutes(userId)
if err != nil {
global.Logger.Error("获取用户菜单失败!", zap.Error(err))
response.FailWithMsg(err.Error(), c)
return
}
response.OkWithData(routes, c)
}
// Route