作者 yangfu

fix: some optimize

@@ -20,7 +20,7 @@ type CreateFileCommand struct { @@ -20,7 +20,7 @@ type CreateFileCommand struct {
20 // 文件来源 20 // 文件来源
21 FileFrom string `json:"-"` 21 FileFrom string `json:"-"`
22 // AppKey 22 // AppKey
23 - AppKey string `json:"-" valid:"Required"` 23 + AppKey string `json:"-"`
24 } 24 }
25 25
26 var MaxFileSize = 50 * 1024 * 1024 26 var MaxFileSize = 50 * 1024 * 1024
@@ -5,10 +5,12 @@ import ( @@ -5,10 +5,12 @@ import (
5 "fmt" 5 "fmt"
6 "github.com/beego/beego/v2/client/httplib" 6 "github.com/beego/beego/v2/client/httplib"
7 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
  8 + "github.com/linmadan/egglib-go/transaction/pg"
8 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
9 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command" 10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command"
10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/dto" 11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/dto"
11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" 12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
  13 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/excel" 14 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/excel"
13 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis" 15 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis"
14 ) 16 )
@@ -63,6 +65,22 @@ func (fileService *FileService) ResetHeaderRow(ctx *domain.Context, loadDataTabl @@ -63,6 +65,22 @@ func (fileService *FileService) ResetHeaderRow(ctx *domain.Context, loadDataTabl
63 } 65 }
64 loadDataTableService, _ := factory.CreateLoadDataTableService(transactionContext) 66 loadDataTableService, _ := factory.CreateLoadDataTableService(transactionContext)
65 data, err := loadDataTableService.RePreview(ctx, loadDataTableCommand.FileId, temporaryFile.Fields, loadDataTableCommand.Where) 67 data, err := loadDataTableService.RePreview(ctx, loadDataTableCommand.FileId, temporaryFile.Fields, loadDataTableCommand.Where)
  68 + // 处理错误
  69 + level := domain.LevelInfo
  70 + errMsg := ""
  71 + if err != nil {
  72 + level = domain.LevelError
  73 + errMsg = err.Error()
  74 + }
  75 + if logErr := domainService.FastLog(transactionContext.(*pg.TransactionContext),
  76 + domain.VerifiedStepLog, temporaryFile.FileId, &domainService.ExcelTableResetHeaderLog{
  77 + LogEntry: domain.NewLogEntry(temporaryFile.FileName, domain.VerifiedFile.ToString(), domain.FileVerify,
  78 + ctx.WithValue(domain.ContextWithLogLevel, level).
  79 + WithValue(domain.ContextWithLogMsg, errMsg)),
  80 + HeaderRow: domain.GetHeaderRow(loadDataTableCommand.HeaderRow),
  81 + }); logErr != nil {
  82 + return nil, logErr
  83 + }
