Эх сурвалжийг харах

Merge branch 'feature/eta_1.6.9' into debug

hsun 1 жил өмнө
parent
commit
eadaf411fc

+ 61 - 1
controllers/speech_recognition/speech_recognition.go

@@ -205,6 +205,8 @@ func (this *SpeechRecognitionController) Convert() {
 		t.SysUserName = sysUser.RealName
 		t.State = speech_recognition.SpeechRecognitionStateWait
 		t.Sort = sortMax
+		t.FileSecond = v.FileSecond
+		t.FileSize = v.FileSize
 		t.CreateTime = nowTime
 		t.ModifyTime = nowTime
 		// CreateMulti拿不到主键, 此处用循环新增获取
@@ -712,8 +714,9 @@ func (this *SpeechRecognitionController) List() {
 	params.FileName = strings.TrimSpace(params.FileName)
 
 	dataResp := new(speech_recognition.SpeechRecognitionListResp)
-	cond := ``
+	cond := fmt.Sprintf(` AND %s = ?`, speech_recognition.SpeechRecognitionCols.State)
 	pars := make([]interface{}, 0)
+	pars = append(pars, speech_recognition.SpeechRecognitionStateSuccess)
 
 	// 筛选项
 	{
@@ -1083,3 +1086,60 @@ func (this *SpeechRecognitionController) Export() {
 	downloadName := fmt.Sprintf("%s%s", speechItem.FileName, suffix)
 	this.Ctx.Output.Download(downloadPath, downloadName)
 }
+
+// CheckFileName
+// @Title 文件重名校验
+// @Description 文件重名校验
+// @Param	request	body speech_recognition.SpeechRecognitionConvertCheckNameReq true "type json string"
+// @Success 200 string "操作成功"
+// @router /convert/check_name [post]
+func (this *SpeechRecognitionController) CheckFileName() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req speech_recognition.SpeechRecognitionConvertCheckNameReq
+	if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
+		br.Msg = "参数有误"
+		br.ErrMsg = "参数解析失败, Err: " + e.Error()
+		return
+	}
+	req.FileName = strings.TrimSpace(req.FileName)
+	if req.FileName == "" {
+		br.Msg = "参数有误"
+		br.ErrMsg = fmt.Sprintf("参数有误, FileName: %s", req.FileName)
+		return
+	}
+
+	var checkResult bool
+	speechOb := new(speech_recognition.SpeechRecognition)
+	cond := fmt.Sprintf(` AND %s = ?`, speech_recognition.SpeechRecognitionCols.FileName)
+	pars := make([]interface{}, 0)
+	pars = append(pars, req.FileName)
+	exists, e := speechOb.GetItemByCondition(cond, pars, "")
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取同名转写文件失败, Err: " + e.Error()
+		return
+	}
+	if exists != nil && exists.SpeechRecognitionId > 0 {
+		checkResult = true
+		return
+	}
+
+	br.Data = checkResult
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}

+ 7 - 0
models/speech_recognition/speech_recognition.go

@@ -267,6 +267,8 @@ type SpeechRecognitionConvertReq struct {
 type SpeechRecognitionConvertFiles struct {
 	FileName    string `description:"文件名称"`
 	ResourceUrl string `description:"文件地址"`
+	FileSecond  int    `description:"文件时长(秒)"`
+	FileSize    int    `description:"文件大小(byte)"`
 }
 
 // UpdateSpeechAndApiLog 更新语音识别及API记录
@@ -486,3 +488,8 @@ func (m *SpeechRecognition) GetFirstByMenuId(menuId int) (item *SpeechRecognitio
 	err = o.Raw(sql, menuId).QueryRow(&item)
 	return
 }
+
+// SpeechRecognitionConvertCheckNameReq 校验文件重名请求体
+type SpeechRecognitionConvertCheckNameReq struct {
+	FileName string `description:"文件名称"`
+}

+ 9 - 0
routers/commentsRouter.go

@@ -6082,6 +6082,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/speech_recognition:SpeechRecognitionController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/speech_recognition:SpeechRecognitionController"],
+        beego.ControllerComments{
+            Method: "CheckFileName",
+            Router: `/convert/check_name`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/speech_recognition:SpeechRecognitionController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/speech_recognition:SpeechRecognitionController"],
         beego.ControllerComments{
             Method: "ConvertList",