作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !5
... ... @@ -25,6 +25,8 @@ type SearchTableQuery struct {
ReturnDetailStructInfo bool `cname:"返回具体的结构信息 默认不返回" json:"returnDetailStructInfo"`
// 排除分组项,只返回一级列表;默认 false 不排除,连分组也返回
ReturnGroupItem bool `cname:"排除分组" json:"returnGroupItem"`
// 排除指定表
ExcludeTables []int `cname:"排除指定表" json:"excludeTables"`
Context *domain.Context
FilterRules []*FilterRule `json:"filterRules"`
TableId int `cname:"ID" json:"tableId"`
... ...
... ... @@ -234,6 +234,18 @@ func (tableService *TableService) Search(searchQuery *query.SearchTableQuery) (i
for _, table := range tables {
var item = &dto.TableDto{}
item.Load(table)
if len(searchQuery.ExcludeTables) > 0 {
exclude := false
for _, t := range searchQuery.ExcludeTables {
if t == item.TableId {
exclude = true
break
}
}
if exclude {
continue
}
}
if searchQuery.ReturnDetailStructInfo {
item.SetDetailStructInfo(table)
}
... ...
... ... @@ -76,6 +76,9 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
querySetMapGroup := make(map[int]bool)
querySetGroups := make([]*domain.QuerySet, 0)
for _, t := range result {
if filterTableByFilterRule(t, searchQuery) {
continue
}
if !domain.TableType(t.TableType).TableHasGroup() {
response = append(response, t)
continue
... ... @@ -87,9 +90,7 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
}
t.Update(v)
parentGroupId := v.ParentId
if filterTableByFilterRule(t, searchQuery.FilterRules) {
continue
}
response = append(response, t)
for {
if parentGroupId == 0 {
... ... @@ -129,7 +130,15 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
}
// true:代表需要过滤 false:不需要过滤
func filterTableByFilterRule(item *dto.TableObjectDto, filterRules []*query.FilterRule) bool {
func filterTableByFilterRule(item *dto.TableObjectDto, searchQuery *query.SearchTableQuery) bool {
filterRules := searchQuery.FilterRules
if len(searchQuery.ExcludeTables) > 0 {
for _, t := range searchQuery.ExcludeTables {
if t == item.TableId {
return true
}
}
}
for _, rule := range filterRules {
if rule.TableType == item.TableType && rule.Status > 0 && rule.Status != item.Status {
return true
... ...
... ... @@ -219,6 +219,7 @@ type (
type ColumnSchema struct {
ColumnName string `json:"columnName"`
ColumnType string `json:"columnType"`
ColumnSqlFriendlyName string `json:"columnSqlFriendlyName"`
}
func ToFields(fields []*Field) []*Field {
... ...
... ... @@ -8,6 +8,7 @@ func DomainFieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
res := domain.ColumnSchema{
ColumnName: f.Name,
ColumnType: f.SQLType,
ColumnSqlFriendlyName: f.SQLName,
}
if convertFiledSQLType(f.SQLType) {
res.ColumnType = domain.DECIMAL279.ToString()
... ... @@ -77,6 +78,7 @@ func FieldsToColumnSchemas(fields []*domain.Field) []domain.ColumnSchema {
result = append(result, domain.ColumnSchema{
ColumnName: f.Name,
ColumnType: f.SQLType,
ColumnSqlFriendlyName: f.SQLName,
})
}
return result
... ...
... ... @@ -54,11 +54,14 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi
}); err != nil {
return nil, err
}
for _, l := range request.RemoveList {
if e := ptr.remove(ctx, table, l, request.Where); e != nil {
log.Logger.Error(e.Error())
}
if err = starrocks.BatchDelete(starrocks.DB, table.SQLName, request.RemoveList); err != nil {
return nil, err
}
//for _, l := range request.RemoveList {
// if e := ptr.remove(ctx, table, l, request.Where); e != nil {
// log.Logger.Error(e.Error())
// }
//}
}
for _, l := range request.UpdateList {
if e := ptr.update(ctx, table, l, request.Where); e != nil {
... ...
... ... @@ -73,6 +73,28 @@ func Delete(db *gorm.DB, tableName string, fields []*domain.FieldValue) error {
return tx.Error
}
func BatchDelete(db *gorm.DB, tableName string, fields []*domain.FieldValues) error {
var pk *domain.FieldValue
var values = make([]string, 0)
for _, row := range fields {
for _, f := range row.FieldValues {
if f.Field.Flag == domain.PKField && f.Value != "" {
pk = f
values = append(values, f.Value)
}
}
}
if len(values) == 0 {
return fmt.Errorf("删除行为空")
}
sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
c := Condition{}
return tx.Table(tableName).Where(fmt.Sprintf("%s in %s", pk.Field.SQLName, c.InArgs(values))).Delete("")
})
tx := db.Exec(sql)
return tx.Error
}
//DROP VIEW IF EXISTS
func DropView(db *gorm.DB, tableName string) error {
... ...