...
|
...
|
@@ -67,22 +67,22 @@ func (table *Table) TableIdString() string { |
|
|
|
|
|
func (table *Table) WithContext(ctx *Context) *Table {
|
|
|
rand.Seed(time.Now().Unix())
|
|
|
table.SQLName = fmt.Sprintf("%v_t%v_c%v", limitStringLen(table.SQLName,40), rand.Intn(1000000), limitStringLen(fmt.Sprintf("%d",ctx.CompanyId),8))
|
|
|
table.SQLName = fmt.Sprintf("%v_t%v_c%v", limitStringLen(table.SQLName, 40), rand.Intn(1000000), limitStringLen(fmt.Sprintf("%d", ctx.CompanyId), 8))
|
|
|
table.Context = ctx
|
|
|
return table
|
|
|
}
|
|
|
|
|
|
func limitStringLen(s string,l int)string{
|
|
|
result:=s
|
|
|
subLength :=l /2
|
|
|
if len(result)>l{
|
|
|
func limitStringLen(s string, l int) string {
|
|
|
result := s
|
|
|
subLength := l / 2
|
|
|
if len(result) > l {
|
|
|
result = result[:subLength] + result[len(result)-subLength:]
|
|
|
}
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
func (table *Table) WithPrefix(prefix string) *Table {
|
|
|
if strings.HasPrefix(table.SQLName,"_"){
|
|
|
if strings.HasPrefix(table.SQLName, "_") {
|
|
|
table.SQLName = fmt.Sprintf("%v%v", strings.ToLower(prefix), table.SQLName)
|
|
|
return table
|
|
|
}
|
...
|
...
|
@@ -90,6 +90,16 @@ func (table *Table) WithPrefix(prefix string) *Table { |
|
|
return table
|
|
|
}
|
|
|
|
|
|
func (table *Table) ApplyDefaultModule() *Table {
|
|
|
if table.TableType == CalculateTable.ToString() || table.TableType == SubProcessTable.ToString() {
|
|
|
table.TableInfo.SetApplyOn(ModuleQuerySetCenter)
|
|
|
}
|
|
|
if table.TableType == SchemaTable.ToString() {
|
|
|
table.TableInfo.SetApplyOn(ModuleQuerySetCenter | ModuleCalculateCenter)
|
|
|
}
|
|
|
return table
|
|
|
}
|
|
|
|
|
|
func (table *Table) WithParentId(parentId int) *Table {
|
|
|
table.ParentId = parentId
|
|
|
return table
|
...
|
...
|
@@ -146,10 +156,10 @@ func (t *Table) AssertTableType(types ...TableType) bool { |
|
|
return false
|
|
|
}
|
|
|
|
|
|
func TableTypesToStringList(list ...TableType)[]string{
|
|
|
var result = make([]string,0)
|
|
|
for _,item:=range list{
|
|
|
func TableTypesToStringList(list ...TableType) []string {
|
|
|
var result = make([]string, 0)
|
|
|
for _, item := range list {
|
|
|
result = append(result, item.ToString())
|
|
|
}
|
|
|
return result
|
|
|
} |
|
|
\ No newline at end of file |
|
|
} |
...
|
...
|
|