...
|
...
|
@@ -6,6 +6,7 @@ import ( |
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
|
|
|
)
|
...
|
...
|
@@ -29,27 +30,27 @@ func (fileService *FileService) CreateFile(createFileCommand *command.CreateFile |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
newFile := &domain.File{
|
|
|
//Name: createFileCommand.Name,
|
|
|
//Url: createFileCommand.Url,
|
|
|
//FileSize: createFileCommand.FileSize,
|
|
|
}
|
|
|
var fileRepository domain.FileRepository
|
|
|
if value, err := factory.CreateFileRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
fileRepository = value
|
|
|
}
|
|
|
if file, err := fileRepository.Save(newFile); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return file, nil
|
|
|
//newFile := &domain.File{
|
|
|
//Name: createFileCommand.Name,
|
|
|
//Url: createFileCommand.Url,
|
|
|
//FileSize: createFileCommand.FileSize,
|
|
|
//}
|
|
|
//var fileRepository domain.FileRepository
|
|
|
//if value, err := factory.CreateFileRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
//}); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
//} else {
|
|
|
// fileRepository = value
|
|
|
//}
|
|
|
//file, err := fileRepository.Save(newFile)
|
|
|
//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())
|
|
|
}
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// 编辑表格数据
|
...
|
...
|
@@ -70,7 +71,7 @@ func (fileService *FileService) EditDataTable(editDataTableCommand *command.Edit |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// 持久化表格数据
|
...
|
...
|
@@ -188,6 +189,42 @@ func (fileService *FileService) ListFile(listFileQuery *query.ListFileQuery) (in |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回文件服务列表
|
|
|
func (fileService *FileService) SearchFile(listFileQuery *query.SearchFileQuery) (interface{}, error) {
|
|
|
if err := listFileQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var fileRepository domain.FileRepository
|
|
|
if value, err := factory.CreateFileRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
fileRepository = value
|
|
|
}
|
|
|
count, files, err := fileRepository.Find(tool_funs.SimpleStructToMap(listFileQuery))
|
|
|
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())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"count": count,
|
|
|
"files": files,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// 加载表格数据
|
|
|
func (fileService *FileService) LoadDataTable(loadDataTableCommand *command.LoadDataTableCommand) (interface{}, error) {
|
|
|
if err := loadDataTableCommand.ValidateCommand(); err != nil {
|
...
|
...
|
@@ -206,7 +243,8 @@ func (fileService *FileService) LoadDataTable(loadDataTableCommand *command.Load |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
|
|
|
return dto.NewDataTableDtoDemo(), nil
|
|
|
}
|
|
|
|
|
|
// 移除文件服务
|
...
|
...
|
|