作者 yangfu

fix: sync data

@@ -162,9 +162,6 @@ func AutoRemoveTemporaryTable(ctx context.Context) error { @@ -162,9 +162,6 @@ func AutoRemoveTemporaryTable(ctx context.Context) error {
162 return nil 162 return nil
163 } 163 }
164 } 164 }
165 - //if err = dao.TableDeleteByTime(transactionContext.(*pgTransaction.TransactionContext), domain.TemporaryTable, begin, end); err != nil {  
166 - // return err  
167 - //}  
168 if err = transactionContext.CommitTransaction(); err != nil { 165 if err = transactionContext.CommitTransaction(); err != nil {
169 return err 166 return err
170 } 167 }
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
7 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command" 7 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command"
8 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
  9 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
9 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/digitalLib" 11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/digitalLib"
11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" 12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
@@ -36,7 +37,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -36,7 +37,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
36 switch data.Type { 37 switch data.Type {
37 case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent: 38 case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent:
38 tableId = data.Table.TableId 39 tableId = data.Table.TableId
39 - case domain.QuerySetUpdateEvent, domain.QuerySetUpdateStatusEvent: 40 + case domain.QuerySetUpdateEvent, domain.QuerySetUpdateRenameEvent:
40 tableId = data.QuerySet.QuerySetInfo.BindTableId 41 tableId = data.QuerySet.QuerySetInfo.BindTableId
41 if data.QuerySet.Status != domain.StatusOn { 42 if data.QuerySet.Status != domain.StatusOn {
42 return nil, nil 43 return nil, nil
@@ -44,6 +45,16 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -44,6 +45,16 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
44 if !domain.AssertTableType(data.QuerySet.Type, domain.SchemaTable, domain.CalculateItem, domain.CalculateSet) { 45 if !domain.AssertTableType(data.QuerySet.Type, domain.SchemaTable, domain.CalculateItem, domain.CalculateSet) {
45 return nil, nil 46 return nil, nil
46 } 47 }
  48 + case domain.QuerySetUpdateStatusEvent:
  49 + tableId = data.QuerySet.QuerySetInfo.BindTableId
  50 + if !domain.AssertTableType(data.QuerySet.Type, domain.SchemaTable, domain.CalculateItem, domain.CalculateSet) {
  51 + return nil, nil
  52 + }
  53 + case domain.TableApplyOnEvent:
  54 + tableId = data.Table.TableId
  55 + dataChanged = false
  56 + case domain.QuerySetDeleteEvent:
  57 + tableId = data.Table.TableId
47 } 58 }
48 if tableId == 0 { 59 if tableId == 0 {
49 return nil, nil 60 return nil, nil
@@ -53,9 +64,13 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -53,9 +64,13 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
53 StructChanged: structChanged, 64 StructChanged: structChanged,
54 TableId: tableId, 65 TableId: tableId,
55 Event: data.Type.ToString(), 66 Event: data.Type.ToString(),
  67 + Metadata: cmd.EventTable.Metadata,
56 } 68 }
57 // tableId 相关联的 69 // tableId 相关联的
58 tableRepository, table, _ := factory.FastPgTable(transactionContext, tableId) 70 tableRepository, table, _ := factory.FastPgTable(transactionContext, tableId)
  71 + if table == nil && data.Table != nil {
  72 + table = data.Table
  73 + }
59 if table != nil { 74 if table != nil {
60 notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, table.TableType) 75 notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, table.TableType)
61 switch domain.TableType(table.TableType) { 76 switch domain.TableType(table.TableType) {
@@ -100,7 +115,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -100,7 +115,7 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
100 } 115 }
101 switch table.TableType { 116 switch table.TableType {
102 case domain.MainTable.ToString(), domain.SubTable.ToString(), domain.SideTable.ToString(): 117 case domain.MainTable.ToString(), domain.SubTable.ToString(), domain.SideTable.ToString():
103 - if table.TableInfo.ApplyOnModule&domain.ModuleDigitalCenter == 0 { 118 + if table.TableInfo != nil && table.TableInfo.ApplyOnModule&domain.ModuleDigitalCenter == 0 {
104 continue 119 continue
105 } 120 }
106 break 121 break
@@ -118,7 +133,16 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -118,7 +133,16 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
118 } 133 }
119 notifyData.TableAffectedList = append(notifyData.TableAffectedList, tree[i]) 134 notifyData.TableAffectedList = append(notifyData.TableAffectedList, tree[i])
120 } 135 }
121 - lib := digitalLib.NewDigitalLib("") 136 + found := false
  137 + for _, id := range notifyData.TableAffectedList {
  138 + if id == tableId {
  139 + found = true
  140 + }
  141 + }
  142 + if !found {
  143 + notifyData.TableAffectedList = append(notifyData.TableAffectedList, tableId)
  144 + }
  145 + lib := digitalLib.NewDigitalLib(constant.DIGITAL_SERVER_HOST)
