...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -94,7 +95,20 @@ func (ptr *QuerySetService) Update(ctx *domain.Context, querySetId int, queryCom |
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() {
|
|
|
return ptr.UpdateDefault(ctx, qs, queryComponents)
|
|
|
}
|
|
|
if qs.Type == domain.CalculateItem.ToString() {
|
|
|
return ptr.UpdateCalculateItem(ctx, qs, queryComponents)
|
|
|
}
|
|
|
if qs.Type == domain.CalculateTable.ToString() {
|
|
|
return ptr.UpdateCalculateTable(ctx, qs, queryComponents)
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (ptr *QuerySetService) UpdateDefault(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) error {
|
|
|
querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
|
|
|
// 生成Table
|
|
|
masterTable := queryComponents[0].MasterTable
|
|
|
table, err := ptr.CreateOrUpdateQuerySetTable(ctx, qs, masterTable, queryComponents)
|
...
|
...
|
@@ -137,6 +151,90 @@ func (ptr *QuerySetService) Update(ctx *domain.Context, querySetId int, queryCom |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (ptr *QuerySetService) UpdateCalculateItem(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) error {
|
|
|
querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
|
|
|
// 生成Table
|
|
|
//masterTable := queryComponents[0].MasterTable
|
|
|
table, err := ptr.CreateOrUpdateCalculateItemTable(ctx, qs, nil, queryComponents)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
if err = ptr.validQueryComponents(queryComponents); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
// 调用底层的组装sql
|
|
|
_, err = ByteCore.FormulasGenerate(domain.ReqFormulasGenerate{
|
|
|
QuerySet: qs,
|
|
|
Table: table,
|
|
|
QueryComponents: queryComponents,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
//if err = starrocks.Exec(starrocks.DB,
|
|
|
// starrocks.CreateViewSql(table.SQLName, table.DataFields,
|
|
|
// starrocks.CalculateItemViewSql(&queryComponents[0].Formula.FieldExpr),
|
|
|
// )); err != nil {
|
|
|
// return err
|
|
|
//}
|
|
|
|
|
|
// 生成日志
|
|
|
if err = ptr.UpdateQuerySetLog(ctx, qs, queryComponents); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
// 保存
|
|
|
qs.Update(queryComponents, table.TableId)
|
|
|
_, err = querySetRepository.Save(qs)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (ptr *QuerySetService) UpdateCalculateTable(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) error {
|
|
|
querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
|
|
|
// 生成Table
|
|
|
masterTable := queryComponents[0].MasterTable
|
|
|
table, err := ptr.CreateOrUpdateCalculateTable(ctx, qs, masterTable, queryComponents)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
if err = ptr.validQueryComponents(queryComponents); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
// 调用底层的组装sql
|
|
|
_, err = ByteCore.FormulasGenerate(domain.ReqFormulasGenerate{
|
|
|
QuerySet: qs,
|
|
|
Table: table,
|
|
|
QueryComponents: queryComponents,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
//if err = starrocks.Exec(starrocks.DB,
|
|
|
// starrocks.CreateViewSql(table.SQLName, table.DataFields,
|
|
|
// starrocks.CalculateTableViewSql(queryComponents[0].MasterTable.SQLName, &queryComponents[0].Aggregation.Aggregation),
|
|
|
// )); err != nil {
|
|
|
// return err
|
|
|
//}
|
|
|
|
|
|
// 生成日志
|
|
|
if err = ptr.UpdateQuerySetLog(ctx, qs, queryComponents); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
// 保存
|
|
|
qs.Update(queryComponents, table.TableId)
|
|
|
_, err = querySetRepository.Save(qs)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (ptr *QuerySetService) PreviewPrepare(ctx *domain.Context, querySetId int, queryComponents []*domain.QueryComponent) (*domain.Table, error) {
|
|
|
querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
|
|
|
querySet, err := querySetRepository.FindOne(map[string]interface{}{"querySetId": querySetId})
|
...
|
...
|
@@ -159,14 +257,24 @@ func (ptr *QuerySetService) PreviewPrepare(ctx *domain.Context, querySetId int, |
|
|
foundMasterTable *domain.Table
|
|
|
)
|
|
|
// 生成Table
|
|
|
masterTable := queryComponents[0].MasterTable
|
|
|
var fields = make([]*domain.Field, 0)
|
|
|
dependencyTables := querySet.GetDependencyTables(queryComponents)
|
|
|
foundMasterTable, err = tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableId": masterTable.TableId})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
if querySet.Type == domain.CalculateTable.ToString() {
|
|
|
aggregationFields := append(queryComponents[0].Aggregation.RowFields, queryComponents[0].Aggregation.ValueFields...)
|
|
|
for index, f := range aggregationFields {
|
|
|
fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index))
|
|
|
}
|
|
|
} else {
|
|
|
masterTable := queryComponents[0].MasterTable
|
|
|
foundMasterTable, err = tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableId": masterTable.TableId})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
masterTable = domain.NewQueryComponentTable(foundMasterTable)
|
|
|
fields = masterTable.Fields
|
|
|
}
|
|
|
masterTable = domain.NewQueryComponentTable(foundMasterTable)
|
|
|
var table *domain.Table = NewCopyTable(domain.TableType(domain.TemporaryTable), querySet.Name, domain.RangeFields(masterTable.Fields, domain.ChangeFieldFlag), 0).
|
|
|
|
|
|
var table *domain.Table = NewCopyTable(domain.TableType(domain.TemporaryTable), querySet.Name, domain.RangeFields(fields, domain.ChangeFieldFlag), 0).
|
|
|
WithContext(ctx).
|
|
|
WithPrefix(strings.ToLower(string(domain.TemporaryTable)))
|
|
|
// 循环依赖判断
|
...
|
...
|
@@ -258,7 +366,12 @@ func (ptr *QuerySetService) UpdateQuerySetLog(ctx *domain.Context, querySet *dom |
|
|
if logs := selectsEditLog(ctx, querySet, queryComponents); len(logs) > 0 {
|
|
|
res = append(res, logs...)
|
|
|
}
|
|
|
|
|
|
if logs := formulaEditLog(ctx, querySet, queryComponents); len(logs) > 0 {
|
|
|
res = append(res, logs...)
|
|
|
}
|
|
|
if logs := aggregationEditLog(ctx, querySet, queryComponents); len(logs) > 0 {
|
|
|
res = append(res, logs...)
|
|
|
}
|
|
|
for _, l := range res {
|
|
|
FastLog(ptr.transactionContext, l.LogType, l.SourceId, l.LogEntry)
|
|
|
}
|
...
|
...
|
@@ -350,23 +463,6 @@ func conditionsEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryComp |
|
|
return res
|
|
|
}
|
|
|
|
|
|
func queryComponentsHasEdit(ctx *domain.Context, querySet *domain.QuerySet, queryComponents []*domain.QueryComponent) bool {
|
|
|
logs := selectsEditLog(ctx, querySet, queryComponents)
|
|
|
if len(logs) > 0 {
|
|
|
return true
|
|
|
}
|
|
|
logs = conditionsEditLog(ctx, querySet, queryComponents)
|
|
|
if len(logs) > 0 {
|
|
|
return true
|
|
|
}
|
|
|
for _, item := range queryComponents {
|
|
|
if len(item.Id) == 0 {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
func selectsEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryComponents []*domain.QueryComponent) []FastSourceLog {
|
|
|
var res = make([]FastSourceLog, 0)
|
|
|
oldQCs := domain.QueryComponentsToMapById(querySet.QueryComponents)
|
...
|
...
|
@@ -451,7 +547,88 @@ func selectsEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryCompone |
|
|
return res
|
|
|
}
|
|
|
|
|
|
func (ptr *QuerySetService) CreateOrUpdateQuerySetTable(ctx *domain.Context, querySet *domain.QuerySet, masterTable domain.QueryComponentTable, queryComponents []*domain.QueryComponent) (*domain.Table, error) {
|
|
|
func formulaEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryComponents []*domain.QueryComponent) []FastSourceLog {
|
|
|
var res = make([]FastSourceLog, 0)
|
|
|
sourceId := querySet.QuerySetId
|
|
|
entry := domain.NewLogEntry(querySet.Name, querySet.Type, domain.UnKnown, ctx)
|
|
|
|
|
|
if len(queryComponents) > 0 && len(querySet.QueryComponents) > 0 {
|
|
|
oldQC := querySet.QueryComponents[0]
|
|
|
newQC := queryComponents[0]
|
|
|
if oldQC.Formula == nil || newQC.Formula == nil {
|
|
|
return res
|
|
|
}
|
|
|
if oldQC.Formula.ExprSql != newQC.Formula.ExprSql {
|
|
|
res = append(res, NewFastSourceLog(domain.QuerySetLog, sourceId, &EditFormulaLog{
|
|
|
LogEntry: entry,
|
|
|
OperationType: domain.EditCalculateItem,
|
|
|
Old: oldQC.Formula.ExprHuman,
|
|
|
New: newQC.Formula.ExprHuman,
|
|
|
}))
|
|
|
}
|
|
|
}
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
func aggregationEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryComponents []*domain.QueryComponent) []FastSourceLog {
|
|
|
var res = make([]FastSourceLog, 0)
|
|
|
sourceId := querySet.QuerySetId
|
|
|
entry := domain.NewLogEntry(querySet.Name, querySet.Type, domain.UnKnown, ctx)
|
|
|
|
|
|
if len(queryComponents) > 0 && len(querySet.QueryComponents) > 0 {
|
|
|
oldQC := querySet.QueryComponents[0]
|
|
|
newQC := queryComponents[0]
|
|
|
if oldQC.Aggregation == nil || newQC.Aggregation == nil {
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
mapOldAgFields := make(map[string]*domain.AggregationField)
|
|
|
for _, f := range oldQC.Aggregation.AggregationFields() {
|
|
|
mapOldAgFields[f.DisplayName] = f
|
|
|
}
|
|
|
changList := make([]string, 0)
|
|
|
for _, f := range newQC.Aggregation.AggregationFields() {
|
|
|
if v, ok := mapOldAgFields[f.DisplayName]; ok {
|
|
|
if f.Diff(v) {
|
|
|
changList = append(changList, fmt.Sprintf("%s修改为%s", v.Info(), f.Info()))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if len(changList) > 0 {
|
|
|
res = append(res, NewFastSourceLog(domain.QuerySetLog, sourceId, &EditFormulaLog{
|
|
|
LogEntry: entry,
|
|
|
OperationType: domain.EditCalculateTable,
|
|
|
Msg: strings.Join(changList, ";"),
|
|
|
}))
|
|
|
}
|
|
|
}
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
func queryComponentsHasEdit(ctx *domain.Context, querySet *domain.QuerySet, queryComponents []*domain.QueryComponent) bool {
|
|
|
logs := selectsEditLog(ctx, querySet, queryComponents)
|
|
|
if len(logs) > 0 {
|
|
|
return true
|
|
|
}
|
|
|
logs = conditionsEditLog(ctx, querySet, queryComponents)
|
|
|
if len(logs) > 0 {
|
|
|
return true
|
|
|
}
|
|
|
logs = aggregationEditLog(ctx, querySet, queryComponents)
|
|
|
if len(logs) > 0 {
|
|
|
return true
|
|
|
}
|
|
|
for _, item := range queryComponents {
|
|
|
if len(item.Id) == 0 {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
// CreateOrUpdateQuerySetTable 计算集
|
|
|
func (ptr *QuerySetService) CreateOrUpdateQuerySetTable(ctx *domain.Context, querySet *domain.QuerySet, masterTable *domain.QueryComponentTable, queryComponents []*domain.QueryComponent) (*domain.Table, error) {
|
|
|
var (
|
|
|
err error
|
|
|
foundMasterTable *domain.Table
|
...
|
...
|
@@ -487,6 +664,80 @@ func (ptr *QuerySetService) CreateOrUpdateQuerySetTable(ctx *domain.Context, que |
|
|
return table, nil
|
|
|
}
|
|
|
|
|
|
// CreateOrUpdateCalculateItemTable 计算项
|
|
|
func (ptr *QuerySetService) CreateOrUpdateCalculateItemTable(ctx *domain.Context, querySet *domain.QuerySet, masterTable *domain.QueryComponentTable, queryComponents []*domain.QueryComponent) (*domain.Table, error) {
|
|
|
var (
|
|
|
err error
|
|
|
)
|
|
|
dependencyTables := querySet.GetDependencyTables(queryComponents)
|
|
|
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
|
|
|
queryComponent := queryComponents[0]
|
|
|
field := DataField(querySet.Name, domain.String.ToString(), domain.MainTableField, 1)
|
|
|
if len(queryComponent.Formula.TableFields) > 0 {
|
|
|
field.SQLType = queryComponent.Formula.TableFields[0].FieldSQLType
|
|
|
}
|
|
|
var table *domain.Table = NewCopyTable(domain.TableType(querySet.Type), querySet.Name, []*domain.Field{field}, 1).WithContext(ctx).WithPrefix(strings.ToLower(querySet.Type))
|
|
|
table.PK = nil
|
|
|
if querySet.QuerySetInfo.BindTableId > 0 {
|
|
|
table, err = tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableId": querySet.QuerySetInfo.BindTableId})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
table.DataFields = []*domain.Field{field}
|
|
|
table.UpdatedAt = time.Now()
|
|
|
}
|
|
|
|
|
|
table.TableInfo.ApplyOnModule = domain.ModuleAll
|
|
|
table.TableInfo.DependencyTables = dependencyTables
|
|
|
table, err = tableRepository.Save(table)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
return table, nil
|
|
|
}
|
|
|
|
|
|
// CreateOrUpdateCalculateTable 计算表
|
|
|
func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, querySet *domain.QuerySet, masterTable *domain.QueryComponentTable, queryComponents []*domain.QueryComponent) (*domain.Table, error) {
|
|
|
var (
|
|
|
err error
|
|
|
foundMasterTable *domain.Table
|
|
|
)
|
|
|
dependencyTables := querySet.GetDependencyTables(queryComponents)
|
|
|
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
|
|
|
foundMasterTable, err = tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableId": masterTable.TableId})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
masterTable = domain.NewQueryComponentTable(foundMasterTable)
|
|
|
queryComponent := queryComponents[0]
|
|
|
queryComponent.MasterTable = masterTable
|
|
|
fields := make([]*domain.Field, 0)
|
|
|
aggregationFields := queryComponent.Aggregation.AggregationFields()
|
|
|
selectedFields := make([]string, 0)
|
|
|
for index, f := range aggregationFields {
|
|
|
fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index))
|
|
|
selectedFields = append(selectedFields, f.Field.Name)
|
|
|
}
|
|
|
queryComponent.Aggregation.SelectFields = selectedFields
|
|
|
var table *domain.Table = NewCopyTable(domain.TableType(querySet.Type), querySet.Name, fields, 0).WithContext(ctx).WithPrefix(strings.ToLower(querySet.Type))
|
|
|
if querySet.QuerySetInfo.BindTableId > 0 {
|
|
|
table, err = tableRepository.FindOne(map[string]interface{}{"context": ctx, "tableId": querySet.QuerySetInfo.BindTableId})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
table.DataFields = fields
|
|
|
table.UpdatedAt = time.Now()
|
|
|
}
|
|
|
|
|
|
table.TableInfo.ApplyOnModule = domain.ModuleAll
|
|
|
table.TableInfo.DependencyTables = dependencyTables
|
|
|
table, err = tableRepository.Save(table)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
return table, nil
|
|
|
}
|
|
|
|
|
|
func (ptr *QuerySetService) Rename(ctx *domain.Context, querySetId int, name string) error {
|
|
|
querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
|
|
|
qs, err := querySetRepository.FindOne(map[string]interface{}{"querySetId": querySetId})
|
...
|
...
|
@@ -520,6 +771,7 @@ func (ptr *QuerySetService) Rename(ctx *domain.Context, querySetId int, name str |
|
|
// 日志
|
|
|
if err = FastLog(ptr.transactionContext, domain.QuerySetLog, qs.QuerySetId, &RenameQuerySetLog{
|
|
|
LogEntry: domain.NewLogEntry(qs.Name, qs.Type, domain.UnKnown, ctx),
|
|
|
Qs: qs,
|
|
|
NewName: name,
|
|
|
OldName: oldName,
|
|
|
}); err != nil {
|
...
|
...
|
@@ -537,7 +789,7 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st |
|
|
if qs.Status == status {
|
|
|
return nil
|
|
|
}
|
|
|
if qs.Type != domain.SchemaTable.ToString() {
|
|
|
if !domain.TableType(qs.Type).TableStatusEditable() {
|
|
|
return fmt.Errorf("方案才可以修改状态")
|
|
|
}
|
|
|
qs.Status = status
|
...
|
...
|
@@ -593,7 +845,6 @@ func (ptr *QuerySetService) Copy(ctx *domain.Context, querySetId int, t string, |
|
|
return nil, err
|
|
|
}
|
|
|
copyTable := NewCopyTable(domain.TableType(t), name, table.Fields(false), 0).WithContext(ctx).WithPrefix(qs.Type)
|
|
|
|
|
|
copyTable, err = tableRepository.Save(copyTable)
|
|
|
if err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -609,12 +860,12 @@ func (ptr *QuerySetService) Copy(ctx *domain.Context, querySetId int, t string, |
|
|
return nil, err
|
|
|
}
|
|
|
if len(formulasGenerateResponse.FormulaName) > 0 && formulasGenerateResponse.FormulaName != table.SQLName {
|
|
|
copyTable.SQLName = formulasGenerateResponse.FormulaName
|
|
|
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
|
|
|
copyTable, err = tableRepository.Save(copyTable)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
//copyTable.SQLName = formulasGenerateResponse.FormulaName
|
|
|
//tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
|
|
|
//copyTable, err = tableRepository.Save(copyTable)
|
|
|
//if err != nil {
|
|
|
// return nil, err
|
|
|
//}
|
|
|
}
|
|
|
copy.QuerySetInfo.BindTableId = copyTable.TableId
|
|
|
}
|
...
|
...
|
@@ -622,6 +873,14 @@ func (ptr *QuerySetService) Copy(ctx *domain.Context, querySetId int, t string, |
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// 日志
|
|
|
if err = FastLog(ptr.transactionContext, domain.QuerySetLog, qs.QuerySetId, &CopyQuerySetLog{
|
|
|
LogEntry: domain.NewLogEntry(qs.Name, qs.Type, domain.UnKnown, ctx),
|
|
|
From: qs,
|
|
|
To: copy,
|
|
|
}); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
return copy, nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -649,21 +908,29 @@ func (ptr *QuerySetService) Delete(ctx *domain.Context, querySetId int) error { |
|
|
return err
|
|
|
}
|
|
|
querySetRepository, _ := repository.NewQuerySetRepository(ptr.transactionContext)
|
|
|
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
|
|
|
tableDependencyService, _ := NewTableDependencyService(ptr.transactionContext)
|
|
|
// 1.判断依赖,删除表
|
|
|
for i := range querySets {
|
|
|
if _, err := querySetRepository.Remove(querySets[i]); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if querySets[i].Flag != domain.FlagGroup && querySets[i].Type == domain.SchemaTable.ToString() && querySets[i].Status == domain.StatusOn {
|
|
|
if querySets[i].Flag != domain.FlagGroup &&
|
|
|
domain.TableType(querySets[i].Type).TableStatusEditable() &&
|
|
|
querySets[i].Status == domain.StatusOn {
|
|
|
return ErrQuerySetDeleteStatusOn
|
|
|
}
|
|
|
if querySets[i].QuerySetInfo.BindTableId > 0 {
|
|
|
if err := tableDependencyService.HasDependencyError(ctx, querySets[i].QuerySetInfo.BindTableId); err != nil {
|
|
|
tableId := querySets[i].QuerySetInfo.BindTableId
|
|
|
if tableId > 0 {
|
|
|
if err := tableDependencyService.HasDependencyError(ctx, tableId); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if err := dao.TableSoftDelete(ptr.transactionContext, querySets[i].QuerySetInfo.BindTableId, domain.TableType(querySets[i].Type)); err != nil {
|
|
|
return err
|
|
|
t, _ := tableRepository.FindOne(map[string]interface{}{"tableId": tableId})
|
|
|
if t != nil {
|
|
|
if err := dao.TableSoftDelete(ptr.transactionContext, tableId, domain.TableType(querySets[i].Type)); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
starrocks.DropView(starrocks.DB, t.SQLName)
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|