feat(ocr): 新增本地 OCR sidecar
This commit is contained in:
@@ -103,7 +103,7 @@ func (h *Handler) GetQrCodeStatsHandler(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"data": stats})
|
||||
}
|
||||
|
||||
// RecognizeQrCodeGroupNameHandler 同步调用 PaddleOCR API 识别二维码图片中的企业微信群名(保留向后兼容)
|
||||
// RecognizeQrCodeGroupNameHandler 同步识别二维码图片中的企业微信群名(保留向后兼容)
|
||||
func (h *Handler) RecognizeQrCodeGroupNameHandler(c *gin.Context) {
|
||||
file, header, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
@@ -120,7 +120,7 @@ func (h *Handler) RecognizeQrCodeGroupNameHandler(c *gin.Context) {
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrQrCodeOCRNotConfigured) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "请先在系统配置中填写 PaddleOCR API Token"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "二维码 OCR 未配置"})
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ErrQrCodeOCRInvalidFile) {
|
||||
@@ -129,7 +129,7 @@ func (h *Handler) RecognizeQrCodeGroupNameHandler(c *gin.Context) {
|
||||
}
|
||||
if errors.Is(err, ErrQrCodeOCRUnavailable) {
|
||||
response.RecordError(c, err)
|
||||
c.JSON(http.StatusBadGateway, gin.H{"error": "PaddleOCR 服务暂时不可用"})
|
||||
c.JSON(http.StatusBadGateway, gin.H{"error": "OCR 服务暂时不可用"})
|
||||
return
|
||||
}
|
||||
response.RecordError(c, err)
|
||||
@@ -140,7 +140,7 @@ func (h *Handler) RecognizeQrCodeGroupNameHandler(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"data": result})
|
||||
}
|
||||
|
||||
// SubmitOCRJobHandler 提交 OCR 任务到 PaddleOCR,立即返回任务 ID
|
||||
// SubmitOCRJobHandler 提交 OCR 任务,立即返回任务 ID
|
||||
func (h *Handler) SubmitOCRJobHandler(c *gin.Context) {
|
||||
file, header, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
@@ -157,7 +157,7 @@ func (h *Handler) SubmitOCRJobHandler(c *gin.Context) {
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrQrCodeOCRNotConfigured) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "请先在系统配置中填写 PaddleOCR API Token"})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "二维码 OCR 未配置"})
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ErrQrCodeOCRInvalidFile) {
|
||||
@@ -166,7 +166,7 @@ func (h *Handler) SubmitOCRJobHandler(c *gin.Context) {
|
||||
}
|
||||
if errors.Is(err, ErrQrCodeOCRUnavailable) {
|
||||
response.RecordError(c, err)
|
||||
c.JSON(http.StatusBadGateway, gin.H{"error": "PaddleOCR 服务暂时不可用"})
|
||||
c.JSON(http.StatusBadGateway, gin.H{"error": "OCR 服务暂时不可用"})
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ErrQrCodeOCRRedisDisabled) {
|
||||
|
||||
Reference in New Issue
Block a user