|
...
|
...
|
@@ -241,6 +241,47 @@ func (tableService *TableService) Search(searchQuery *query.SearchTableQuery) (i |
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// 表搜索
|
|
|
|
func (tableService *TableService) RelationGraph(searchQuery *query.SearchTableQuery) (interface{}, error) {
|
|
|
|
if err := searchQuery.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()
|
|
|
|
}()
|
|
|
|
|
|
|
|
tableRepository, _, _ := factory.FastPgTable(transactionContext, 0)
|
|
|
|
name :=searchQuery.Name
|
|
|
|
searchQuery.Name = ""
|
|
|
|
_, tables, err := tableRepository.Find(utils.ObjectToMap(searchQuery))
|
|
|
|
if err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
var result = make([]*dto.TableDto, 0)
|
|
|
|
for _, table := range tables {
|
|
|
|
var item = &dto.TableDto{}
|
|
|
|
item.Load(table)
|
|
|
|
result = append(result, item)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
result = dto.SuitTableByView(result,searchQuery.ViewType,name)
|
|
|
|
return map[string]interface{}{
|
|
|
|
"count": len(result),
|
|
|
|
"tables":result,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// 更新表服务
|
|
|
|
func (tableService *TableService) UpdateTable(updateTableCommand *command.UpdateTableCommand) (interface{}, error) {
|
|
|
|
if err := updateTableCommand.ValidateCommand(); err != nil {
|
...
|
...
|
|