...
|
...
|
@@ -79,7 +79,7 @@ func (fileService *FileService) CreateFile(ctx *domain.Context, createFileComman |
|
|
}
|
|
|
|
|
|
// 返回文件服务
|
|
|
func (fileService *FileService) GetFile(getFileQuery *query.GetFileQuery) (interface{}, error) {
|
|
|
func (fileService *FileService) GetFile(ctx *domain.Context, getFileQuery *query.GetFileQuery) (interface{}, error) {
|
|
|
if err := getFileQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -101,18 +101,31 @@ func (fileService *FileService) GetFile(getFileQuery *query.GetFileQuery) (inter |
|
|
} else {
|
|
|
fileRepository = value
|
|
|
}
|
|
|
file, err := fileRepository.FindOne(map[string]interface{}{"fileId": getFileQuery.FileId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
response := map[string]interface{}{
|
|
|
"file": nil,
|
|
|
}
|
|
|
if file == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%d", getFileQuery.FileId))
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return file, nil
|
|
|
options := map[string]interface{}{"context": ctx}
|
|
|
if getFileQuery.FileId > 0 {
|
|
|
options["fileId"] = getFileQuery.FileId
|
|
|
}
|
|
|
if len(getFileQuery.FileName) > 0 {
|
|
|
options["fileName"] = getFileQuery.FileName
|
|
|
}
|
|
|
if len(getFileQuery.FileType) > 0 {
|
|
|
options["fileType"] = getFileQuery.FileType
|
|
|
}
|
|
|
if len(options) == 0 {
|
|
|
return response, nil
|
|
|
}
|
|
|
file, _ := fileRepository.FindOne(options)
|
|
|
//if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
//}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
response["file"] = (&dto.FileDto{}).Load(file)
|
|
|
return response, nil
|
|
|
}
|
|
|
|
|
|
// 返回文件服务列表
|
...
|
...
|
|