作者 yangfu

fix: query set copy set default module

@@ -67,22 +67,22 @@ func (table *Table) TableIdString() string { @@ -67,22 +67,22 @@ func (table *Table) TableIdString() string {
67 67
68 func (table *Table) WithContext(ctx *Context) *Table { 68 func (table *Table) WithContext(ctx *Context) *Table {
69 rand.Seed(time.Now().Unix()) 69 rand.Seed(time.Now().Unix())
70 - table.SQLName = fmt.Sprintf("%v_t%v_c%v", limitStringLen(table.SQLName,40), rand.Intn(1000000), limitStringLen(fmt.Sprintf("%d",ctx.CompanyId),8)) 70 + table.SQLName = fmt.Sprintf("%v_t%v_c%v", limitStringLen(table.SQLName, 40), rand.Intn(1000000), limitStringLen(fmt.Sprintf("%d", ctx.CompanyId), 8))
71 table.Context = ctx 71 table.Context = ctx
72 return table 72 return table
73 } 73 }
74 74
75 -func limitStringLen(s string,l int)string{  
76 - result:=s  
77 - subLength :=l /2  
78 - if len(result)>l{ 75 +func limitStringLen(s string, l int) string {
  76 + result := s
  77 + subLength := l / 2
  78 + if len(result) > l {
79 result = result[:subLength] + result[len(result)-subLength:] 79 result = result[:subLength] + result[len(result)-subLength:]
80 } 80 }
81 return result 81 return result
82 } 82 }
83 83
84 func (table *Table) WithPrefix(prefix string) *Table { 84 func (table *Table) WithPrefix(prefix string) *Table {
85 - if strings.HasPrefix(table.SQLName,"_"){ 85 + if strings.HasPrefix(table.SQLName, "_") {
86 table.SQLName = fmt.Sprintf("%v%v", strings.ToLower(prefix), table.SQLName) 86 table.SQLName = fmt.Sprintf("%v%v", strings.ToLower(prefix), table.SQLName)
87 return table 87 return table
88 } 88 }
@@ -90,6 +90,16 @@ func (table *Table) WithPrefix(prefix string) *Table { @@ -90,6 +90,16 @@ func (table *Table) WithPrefix(prefix string) *Table {
90 return table 90 return table
91 } 91 }
92 92
  93 +func (table *Table) ApplyDefaultModule() *Table {
  94 + if table.TableType == CalculateTable.ToString() || table.TableType == SubProcessTable.ToString() {
  95 + table.TableInfo.SetApplyOn(ModuleQuerySetCenter)
  96 + }
  97 + if table.TableType == SchemaTable.ToString() {
  98 + table.TableInfo.SetApplyOn(ModuleQuerySetCenter | ModuleCalculateCenter)
  99 + }
  100 + return table
  101 +}
  102 +
93 func (table *Table) WithParentId(parentId int) *Table { 103 func (table *Table) WithParentId(parentId int) *Table {
94 table.ParentId = parentId 104 table.ParentId = parentId
95 return table 105 return table
@@ -146,9 +156,9 @@ func (t *Table) AssertTableType(types ...TableType) bool { @@ -146,9 +156,9 @@ func (t *Table) AssertTableType(types ...TableType) bool {
146 return false 156 return false
147 } 157 }
148 158
149 -func TableTypesToStringList(list ...TableType)[]string{  
150 - var result = make([]string,0)  
151 - for _,item:=range list{ 159 +func TableTypesToStringList(list ...TableType) []string {
  160 + var result = make([]string, 0)
  161 + for _, item := range list {
152 result = append(result, item.ToString()) 162 result = append(result, item.ToString())
153 } 163 }
154 return result 164 return result
@@ -937,7 +937,10 @@ func (ptr *QuerySetService) Copy(ctx *domain.Context, querySetId int, t string, @@ -937,7 +937,10 @@ func (ptr *QuerySetService) Copy(ctx *domain.Context, querySetId int, t string,
937 if err != nil { 937 if err != nil {
938 return nil, err 938 return nil, err
939 } 939 }
940 - copyTable := NewCopyTable(domain.TableType(t), name, table.Fields(false), 0).WithContext(ctx).WithPrefix(qs.Type) 940 + copyTable := NewCopyTable(domain.TableType(t), name, table.Fields(false), 0).
  941 + WithContext(ctx).
  942 + WithPrefix(qs.Type).
  943 + ApplyDefaultModule()
941 copyTable, err = tableRepository.Save(copyTable) 944 copyTable, err = tableRepository.Save(copyTable)
942 if err != nil { 945 if err != nil {
943 return nil, err 946 return nil, err