...
|
...
|
@@ -19,12 +19,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab |
|
|
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)
|
|
|
_, tables, err := tableRepository.Find(utils.ObjectToMap(searchQuery))
|
...
|
...
|
@@ -40,7 +34,9 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab |
|
|
item.SetDetailStructInfo(table)
|
|
|
}
|
|
|
item.Flag = domain.FlagSet
|
|
|
if item.TableType == domain.MainTable.ToString() || item.TableType == domain.SubTable.ToString() || item.TableType == domain.SideTable.ToString() {
|
|
|
if item.TableType == domain.MainTable.ToString() ||
|
|
|
item.TableType == domain.SubTable.ToString() ||
|
|
|
item.TableType == domain.SideTable.ToString() {
|
|
|
item.ParentId = 0
|
|
|
item.Status = domain.StatusOn
|
|
|
}
|
...
|
...
|
@@ -55,23 +51,33 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab |
|
|
|
|
|
querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0)
|
|
|
_, querySets, _ := querySetRepository.Find(map[string]interface{}{"context": searchQuery.Context})
|
|
|
if !searchQuery.ReturnGroupItem {
|
|
|
querySets = make([]*domain.QuerySet, 0)
|
|
|
|
|
|
var (
|
|
|
querySetMapById = make(map[int]*domain.QuerySet)
|
|
|
// BindTableId , parentId
|
|
|
querySetMapByTableId = make(map[int]*domain.QuerySet)
|
|
|
)
|
|
|
if searchQuery.ReturnGroupItem {
|
|
|
for _, qs := range querySets {
|
|
|
querySetMapById[qs.QuerySetId] = qs
|
|
|
}
|
|
|
}
|
|
|
// BindTableId , parentId
|
|
|
querySetMapByTableId := make(map[int]*domain.QuerySet)
|
|
|
|
|
|
for _, qs := range querySets {
|
|
|
if qs.QuerySetInfo.BindTableId == 0 {
|
|
|
continue
|
|
|
}
|
|
|
querySetMapByTableId[qs.QuerySetInfo.BindTableId] = qs
|
|
|
}
|
|
|
querySetMapById := make(map[int]*domain.QuerySet)
|
|
|
for _, qs := range querySets {
|
|
|
querySetMapById[qs.QuerySetId] = qs
|
|
|
}
|
|
|
|
|
|
var response = make([]*dto.TableObjectDto, 0)
|
|
|
for index, t := range result {
|
|
|
v, ok := querySetMapByTableId[t.TableId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
result[index].Update(v)
|
|
|
}
|
|
|
// 分组
|
|
|
querySetMapGroup := make(map[int]bool)
|
|
|
querySetGroups := make([]*domain.QuerySet, 0)
|
...
|
...
|
@@ -79,7 +85,7 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab |
|
|
if filterTableByFilterRule(t, searchQuery) {
|
|
|
continue
|
|
|
}
|
|
|
if !domain.TableType(t.TableType).TableHasGroup() {
|
|
|
if !domain.TableType(t.TableType).TableIsSplitByGroup() {
|
|
|
response = append(response, t)
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -112,9 +118,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab |
|
|
groupItem.LoadGroup(querySetGroup)
|
|
|
response = append(response, groupItem)
|
|
|
}
|
|
|
//if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
//}
|
|
|
|
|
|
sort.Slice(response, func(i, j int) bool {
|
|
|
item1 := response[i]
|
...
|
...
|
|