66 if err != nil { 84 if err != nil {
67 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 85 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
68 } 86 }
@@ -134,6 +152,13 @@ func (fileService *FileService) EditDataTable(ctx *domain.Context, editDataTable @@ -134,6 +152,13 @@ func (fileService *FileService) EditDataTable(ctx *domain.Context, editDataTable
134 if editDataTableCommand.Action == "remove-column" && len(temporaryFile.Fields) == len(editDataTableCommand.ProcessFields) { 152 if editDataTableCommand.Action == "remove-column" && len(temporaryFile.Fields) == len(editDataTableCommand.ProcessFields) {
135 return nil, factory.FastError(fmt.Errorf("请至少保留一个数据列")) 153 return nil, factory.FastError(fmt.Errorf("请至少保留一个数据列"))
136 } 154 }
  155 + if editDataTableCommand.Action == "rename-column" {
  156 + targetColumn := editDataTableCommand.ProcessFieldNames[0]
  157 + newColumnName := editDataTableCommand.Params["newColumnName"].(string)
  158 + if len(temporaryFile.MatchFields([]string{newColumnName})) > 0 && newColumnName != targetColumn {
  159 + return nil, factory.FastError(fmt.Errorf("已存在相同名称,修改无效"))
  160 + }
  161 + }
137 // allowAction := func(fields []*domain.Field, action string) error { 162 // allowAction := func(fields []*domain.Field, action string) error {
138 // for _, f := range fields { 163 // for _, f := range fields {
139 // if f.SQLType != string(domain.String) && 164 // if f.SQLType != string(domain.String) &&
@@ -178,6 +203,9 @@ func (fileService *FileService) FlushDataTable(ctx *domain.Context, flushDataTab @@ -178,6 +203,9 @@ func (fileService *FileService) FlushDataTable(ctx *domain.Context, flushDataTab
178 if err != nil { 203 if err != nil {
179 return nil, factory.FastError(err) 204 return nil, factory.FastError(err)
180 } 205 }
  206 + if err = temporaryFile.Valid(); err != nil {
  207 + return nil, factory.FastError(err)
  208 + }
181 209
182 if _, err := flushDataTableService.Flush(ctx, flushDataTableCommand.ObjectId, &domain.Table{ 210 if _, err := flushDataTableService.Flush(ctx, flushDataTableCommand.ObjectId, &domain.Table{
183 DataFields: temporaryFile.Fields, 211 DataFields: temporaryFile.Fields,
@@ -41,6 +41,12 @@ func (searchQuery *SearchTableQuery) Valid(validation *validation.Validation) { @@ -41,6 +41,12 @@ func (searchQuery *SearchTableQuery) Valid(validation *validation.Validation) {
41 if searchQuery.ParentTableId > 0 && searchQuery.ParentId == 0 { 41 if searchQuery.ParentTableId > 0 && searchQuery.ParentId == 0 {
42 searchQuery.ParentId = searchQuery.ParentTableId 42 searchQuery.ParentId = searchQuery.ParentTableId
43 } 43 }
  44 + if searchQuery.Module == 4 {
  45 + searchQuery.FilterRules = append(searchQuery.FilterRules, &FilterRule{
  46 + TableType: domain.SchemaTable.ToString(),
  47 + Status: domain.StatusOn,
  48 + })
  49 + }
44 } 50 }
45 51
46 func (searchQuery *SearchTableQuery) ValidateQuery() error { 52 func (searchQuery *SearchTableQuery) ValidateQuery() error {
@@ -19,12 +19,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab @@ -19,12 +19,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
19 if err != nil { 19 if err != nil {
20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
21 } 21 }
22 - //if err := transactionContext.StartTransaction(); err != nil {  
23 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
24 - //}  
25 - //defer func() {  
26 - // transactionContext.RollbackTransaction()  
27 - //}()  
28 22
29 tableRepository, _, _ := factory.FastPgTable(transactionContext, 0) 23 tableRepository, _, _ := factory.FastPgTable(transactionContext, 0)
30 _, tables, err := tableRepository.Find(utils.ObjectToMap(searchQuery)) 24 _, tables, err := tableRepository.Find(utils.ObjectToMap(searchQuery))
@@ -40,7 +34,9 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab @@ -40,7 +34,9 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
40 item.SetDetailStructInfo(table) 34 item.SetDetailStructInfo(table)
41 } 35 }
42 item.Flag = domain.FlagSet 36 item.Flag = domain.FlagSet
43 - if item.TableType == domain.MainTable.ToString() || item.TableType == domain.SubTable.ToString() || item.TableType == domain.SideTable.ToString() { 37 + if item.TableType == domain.MainTable.ToString() ||
  38 + item.TableType == domain.SubTable.ToString() ||
  39 + item.TableType == domain.SideTable.ToString() {
44 item.ParentId = 0 40 item.ParentId = 0
45 item.Status = domain.StatusOn 41 item.Status = domain.StatusOn
46 } 42 }
@@ -55,23 +51,33 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab @@ -55,23 +51,33 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
55 51
56 querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0) 52 querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0)
57 _, querySets, _ := querySetRepository.Find(map[string]interface{}{"context": searchQuery.Context}) 53 _, querySets, _ := querySetRepository.Find(map[string]interface{}{"context": searchQuery.Context})
58 - if !searchQuery.ReturnGroupItem {  
59 - querySets = make([]*domain.QuerySet, 0) 54 +
  55 + var (
  56 + querySetMapById = make(map[int]*domain.QuerySet)
  57 + // BindTableId , parentId
  58 + querySetMapByTableId = make(map[int]*domain.QuerySet)
  59 + )
  60 + if searchQuery.ReturnGroupItem {
  61 + for _, qs := range querySets {
  62 + querySetMapById[qs.QuerySetId] = qs
  63 + }
60 } 64 }
61 - // BindTableId , parentId  
62 - querySetMapByTableId := make(map[int]*domain.QuerySet) 65 +
63 for _, qs := range querySets { 66 for _, qs := range querySets {
64 if qs.QuerySetInfo.BindTableId == 0 { 67 if qs.QuerySetInfo.BindTableId == 0 {
65 continue 68 continue
66 } 69 }
67 querySetMapByTableId[qs.QuerySetInfo.BindTableId] = qs 70 querySetMapByTableId[qs.QuerySetInfo.BindTableId] = qs
68 } 71 }
69 - querySetMapById := make(map[int]*domain.QuerySet)  
70 - for _, qs := range querySets {  
71 - querySetMapById[qs.QuerySetId] = qs  
72 - }  
73 72
74 var response = make([]*dto.TableObjectDto, 0) 73 var response = make([]*dto.TableObjectDto, 0)
  74 + for index, t := range result {
  75 + v, ok := querySetMapByTableId[t.TableId]
  76 + if !ok {
  77 + continue
  78 + }
  79 + result[index].Update(v)
  80 + }
75 // 分组 81 // 分组
76 querySetMapGroup := make(map[int]bool) 82 querySetMapGroup := make(map[int]bool)
77 querySetGroups := make([]*domain.QuerySet, 0) 83 querySetGroups := make([]*domain.QuerySet, 0)
@@ -79,7 +85,7 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab @@ -79,7 +85,7 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
79 if filterTableByFilterRule(t, searchQuery) { 85 if filterTableByFilterRule(t, searchQuery) {
80 continue 86 continue
81 } 87 }
82 - if !domain.TableType(t.TableType).TableHasGroup() { 88 + if !domain.TableType(t.TableType).TableIsSplitByGroup() {
83 response = append(response, t) 89 response = append(response, t)
84 continue 90 continue
85 } 91 }
@@ -112,9 +118,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab @@ -112,9 +118,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
112 groupItem.LoadGroup(querySetGroup) 118 groupItem.LoadGroup(querySetGroup)
113 response = append(response, groupItem) 119 response = append(response, groupItem)
114 } 120 }
115 - //if err := transactionContext.CommitTransaction(); err != nil {  
116 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
117 - //}  
118 121
119 sort.Slice(response, func(i, j int) bool { 122 sort.Slice(response, func(i, j int) bool {
120 item1 := response[i] 123 item1 := response[i]
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "fmt"
4 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
5 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" 6 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
6 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" 7 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command"
@@ -8,6 +9,7 @@ import ( @@ -8,6 +9,7 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" 9 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
9 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache" 10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache"
10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" 11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks"
  12 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
11 ) 13 )
12 14
13 func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command.TablePreviewCommand) (interface{}, error) { 15 func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command.TablePreviewCommand) (interface{}, error) {
@@ -21,12 +23,6 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command @@ -21,12 +23,6 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command
21 if err != nil { 23 if err != nil {
22 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 24 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
23 } 25 }
24 - //if err := transactionContext.StartTransaction(); err != nil {  
25 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
26 - //}  
27 - //defer func() {  
28 - // transactionContext.RollbackTransaction()  
29 - //}()  
30 var dataTable *domain.DataTable 26 var dataTable *domain.DataTable
31 var table *domain.Table 27 var table *domain.Table
32 var cacheMiss bool 28 var cacheMiss bool
@@ -57,7 +53,7 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command @@ -57,7 +53,7 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command
57 return nil, factory.FastError(err) 53 return nil, factory.FastError(err)
58 } 54 }
59 response.Fields = dataTable.Fields 55 response.Fields = dataTable.Fields
60 - response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, dataTable.Data, false), int64(len(dataTable.Data))) 56 + response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, pageData(cmd.PageNumber, cmd.PageSize, dataTable.Data), false), int64(len(dataTable.Data)))
61 default: 57 default:
62 var options = starrocks.QueryOptions{ 58 var options = starrocks.QueryOptions{
63 Table: table, 59 Table: table,
@@ -77,22 +73,34 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command @@ -77,22 +73,34 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command
77 // } 73 // }
78 response.Load(table, dataTable, domain.ObjectMetaTable) 74 response.Load(table, dataTable, domain.ObjectMetaTable)
79 } 75 }
80 - }  
81 -  
82 - switch table.TableType {  
83 - case domain.CalculateSet.ToString():  
84 - response.Fields = dataTable.Fields  
85 - response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, dataTable.Data, false), int64(len(dataTable.Data)))  
86 - default:  
87 - response.Load(table, dataTable, domain.ObjectMetaTable) 76 + } else {
  77 + switch table.TableType {
  78 + case domain.CalculateSet.ToString():
  79 + response.Fields = dataTable.Fields
  80 + response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, pageData(cmd.PageNumber, cmd.PageSize, dataTable.Data), false), int64(len(dataTable.Data)))
  81 + default:
  82 + response.Load(table, dataTable, domain.ObjectMetaTable)
  83 + }
