Переглянути джерело

Merge remote-tracking branch 'origin/master'

wangbin 2 роки тому
батько
коміт
b19c3d15b2

+ 2 - 2
api/v1/task/task_conf.go

@@ -56,9 +56,9 @@ func (b *TaskConfApi) DownloadFile(c *gin.Context) {
 	downloadFile, err := taskConfService.DownloadFile(taskId, md5String)
 	if err != nil {
 		global.GVA_LOG.Error("查询失败!", zap.Error(err))
-		response.FailWithMessage("查询失败,无对应脚本", c)
+		response.FailWithMessage(err.Error(), c)
 	} else {
-		response.OkWithDetailed(taskRes.DownloadInfoResponse{downloadFile}, "查询成功", c)
+		response.OkWithDetailed(downloadFile, "查询成功", c)
 	}
 
 }

+ 3 - 3
model/task/response/upload_file.go

@@ -16,6 +16,6 @@ type InfoResponse struct {
 	File UploadFileResponse `json:"file"`
 }
 
-type DownloadInfoResponse struct {
-	Info DownloadFile `json:"info"`
-}
+//type DownloadInfoResponse struct {
+//	Info DownloadFile `json:"info"`
+//}

+ 2 - 1
service/task/task_conf.go

@@ -189,7 +189,7 @@ func (e *TaskConfService) DownloadFile(taskId int, md5String string) (info respo
 	//改由存储至数据库的时候拼接前缀
 	//var prefix string = global.GVA_CONFIG.PrefixUrl.PrefixLocal
 	//数据库中无记录,即不需要更新
-	err = global.GVA_DB.Table("upload_file").Where("task_id = ? and state = 1", taskId).Order("id desc").Limit(1).Find(&file).Error
+	err = global.GVA_DB.Table("upload_file").Where("task_id = ? and state = 1", taskId).Order("id desc").First(&file).Error
 	if errors.Is(err, gorm.ErrRecordNotFound) {
 		info = response.DownloadFile{
 			Url: "",
@@ -205,6 +205,7 @@ func (e *TaskConfService) DownloadFile(taskId int, md5String string) (info respo
 			Md5String: "",
 			Flag: false,
 		}
+		return info, errors.New("不需要更新")
 	} else {
 		fullUrl := file.Url
 		info = response.DownloadFile{