正在显示
9 个修改的文件
包含
28 行增加
和
5 行删除
@@ -3,3 +3,7 @@ ALTER TABLE files ADD app_key TEXT; | @@ -3,3 +3,7 @@ ALTER TABLE files ADD app_key TEXT; | ||
3 | Update files set file_from = 'ByteBankWebClient'; | 3 | Update files set file_from = 'ByteBankWebClient'; |
4 | 4 | ||
5 | CREATE INDEX IF NOT EXISTS idx_files_app_key ON metadata.files USING btree(app_key); | 5 | CREATE INDEX IF NOT EXISTS idx_files_app_key ON metadata.files USING btree(app_key); |
6 | + | ||
7 | + | ||
8 | +alter table metadata.tables add column apply_at timestamptz; | ||
9 | +update metadata.tables set apply_at = null where table_type in ('MainTable','SubTable','SideTable') and apply_at is null; |
@@ -16,7 +16,7 @@ import ( | @@ -16,7 +16,7 @@ import ( | ||
16 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/port/event" | 16 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/port/event" |
17 | ) | 17 | ) |
18 | 18 | ||
19 | -const Version = "v1.3.0" | 19 | +const Version = "v1.4.0" |
20 | 20 | ||
21 | func main() { | 21 | func main() { |
22 | defer func() { | 22 | defer func() { |
@@ -27,6 +27,9 @@ type TableObjectDto struct { | @@ -27,6 +27,9 @@ type TableObjectDto struct { | ||
27 | InConflict bool `json:"inConflict"` | 27 | InConflict bool `json:"inConflict"` |
28 | // 表字段 | 28 | // 表字段 |
29 | Fields []*domain.Field `json:"fields"` | 29 | Fields []*domain.Field `json:"fields"` |
30 | + // 引用于时间 | ||
31 | + ApplyAt int64 `json:"-"` | ||
32 | + ApplyString string `json:"applyAtString"` | ||
30 | } | 33 | } |
31 | 34 | ||
32 | func (d *TableObjectDto) Load(m *domain.Table) *TableObjectDto { | 35 | func (d *TableObjectDto) Load(m *domain.Table) *TableObjectDto { |
@@ -40,6 +43,8 @@ func (d *TableObjectDto) Load(m *domain.Table) *TableObjectDto { | @@ -40,6 +43,8 @@ func (d *TableObjectDto) Load(m *domain.Table) *TableObjectDto { | ||
40 | d.Module = m.TableInfo.ApplyOnModule | 43 | d.Module = m.TableInfo.ApplyOnModule |
41 | } | 44 | } |
42 | d.Fields = make([]*domain.Field, 0) | 45 | d.Fields = make([]*domain.Field, 0) |
46 | + d.ApplyAt = m.ApplyAt.Unix() | ||
47 | + d.ApplyString = m.ApplyAt.Format("2006-01-02 15:00") | ||
43 | return d | 48 | return d |
44 | } | 49 | } |
45 | 50 |
@@ -16,6 +16,7 @@ import ( | @@ -16,6 +16,7 @@ import ( | ||
16 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" | 16 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" |
17 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" | 17 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" |
18 | "strings" | 18 | "strings" |
19 | + "time" | ||
19 | ) | 20 | ) |
20 | 21 | ||
21 | // 表服务 | 22 | // 表服务 |
@@ -424,8 +425,10 @@ func (tableService *TableService) ApplyOn(ctx *domain.Context, cmd *command.Appl | @@ -424,8 +425,10 @@ func (tableService *TableService) ApplyOn(ctx *domain.Context, cmd *command.Appl | ||
424 | } | 425 | } |
425 | if table.TableInfo == nil { | 426 | if table.TableInfo == nil { |
426 | table.TableInfo = domain.NewTableInfo().SetApplyOn(cmd.Module) | 427 | table.TableInfo = domain.NewTableInfo().SetApplyOn(cmd.Module) |
428 | + table.ApplyAt = time.Now() | ||
427 | } else { | 429 | } else { |
428 | table.TableInfo.SetApplyOn(cmd.Module) | 430 | table.TableInfo.SetApplyOn(cmd.Module) |
431 | + table.ApplyAt = time.Now() | ||
429 | } | 432 | } |
430 | defer func() { | 433 | defer func() { |
431 | domainService.AsyncEvent(domain.NewEventTable(ctx, domain.TableApplyOnEvent).WithTable(table).WithMetadata("module", cmd.Module)) | 434 | domainService.AsyncEvent(domain.NewEventTable(ctx, domain.TableApplyOnEvent).WithTable(table).WithMetadata("module", cmd.Module)) |
@@ -124,9 +124,11 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab | @@ -124,9 +124,11 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab | ||
124 | sort.Slice(response, func(i, j int) bool { | 124 | sort.Slice(response, func(i, j int) bool { |
125 | item1 := response[i] | 125 | item1 := response[i] |
126 | item2 := response[j] | 126 | item2 := response[j] |
127 | - //k1 := fmt.Sprintf("%v-%v-%v", item1.TableType, item1.ParentId, item1.Id) | ||
128 | - //k2 := fmt.Sprintf("%v-%v-%v", item2.TableType, item2.ParentId, item2.Id) | ||
129 | - //return k1 < k2 | 127 | + // 拆解模块按应用时间倒叙排列 |
128 | + if domain.AssertTableType(item1.TableType, domain.MainTable, domain.SubTable, domain.SideTable) && | ||
129 | + domain.AssertTableType(item2.TableType, domain.MainTable, domain.SubTable, domain.SideTable) { | ||
130 | + return item1.ApplyAt > item2.ApplyAt | ||
131 | + } | ||
130 | return item1.Id < item2.Id | 132 | return item1.Id < item2.Id |
131 | }) | 133 | }) |
132 | return map[string]interface{}{ | 134 | return map[string]interface{}{ |
@@ -45,7 +45,8 @@ type Table struct { | @@ -45,7 +45,8 @@ type Table struct { | ||
45 | Context *Context `json:"context"` | 45 | Context *Context `json:"context"` |
46 | // 表信息 | 46 | // 表信息 |
47 | TableInfo *TableInfo `json:"tableInfo"` | 47 | TableInfo *TableInfo `json:"tableInfo"` |
48 | - | 48 | + // 应用于的时间 |
49 | + ApplyAt time.Time `json:"applyAt"` | ||
49 | // 表头行号 从0开始 | 50 | // 表头行号 从0开始 |
50 | HeaderRow int `json:"-"` | 51 | HeaderRow int `json:"-"` |
51 | } | 52 | } |
@@ -41,4 +41,6 @@ type Table struct { | @@ -41,4 +41,6 @@ type Table struct { | ||
41 | Context *domain.Context `comment:"扩展"` | 41 | Context *domain.Context `comment:"扩展"` |
42 | // 表信息 | 42 | // 表信息 |
43 | TableInfo *domain.TableInfo `comment:"表信息"` | 43 | TableInfo *domain.TableInfo `comment:"表信息"` |
44 | + // 应用于的时间 | ||
45 | + ApplyAt time.Time `comment:"应用于的时间"` | ||
44 | } | 46 | } |
@@ -27,5 +27,6 @@ func TransformToTableDomainModelFromPgModels(tableModel *models.Table) (*domain. | @@ -27,5 +27,6 @@ func TransformToTableDomainModelFromPgModels(tableModel *models.Table) (*domain. | ||
27 | RowCount: tableModel.RowCount, | 27 | RowCount: tableModel.RowCount, |
28 | Context: tableModel.Context, | 28 | Context: tableModel.Context, |
29 | TableInfo: tableModel.TableInfo, | 29 | TableInfo: tableModel.TableInfo, |
30 | + ApplyAt: tableModel.ApplyAt, | ||
30 | }, nil | 31 | }, nil |
31 | } | 32 | } |
@@ -33,6 +33,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | @@ -33,6 +33,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | ||
33 | "row_count", | 33 | "row_count", |
34 | "context", | 34 | "context", |
35 | "table_info", | 35 | "table_info", |
36 | + "apply_at", | ||
36 | } | 37 | } |
37 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "table_id", "deleted_at")) | 38 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "table_id", "deleted_at")) |
38 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "table_id", "deleted_at")) | 39 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "table_id", "deleted_at")) |
@@ -59,6 +60,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | @@ -59,6 +60,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | ||
59 | &table.RowCount, | 60 | &table.RowCount, |
60 | &table.Context, | 61 | &table.Context, |
61 | &table.TableInfo, | 62 | &table.TableInfo, |
63 | + &table.ApplyAt, | ||
62 | ), | 64 | ), |
63 | fmt.Sprintf("INSERT INTO metadata.tables (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | 65 | fmt.Sprintf("INSERT INTO metadata.tables (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
64 | table.TableType, | 66 | table.TableType, |
@@ -75,6 +77,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | @@ -75,6 +77,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | ||
75 | table.RowCount, | 77 | table.RowCount, |
76 | table.Context, | 78 | table.Context, |
77 | table.TableInfo, | 79 | table.TableInfo, |
80 | + table.ApplyAt, | ||
78 | ); err != nil { | 81 | ); err != nil { |
79 | return table, err | 82 | return table, err |
80 | } | 83 | } |
@@ -99,6 +102,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | @@ -99,6 +102,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | ||
99 | &table.RowCount, | 102 | &table.RowCount, |
100 | &table.Context, | 103 | &table.Context, |
101 | &table.TableInfo, | 104 | &table.TableInfo, |
105 | + &table.ApplyAt, | ||
102 | ), | 106 | ), |
103 | fmt.Sprintf("UPDATE metadata.tables SET %s WHERE table_id=? and version=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | 107 | fmt.Sprintf("UPDATE metadata.tables SET %s WHERE table_id=? and version=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
104 | table.TableType, | 108 | table.TableType, |
@@ -115,6 +119,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | @@ -115,6 +119,7 @@ func (repository *TableRepository) Save(table *domain.Table) (*domain.Table, err | ||
115 | table.RowCount, | 119 | table.RowCount, |
116 | table.Context, | 120 | table.Context, |
117 | table.TableInfo, | 121 | table.TableInfo, |
122 | + table.ApplyAt, | ||
118 | table.Identify(), | 123 | table.Identify(), |
119 | oldVersion, | 124 | oldVersion, |
120 | ); err != nil { | 125 | ); err != nil { |
-
请 注册 或 登录 后发表评论