| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package util
- import "fmt"
- type GTable struct {
- GenTable GenTable
- GenTableColumn []GenTableColumn
- }
- var GTables = make([]GTable, 0)
- // InitTable 初始化表格生成
- func InitTable() {
- for i := range MTables {
- table := MTables[i]
- //表格
- gt := GenTable{
- TableName: table.Name,
- TableComment: table.Comment,
- Name: table.GreatHump,
- RouterName: table.LittleHump,
- Remark: table.Comment,
- }
- list, _ := GetGenTableList(gt, 1, 1)
- if list.Total == 0 {
- gt, _ = SaveGenTable(>)
- } else {
- gt = list.List[0].(GenTable)
- }
- gtcs := make([]GenTableColumn, 0)
- for j := range table.MColumns {
- column := table.MColumns[j]
- gtc := GenTableColumn{
- TableId: gt.Id,
- ColumnName: column.Name,
- }
- subList, _ := GetGenTableColumnList(gtc, 1, 1)
- if gtc.TableId == 34 {
- fmt.Println(subList.List[0])
- }
- if subList.Total == 0 {
- //gtc, _ = SaveGenTableColumn(>c)
- } else {
- gtc = subList.List[0].(GenTableColumn)
- }
- gtcs = append(gtcs, gtc)
- }
- GTables = append(GTables, GTable{
- GenTable: gt,
- GenTableColumn: gtcs,
- })
- }
- }
- func UpdateTable() {
- list, err := GetGenTableList(GenTable{}, 1, 10000)
- if err != nil {
- fmt.Println(err)
- return
- }
- SqlMap := map[string]GenTable{}
- for i := range list.List {
- gt := list.List[i].(GenTable)
- SqlMap[gt.TableName] = gt
- }
- MTableMap := map[string]MTable{}
- for i := range MTables {
- table := MTables[i]
- MTableMap[table.Name] = table
- }
- for s := range MTableMap {
- if SqlMap[s].Id == 0 {
- DeleteGenTable(SqlMap[s].Id)
- }
- }
- }
|