88 } 84 }
89 85
90 if cacheMiss && dataTable != nil { 86 if cacheMiss && dataTable != nil {
91 // 存储缓存 87 // 存储缓存
92 cache.SetDataTable(table.TableId, dataTable) 88 cache.SetDataTable(table.TableId, dataTable)
93 } 89 }
94 - //if err := transactionContext.CommitTransaction(); err != nil {  
95 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
96 - //}  
97 return response, nil 90 return response, nil
98 } 91 }
  92 +
  93 +func pageData(pageNumber, pageSize int, data [][]string) [][]string {
  94 + if pageNumber == 0 || pageSize == 0 {
  95 + return data
  96 + }
  97 + offset := (pageNumber - 1) * pageSize
  98 + if len(data) < offset {
  99 + return [][]string{}
  100 + }
  101 + if len(data) < offset+pageSize {
  102 + pageSize = len(data) - offset
  103 + }
  104 + log.Logger.Info(fmt.Sprintf("%v %v %v", len(data), offset, pageSize))
  105 + return data[offset : offset+pageSize]
  106 +}
@@ -10,6 +10,10 @@ const ( @@ -10,6 +10,10 @@ const (
10 ExprModeExcelFunction 10 ExprModeExcelFunction
11 ) 11 )
12 12
  13 +const (
  14 + MaxQueryRow = 1000
  15 +)
  16 +