122 if _, err = lib.SyncNotice(digitalLib.RequestSyncNotice{Body: notifyData}); err != nil { 146 if _, err = lib.SyncNotice(digitalLib.RequestSyncNotice{Body: notifyData}); err != nil {
123 log.Logger.Error(fmt.Sprintf("通知数控失败:%s", err.Error())) 147 log.Logger.Error(fmt.Sprintf("通知数控失败:%s", err.Error()))
124 if t, ok := notifyData.Retry(); ok { 148 if t, ok := notifyData.Retry(); ok {
@@ -134,14 +158,15 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -134,14 +158,15 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
134 } 158 }
135 159
136 type NotifyData struct { 160 type NotifyData struct {
137 - DataChanged bool `json:"dataChanged"` // 数据有变化  
138 - StructChanged bool `json:"structChanged"` // 结构有变化  
139 - TableId int `json:"tableId"` // 表ID  
140 - TableType string `json:"tableType"` // 表类型:导入模块(主表,副表,分表) 拆解模块(方案、子过程、计算表) 计算模块(计算项,计算集)  
141 - ObjectType string `json:"objectType"` // 导入模块、拆解模块、计算模块  
142 - CompanyId int `json:"companyId"` // 公司  
143 - Event string `json:"event"` // 事件名称  
144 - TableAffectedList []int `json:"tableAffectedList"` // 级联影响到的表 161 + DataChanged bool `json:"dataChanged"` // 数据有变化
  162 + StructChanged bool `json:"structChanged"` // 结构有变化
  163 + TableId int `json:"tableId"` // 表ID
  164 + TableType string `json:"tableType"` // 表类型:导入模块(主表,副表,分表) 拆解模块(方案、子过程、计算表) 计算模块(计算项,计算集)
  165 + ObjectType string `json:"objectType"` // 导入模块、拆解模块、计算模块
  166 + CompanyId int `json:"companyId"` // 公司
  167 + Event string `json:"event"` // 事件名称
  168 + TableAffectedList []int `json:"tableAffectedList"` // 级联影响到的表
  169 + Metadata map[string]interface{} `json:"metadata"` // 元数据
145 sendRetry int 170 sendRetry int
146 } 171 }
147 172
@@ -23,9 +23,9 @@ func FastPgFile(transactionContext application.TransactionContext, id int) (doma @@ -23,9 +23,9 @@ func FastPgFile(transactionContext application.TransactionContext, id int) (doma
23 if id > 0 { 23 if id > 0 {
24 if mod, err = rep.FindOne(map[string]interface{}{"fileId": id}); err != nil { 24 if mod, err = rep.FindOne(map[string]interface{}{"fileId": id}); err != nil {
25 if err == domain.ErrorNotFound { 25 if err == domain.ErrorNotFound {
26 - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该文件不存在") 26 + return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该文件不存在")
27 } 27 }
28 - return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 28 + return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
29 } 29 }
30 } 30 }
31 //if err = fastPgDataAuth(transactionContext, mod, options...); err != nil { 31 //if err = fastPgDataAuth(transactionContext, mod, options...); err != nil {
@@ -52,9 +52,9 @@ func FastPgTable(transactionContext application.TransactionContext, id int) (dom @@ -52,9 +52,9 @@ func FastPgTable(transactionContext application.TransactionContext, id int) (dom
52 if id > 0 { 52 if id > 0 {
53 if mod, err = rep.FindOne(map[string]interface{}{"tableId": id}); err != nil { 53 if mod, err = rep.FindOne(map[string]interface{}{"tableId": id}); err != nil {
54 if err == domain.ErrorNotFound { 54 if err == domain.ErrorNotFound {
55 - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该表格不存在") 55 + return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该表格不存在")
56 } 56 }
57 - return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 57 + return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
58 } 58 }
59 } 59 }
60 return rep, mod, err 60 return rep, mod, err
@@ -78,9 +78,9 @@ func FastPgLog(transactionContext application.TransactionContext, id int) (domai @@ -78,9 +78,9 @@ func FastPgLog(transactionContext application.TransactionContext, id int) (domai
78 if id > 0 { 78 if id > 0 {
79 if mod, err = rep.FindOne(map[string]interface{}{"logId": id}); err != nil { 79 if mod, err = rep.FindOne(map[string]interface{}{"logId": id}); err != nil {
80 if err == domain.ErrorNotFound { 80 if err == domain.ErrorNotFound {
81 - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该日志不存在") 81 + return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该日志不存在")
82 } 82 }
83 - return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 83 + return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
84 } 84 }
85 } 85 }
86 return rep, mod, err 86 return rep, mod, err
@@ -104,9 +104,9 @@ func FastPgMappingRule(transactionContext application.TransactionContext, id int @@ -104,9 +104,9 @@ func FastPgMappingRule(transactionContext application.TransactionContext, id int
104 if id > 0 { 104 if id > 0 {
105 if mod, err = rep.FindOne(map[string]interface{}{"mappingRuleId": id}); err != nil { 105 if mod, err = rep.FindOne(map[string]interface{}{"mappingRuleId": id}); err != nil {
106 if err == domain.ErrorNotFound { 106 if err == domain.ErrorNotFound {
107 - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该匹配规则不存在") 107 + return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该匹配规则不存在")
108 } 108 }
109 - return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 109 + return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
110 } 110 }
111 } 111 }
112 return rep, mod, err 112 return rep, mod, err
@@ -130,9 +130,9 @@ func FastPgQuerySet(transactionContext application.TransactionContext, id int) ( @@ -130,9 +130,9 @@ func FastPgQuerySet(transactionContext application.TransactionContext, id int) (
130 if id > 0 { 130 if id > 0 {
131 if mod, err = rep.FindOne(map[string]interface{}{"querySetId": id}); err != nil { 131 if mod, err = rep.FindOne(map[string]interface{}{"querySetId": id}); err != nil {
132 if err == domain.ErrorNotFound { 132 if err == domain.ErrorNotFound {
133 - return nil, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该查询集合不存在") 133 + return rep, nil, application.ThrowError(application.RES_NO_FIND_ERROR, "该查询集合不存在")
134 } 134 }
135 - return nil, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 135 + return rep, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
136 } 136 }
137 } 137 }
138 return rep, mod, err 138 return rep, mod, err
@@ -91,9 +91,6 @@ type FileUpload struct { @@ -91,9 +91,6 @@ type FileUpload struct {
91 } 91 }
92 92
93 func (fileService *FileService) DeleteAppTableFile(ctx *domain.Context, cmd *command.DeleteAppTableFileCommand) (interface{}, error) { 93 func (fileService *FileService) DeleteAppTableFile(ctx *domain.Context, cmd *command.DeleteAppTableFileCommand) (interface{}, error) {
94 - //if err := cmd.ValidateCommand(); err != nil {  
95 - // return nil, application.ThrowError(application.ARG_ERROR, err.Error())  
96 - //}  
97 transactionContext, err := factory.CreateTransactionContext(nil) 94 transactionContext, err := factory.CreateTransactionContext(nil)
98 if err != nil { 95 if err != nil {
99 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 96 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -123,9 +120,6 @@ func (fileService *FileService) DeleteAppTableFile(ctx *domain.Context, cmd *com @@ -123,9 +120,6 @@ func (fileService *FileService) DeleteAppTableFile(ctx *domain.Context, cmd *com
123 } 120 }
124 121
125 func (fileService *FileService) AppTableFileAppendData(ctx *domain.Context, cmd *command.AppTableFileAppendDataCommand) (interface{}, error) { 122 func (fileService *FileService) AppTableFileAppendData(ctx *domain.Context, cmd *command.AppTableFileAppendDataCommand) (interface{}, error) {
126 - //if err := cmd.ValidateCommand(); err != nil {  
127 - // return nil, application.ThrowError(application.ARG_ERROR, err.Error())  
128 - //}  
129 transactionContext, err := factory.CreateTransactionContext(nil) 123 transactionContext, err := factory.CreateTransactionContext(nil)
130 if err != nil { 124 if err != nil {
131 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 125 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -277,7 +277,7 @@ func (fileService *FileService) AppendDataToTable(ctx *domain.Context, cmd *comm @@ -277,7 +277,7 @@ func (fileService *FileService) AppendDataToTable(ctx *domain.Context, cmd *comm
277 return result, nil 277 return result, nil
278 } 278 }
279 279
280 -// AppendDataToTable 追加数据 280 +// AppendDataToTablePreflightCheck 追加数据预查
281 func (fileService *FileService) AppendDataToTablePreflightCheck(ctx *domain.Context, cmd *command.AppendDataToTableCommand) (interface{}, error) { 281 func (fileService *FileService) AppendDataToTablePreflightCheck(ctx *domain.Context, cmd *command.AppendDataToTableCommand) (interface{}, error) {
282 if err := cmd.ValidateCommand(); err != nil { 282 if err := cmd.ValidateCommand(); err != nil {
283 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 283 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -352,41 +352,6 @@ func (fileService *FileService) ExportFile(ctx *domain.Context, cmd *command.Exp @@ -352,41 +352,6 @@ func (fileService *FileService) ExportFile(ctx *domain.Context, cmd *command.Exp
352 if err != nil { 352 if err != nil {
353 return nil, factory.FastError(err) 353 return nil, factory.FastError(err)
354 } 354 }
355 - //filename := fmt.Sprintf("%v_%v.xlsx", file.FileInfo.Name, time.Now().Format("060102150405"))  
356 - //path := fmt.Sprintf("public/%v", filename)  
357 - //writerTo := excel.NewXLXSWriterTo(importer.Reader().Header().Columns, data)  
358 - //writerTo.ToInterfaces = domain.MakeToInterfaces(table.DataFields)  
359 - //if err := writerTo.Save(path); err != nil {  
360 - // return nil, factory.FastError(err)  
361 - //}  
362 - //  
363 - //var (  
364 - // config = utils.RouterConfig{  
365 - // OssEndPoint: "oss-cn-hangzhou.aliyuncs-internal.com",  
366 - // AccessKeyID: "LTAI4Fz1LUBW2fXp6QWaJHRS",  
367 - // AccessKeySecret: "aLZXwK8pgrs10Ws03qcN7NsrSXFVsg",  
368 - // BuckName: "byte-bank",  
369 - // }  
370 - // key = fmt.Sprintf("byte-bank/%v/%v", time.Now().Format("2006-01-02"), filename)  
371 - //)  
372 - //bucket, bucketErr := utils.NewBucket(config)  
373 - //if bucketErr == nil && bucket != nil {  
374 - // log.Logger.Info(fmt.Sprintf("end-point:%v key:%v", config.OssEndPoint, key))  
375 - // f, _ := os.Open(path)  
376 - // if err = utils.CreateObjects(bucket, utils.Object{  
377 - // Key: key,  
378 - // Value: f,  
379 - // }); err != nil {  
380 - // log.Logger.Error(err.Error())  
381 - // } else {  
382 - // response.Url = domain.ConvertInternalFileUrlToPublic(fmt.Sprintf("https://%v.%v/%v", config.BuckName, config.OssEndPoint, key))  
383 - // }  
384 - //}  
385 - //if len(response.Url) == 0 {  
386 - // response.Url = domain.DownloadUrl(filename)  
387 - //}  
388 - //response.FileName = file.FileInfo.Name  
389 - //response.Ext = domain.XLSX  
390 355
391 if err := transactionContext.CommitTransaction(); err != nil { 356 if err := transactionContext.CommitTransaction(); err != nil {
392 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 357 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -19,11 +19,11 @@ import ( @@ -19,11 +19,11 @@ import (
19 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" 19 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
20 ) 20 )
21 21
22 -// 文件服务 22 +// FileService 文件服务
23 type FileService struct { 23 type FileService struct {
24 } 24 }
25 25
26 -// 创建文件服务 26 +// CreateFile 创建文件服务
27 func (fileService *FileService) CreateFile(ctx *domain.Context, createFileCommand *command.CreateFileCommand) (interface{}, error) { 27 func (fileService *FileService) CreateFile(ctx *domain.Context, createFileCommand *command.CreateFileCommand) (interface{}, error) {
28 if err := createFileCommand.ValidateCommand(); err != nil { 28 if err := createFileCommand.ValidateCommand(); err != nil {
29 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 29 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -89,7 +89,7 @@ func (fileService *FileService) CreateFile(ctx *domain.Context, createFileComman @@ -89,7 +89,7 @@ func (fileService *FileService) CreateFile(ctx *domain.Context, createFileComman
89 return struct{}{}, nil 89 return struct{}{}, nil
90 } 90 }
91 91
92 -// 返回文件服务 92 +// GetFile 返回文件服务
93 func (fileService *FileService) GetFile(ctx *domain.Context, getFileQuery *query.GetFileQuery) (interface{}, error) { 93 func (fileService *FileService) GetFile(ctx *domain.Context, getFileQuery *query.GetFileQuery) (interface{}, error) {
94 if err := getFileQuery.ValidateQuery(); err != nil { 94 if err := getFileQuery.ValidateQuery(); err != nil {
95 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 95 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -140,7 +140,7 @@ func (fileService *FileService) GetFile(ctx *domain.Context, getFileQuery *query @@ -140,7 +140,7 @@ func (fileService *FileService) GetFile(ctx *domain.Context, getFileQuery *query
140 return response, nil 140 return response, nil
141 } 141 }
142 142
143 -// 返回文件服务列表 143 +// ListFile 返回文件服务列表
144 func (fileService *FileService) ListFile(listFileQuery *query.ListFileQuery) (interface{}, error) { 144 func (fileService *FileService) ListFile(listFileQuery *query.ListFileQuery) (interface{}, error) {
145 if err := listFileQuery.ValidateQuery(); err != nil { 145 if err := listFileQuery.ValidateQuery(); err != nil {
146 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 146 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -218,7 +218,7 @@ func (fileService *FileService) SearchFile(listFileQuery *query.SearchFileQuery) @@ -218,7 +218,7 @@ func (fileService *FileService) SearchFile(listFileQuery *query.SearchFileQuery)
218 }, nil 218 }, nil
219 } 219 }
220 220
221 -// 返回文件服务列表 221 +// SearchAppFile 返回文件服务列表
222 func (fileService *FileService) SearchAppFile(ctx *domain.Context, listFileQuery *query.SearchFileQuery) (interface{}, error) { 222 func (fileService *FileService) SearchAppFile(ctx *domain.Context, listFileQuery *query.SearchFileQuery) (interface{}, error) {
223 if err := listFileQuery.ValidateQuery(); err != nil { 223 if err := listFileQuery.ValidateQuery(); err != nil {
224 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 224 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -338,7 +338,7 @@ func (fileService *FileService) GetAppFile(ctx *domain.Context, appKey string, f @@ -338,7 +338,7 @@ func (fileService *FileService) GetAppFile(ctx *domain.Context, appKey string, f
338 }, nil 338 }, nil
339 } 339 }
340 340
341 -// 移除文件服务 341 +// RemoveFile 移除文件服务
342 func (fileService *FileService) RemoveFile(ctx *domain.Context, removeFileCommand *command.RemoveFileCommand) (interface{}, error) { 342 func (fileService *FileService) RemoveFile(ctx *domain.Context, removeFileCommand *command.RemoveFileCommand) (interface{}, error) {
343 if err := removeFileCommand.ValidateCommand(); err != nil { 343 if err := removeFileCommand.ValidateCommand(); err != nil {
344 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 344 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -379,7 +379,7 @@ func (fileService *FileService) RemoveFile(ctx *domain.Context, removeFileComman @@ -379,7 +379,7 @@ func (fileService *FileService) RemoveFile(ctx *domain.Context, removeFileComman
379 return struct{}{}, nil 379 return struct{}{}, nil
380 } 380 }
381 381
382 -// 更新文件服务 382 +// UpdateFile 更新文件服务
383 func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFileCommand) (interface{}, error) { 383 func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFileCommand) (interface{}, error) {
384 if err := updateFileCommand.ValidateCommand(); err != nil { 384 if err := updateFileCommand.ValidateCommand(); err != nil {
385 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 385 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -422,7 +422,7 @@ func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFile @@ -422,7 +422,7 @@ func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFile
422 } 422 }
423 } 423 }
424 424
425 -// 取消校验中的文件 425 +// CancelVerifyingFile 取消校验中的文件
426 func (fileService *FileService) CancelVerifyingFile(ctx *domain.Context, cmd *command.CancelVerifyingFileCommand) (interface{}, error) { 426 func (fileService *FileService) CancelVerifyingFile(ctx *domain.Context, cmd *command.CancelVerifyingFileCommand) (interface{}, error) {
427 if err := cmd.ValidateCommand(); err != nil { 427 if err := cmd.ValidateCommand(); err != nil {
428 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 428 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -12,11 +12,9 @@ import ( @@ -12,11 +12,9 @@ import (
12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" 12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
13 ) 13 )
14 14
15 -// 日志服务  
16 type LogService struct { 15 type LogService struct {
17 } 16 }
18 17
19 -// 创建日志服务  
20 func (logService *LogService) CreateLog(createLogCommand *command.CreateLogCommand) (interface{}, error) { 18 func (logService *LogService) CreateLog(createLogCommand *command.CreateLogCommand) (interface{}, error) {
21 if err := createLogCommand.ValidateCommand(); err != nil { 19 if err := createLogCommand.ValidateCommand(); err != nil {
22 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 20 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -56,7 +54,6 @@ func (logService *LogService) CreateLog(createLogCommand *command.CreateLogComma @@ -56,7 +54,6 @@ func (logService *LogService) CreateLog(createLogCommand *command.CreateLogComma
56 } 54 }
57 } 55 }
58 56
59 -// 返回日志服务  
60 func (logService *LogService) GetLog(getLogQuery *query.GetLogQuery) (interface{}, error) { 57 func (logService *LogService) GetLog(getLogQuery *query.GetLogQuery) (interface{}, error) {
61 if err := getLogQuery.ValidateQuery(); err != nil { 58 if err := getLogQuery.ValidateQuery(); err != nil {
62 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 59 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -93,7 +90,6 @@ func (logService *LogService) GetLog(getLogQuery *query.GetLogQuery) (interface{ @@ -93,7 +90,6 @@ func (logService *LogService) GetLog(getLogQuery *query.GetLogQuery) (interface{
93 } 90 }
94 } 91 }
95 92
96 -// 返回日志服务列表  
97 func (logService *LogService) ListLog(listLogQuery *query.ListLogQuery) (interface{}, error) { 93 func (logService *LogService) ListLog(listLogQuery *query.ListLogQuery) (interface{}, error) {
98 if err := listLogQuery.ValidateQuery(); err != nil { 94 if err := listLogQuery.ValidateQuery(); err != nil {
99 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 95 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -129,7 +125,6 @@ func (logService *LogService) ListLog(listLogQuery *query.ListLogQuery) (interfa @@ -129,7 +125,6 @@ func (logService *LogService) ListLog(listLogQuery *query.ListLogQuery) (interfa
129 } 125 }
130 } 126 }
131 127
132 -// 移除日志服务  
133 func (logService *LogService) RemoveLog(removeLogCommand *command.RemoveLogCommand) (interface{}, error) { 128 func (logService *LogService) RemoveLog(removeLogCommand *command.RemoveLogCommand) (interface{}, error) {
134 if err := removeLogCommand.ValidateCommand(); err != nil { 129 if err := removeLogCommand.ValidateCommand(); err != nil {
135 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 130 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -169,7 +164,6 @@ func (logService *LogService) RemoveLog(removeLogCommand *command.RemoveLogComma @@ -169,7 +164,6 @@ func (logService *LogService) RemoveLog(removeLogCommand *command.RemoveLogComma
169 } 164 }
170 } 165 }
171 166
172 -// 搜索日志  
173 func (logService *LogService) SearchLog(searchLogCommand *command.SearchLogCommand) (int64, interface{}, error) { 167 func (logService *LogService) SearchLog(searchLogCommand *command.SearchLogCommand) (int64, interface{}, error) {
174 if err := searchLogCommand.ValidateCommand(); err != nil { 168 if err := searchLogCommand.ValidateCommand(); err != nil {
175 return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) 169 return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -204,7 +198,6 @@ func (logService *LogService) SearchLog(searchLogCommand *command.SearchLogComma @@ -204,7 +198,6 @@ func (logService *LogService) SearchLog(searchLogCommand *command.SearchLogComma
204 return count, result, nil 198 return count, result, nil
205 } 199 }
206 200
207 -// 搜索日志  
208 func (logService *LogService) VerifiedStepLog(searchLogCommand *command.SearchLogCommand) (int64, interface{}, error) { 201 func (logService *LogService) VerifiedStepLog(searchLogCommand *command.SearchLogCommand) (int64, interface{}, error) {
209 if err := searchLogCommand.ValidateCommand(); err != nil { 202 if err := searchLogCommand.ValidateCommand(); err != nil {
210 return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error()) 203 return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -252,7 +245,6 @@ func (logService *LogService) VerifiedStepLog(searchLogCommand *command.SearchLo @@ -252,7 +245,6 @@ func (logService *LogService) VerifiedStepLog(searchLogCommand *command.SearchLo
252 }, nil 245 }, nil
253 } 246 }
254 247
255 -// 更新日志服务  
256 func (logService *LogService) UpdateLog(updateLogCommand *command.UpdateLogCommand) (interface{}, error) { 248 func (logService *LogService) UpdateLog(updateLogCommand *command.UpdateLogCommand) (interface{}, error) {
257 if err := updateLogCommand.ValidateCommand(); err != nil { 249 if err := updateLogCommand.ValidateCommand(); err != nil {
258 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 250 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -13,11 +13,11 @@ import ( @@ -13,11 +13,11 @@ import (
13 "time" 13 "time"
14 ) 14 )
15 15
16 -// 匹配规则服务 16 +// MappingRuleService 匹配规则服务
17 type MappingRuleService struct { 17 type MappingRuleService struct {
18 } 18 }
19 19
20 -// 创建匹配规则服务 20 +// CreateMappingRule 创建匹配规则服务
21 func (mappingRuleService *MappingRuleService) CreateMappingRule(ctx *domain.Context, cmd *command.CreateMappingRuleCommand) (interface{}, error) { 21 func (mappingRuleService *MappingRuleService) CreateMappingRule(ctx *domain.Context, cmd *command.CreateMappingRuleCommand) (interface{}, error) {
22 if err := cmd.ValidateCommand(); err != nil { 22 if err := cmd.ValidateCommand(); err != nil {
23 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 23 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -81,7 +81,7 @@ func (mappingRuleService *MappingRuleService) CreateMappingRule(ctx *domain.Cont @@ -81,7 +81,7 @@ func (mappingRuleService *MappingRuleService) CreateMappingRule(ctx *domain.Cont
81 return result, nil 81 return result, nil
82 } 82 }
83 83
84 -// 返回匹配规则服务 84 +// GetMappingRule 返回匹配规则服务
85 func (mappingRuleService *MappingRuleService) GetMappingRule(getMappingRuleQuery *query.GetMappingRuleQuery) (interface{}, error) { 85 func (mappingRuleService *MappingRuleService) GetMappingRule(getMappingRuleQuery *query.GetMappingRuleQuery) (interface{}, error) {
86 if err := getMappingRuleQuery.ValidateQuery(); err != nil { 86 if err := getMappingRuleQuery.ValidateQuery(); err != nil {
87 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 87 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -109,7 +109,7 @@ func (mappingRuleService *MappingRuleService) GetMappingRule(getMappingRuleQuery @@ -109,7 +109,7 @@ func (mappingRuleService *MappingRuleService) GetMappingRule(getMappingRuleQuery
109 return result, nil 109 return result, nil
110 } 110 }
111 111
112 -// 返回匹配规则服务列表 112 +// ListMappingRule 返回匹配规则服务列表
113 func (mappingRuleService *MappingRuleService) ListMappingRule(listMappingRuleQuery *query.ListMappingRuleQuery) (interface{}, error) { 113 func (mappingRuleService *MappingRuleService) ListMappingRule(listMappingRuleQuery *query.ListMappingRuleQuery) (interface{}, error) {
114 if err := listMappingRuleQuery.ValidateQuery(); err != nil { 114 if err := listMappingRuleQuery.ValidateQuery(); err != nil {
115 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 115 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -145,7 +145,7 @@ func (mappingRuleService *MappingRuleService) ListMappingRule(listMappingRuleQue @@ -145,7 +145,7 @@ func (mappingRuleService *MappingRuleService) ListMappingRule(listMappingRuleQue
145 } 145 }
146 } 146 }
147 147
148 -// 匹配规则预准备(新建规则) 148 +// Prepare 匹配规则预准备(新建规则)
149 func (mappingRuleService *MappingRuleService) Prepare(prepareCommand *command.PrepareCommand) (interface{}, error) { 149 func (mappingRuleService *MappingRuleService) Prepare(prepareCommand *command.PrepareCommand) (interface{}, error) {
150 if err := prepareCommand.ValidateCommand(); err != nil { 150 if err := prepareCommand.ValidateCommand(); err != nil {
151 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 151 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -182,7 +182,7 @@ func (mappingRuleService *MappingRuleService) Prepare(prepareCommand *command.Pr @@ -182,7 +182,7 @@ func (mappingRuleService *MappingRuleService) Prepare(prepareCommand *command.Pr
182 return ruleDto, nil 182 return ruleDto, nil
183 } 183 }
184 184
185 -// 移除匹配规则服务 185 +// RemoveMappingRule 移除匹配规则服务
186 func (mappingRuleService *MappingRuleService) RemoveMappingRule(removeMappingRuleCommand *command.RemoveMappingRuleCommand) (interface{}, error) { 186 func (mappingRuleService *MappingRuleService) RemoveMappingRule(removeMappingRuleCommand *command.RemoveMappingRuleCommand) (interface{}, error) {
187 if err := removeMappingRuleCommand.ValidateCommand(); err != nil { 187 if err := removeMappingRuleCommand.ValidateCommand(); err != nil {
188 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 188 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -222,7 +222,7 @@ func (mappingRuleService *MappingRuleService) RemoveMappingRule(removeMappingRul @@ -222,7 +222,7 @@ func (mappingRuleService *MappingRuleService) RemoveMappingRule(removeMappingRul
222 }{}, nil 222 }{}, nil
223 } 223 }
224 224
225 -// 搜索规则 225 +// Search 搜索规则
226 func (mappingRuleService *MappingRuleService) Search(searchCommand *command.SearchCommand) (interface{}, error) { 226 func (mappingRuleService *MappingRuleService) Search(searchCommand *command.SearchCommand) (interface{}, error) {
227 if err := searchCommand.ValidateCommand(); err != nil { 227 if err := searchCommand.ValidateCommand(); err != nil {
228 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 228 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -259,7 +259,7 @@ func (mappingRuleService *MappingRuleService) Search(searchCommand *command.Sear @@ -259,7 +259,7 @@ func (mappingRuleService *MappingRuleService) Search(searchCommand *command.Sear
259 }, nil 259 }, nil
260 } 260 }
261 261
262 -// 更新匹配规则服务 262 +// UpdateMappingRule 更新匹配规则服务
263 func (mappingRuleService *MappingRuleService) UpdateMappingRule(ctx *domain.Context, cmd *command.UpdateMappingRuleCommand) (interface{}, error) { 263 func (mappingRuleService *MappingRuleService) UpdateMappingRule(ctx *domain.Context, cmd *command.UpdateMappingRuleCommand) (interface{}, error) {
264 if err := cmd.ValidateCommand(); err != nil { 264 if err := cmd.ValidateCommand(); err != nil {
265 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 265 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "time" 11 "time"
12 ) 12 )
13 13
  14 +// CalculateSetPreview 计算集预览
14 func (querySetService *QuerySetService) CalculateSetPreview(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) { 15 func (querySetService *QuerySetService) CalculateSetPreview(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
15 if err := updateQuerySetCommand.ValidateCommand(); err != nil { 16 if err := updateQuerySetCommand.ValidateCommand(); err != nil {
16 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 17 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -50,6 +51,7 @@ func (querySetService *QuerySetService) CalculateSetPreview(ctx *domain.Context, @@ -50,6 +51,7 @@ func (querySetService *QuerySetService) CalculateSetPreview(ctx *domain.Context,
50 return response, nil 51 return response, nil
51 } 52 }
52 53
  54 +// CalculateSetExport 计算集导出
53 func (querySetService *QuerySetService) CalculateSetExport(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) { 55 func (querySetService *QuerySetService) CalculateSetExport(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
54 if err := updateQuerySetCommand.ValidateCommand(); err != nil { 56 if err := updateQuerySetCommand.ValidateCommand(); err != nil {
55 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 57 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -79,10 +81,6 @@ func (querySetService *QuerySetService) CalculateSetExport(ctx *domain.Context, @@ -79,10 +81,6 @@ func (querySetService *QuerySetService) CalculateSetExport(ctx *domain.Context,
79 } 81 }
80 82
81 var fields []string 83 var fields []string
82 - //for i := range dataTable.Fields {  
83 - // fields = append(fields, dataTable.Fields[i].Name)  
84 - //}  
85 -  
86 filename := fmt.Sprintf("%v_%v.xlsx", querySet.Name, time.Now().Format("060102150405")) 84 filename := fmt.Sprintf("%v_%v.xlsx", querySet.Name, time.Now().Format("060102150405"))
87 path := fmt.Sprintf("public/%v", filename) 85 path := fmt.Sprintf("public/%v", filename)
88 excelWriter := excel.NewXLXSWriterTo(fields, dataTable.Data) 86 excelWriter := excel.NewXLXSWriterTo(fields, dataTable.Data)
@@ -18,11 +18,11 @@ import ( @@ -18,11 +18,11 @@ import (
18 "time" 18 "time"
19 ) 19 )
20 20
21 -// 查询集合服务 21 +// QuerySetService 查询集合服务
22 type QuerySetService struct { 22 type QuerySetService struct {
23 } 23 }
24 24
25 -// 修改状态 25 +// ChangeStatus 修改状态
26 func (querySetService *QuerySetService) ChangeStatus(ctx *domain.Context, changeStatusCommand *command.ChangeStatusCommand) (interface{}, error) { 26 func (querySetService *QuerySetService) ChangeStatus(ctx *domain.Context, changeStatusCommand *command.ChangeStatusCommand) (interface{}, error) {
27 if err := changeStatusCommand.ValidateCommand(); err != nil { 27 if err := changeStatusCommand.ValidateCommand(); err != nil {
28 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 28 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -48,7 +48,7 @@ func (querySetService *QuerySetService) ChangeStatus(ctx *domain.Context, change @@ -48,7 +48,7 @@ func (querySetService *QuerySetService) ChangeStatus(ctx *domain.Context, change
48 return struct{}{}, nil 48 return struct{}{}, nil
49 } 49 }
50 50
51 -// 移动 51 +// Copy 复制
52 func (querySetService *QuerySetService) Copy(ctx *domain.Context, copyCommand *command.CopyCommand) (interface{}, error) { 52 func (querySetService *QuerySetService) Copy(ctx *domain.Context, copyCommand *command.CopyCommand) (interface{}, error) {
53 if err := copyCommand.ValidateCommand(); err != nil { 53 if err := copyCommand.ValidateCommand(); err != nil {
54 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 54 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -77,7 +77,7 @@ func (querySetService *QuerySetService) Copy(ctx *domain.Context, copyCommand *c @@ -77,7 +77,7 @@ func (querySetService *QuerySetService) Copy(ctx *domain.Context, copyCommand *c
77 return result, nil 77 return result, nil
78 } 78 }
79 79
80 -// 创建查询集合服务 80 +// CreateQuerySet 创建查询集合服务
81 func (querySetService *QuerySetService) CreateQuerySet(ctx *domain.Context, createQuerySetCommand *command.CreateQuerySetCommand) (interface{}, error) { 81 func (querySetService *QuerySetService) CreateQuerySet(ctx *domain.Context, createQuerySetCommand *command.CreateQuerySetCommand) (interface{}, error) {
82 if err := createQuerySetCommand.ValidateCommand(); err != nil { 82 if err := createQuerySetCommand.ValidateCommand(); err != nil {
83 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 83 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -113,7 +113,7 @@ func (querySetService *QuerySetService) CreateQuerySet(ctx *domain.Context, crea @@ -113,7 +113,7 @@ func (querySetService *QuerySetService) CreateQuerySet(ctx *domain.Context, crea
113 return response, nil 113 return response, nil
114 } 114 }
115 115
116 -// 依赖关系图 116 +// DependencyGraph 依赖关系图
117 func (querySetService *QuerySetService) DependencyGraph(ctx *domain.Context, dependencyGraphQuery *query.DependencyGraphQuery) (interface{}, error) { 117 func (querySetService *QuerySetService) DependencyGraph(ctx *domain.Context, dependencyGraphQuery *query.DependencyGraphQuery) (interface{}, error) {
118 if err := dependencyGraphQuery.ValidateQuery(); err != nil { 118 if err := dependencyGraphQuery.ValidateQuery(); err != nil {
119 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 119 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -141,7 +141,7 @@ func (querySetService *QuerySetService) DependencyGraph(ctx *domain.Context, dep @@ -141,7 +141,7 @@ func (querySetService *QuerySetService) DependencyGraph(ctx *domain.Context, dep
141 return data, nil 141 return data, nil
142 } 142 }
143 143
144 -// 返回查询集合服务 144 +// GetQuerySet 返回查询集合服务
145 func (querySetService *QuerySetService) GetQuerySet(ctx *domain.Context, getQuerySetQuery *query.GetQuerySetQuery) (interface{}, error) { 145 func (querySetService *QuerySetService) GetQuerySet(ctx *domain.Context, getQuerySetQuery *query.GetQuerySetQuery) (interface{}, error) {
146 if err := getQuerySetQuery.ValidateQuery(); err != nil { 146 if err := getQuerySetQuery.ValidateQuery(); err != nil {
147 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 147 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -173,7 +173,7 @@ func (querySetService *QuerySetService) GetQuerySet(ctx *domain.Context, getQuer @@ -173,7 +173,7 @@ func (querySetService *QuerySetService) GetQuerySet(ctx *domain.Context, getQuer
173 return (&dto.QuerySetDetailDto{}).Load(querySet, tables.ToMap()), nil 173 return (&dto.QuerySetDetailDto{}).Load(querySet, tables.ToMap()), nil
174 } 174 }
175 175
176 -// 返回查询集合服务列表 176 +// ListQuerySet 返回查询集合服务列表
177 func (querySetService *QuerySetService) ListQuerySet(ctx *domain.Context, listQuerySetQuery *query.ListQuerySetQuery) (interface{}, error) { 177 func (querySetService *QuerySetService) ListQuerySet(ctx *domain.Context, listQuerySetQuery *query.ListQuerySetQuery) (interface{}, error) {
178 if err := listQuerySetQuery.ValidateQuery(); err != nil { 178 if err := listQuerySetQuery.ValidateQuery(); err != nil {
179 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 179 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -209,7 +209,7 @@ func (querySetService *QuerySetService) ListQuerySet(ctx *domain.Context, listQu @@ -209,7 +209,7 @@ func (querySetService *QuerySetService) ListQuerySet(ctx *domain.Context, listQu
209 } 209 }
210 } 210 }
211 211
212 -// 移动 212 +// Move 移动
213 func (querySetService *QuerySetService) Move(ctx *domain.Context, moveCommand *command.MoveCommand) (interface{}, error) { 213 func (querySetService *QuerySetService) Move(ctx *domain.Context, moveCommand *command.MoveCommand) (interface{}, error) {
214 if err := moveCommand.ValidateCommand(); err != nil { 214 if err := moveCommand.ValidateCommand(); err != nil {
215 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 215 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -236,7 +236,7 @@ func (querySetService *QuerySetService) Move(ctx *domain.Context, moveCommand *c @@ -236,7 +236,7 @@ func (querySetService *QuerySetService) Move(ctx *domain.Context, moveCommand *c
236 return struct{}{}, nil 236 return struct{}{}, nil
237 } 237 }
238 238
239 -// 移除查询集合服务 239 +// RemoveQuerySet 移除查询集合服务
240 func (querySetService *QuerySetService) RemoveQuerySet(ctx *domain.Context, removeQuerySetCommand *command.RemoveQuerySetCommand) (interface{}, error) { 240 func (querySetService *QuerySetService) RemoveQuerySet(ctx *domain.Context, removeQuerySetCommand *command.RemoveQuerySetCommand) (interface{}, error) {
241 if err := removeQuerySetCommand.ValidateCommand(); err != nil { 241 if err := removeQuerySetCommand.ValidateCommand(); err != nil {
242 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 242 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -275,7 +275,7 @@ func (querySetService *QuerySetService) RemoveQuerySet(ctx *domain.Context, remo @@ -275,7 +275,7 @@ func (querySetService *QuerySetService) RemoveQuerySet(ctx *domain.Context, remo
275 return struct{}{}, nil 275 return struct{}{}, nil
276 } 276 }
277 277
278 -// 重命名 278 +// Rename 重命名
279 func (querySetService *QuerySetService) Rename(ctx *domain.Context, renameCommand *command.RenameCommand) (interface{}, error) { 279 func (querySetService *QuerySetService) Rename(ctx *domain.Context, renameCommand *command.RenameCommand) (interface{}, error) {
280 if err := renameCommand.ValidateCommand(); err != nil { 280 if err := renameCommand.ValidateCommand(); err != nil {
281 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 281 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -302,7 +302,7 @@ func (querySetService *QuerySetService) Rename(ctx *domain.Context, renameComman @@ -302,7 +302,7 @@ func (querySetService *QuerySetService) Rename(ctx *domain.Context, renameComman
302 return struct{}{}, nil 302 return struct{}{}, nil
303 } 303 }
304 304
305 -// 返回查询集合服务列表 305 +// SearchQuerySet 返回查询集合服务列表
306 func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, searchQuerySetQuery *query.SearchQuerySetQuery) (interface{}, error) { 306 func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, searchQuerySetQuery *query.SearchQuerySetQuery) (interface{}, error) {
307 if err := searchQuerySetQuery.ValidateQuery(); err != nil { 307 if err := searchQuerySetQuery.ValidateQuery(); err != nil {
308 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 308 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -311,12 +311,6 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear @@ -311,12 +311,6 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear
311 if err != nil { 311 if err != nil {
312 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 312 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
313 } 313 }
314 - //if err := transactionContext.StartTransaction(); err != nil {  
315 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
316 - //}  
317 - //defer func() {  
318 - // transactionContext.RollbackTransaction()  
319 - //}()  
320 314
321 QuerySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0) 315 QuerySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0)
322 options := utils.ObjectToMap(searchQuerySetQuery) 316 options := utils.ObjectToMap(searchQuerySetQuery)
@@ -361,16 +355,13 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear @@ -361,16 +355,13 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear
361 355
362 var result = dto.NewQuerySetDtoList(querySets) 356 var result = dto.NewQuerySetDtoList(querySets)
363 357
364 - //if err := transactionContext.CommitTransaction(); err != nil {  
365 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
366 - //}  
367 return map[string]interface{}{ 358 return map[string]interface{}{
368 "count": count, 359 "count": count,
369 "querySets": result, 360 "querySets": result,
370 }, nil 361 }, nil
371 } 362 }
372 363
373 -// 更新查询集合服务 364 +// UpdateQuerySet 更新查询集合服务
374 func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) { 365 func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
375 if err := updateQuerySetCommand.ValidateCommand(); err != nil { 366 if err := updateQuerySetCommand.ValidateCommand(); err != nil {
376 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 367 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -396,7 +387,7 @@ func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, upda @@ -396,7 +387,7 @@ func (querySetService *QuerySetService) UpdateQuerySet(ctx *domain.Context, upda
396 return struct{}{}, nil 387 return struct{}{}, nil
397 } 388 }
398 389
399 -// 更新查询集合服务 390 +// RefreshQuerySet 更新查询集合服务
400 func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, updateQuerySetCommand *command.RefreshQuerySetCommand) (interface{}, error) { 391 func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, updateQuerySetCommand *command.RefreshQuerySetCommand) (interface{}, error) {
401 if err := updateQuerySetCommand.ValidateCommand(); err != nil { 392 if err := updateQuerySetCommand.ValidateCommand(); err != nil {
402 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 393 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -426,6 +417,7 @@ func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, upd @@ -426,6 +417,7 @@ func (querySetService *QuerySetService) RefreshQuerySet(ctx *domain.Context, upd
426 return struct{}{}, nil 417 return struct{}{}, nil
427 } 418 }
428 419
  420 +// PreviewPrepare 预览准备
429 func (querySetService *QuerySetService) PreviewPrepare(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) { 421 func (querySetService *QuerySetService) PreviewPrepare(ctx *domain.Context, updateQuerySetCommand *command.UpdateQuerySetCommand) (interface{}, error) {
430 if err := updateQuerySetCommand.ValidateCommand(); err != nil { 422 if err := updateQuerySetCommand.ValidateCommand(); err != nil {
431 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 423 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -455,6 +447,7 @@ func (querySetService *QuerySetService) PreviewPrepare(ctx *domain.Context, upda @@ -455,6 +447,7 @@ func (querySetService *QuerySetService) PreviewPrepare(ctx *domain.Context, upda
455 }, nil 447 }, nil
456 } 448 }
457 449
  450 +// CalculateItemPreview 计算项预览
458 func (querySetService *QuerySetService) CalculateItemPreview(ctx *domain.Context, q *query.CalculateItemPreviewQuery) (interface{}, error) { 451 func (querySetService *QuerySetService) CalculateItemPreview(ctx *domain.Context, q *query.CalculateItemPreviewQuery) (interface{}, error) {
459 if err := q.ValidateQuery(); err != nil { 452 if err := q.ValidateQuery(); err != nil {
460 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 453 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -481,6 +474,7 @@ func (querySetService *QuerySetService) CalculateItemPreview(ctx *domain.Context @@ -481,6 +474,7 @@ func (querySetService *QuerySetService) CalculateItemPreview(ctx *domain.Context
481 }, nil 474 }, nil
482 } 475 }
483 476
  477 +// CalculateItemExport 计算项导出
484 func (querySetService *QuerySetService) CalculateItemExport(ctx *domain.Context, q *query.CalculateItemPreviewQuery) (interface{}, error) { 478 func (querySetService *QuerySetService) CalculateItemExport(ctx *domain.Context, q *query.CalculateItemPreviewQuery) (interface{}, error) {
485 if err := q.ValidateQuery(); err != nil { 479 if err := q.ValidateQuery(); err != nil {
486 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 480 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -31,7 +31,6 @@ func (tableService *TableService) ExportDataTable(ctx *domain.Context, cmd *comm @@ -31,7 +31,6 @@ func (tableService *TableService) ExportDataTable(ctx *domain.Context, cmd *comm
31 }() 31 }()
32 32
33 var table *domain.Table 33 var table *domain.Table
34 - //var mainTable *domain.Table  
35 _, table, err = factory.FastPgTable(transactionContext, cmd.TableId) 34 _, table, err = factory.FastPgTable(transactionContext, cmd.TableId)
36 if err != nil { 35 if err != nil {
37 return nil, factory.FastError(err) 36 return nil, factory.FastError(err)
@@ -92,7 +91,6 @@ func (tableService *TableService) ExportDataTableV2(ctx *domain.Context, cmd *co @@ -92,7 +91,6 @@ func (tableService *TableService) ExportDataTableV2(ctx *domain.Context, cmd *co
92 } 91 }
93 defer locker.Release() 92 defer locker.Release()
94 var table *domain.Table 93 var table *domain.Table
95 - //var mainTable *domain.Table  
96 if cmd.ObjectType == domain.ObjectDBTable { 94 if cmd.ObjectType == domain.ObjectDBTable {
97 table = domain.DBTables[cmd.TableId] 95 table = domain.DBTables[cmd.TableId]
98 if table == nil { 96 if table == nil {
@@ -120,7 +118,6 @@ func exportTableTo(ctx *domain.Context, cmd *command.TablePreviewCommand, table @@ -120,7 +118,6 @@ func exportTableTo(ctx *domain.Context, cmd *command.TablePreviewCommand, table
120 var options = starrocks.QueryOptions{ 118 var options = starrocks.QueryOptions{
121 TableName: table.SQLName, 119 TableName: table.SQLName,
122 Select: table.Fields(false), 120 Select: table.Fields(false),
123 - //Table: table,  
124 } 121 }
125 122
126 db := starrocks.DB 123 db := starrocks.DB
@@ -105,12 +105,6 @@ func (tableService *TableService) RowsDelete(ctx *domain.Context, cmd *command.R @@ -105,12 +105,6 @@ func (tableService *TableService) RowsDelete(ctx *domain.Context, cmd *command.R
105 if err != nil { 105 if err != nil {
106 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 106 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
107 } 107 }
108 - //if err := transactionContext.StartTransaction(); err != nil {  
109 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
110 - //}  
111 - //defer func() {  
112 - // transactionContext.RollbackTransaction()  
113 - //}()  
114 108
115 var table *domain.Table 109 var table *domain.Table
116 _, table, err = factory.FastPgTable(transactionContext, cmd.TableId) 110 _, table, err = factory.FastPgTable(transactionContext, cmd.TableId)
@@ -127,9 +121,6 @@ func (tableService *TableService) RowsDelete(ctx *domain.Context, cmd *command.R @@ -127,9 +121,6 @@ func (tableService *TableService) RowsDelete(ctx *domain.Context, cmd *command.R
127 } 121 }
128 options.SetCondition(cmd.Where.Conditions) 122 options.SetCondition(cmd.Where.Conditions)
129 total, err := starrocks.WrapDeleteFuncWithDB(starrocks.DB)(options) 123 total, err := starrocks.WrapDeleteFuncWithDB(starrocks.DB)(options)
130 - //if err := transactionContext.CommitTransaction(); err != nil {  
131 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
132 - //}  
133 return map[string]interface{}{ 124 return map[string]interface{}{
134 "rowsAffected": total, 125 "rowsAffected": total,
135 }, nil 126 }, nil
@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/query" 11 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/query"
12 "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/domain/astexpr" 13 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/astexpr"
  14 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
14 "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"
15 "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"
16 "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"
@@ -426,6 +427,9 @@ func (tableService *TableService) ApplyOn(ctx *domain.Context, cmd *command.Appl @@ -426,6 +427,9 @@ func (tableService *TableService) ApplyOn(ctx *domain.Context, cmd *command.Appl
426 } else { 427 } else {
427 table.TableInfo.SetApplyOn(cmd.Module) 428 table.TableInfo.SetApplyOn(cmd.Module)
428 } 429 }
  430 + defer func() {
  431 + domainService.AsyncEvent(domain.NewEventTable(ctx, domain.TableApplyOnEvent).WithTable(table).WithMetadata("module", cmd.Module))
  432 + }()
429 if !ctx.Access() { 433 if !ctx.Access() {
430 for i := range cmd.Modules { 434 for i := range cmd.Modules {
431 // 字库应用于数控目前限制在3万条记录以内,在字库的应用于数控按钮上增加判断,如果超过3万条, 435 // 字库应用于数控目前限制在3万条记录以内,在字库的应用于数控按钮上增加判断,如果超过3万条,
@@ -53,8 +53,7 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab @@ -53,8 +53,7 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
53 _, querySets, _ := querySetRepository.Find(map[string]interface{}{"context": searchQuery.Context}) 53 _, querySets, _ := querySetRepository.Find(map[string]interface{}{"context": searchQuery.Context})
54 54
55 var ( 55 var (
56 - querySetMapById = make(map[int]*domain.QuerySet)  
57 - // BindTableId , parentId 56 + querySetMapById = make(map[int]*domain.QuerySet)
58 querySetMapByTableId = make(map[int]*domain.QuerySet) 57 querySetMapByTableId = make(map[int]*domain.QuerySet)
59 ) 58 )
60 if searchQuery.ReturnGroupItem { 59 if searchQuery.ReturnGroupItem {
@@ -154,9 +153,6 @@ func filterTableByFilterRule(item *dto.TableObjectDto, searchQuery *query.Search @@ -154,9 +153,6 @@ func filterTableByFilterRule(item *dto.TableObjectDto, searchQuery *query.Search
154 if rule.TableType == "*" && rule.Status > 0 && rule.Status != item.Status { 153 if rule.TableType == "*" && rule.Status > 0 && rule.Status != item.Status {
155 return true 154 return true
156 } 155 }
157 - //if rule.TableType == rule.TableType && rule.Status > 0 && rule.Status != item.Status {  
158 - // return true  
159 - //}  
160 } 156 }
161 return false 157 return false
162 } 158 }
@@ -14,12 +14,6 @@ var LOG_LEVEL = "debug" @@ -14,12 +14,6 @@ var LOG_LEVEL = "debug"
14 var LOG_FILE = "app.log" 14 var LOG_FILE = "app.log"
15 var PPROF_ON = true 15 var PPROF_ON = true
16 16
17 -//天联共创基础模块  
18 -//var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com"  
19 -  
20 -// 天联共创用户模块  
21 -var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com"  
22 -  
23 var MMM_BYTE_BANK_HOST = "http://220.250.41.79:8301" 17 var MMM_BYTE_BANK_HOST = "http://220.250.41.79:8301"
24 18
25 var METADATA_BASTION_HOST = "http://127.0.0.1:8080" 19 var METADATA_BASTION_HOST = "http://127.0.0.1:8080"
@@ -31,26 +25,14 @@ var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com" @@ -31,26 +25,14 @@ var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com"
31 var OPEN_API_HOST = "http://mmm-open-api-test.fjmaimaimai.com" 25 var OPEN_API_HOST = "http://mmm-open-api-test.fjmaimaimai.com"
32 26
33 // 数控服务域名地址 27 // 数控服务域名地址
34 -var DIGITAL_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com" 28 +var DIGITAL_SERVER_HOST = "http://digitization-server-dev.fjmaimaimai.com"
35 29
36 var BLACK_LIST_USER int64 30 var BLACK_LIST_USER int64
37 var BLACK_LIST_COMPANY int64 31 var BLACK_LIST_COMPANY int64
38 var WHITE_LIST_USERS []int 32 var WHITE_LIST_USERS []int
39 33
40 -//var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384}  
41 -  
42 -//const CUSTOMER_ACCOUNT_DELIMITER = ","  
43 -  
44 -/***** 1.数据传输 *****/  
45 -//const HeaderCompanyId = "companyId"  
46 -//const HeaderUserId = "userId"  
47 -//const HeaderOrgId = "orgId"  
48 -//const HeaderOrgIds = "orgIds"  
49 -  
50 func init() { 34 func init() {
51 LOG_LEVEL = Configurator.DefaultString("LOG_LEVEL", LOG_LEVEL) 35 LOG_LEVEL = Configurator.DefaultString("LOG_LEVEL", LOG_LEVEL)
52 - //ALLIED_CREATION_BASIC_HOST = Configurator.DefaultString("ALLIED_CREATION_BASIC_HOST", ALLIED_CREATION_BASIC_HOST)  
53 - ALLIED_CREATION_USER_HOST = Configurator.DefaultString("ALLIED_CREATION_USER_HOST", ALLIED_CREATION_USER_HOST)  
54 MMM_BYTE_BANK_HOST = Configurator.DefaultString("MMM_BYTE_BANK_HOST", MMM_BYTE_BANK_HOST) 36 MMM_BYTE_BANK_HOST = Configurator.DefaultString("MMM_BYTE_BANK_HOST", MMM_BYTE_BANK_HOST)
55 METADATA_BASTION_HOST = Configurator.DefaultString("METADATA_BASTION_HOST", METADATA_BASTION_HOST) 37 METADATA_BASTION_HOST = Configurator.DefaultString("METADATA_BASTION_HOST", METADATA_BASTION_HOST)
56 BYTE_CORE_HOST = Configurator.DefaultString("BYTE_CORE_HOST", BYTE_CORE_HOST) 38 BYTE_CORE_HOST = Configurator.DefaultString("BYTE_CORE_HOST", BYTE_CORE_HOST)
@@ -3,5 +3,3 @@ package constant @@ -3,5 +3,3 @@ package constant
3 var JWTSecretKey = "digital-platform" 3 var JWTSecretKey = "digital-platform"
4 4
5 var JWTExpiresIn = 60 * 60 * 24 //单位:秒 5 var JWTExpiresIn = 60 * 60 * 24 //单位:秒
6 -  
7 -var JWTCacheExpiresIn = 60 * 60 * 24 //单位:秒  
@@ -25,12 +25,14 @@ type EventTable struct { @@ -25,12 +25,14 @@ type EventTable struct {
25 Type EventType 25 Type EventType
26 Table *Table 26 Table *Table
27 QuerySet *QuerySet 27 QuerySet *QuerySet
  28 + Metadata map[string]interface{}
28 } 29 }
29 30
30 func NewEventTable(ctx *Context, t EventType) *EventTable { 31 func NewEventTable(ctx *Context, t EventType) *EventTable {
31 return &EventTable{ 32 return &EventTable{
32 - Context: ctx,  
33 - Type: t, 33 + Context: ctx,
  34 + Type: t,
  35 + Metadata: make(map[string]interface{}),
34 } 36 }
35 } 37 }
36 func (et *EventTable) WithContext(t *Context) *EventTable { 38 func (et *EventTable) WithContext(t *Context) *EventTable {
@@ -52,11 +54,17 @@ func (et *EventTable) WithQuerySet(t *QuerySet) *EventTable { @@ -52,11 +54,17 @@ func (et *EventTable) WithQuerySet(t *QuerySet) *EventTable {
52 return et 54 return et
53 } 55 }
54 56
  57 +func (et *EventTable) WithMetadata(key string, values interface{}) *EventTable {
  58 + et.Metadata[key] = values
  59 + return et
  60 +}
  61 +
55 func (et *EventTable) ResolveEvent(e event.Event) { 62 func (et *EventTable) ResolveEvent(e event.Event) {
56 et.Context = e.Get("Context").(*Context) 63 et.Context = e.Get("Context").(*Context)
57 et.Type = e.Get("Type").(EventType) 64 et.Type = e.Get("Type").(EventType)
58 et.Table = e.Get("Table").(*Table) 65 et.Table = e.Get("Table").(*Table)
59 et.QuerySet = e.Get("QuerySet").(*QuerySet) 66 et.QuerySet = e.Get("QuerySet").(*QuerySet)
  67 + et.Metadata = e.Get("Metadata").(map[string]interface{})
60 } 68 }
61 69
62 func (et *EventTable) FireEvent() event.Event { 70 func (et *EventTable) FireEvent() event.Event {
@@ -65,5 +73,6 @@ func (et *EventTable) FireEvent() event.Event { @@ -65,5 +73,6 @@ func (et *EventTable) FireEvent() event.Event {
65 e["Type"] = et.Type 73 e["Type"] = et.Type
66 e["Table"] = et.Table 74 e["Table"] = et.Table
67 e["QuerySet"] = et.QuerySet 75 e["QuerySet"] = et.QuerySet
  76 + e["Metadata"] = et.Metadata
68 return event.MustFire(et.Type.ToString(), e) 77 return event.MustFire(et.Type.ToString(), e)
69 } 78 }
@@ -93,12 +93,10 @@ func (file *File) CopyTo(fileType FileType, ctx *Context) *File { @@ -93,12 +93,10 @@ func (file *File) CopyTo(fileType FileType, ctx *Context) *File {
93 } 93 }
94 94
95 func (file *File) SetHeaderRow(headerRow int) *File { 95 func (file *File) SetHeaderRow(headerRow int) *File {
96 - //file.FileInfo.HeaderRow = headerRow  
97 return file 96 return file
98 } 97 }
99 98
100 func (file *File) SetContext(context *Context) *File { 99 func (file *File) SetContext(context *Context) *File {
101 - //file.FileInfo.HeaderRow = headerRow  
102 file.Context = context 100 file.Context = context
103 return file 101 return file
104 } 102 }
@@ -17,6 +17,6 @@ func AsyncEvent(e *domain.EventTable) { @@ -17,6 +17,6 @@ func AsyncEvent(e *domain.EventTable) {
17 e.FireEvent() 17 e.FireEvent()
18 }() 18 }()
19 log.Logger.Info("开始事件..." + e.Type.ToString()) 19 log.Logger.Info("开始事件..." + e.Type.ToString())
20 - time.Sleep(time.Millisecond * 400) 20 + time.Sleep(time.Millisecond * 10)
21 log.Logger.Info("结束事件..." + e.Type.ToString()) 21 log.Logger.Info("结束事件..." + e.Type.ToString())
22 } 22 }
@@ -960,7 +960,7 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st @@ -960,7 +960,7 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st
960 } 960 }
961 961
962 defer func() { 962 defer func() {
963 - AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateStatusEvent).WithTable(table).WithQuerySet(qs)) 963 + AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateStatusEvent).WithTable(table).WithQuerySet(qs).WithMetadata("status", status))
964 }() 964 }()
965 } 965 }
966 return nil 966 return nil
@@ -1079,6 +1079,7 @@ func (ptr *QuerySetService) Delete(ctx *domain.Context, querySetId int) error { @@ -1079,6 +1079,7 @@ func (ptr *QuerySetService) Delete(ctx *domain.Context, querySetId int) error {
1079 } 1079 }
1080 starrocks.DropView(starrocks.DB, t.SQLName) 1080 starrocks.DropView(starrocks.DB, t.SQLName)
1081 } 1081 }
  1082 + AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetDeleteEvent).WithQuerySet(querySets[i]).WithTable(t))
1082 } 1083 }
1083 } 1084 }
1084 // 2.底层清理 1085 // 2.底层清理
@@ -73,6 +73,7 @@ func (ptr *DeleteDataTableService) DeleteTables(ctx *domain.Context, tables ...* @@ -73,6 +73,7 @@ func (ptr *DeleteDataTableService) DeleteTables(ctx *domain.Context, tables ...*
73 if _, err := tableRepository.Remove(t); err != nil { 73 if _, err := tableRepository.Remove(t); err != nil {
74 return err 74 return err
75 } 75 }
  76 + AsyncEvent(domain.NewEventTable(ctx, domain.TableDeleteEvent).WithTable(t))
76 tableIds = append(tableIds, t.TableId) 77 tableIds = append(tableIds, t.TableId)
77 } 78 }
78 // delete log 79 // delete log
@@ -330,6 +330,9 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT @@ -330,6 +330,9 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT
330 Edges: make([]TableEdge, 0), 330 Edges: make([]TableEdge, 0),
331 Tree: tree, 331 Tree: tree,
332 } 332 }
  333 + if len(tree) == 0 || tableMap == nil {
  334 + return dependTree
  335 + }
333 336
334 for _, node := range tree { 337 for _, node := range tree {
335 t, ok := tableMap[node] 338 t, ok := tableMap[node]
@@ -348,11 +351,14 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT @@ -348,11 +351,14 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT
348 return dependTree 351 return dependTree
349 } 352 }
350 func NewTableNode(table *domain.Table) TableNode { 353 func NewTableNode(table *domain.Table) TableNode {
  354 + if table == nil {
  355 + return TableNode{}
  356 + }
351 return TableNode{ 357 return TableNode{
352 TableId: table.TableId, 358 TableId: table.TableId,
353 Type: table.TableType, 359 Type: table.TableType,
354 Name: table.Name, 360 Name: table.Name,
355 - DependencyTables: table.TableInfo.DependencyTables, 361 + DependencyTables: table.DependencyTables(),
356 } 362 }
357 } 363 }
358 func NewTableEdge(table *domain.Table, dependTable *domain.Table) TableEdge { 364 func NewTableEdge(table *domain.Table, dependTable *domain.Table) TableEdge {
@@ -57,11 +57,6 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi @@ -57,11 +57,6 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi
57 if err = starrocks.BatchDelete(starrocks.DB, table.SQLName, request.RemoveList); err != nil { 57 if err = starrocks.BatchDelete(starrocks.DB, table.SQLName, request.RemoveList); err != nil {
58 return nil, err 58 return nil, err
59 } 59 }
60 - //for _, l := range request.RemoveList {  
61 - // if e := ptr.remove(ctx, table, l, request.Where); e != nil {  
62 - // log.Logger.Error(e.Error())  
63 - // }  
64 - //}  
65 } 60 }
66 for _, l := range request.UpdateList { 61 for _, l := range request.UpdateList {
67 if e := ptr.update(ctx, table, l, request.Where); e != nil { 62 if e := ptr.update(ctx, table, l, request.Where); e != nil {
@@ -80,13 +80,6 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl @@ -80,13 +80,6 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl
80 if _, err = ByteCore.SplitTable(domain.ReqSplitTable{FromTable: mainTable, ToSubTable: table}); err != nil { 80 if _, err = ByteCore.SplitTable(domain.ReqSplitTable{FromTable: mainTable, ToSubTable: table}); err != nil {
81 return nil, err 81 return nil, err
82 } 82 }
83 - //var tablesAffected []TableNode  
84 - //if len(adds) > 0 {  
85 - // tablesAffected, _ = DependencyTables(ptr.transactionContext, ctx, tableId)  
86 - //}  
87 - //return map[string]interface{}{  
88 - // "tablesAffected": tablesAffected,  
89 - //}, nil  
90 return struct{}{}, nil 83 return struct{}{}, nil
91 } 84 }
92 85
@@ -140,29 +133,6 @@ func DependencyTables(ptr *pgTransaction.TransactionContext, context *domain.Con @@ -140,29 +133,6 @@ func DependencyTables(ptr *pgTransaction.TransactionContext, context *domain.Con
140 return ret, nil 133 return ret, nil
141 } 134 }
142 135
143 -//func MappingFields(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {  
144 -// tableFields := mainTable.Fields(false)  
145 -// tableFieldsMap := (domain.Fields)(tableFields).ToMap()  
146 -// for i := range fields {  
147 -// f := fields[i]  
148 -// if v, ok := tableFieldsMap[f.Name]; ok {  
149 -// fields[i].Name = v.Name  
150 -// fields[i].SQLName = v.SQLName  
151 -// fields[i].Index = v.Index  
152 -// fields[i].SQLType = v.SQLType  
153 -// fields[i].Description = f.Description  
154 -// fields[i].Flag = v.Flag  
155 -// } else {  
156 -// if f.Flag == domain.ManualField && f.Index == 0 {  
157 -// mainTable.DataFieldIndex += 1  
158 -// fields[i] = DataField(f.Name, f.SQLType, domain.ManualField, mainTable.DataFieldIndex)  
159 -// fields[i].Description = f.Description  
160 -// }  
161 -// }  
162 -// }  
163 -// return fields  
164 -//}  
165 -  
166 func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.Field { 136 func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {
167 tableFields := mainTable.Fields(false) 137 tableFields := mainTable.Fields(false)
168 tableFieldsMap := (domain.Fields)(tableFields).ToMap() 138 tableFieldsMap := (domain.Fields)(tableFields).ToMap()
@@ -179,7 +149,6 @@ func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain. @@ -179,7 +149,6 @@ func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.
179 builder.NewDataField(v.Name, v.SQLType, v.Flag) 149 builder.NewDataField(v.Name, v.SQLType, v.Flag)
180 } else { 150 } else {
181 if f.Flag == domain.ManualField { 151 if f.Flag == domain.ManualField {
182 - //mainTable.DataFieldIndex += 1  
183 fields[i] = builder.NewDataField(f.Name, f.SQLType, domain.ManualField) 152 fields[i] = builder.NewDataField(f.Name, f.SQLType, domain.ManualField)
184 fields[i].Description = f.Description 153 fields[i].Description = f.Description
185 } 154 }
@@ -16,4 +16,6 @@ func RegisterEvent() { @@ -16,4 +16,6 @@ func RegisterEvent() {
16 event.On(domain.QuerySetUpdateEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) 16 event.On(domain.QuerySetUpdateEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
17 event.On(domain.QuerySetUpdateRenameEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) 17 event.On(domain.QuerySetUpdateRenameEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
18 event.On(domain.QuerySetUpdateStatusEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) 18 event.On(domain.QuerySetUpdateStatusEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
  19 + event.On(domain.TableApplyOnEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
  20 + event.On(domain.QuerySetDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
19 } 21 }