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" ) 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 /classify/plant [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 } userId := auth.GetUserId(c) res, err := ocrService.ClassifyPlant(multipartFile, header, userId) if err != nil { global.Logger.Error("植物识别识别!", zap.Error(err)) response.FailWithMsg("植物识别失败!", c) return } response.OkWithData(res, c) } // MyClassifyLog // @tags 识别相关 // @Summary 我的植物识别记录 // @Security ApiKeyAuth // @accept application/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) } // DeleteClassifyLog // @tags 识别相关 // @Summary 删除识别记录 // @Security ApiKeyAuth // @accept application/json // @Produce application/json // @Param data body request.IdsReq true "删除识别记录" // @Success 200 {object} response.Response{msg=string} "删除识别记录" // @router /classify/deleteClassifyLog [post] func (o *OcrApi) DeleteClassifyLog(c *gin.Context) { var req request.IdsReq err := c.ShouldBind(&req) if err != nil { response.FailWithMsg("请求参数错误", c) return } userId := auth.GetUserId(c) err = ocrService.DeleteClassifyLog(req, userId) if err != nil { global.Logger.Error("删除识别记录失败!", zap.Error(err)) response.FailWithMsg("删除识别记录失败!", c) return } response.OkWithMsg("删除识别记录成功!", c) }