13 var ( 17 var (
14 ErrorNotFound = fmt.Errorf("没有此资源") 18 ErrorNotFound = fmt.Errorf("没有此资源")
15 ) 19 )
@@ -170,7 +174,7 @@ func (t TableType) TableStatusEditable() bool { @@ -170,7 +174,7 @@ func (t TableType) TableStatusEditable() bool {
170 return t == SchemaTable || t == CalculateItem || t == CalculateSet 174 return t == SchemaTable || t == CalculateItem || t == CalculateSet
171 } 175 }
172 176
173 -func (t TableType) TableHasGroup() bool { 177 +func (t TableType) TableIsSplitByGroup() bool {
174 return t == SchemaTable || t == SubProcessTable || t == CalculateItem || t == CalculateTable || t == CalculateSet 178 return t == SchemaTable || t == SubProcessTable || t == CalculateItem || t == CalculateTable || t == CalculateSet
175 } 179 }
176 180
@@ -348,6 +348,19 @@ func (l *ExcelTableEditLog) Content() string { @@ -348,6 +348,19 @@ func (l *ExcelTableEditLog) Content() string {
348 return msg 348 return msg
349 } 349 }
350 350
  351 +type ExcelTableResetHeaderLog struct {
  352 + domain.LogEntry
  353 + // 操作名称
  354 + // OperateName string
  355 + // 操作列
  356 + HeaderRow int
  357 +}
  358 +
  359 +func (l *ExcelTableResetHeaderLog) Content() string {
  360 + msg := fmt.Sprintf("修改标题行位置:%v行", l.HeaderRow)
  361 + return msg
  362 +}
  363 +
