feat: 植物识别记录

This commit is contained in:
Blizzard
2026-02-10 17:14:49 +08:00
parent 01f8306be2
commit dd6a638982
6 changed files with 163 additions and 16 deletions
+35 -2
View File
@@ -2,7 +2,9 @@ package plant
import (
"sundynix-go/global"
"sundynix-go/model/commom/request"
"sundynix-go/model/commom/response"
"sundynix-go/utils/auth"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
@@ -18,7 +20,7 @@ type OcrApi struct{}
// @Produce application/json
// @Param file formData file true "植物识别"
// @Success 200 {object} response.Response{msg=string} "文件OCR"
// @router /ocr/base64 [post]
// @router /classify/plant [post]
func (o *OcrApi) ClassifyPlant(c *gin.Context) {
multipartFile, header, err := c.Request.FormFile("file")
if err != nil {
@@ -26,7 +28,8 @@ func (o *OcrApi) ClassifyPlant(c *gin.Context) {
response.FailWithMsg("接收文件失败!", c)
return
}
res, err := ocrService.ClassifyPlant(multipartFile, header)
userId := auth.GetUserId(c)
res, err := ocrService.ClassifyPlant(multipartFile, header, userId)
if err != nil {
global.Logger.Error("植物识别识别!", zap.Error(err))
response.FailWithMsg("植物识别失败!", c)
@@ -34,3 +37,33 @@ func (o *OcrApi) ClassifyPlant(c *gin.Context) {
}
response.OkWithData(res, c)
}
// MyClassifyLog
// @tags 识别相关
// @Summary 我的植物识别记录
// @Security ApiKeyAuth
// @accept json
// @Produce application/json
// @Param data body request.PageInfo true "分页"
// @Success 200 {object} response.Response{msg=string} "识别记录"
// @router /classify/myClassifyLog [post]
func (o *OcrApi) MyClassifyLog(c *gin.Context) {
var req request.PageInfo
if err := c.ShouldBind(&req); err != nil {
response.FailWithMsg("请求参数错误", c)
return
}
userId := auth.GetUserId(c)
list, total, err := ocrService.MyClassifyLog(req, userId)
if err != nil {
global.Logger.Error("获取识别记录失败!", zap.Error(err))
response.FailWithMsg("获取识别记录失败!", c)
return
}
response.OkWithData(response.PageResult{
List: list,
Total: total,
Page: req.Current,
PageSize: req.PageSize,
}, c)
}