diff --git a/internal/model/formula/response.go b/internal/model/formula/response.go index bf8fe22..e76e89c 100644 --- a/internal/model/formula/response.go +++ b/internal/model/formula/response.go @@ -6,16 +6,13 @@ type CreateTaskResponse struct { } type GetFormulaTaskResponse struct { - TaskNo string `json:"task_no"` - Status int `json:"status"` - Count int `json:"count"` - Latex string `json:"latex"` - Markdown string `json:"markdown"` - MathML string `json:"mathml"` - MathMLMW string `json:"mathml_mw"` - ImageBlob string `json:"image_blob"` - DocxURL string `json:"docx_url"` - PDFURL string `json:"pdf_url"` + TaskNo string `json:"task_no"` + Status int `json:"status"` + Count int `json:"count"` + Latex string `json:"latex"` + Markdown string `json:"markdown"` + MathML string `json:"mathml"` + MML string `json:"mml"` } // FormulaRecognitionResponse 公式识别服务返回的响应 @@ -25,7 +22,8 @@ type FormulaRecognitionResponse struct { // ImageOCRResponse 图片OCR接口返回的响应 type ImageOCRResponse struct { - Latex string `json:"latex"` // LaTeX 格式内容 - Markdown string `json:"markdown"` // Markdown 格式内容 - MathML string `json:"mathml"` // MathML 格式(无公式时为空) + Markdown string `json:"markdown"` // Markdown 格式内容 + Latex string `json:"latex"` // LaTeX 格式内容 (无公式时为空) + MathML string `json:"mathml"` // MathML 格式(无公式时为空) + MML string `json:"mml"` // MML 格式(无公式时为空) } diff --git a/internal/model/task/request.go b/internal/model/task/request.go index 8231d94..74bf68f 100644 --- a/internal/model/task/request.go +++ b/internal/model/task/request.go @@ -24,10 +24,7 @@ type TaskListDTO struct { Latex string `json:"latex"` Markdown string `json:"markdown"` MathML string `json:"mathml"` - MathMLMW string `json:"mathml_mw"` - ImageBlob string `json:"image_blob"` - DocxURL string `json:"docx_url"` - PDFURL string `json:"pdf_url"` + MML string `json:"mml"` } type TaskListResponse struct { diff --git a/internal/service/recognition_service.go b/internal/service/recognition_service.go index 0e44015..4926799 100644 --- a/internal/service/recognition_service.go +++ b/internal/service/recognition_service.go @@ -180,6 +180,7 @@ func (s *RecognitionService) GetFormualTask(ctx context.Context, taskNo string) Latex: taskRet.Latex, Markdown: markdown, MathML: taskRet.MathML, + MML: taskRet.MML, Status: int(task.Status), }, nil } @@ -544,6 +545,7 @@ func (s *RecognitionService) processFormulaTask(ctx context.Context, taskID int6 Latex: ocrResp.Latex, Markdown: ocrResp.Markdown, MathML: ocrResp.MathML, + MML: ocrResp.MML, }) if err != nil { log.Error(ctx, "func", "processFormulaTask", "msg", "保存任务结果失败", "error", err) diff --git a/internal/service/task.go b/internal/service/task.go index 8d5e8c2..a8a0965 100644 --- a/internal/service/task.go +++ b/internal/service/task.go @@ -92,11 +92,13 @@ func (svc *TaskService) GetTaskList(ctx context.Context, req *task.TaskListReque var latex string var markdown string var mathML string + var mml string recognitionResult := recognitionResultMap[item.ID] if recognitionResult != nil { latex = recognitionResult.Latex markdown = recognitionResult.Markdown mathML = recognitionResult.MathML + mml = recognitionResult.MML } originURL, err := oss.GetDownloadURL(ctx, item.FileURL) if err != nil { @@ -106,6 +108,7 @@ func (svc *TaskService) GetTaskList(ctx context.Context, req *task.TaskListReque Latex: latex, Markdown: markdown, MathML: mathML, + MML: mml, TaskID: item.TaskUUID, FileName: item.FileName, Status: int(item.Status), diff --git a/internal/storage/dao/result.go b/internal/storage/dao/result.go index 18416c3..43acb70 100644 --- a/internal/storage/dao/result.go +++ b/internal/storage/dao/result.go @@ -9,8 +9,9 @@ type RecognitionResult struct { TaskID int64 `gorm:"column:task_id;bigint;not null;default:0;comment:任务ID" json:"task_id"` TaskType TaskType `gorm:"column:task_type;varchar(16);not null;comment:任务类型;default:''" json:"task_type"` Latex string `json:"latex" gorm:"column:latex;type:text;not null;default:''"` - Markdown string `json:"markdown" gorm:"column:markdown;type:text;not null;default:''"` // Mathpix Markdown 格式 + Markdown string `json:"markdown" gorm:"column:markdown;type:text;not null;default:''"` // Markdown 格式 MathML string `json:"mathml" gorm:"column:mathml;type:text;not null;default:''"` // MathML 格式 + MML string `json:"mml" gorm:"column:mml;type:text;not null;default:''"` // MML 格式 } type RecognitionResultDao struct {