351 /* *********************************************拆解模块************************************************** */ 364 /* *********************************************拆解模块************************************************** */
352 365
353 type CreateQuerySetLog struct { 366 type CreateQuerySetLog struct {
@@ -368,11 +368,18 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [ @@ -368,11 +368,18 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [
368 } 368 }
369 d.PointEnd.Update(cell.X+len(blockData)-1, cell.Y, max) 369 d.PointEnd.Update(cell.X+len(blockData)-1, cell.Y, max)
370 case domain.DirectionNone: 370 case domain.DirectionNone:
371 - d.DataTable.Data[cell.X][cell.Y] = blockData[0] 371 + d.DataTable.Data[cell.X][cell.Y] = safeBlockData(blockData, 0)
372 d.PointEnd.Update(cell.X, cell.Y, max) 372 d.PointEnd.Update(cell.X, cell.Y, max)
373 } 373 }
374 } 374 }
375 375
  376 +func safeBlockData(data []string, index int) string {
  377 + if len(data) < index+1 {
  378 + return ""
  379 + }
  380 + return data[index]
  381 +}
  382 +
376 func (d *DataLayoutDataTable) changeUnProcessedLocation(lastCell *domain.LayoutCell, length int) { 383 func (d *DataLayoutDataTable) changeUnProcessedLocation(lastCell *domain.LayoutCell, length int) {
377 for _, cell := range d.unprocessed { 384 for _, cell := range d.unprocessed {
378 switch lastCell.Direction { 385 switch lastCell.Direction {
@@ -389,7 +396,7 @@ func (d *DataLayoutDataTable) changeUnProcessedLocation(lastCell *domain.LayoutC @@ -389,7 +396,7 @@ func (d *DataLayoutDataTable) changeUnProcessedLocation(lastCell *domain.LayoutC
389 } 396 }
390 397
391 func (d *DataLayoutDataTable) BlockData(cells *domain.LayoutCell) ([]string, int) { 398 func (d *DataLayoutDataTable) BlockData(cells *domain.LayoutCell) ([]string, int) {
392 - var block []string 399 + var block = make([]string, 0)
393 if cells.Type == domain.CellTypeText { 400 if cells.Type == domain.CellTypeText {
394 data := []string{cells.Data.Text} 401 data := []string{cells.Data.Text}
395 return data, 1 402 return data, 1
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/linmadan/egglib-go/utils/json" 5 "github.com/linmadan/egglib-go/utils/json"
6 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant" 6 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
7 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
  8 + "strings"
8 ) 9 )
9 10
10 const ( 11 const (
@@ -19,6 +20,7 @@ type TemporaryFileInfo struct { @@ -19,6 +20,7 @@ type TemporaryFileInfo struct {
19 OriginalFileId int `json:"originalFileId"` 20 OriginalFileId int `json:"originalFileId"`
20 FileId int `json:"fileId"` 21 FileId int `json:"fileId"`
21 FileType string `json:"fileType"` 22 FileType string `json:"fileType"`
  23 + FileName string `json:"fileName"`
22 Total int `json:"total"` 24 Total int `json:"total"`
23 HeaderRow int `json:"headerRow"` 25 HeaderRow int `json:"headerRow"`
24 Fields []*domain.Field `json:"fields"` 26 Fields []*domain.Field `json:"fields"`
@@ -29,6 +31,15 @@ type TemporaryFileInfo struct { @@ -29,6 +31,15 @@ type TemporaryFileInfo struct {
29 ConvertTypeErrors []ConvertTypeError `json:"convertTypeErrors"` 31 ConvertTypeErrors []ConvertTypeError `json:"convertTypeErrors"`
30 } 32 }
31 33
  34 +func (f *TemporaryFileInfo) Valid() error {
  35 + for _, f := range f.Fields {
  36 + if strings.HasPrefix(f.Name, "Unnamed:") {
  37 + return fmt.Errorf("存在空字段 `%s` 请重命名", f.Name)
  38 + }
  39 + }
  40 + return nil
  41 +}
  42 +
32 func (f *TemporaryFileInfo) MatchFields(columns []string) []*domain.Field { 43 func (f *TemporaryFileInfo) MatchFields(columns []string) []*domain.Field {
33 mapFields := (domain.Fields)(f.Fields).ToMap() 44 mapFields := (domain.Fields)(f.Fields).ToMap()
34 var result = make([]*domain.Field, 0) 45 var result = make([]*domain.Field, 0)
@@ -43,6 +54,7 @@ func (f *TemporaryFileInfo) MatchFields(columns []string) []*domain.Field { @@ -43,6 +54,7 @@ func (f *TemporaryFileInfo) MatchFields(columns []string) []*domain.Field {
43 func (f *TemporaryFileInfo) SetFile(file *domain.File) *TemporaryFileInfo { 54 func (f *TemporaryFileInfo) SetFile(file *domain.File) *TemporaryFileInfo {
44 f.FileId = file.FileId 55 f.FileId = file.FileId
45 f.FileType = file.FileType 56 f.FileType = file.FileType
  57 + f.FileName = file.FileInfo.Name
46 return f 58 return f
47 } 59 }
48 60
@@ -120,6 +120,9 @@ func (controller *FileController) SearchSourceFile() { @@ -120,6 +120,9 @@ func (controller *FileController) SearchSourceFile() {
120 fileService := service.NewFileService(nil) 120 fileService := service.NewFileService(nil)
121 cmd := &query.SearchFileQuery{} 121 cmd := &query.SearchFileQuery{}
122 Must(controller.Unmarshal(cmd)) 122 Must(controller.Unmarshal(cmd))
  123 + if cmd.PageSize == 0 {
  124 + cmd.PageSize = domain.MaxQueryRow
  125 + }
123 cmd.FileType = domain.SourceFile 126 cmd.FileType = domain.SourceFile
124 cmd.Context = ParseContext(controller.BaseController) 127 cmd.Context = ParseContext(controller.BaseController)
125 data, err := fileService.SearchFile(cmd) 128 data, err := fileService.SearchFile(cmd)
@@ -130,6 +133,9 @@ func (controller *FileController) SearchAppSourceFile() { @@ -130,6 +133,9 @@ func (controller *FileController) SearchAppSourceFile() {
130 fileService := service.NewFileService(nil) 133 fileService := service.NewFileService(nil)
131 cmd := &query.SearchFileQuery{} 134 cmd := &query.SearchFileQuery{}
132 Must(controller.Unmarshal(cmd)) 135 Must(controller.Unmarshal(cmd))
  136 + if cmd.PageSize == 0 {
  137 + cmd.PageSize = domain.MaxQueryRow
  138 + }
133 cmd.FileType = domain.SourceFile 139 cmd.FileType = domain.SourceFile
134 data, err := fileService.SearchAppFile(ParseContext(controller.BaseController), cmd) 140 data, err := fileService.SearchAppFile(ParseContext(controller.BaseController), cmd)
135 controller.Response(data, err) 141 controller.Response(data, err)
@@ -146,6 +152,9 @@ func (controller *FileController) SearchVerifiedFile() { @@ -146,6 +152,9 @@ func (controller *FileController) SearchVerifiedFile() {
146 fileService := service.NewFileService(nil) 152 fileService := service.NewFileService(nil)
147 cmd := &query.SearchFileQuery{} 153 cmd := &query.SearchFileQuery{}
148 Must(controller.Unmarshal(cmd)) 154 Must(controller.Unmarshal(cmd))
  155 + if cmd.PageSize == 0 {
  156 + cmd.PageSize = domain.MaxQueryRow
  157 + }
149 cmd.FileType = domain.VerifiedFile 158 cmd.FileType = domain.VerifiedFile
150 cmd.Context = ParseContext(controller.BaseController) 159 cmd.Context = ParseContext(controller.BaseController)
151 data, err := fileService.SearchFile(cmd) 160 data, err := fileService.SearchFile(cmd)