Fix responses
This commit is contained in:
@@ -23,11 +23,17 @@ func NewTranscribeHandler(jobRepo repo.TranscriptJobRepository, fileRepo repo.Fi
|
|||||||
return &TranscribeHandler{jobRepo: jobRepo, fileRepo: fileRepo}
|
return &TranscribeHandler{jobRepo: jobRepo, fileRepo: fileRepo}
|
||||||
}
|
}
|
||||||
|
|
||||||
type TranscribeResponse struct {
|
type CreateTranscribeJobResponse struct {
|
||||||
JobID string `json:"job_id"`
|
JobID string `json:"job_id"`
|
||||||
State string `json:"status"`
|
State string `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetTranscribeJobResponse struct {
|
||||||
|
JobID string `json:"job_id"`
|
||||||
|
State string `json:"status"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
func (h *TranscribeHandler) CreateTranscribeJob(c *gin.Context) {
|
func (h *TranscribeHandler) CreateTranscribeJob(c *gin.Context) {
|
||||||
// Получаем файл из формы
|
// Получаем файл из формы
|
||||||
file, header, err := c.Request.FormFile("audio")
|
file, header, err := c.Request.FormFile("audio")
|
||||||
@@ -96,7 +102,7 @@ func (h *TranscribeHandler) CreateTranscribeJob(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Возвращаем успешный ответ
|
// Возвращаем успешный ответ
|
||||||
response := TranscribeResponse{
|
response := CreateTranscribeJobResponse{
|
||||||
JobID: job.Id,
|
JobID: job.Id,
|
||||||
State: job.State,
|
State: job.State,
|
||||||
}
|
}
|
||||||
@@ -113,5 +119,9 @@ func (h *TranscribeHandler) GetTranscribeJobStatus(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, job)
|
c.JSON(http.StatusOK, GetTranscribeJobResponse{
|
||||||
|
JobID: job.Id,
|
||||||
|
State: job.State,
|
||||||
|
CreatedAt: job.CreatedAt,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user