datatable_dto.go 1.2 KB
package dto

import "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"

type DataTableDto struct {
	FileId       int             `json:"fileId"`
	DataFields   []*Field        `json:"dataFields"`
	DataRows     [][]interface{} `json:"dataRows"`
	Total        int             `json:"total"`
	PageNumber   int             `json:"pageNumber"`
	InValidCells []InValidCell   `json:"inValidCells"`
}

type Field struct {
	// 索引序号
	// Index int `json:"index"`
	// 名称
	Name string `json:"name"`
	// 对应数据库类型
	Type string `json:"type"`
}

type InValidCell struct {
	X     int    `json:"x"`
	Y     int    `json:"y"`
	Error string `json:"error"`
}

func NewDataTableDtoDemo(fileId int) DataTableDto {
	return DataTableDto{
		DataFields: []*Field{
			{
				//Index: 1,
				Name: "产品名称",
				Type: domain.String.ToString(),
			},
			{
				//Index: 2,
				Name: "产品数量",
				Type: domain.Int.ToString(),
			},
		},
		DataRows: [][]interface{}{
			{"素面", 200},
			{"冻豆腐", 400},
			{"冻豆腐1", 300},
			{"冻豆2", "A"},
		},
		InValidCells: []InValidCell{
			{
				X:     1,
				Y:     3,
				Error: "不是一个有效的数值",
			},
		},
		PageNumber: 1,
		Total:      100,
		FileId:     fileId,
	}
}