...
|
...
|
@@ -17,25 +17,25 @@ type TableService struct { |
|
|
}
|
|
|
|
|
|
// 批量编辑分表
|
|
|
func (tableService *TableService) BatchEditSubTable(batchEditSubTableCommand *command.BatchEditSubTableCommand) (interface{}, error) {
|
|
|
if err := batchEditSubTableCommand.ValidateCommand(); 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()
|
|
|
}()
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
}
|
|
|
//func (tableService *TableService) BatchEditSubTable(batchEditSubTableCommand *command.BatchEditSubTableCommand) (interface{}, error) {
|
|
|
// if err := batchEditSubTableCommand.ValidateCommand(); 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()
|
|
|
// }()
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// return nil, nil
|
|
|
//}
|
|
|
|
|
|
// 表复制
|
|
|
func (tableService *TableService) CopyDataTable(ctx *domain.Context, cmd *command.CopyDataTableCommand) (interface{}, error) {
|
...
|
...
|
@@ -132,6 +132,36 @@ func (tableService *TableService) GetTable(getTableQuery *query.GetTableQuery) ( |
|
|
return tableDetailDto, nil
|
|
|
}
|
|
|
|
|
|
// 返回表服务
|
|
|
func (tableService *TableService) PrepareSubTable(getTableQuery *query.GetTableQuery) (interface{}, error) {
|
|
|
if err := getTableQuery.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()
|
|
|
}()
|
|
|
_, table, err := factory.FastPgTable(transactionContext, getTableQuery.TableId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
tableDetailDto := dto.TableDetailDto{}
|
|
|
tableDetailDto.Load(table, table)
|
|
|
tableDetailDto.TableType = domain.SubTable.ToString()
|
|
|
tableDetailDto.TableId = 0
|
|
|
tableDetailDto.ParentId = table.TableId
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return tableDetailDto, nil
|
|
|
}
|
|
|
|
|
|
// 返回表服务列表
|
|
|
func (tableService *TableService) ListTable(listTableQuery *query.ListTableQuery) (interface{}, error) {
|
|
|
if err := listTableQuery.ValidateQuery(); err != nil {
|
...
|
...
|
@@ -233,25 +263,25 @@ func (tableService *TableService) Search(searchQuery *query.SearchTableQuery) (i |
|
|
}
|
|
|
|
|
|
// 表拆分
|
|
|
func (tableService *TableService) SplitDataTable(splitDataTableCommand *command.SplitDataTableCommand) (interface{}, error) {
|
|
|
if err := splitDataTableCommand.ValidateCommand(); 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()
|
|
|
}()
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
}
|
|
|
//func (tableService *TableService) SplitDataTable(splitDataTableCommand *command.SplitDataTableCommand) (interface{}, error) {
|
|
|
// if err := splitDataTableCommand.ValidateCommand(); 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()
|
|
|
// }()
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// return nil, nil
|
|
|
//}
|
|
|
|
|
|
// 更新表服务
|
|
|
func (tableService *TableService) UpdateTable(updateTableCommand *command.UpdateTableCommand) (interface{}, error) {
|
...
|
...
|
@@ -339,13 +369,16 @@ func (tableService *TableService) AddTableStruct(ctx *domain.Context, cmd *comma |
|
|
}()
|
|
|
|
|
|
AddTableStructService, _ := factory.CreateAddTableStructService(transactionContext)
|
|
|
if _, err := AddTableStructService.AddTableStruct(ctx, cmd.TableId, cmd.Fields, cmd.Name); err != nil {
|
|
|
table, err := AddTableStructService.AddTableStruct(ctx, cmd.TableId, cmd.Fields, cmd.Name)
|
|
|
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
|
|
|
tableDetailDto := dto.TableDetailDto{}
|
|
|
tableDetailDto.Load(table, nil)
|
|
|
return tableDetailDto, nil
|
|
|
}
|
|
|
|
|
|
func NewTableService(options map[string]interface{}) *TableService {
|
...
|
...
|
|