table_preview_dto.go
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package dto
import "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
type TablePreviewDto struct {
// 表Id
TableId int `json:"objectId"`
// 表Id
ObjectType string `json:"objectType"`
// 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表
TableType string `json:"tableType"`
// 名称
Name string `json:"name"`
// 数据
//*domain.DataTable
Fields []*domain.Field `json:"fields"`
Data interface{} `json:"grid"`
//Total int64 `json:"total"`
}
func (d *TablePreviewDto) Load(m *domain.Table, dataTable *domain.DataTable, objectType string) *TablePreviewDto {
d.TableId = m.TableId
d.TableType = m.TableType
d.ObjectType = objectType
d.Name = m.Name
d.Fields = dataTable.MatchFields(m.Fields(true))
d.Data = domain.GripData(domain.ToFieldData(m.Fields(true), dataTable.Data, false), dataTable.Total)
//d.Total = dataTable.Total
return d
}
func ToFieldDataByPK(m *domain.Table, dataTable *domain.DataTable) map[string]map[string]string {
var dataListByPk = make(map[string]map[string]string)
for _, item := range domain.ToFieldData(m.Fields(true), dataTable.Data, false) {
if v, ok := item[domain.DefaultPkField]; ok {
dataListByPk[v] = item
}
}
return dataListByPk
}