作者 yangfu

chore: domain code optimize

... ... @@ -28,9 +28,6 @@ type (
IsFromOriginalTable bool `json:"isFromOriginalTable"`
TableFileUrl string `json:"tableFileUrl"`
ColumnSchemas []ColumnSchema `json:"columnSchemas"`
//PageNumber int `json:"pageNumber"`
//PageSize int `json:"pageSize"`
//QueryParameters []QueryParameter `json:"queryParameters"`
SortParameters map[string]interface{} `json:"sortParameters"`
}
... ... @@ -50,14 +47,6 @@ type (
ColumnContents []string `json:"columnContents"`
IsContainContent bool `json:"isContainContent"`
}
//Field struct {
// // 索引序号
// Index int `json:"index"`
// // 名称
// Name string `json:"name"`
// // 对应数据库类型
// Type string `json:"sqlType"`
//}
InValidCell struct {
Col string `json:"col"`
... ... @@ -157,11 +146,6 @@ type (
MainTable *Table
Table *Table
CopyToTable *Table
// 数据列
//DataFields []*Field `json:"dataFields"`
// 手动添加的列
//ManualFields []*Field `json:"manualFields"`
}
DataCopyTable struct {
... ... @@ -249,27 +233,6 @@ func ToFields(fields []*Field) []*Field {
return result
}
//func ToFieldData(fields []*Field, data [][]string, byteName bool) []map[string]string {
// var result = make([]map[string]string, 0)
// var key string
// for _, d := range data {
// var item = make(map[string]string)
// for j, f := range fields {
// key = f.Name
// if byteName {
// key = f.Name
// }
// if len(d) >= j {
// item[key] = d[j]
// } else {
// item[key] = ""
// }
// }
// result = append(result, item)
// }
// return result
//}
type (
ReqFormulasGenerate struct {
QuerySet *QuerySet
... ...
... ... @@ -9,7 +9,7 @@ type Context struct {
OperatorName string `json:"operatorName"`
// 租户 (个人、企业)
TenantId int `json:"tenantId"`
// 附加数据
data map[string]interface{}
}
... ...
... ... @@ -16,8 +16,6 @@ type File struct {
FileInfo *FileInfo `json:"fileInfo"`
// 源文件Id(FileType为TemporaryFile或VerifiedFile时有值)
SourceFileId int `json:"sourceFileId"`
// 操作人
// Operator string `json:"operator"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 更新时间
... ... @@ -78,7 +76,6 @@ func (file *File) CopyTo(fileType FileType, ctx *Context) *File {
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
SourceFileId: file.FileId,
//Operator: file.Operator,
Context: ctx,
}
return t
... ...
... ... @@ -8,8 +8,6 @@ type FileInfo struct {
Url string `json:"url"`
// 文件大小
FileSize int `json:"fileSize"`
// 文件编号,以固定字符“F”+4位年+2位月+2位日+三位流水,每天编号从001开始
// FileCode string `json:"fileCode"`
// 后缀扩展
Ext string `json:"ext"`
// 记录数
... ...
... ... @@ -45,6 +45,5 @@ func (log *Log) Identify() interface{} {
}
func (log *Log) Update(data map[string]interface{}) error {
return nil
}
... ...
... ... @@ -2,7 +2,7 @@ package domain
import "time"
// 匹配规则配置
// MappingRule 匹配规则配置
type MappingRule struct {
// 匹配规则ID
MappingRuleId int `json:"mappingRuleId"`
... ... @@ -53,7 +53,6 @@ type MappingField struct {
func NewMappingFields(all []*Field, some []*Field) []*MappingField {
var result []*MappingField
//allMap :=(Fields)(all).ToMap()
someMap := (Fields)(some).ToMap()
for _, f := range all {
item := &MappingField{
... ...
... ... @@ -8,7 +8,7 @@ import (
"time"
)
// 查询集合
// QuerySet 查询集合
type QuerySet struct {
// 查询集合ID
QuerySetId int `json:"querySetId"`
... ...
... ... @@ -76,7 +76,6 @@ type SelectExpr struct { // 查询表达式
FieldLeft FieldExpr `json:"fieldLeft"`
FieldRight FieldExpr `json:"fieldRight"` // has value when type is equal to 1
Type string `json:"type"` // 1.拆分 2.拆方赋值 3.正常赋值
//SubGroup []SelectExpr `json:"subGroup,omitempty"`
}
func (s SelectExpr) Equal(compare SelectExpr) bool {
... ... @@ -94,7 +93,6 @@ type SelectExprGroup struct { // 查询表达式
}
type FieldExpr struct {
//LabelColumns []LabelColumn `json:"labelColumns"`
TableFields []TableField `json:"tableFields"`
ExprHuman string `json:"exprHuman"`
ExprSql string `json:"exprSql"`
... ... @@ -104,15 +102,11 @@ func (expr *FieldExpr) Complete() string {
exprSql := expr.ExprSql
for _, f := range expr.TableFields {
sql := fmt.Sprintf("%s.%s", f.TableSqlName, f.FieldSqlName)
//zhSql := fmt.Sprintf("%s.%s", f.TableName, f.FieldSqlName)
sub := fmt.Sprintf("max(%s.%s)", f.TableSqlName, f.FieldSqlName)
//zhSub := fmt.Sprintf("max(%s.%s)", f.TableName, f.FieldSqlName)
if strings.Contains(expr.ExprSql, fmt.Sprintf("(%s)", sql)) {
continue
}
exprSql = strings.ReplaceAll(exprSql, sql, sub)
//expr.ExprSql = strings.ReplaceAll(expr.ExprSql, sql, sub)
//expr.ExprHuman = strings.ReplaceAll(expr.ExprHuman, zhSql, zhSub)
}
return exprSql
}
... ...
... ... @@ -2,8 +2,8 @@ package domain
import (
"github.com/zeromicro/go-zero/core/collection"
"strings"
"sort"
"strings"
)
const (
... ... @@ -44,24 +44,12 @@ type Location struct {
}
type LayoutCellData struct {
//Table *Table `json:"table,omitempty"`
//Field *Field `json:"field,omitempty"`
TableField *TableField `json:"tableField"`
Text string `json:"text,omitempty"`
}
func (l *LayoutRuleItem) LayoutCells() []*LayoutCell {
var cells = make([]*LayoutCell, 0)
//for i, rows := range l.Cells {
// for j, item := range rows {
// if item.Type == CellTypeNull || item.Type == "" {
// continue
// }
// item.X = i
// item.Y = j
// cells = append(cells, item)
// }
//}
for _, item := range l.Cells {
item.X = item.Position.X
item.Y = item.Position.Y
... ... @@ -70,19 +58,18 @@ func (l *LayoutRuleItem) LayoutCells() []*LayoutCell {
return cells
}
type LayoutCells []*LayoutCell
func(cells LayoutCells)CellsRange(direction string)[]int{
list:=collection.NewSet()
for i:=range cells{
if strings.ToLower(direction)=="x"{
func (cells LayoutCells) CellsRange(direction string) []int {
list := collection.NewSet()
for i := range cells {
if strings.ToLower(direction) == "x" {
list.Add(cells[i].X)
}else{
} else {
list.Add(cells[i].Y)
}
}
sortList :=list.KeysInt()
sortList := list.KeysInt()
sort.Ints(sortList)
return sortList
}
... ...
... ... @@ -2,5 +2,4 @@ package domain
type QuerySetInfo struct {
BindTableId int // 查询集绑定的表
//DependentTables []int // 依赖的表
}
... ...
... ... @@ -114,42 +114,42 @@ func (table *Table) Update(data map[string]interface{}) error {
return nil
}
func (t *Table) Fields(includePK bool) []*Field {
func (table *Table) Fields(includePK bool) []*Field {
var fields []*Field
if includePK && t.PK != nil {
fields = append(fields, t.PK)
if includePK && table.PK != nil {
fields = append(fields, table.PK)
}
fields = append(fields, t.DataFields...)
if t.TableType == SubTable.ToString() {
fields = append(fields, t.ManualFields...)
fields = append(fields, table.DataFields...)
if table.TableType == SubTable.ToString() {
fields = append(fields, table.ManualFields...)
}
t.fields = fields
table.fields = fields
return t.fields
return table.fields
}
func (t *Table) MatchField(field *Field) (*Field, bool) {
if len(t.fields) == 0 {
t.fields = t.Fields(true)
func (table *Table) MatchField(field *Field) (*Field, bool) {
if len(table.fields) == 0 {
table.fields = table.Fields(true)
}
mField := (Fields)(t.fields).ToMap()
mField := (Fields)(table.fields).ToMap()
if v, ok := mField[field.Name]; ok {
return v, true
}
return nil, false
}
func (t *Table) DependencyTables() []int {
if t.TableInfo == nil {
func (table *Table) DependencyTables() []int {
if table.TableInfo == nil {
return []int{}
}
return t.TableInfo.DependencyTables
return table.TableInfo.DependencyTables
}
func (t *Table) AssertTableType(types ...TableType) bool {
func (table *Table) AssertTableType(types ...TableType) bool {
for _, item := range types {
if t.TableType == item.ToString() {
if table.TableType == item.ToString() {
return true
}
}
... ...
package domain
// 用户对象
// User 用户对象
type User struct {
// 用户Id 用户唯一标识
Id int `json:"id"`
... ...