作者 yangfu

Merge branch 'test'

正在显示 42 个修改的文件 包含 454 行增加250 行删除
@@ -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 }
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 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "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"
7 "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"
8 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
9 - "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache" 11 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/digitalLib"
10 "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"
  13 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
  14 + "math"
  15 + "time"
11 ) 16 )
12 17
13 func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) { 18 func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) {
@@ -15,12 +20,12 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -15,12 +20,12 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
15 if err != nil { 20 if err != nil {
16 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 21 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
17 } 22 }
18 - //if err := transactionContext.StartTransaction(); err != nil {  
19 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
20 - //}  
21 - //defer func() {  
22 - // transactionContext.RollbackTransaction()  
23 - //}() 23 + if err := transactionContext.StartTransaction(); err != nil {
  24 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  25 + }
  26 + defer func() {
  27 + transactionContext.RollbackTransaction()
  28 + }()
24 29
25 var ( 30 var (
26 dataChanged = true 31 dataChanged = true
@@ -31,29 +36,54 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -31,29 +36,54 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
31 tableId := 0 36 tableId := 0
32 switch data.Type { 37 switch data.Type {
33 case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent: 38 case domain.TableDataImportEvent, domain.TableDataEditEvent, domain.TableDeleteEvent:
34 - // dataChanged = true  
35 tableId = data.Table.TableId 39 tableId = data.Table.TableId
36 - case domain.QuerySetUpdateEvent: 40 + case domain.QuerySetUpdateEvent, domain.QuerySetUpdateRenameEvent:
37 tableId = data.QuerySet.QuerySetInfo.BindTableId 41 tableId = data.QuerySet.QuerySetInfo.BindTableId
38 - // structChanged = true 42 + if data.QuerySet.Status != domain.StatusOn {
  43 + return nil, nil
  44 + }
  45 + if !domain.AssertTableType(data.QuerySet.Type, domain.SchemaTable, domain.CalculateItem, domain.CalculateSet) {
  46 + return nil, nil
  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
39 } 58 }
40 if tableId == 0 { 59 if tableId == 0 {
41 return nil, nil 60 return nil, nil
42 } 61 }
43 - var notifyData = struct {  
44 - DataChanged bool `json:"dataChanged"`  
45 - StructChanged bool `json:"structChanged"`  
46 - TableId int `json:"tableId"`  
47 - Event string `json:"event"`  
48 - TableAffectedList []int `json:"tableAffectedList"`  
49 - }{ 62 + var notifyData = NotifyData{
50 DataChanged: dataChanged, 63 DataChanged: dataChanged,
51 StructChanged: structChanged, 64 StructChanged: structChanged,
52 TableId: tableId, 65 TableId: tableId,
53 Event: data.Type.ToString(), 66 Event: data.Type.ToString(),
  67 + Metadata: cmd.EventTable.Metadata,
54 } 68 }
55 // tableId 相关联的 69 // tableId 相关联的
56 - tableRepository, _, _ := factory.FastPgTable(transactionContext, 0) 70 + tableRepository, table, _ := factory.FastPgTable(transactionContext, tableId)
  71 + if table == nil && data.Table != nil {
  72 + table = data.Table
  73 + notifyData.CompanyId = table.Context.CompanyId
  74 + }
  75 + if table != nil {
  76 + notifyData.TableType = domain.EnumsDescription(domain.ObjectTypeMap, table.TableType)
  77 + switch domain.TableType(table.TableType) {
  78 + case domain.MainTable, domain.SubTable, domain.SideTable:
  79 + notifyData.ObjectType = "导入模块"
  80 + case domain.SchemaTable, domain.SubProcessTable, domain.CalculateTable:
  81 + notifyData.ObjectType = "拆解模块"
  82 + case domain.CalculateItem, domain.CalculateSet:
  83 + notifyData.ObjectType = "计算模块"
  84 + }
  85 + }
  86 +
57 _, tables, err := tableRepository.Find(map[string]interface{}{"context": data.Context, "tableTypesNotIn": []string{domain.TemporaryTable.ToString(), domain.ExcelTable.ToString()}}) 87 _, tables, err := tableRepository.Find(map[string]interface{}{"context": data.Context, "tableTypesNotIn": []string{domain.TemporaryTable.ToString(), domain.ExcelTable.ToString()}})
58 if err != nil { 88 if err != nil {
59 return nil, err 89 return nil, err
@@ -63,22 +93,103 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d @@ -63,22 +93,103 @@ func (tableEventService *TableEventService) DigitalPlatformEventSubscribe(ctx *d
63 tableDependTree := tableDependencyService.TableDependTree(tables, tableId) 93 tableDependTree := tableDependencyService.TableDependTree(tables, tableId)
64 tree := tableDependTree.Tree 94 tree := tableDependTree.Tree
65 95
66 - //tableService := tableservice.NewTableService(nil) 96 + querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0)
  97 + var mapTableQuerySet = make(map[int]*domain.QuerySet)
  98 + if len(tree) > 0 && cmd.EventTable.QuerySet != nil {
  99 + _, querySets, _ := querySetRepository.Find(map[string]interface{}{
  100 + "types": []string{domain.SchemaTable.ToString(), domain.CalculateItem.ToString(), domain.CalculateSet.ToString()},
  101 + "bindTableIds": tree,
  102 + "status": domain.StatusOn,
  103 + })
  104 + for _, q := range querySets {
  105 + mapTableQuerySet[q.QuerySetInfo.BindTableId] = q
  106 + }
  107 + }
  108 +
67 for i := range tree { 109 for i := range tree {
68 - cache.DefaultDataTableCacheService.DeleteDataTable(tree[i])  
69 - // fresh cache  
70 - //tableService.TablePreview(data.Context, &tablecommand.TablePreviewCommand{  
71 - // TableId: tree[i],  
72 - // ObjectType: domain.ObjectMetaTable,  
73 - // PageSize: 10000,  
74 - // PageNumber: 0,  
75 - // UseCache: true,  
76 - //}) 110 + table, ok := tableDependencyService.TableMap[tree[i]]
  111 + if !ok {
  112 + continue
  113 + }
  114 + if notifyData.CompanyId == 0 {
  115 + notifyData.CompanyId = table.Context.CompanyId
  116 + }
  117 + switch table.TableType {
  118 + case domain.MainTable.ToString(), domain.SubTable.ToString(), domain.SideTable.ToString():
  119 + if table.TableInfo != nil && table.TableInfo.ApplyOnModule&domain.ModuleDigitalCenter == 0 {
  120 + continue
  121 + }
  122 + break
  123 + case domain.SubProcessTable.ToString(), domain.CalculateTable.ToString():
  124 + continue
  125 + case domain.SchemaTable.ToString(), domain.CalculateSet.ToString(), domain.CalculateItem.ToString():
  126 + if querySet, ok := mapTableQuerySet[tree[i]]; !ok {
  127 + continue
  128 + } else {
  129 + // 不是当前的查询集。且状态为关闭的都补推送
  130 + if querySet.Status != domain.StatusOn && querySet.QuerySetInfo.BindTableId != 0 && querySet.QuerySetInfo.BindTableId != tableId {
  131 + continue
  132 + }
  133 + }
  134 + }
77 notifyData.TableAffectedList = append(notifyData.TableAffectedList, tree[i]) 135 notifyData.TableAffectedList = append(notifyData.TableAffectedList, tree[i])
78 } 136 }
  137 + found := false
  138 + for _, id := range notifyData.TableAffectedList {
  139 + if id == tableId {
  140 + found = true
  141 + }
  142 + }
  143 + if !found {
  144 + notifyData.TableAffectedList = append(notifyData.TableAffectedList, tableId)
  145 + }
  146 + lib := digitalLib.NewDigitalLib(constant.DIGITAL_SERVER_HOST)
  147 + if _, err = lib.SyncNotice(digitalLib.RequestSyncNotice{Body: notifyData}); err != nil {
  148 + log.Logger.Error(fmt.Sprintf("通知数控失败:%s", err.Error()))
  149 + if t, ok := notifyData.Retry(); ok {
  150 + tableEventService.TimingWheel.SetTimer(notifyData.Key(), &notifyData, t)
  151 + log.Logger.Debug(fmt.Sprintf("通知数控重试 key:%s wait:%vs", notifyData.Key(), t.Seconds()))
  152 + }
79 153
80 - //if err := transactionContext.CommitTransaction(); err != nil {  
81 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
82 - //} 154 + }
  155 + if err := transactionContext.CommitTransaction(); err != nil {
  156 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  157 + }
83 return nil, nil 158 return nil, nil
84 } 159 }
  160 +
  161 +type NotifyData struct {
  162 + DataChanged bool `json:"dataChanged"` // 数据有变化
  163 + StructChanged bool `json:"structChanged"` // 结构有变化
  164 + TableId int `json:"tableId"` // 表ID
  165 + TableType string `json:"tableType"` // 表类型:导入模块(主表,副表,分表) 拆解模块(方案、子过程、计算表) 计算模块(计算项,计算集)
  166 + ObjectType string `json:"objectType"` // 导入模块、拆解模块、计算模块
  167 + CompanyId int `json:"companyId"` // 公司
  168 + Event string `json:"event"` // 事件名称
  169 + TableAffectedList []int `json:"tableAffectedList"` // 级联影响到的表
  170 + Metadata map[string]interface{} `json:"metadata"` // 元数据
  171 + sendRetry int
  172 +}
  173 +
  174 +func (n *NotifyData) Key() string {
  175 + return fmt.Sprintf("delay:notify:table:%d", n.TableId)
  176 +}
  177 +
  178 +func (n *NotifyData) Retry() (time.Duration, bool) {
  179 + n.sendRetry++
  180 + if n.sendRetry > 3 {
  181 + return n.Delay(), false
  182 + }
  183 + if n.sendRetry == 1 {
  184 + return n.Delay(), true
  185 + }
  186 + return n.Delay() * time.Duration(int(math.Pow(float64(2), float64(n.sendRetry)))), true
  187 +}
  188 +
  189 +func (n *NotifyData) Delay() time.Duration {
  190 + return time.Second * 10
  191 +}
  192 +
  193 +func (n *NotifyData) RetryTime() int {
  194 + return n.sendRetry
  195 +}
@@ -5,17 +5,21 @@ import ( @@ -5,17 +5,21 @@ import (
5 "fmt" 5 "fmt"
6 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 + "github.com/zeromicro/go-zero/core/collection"
8 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command" 9 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/event/command"
9 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
10 tablecommand "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" 11 tablecommand "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command"
11 tableservice "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/service" 12 tableservice "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/service"
12 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" 13 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
  14 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/digitalLib"
13 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache" 15 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/cache"
14 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" 16 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService"
15 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" 17 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
  18 + "time"
16 ) 19 )
17 20
18 type TableEventService struct { 21 type TableEventService struct {
  22 + TimingWheel *collection.TimingWheel
19 } 23 }
20 24
21 func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) { 25 func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *command.TableEventCommand) (interface{}, error) {
@@ -37,6 +41,8 @@ func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *co @@ -37,6 +41,8 @@ func (tableEventService *TableEventService) Handler(ctx *domain.Context, cmd *co
37 tableId = data.Table.TableId 41 tableId = data.Table.TableId
38 case domain.QuerySetUpdateEvent: 42 case domain.QuerySetUpdateEvent:
39 tableId = data.QuerySet.QuerySetInfo.BindTableId 43 tableId = data.QuerySet.QuerySetInfo.BindTableId
  44 + default:
  45 + return nil, err
40 } 46 }
41 if tableId == 0 { 47 if tableId == 0 {
42 return nil, nil 48 return nil, nil
@@ -129,5 +135,25 @@ func (tableEventService *TableEventService) HandlerTableAffectedMarkToConflictSt @@ -129,5 +135,25 @@ func (tableEventService *TableEventService) HandlerTableAffectedMarkToConflictSt
129 135
130 func NewTableEventService(options map[string]interface{}) *TableEventService { 136 func NewTableEventService(options map[string]interface{}) *TableEventService {
131 svr := &TableEventService{} 137 svr := &TableEventService{}
  138 + delayNotifyTimingWheel, _ := collection.NewTimingWheel(time.Second, 10, svr.TimingWheelFunc)
  139 + svr.TimingWheel = delayNotifyTimingWheel
132 return svr 140 return svr
133 } 141 }
  142 +
  143 +func (tableEventService *TableEventService) TimingWheelFunc(key, value interface{}) {
  144 + v, ok := value.(*NotifyData)
  145 + if !ok {
  146 + return
  147 + }
  148 + lib := digitalLib.NewDigitalLib("")
  149 + if _, err := lib.SyncNotice(digitalLib.RequestSyncNotice{Body: v}); err != nil {
  150 + log.Logger.Error(fmt.Sprintf("通知数控失败:%s", err.Error()))
  151 + if t, ok := v.Retry(); ok {
  152 + if err = tableEventService.TimingWheel.SetTimer(v.Key(), v, t); err == nil {
  153 + log.Logger.Debug(fmt.Sprintf("通知数控重试(%d) key:%s wait:%vs", v.RetryTime(), v.Key(), t.Seconds()))
  154 + return
  155 + }
  156 + }
  157 + }
  158 + tableEventService.TimingWheel.RemoveTimer(v.Key())
  159 +}
@@ -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万条,
@@ -54,7 +54,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab @@ -54,7 +54,6 @@ func (tableService *TableService) TableObjectSearch(searchQuery *query.SearchTab
54 54
55 var ( 55 var (
56 querySetMapById = make(map[int]*domain.QuerySet) 56 querySetMapById = make(map[int]*domain.QuerySet)
57 - // BindTableId , parentId  
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 }
@@ -38,7 +38,7 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command @@ -38,7 +38,7 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command
38 cacheMiss = true 38 cacheMiss = true
39 } 39 }
40 } 40 }
41 - response := &dto.TablePreviewDto{HiddenData: cmd.HiddenData} 41 + response := &dto.TablePreviewDto{HiddenData: cmd.HiddenData, TableType: table.TableType, Name: table.Name, TableId: table.TableId}
42 if dataTable == nil { 42 if dataTable == nil {
43 switch table.TableType { 43 switch table.TableType {
44 case domain.CalculateSet.ToString(): 44 case domain.CalculateSet.ToString():
@@ -52,8 +52,9 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command @@ -52,8 +52,9 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command
52 if err != nil { 52 if err != nil {
53 return nil, factory.FastError(err) 53 return nil, factory.FastError(err)
54 } 54 }
  55 + data, total := dataTable.FilterByWhere(cmd.Where)
55 response.Fields = dataTable.Fields 56 response.Fields = dataTable.Fields
56 - response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, pageData(cmd.Where.PageNumber, cmd.Where.PageSize, dataTable.Data), false), int64(len(dataTable.Data))) 57 + response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, data, false), total)
57 default: 58 default:
58 var options = starrocks.QueryOptions{ 59 var options = starrocks.QueryOptions{
59 Table: table, 60 Table: table,
@@ -76,8 +77,9 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command @@ -76,8 +77,9 @@ func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command
76 } else { 77 } else {
77 switch table.TableType { 78 switch table.TableType {
78 case domain.CalculateSet.ToString(): 79 case domain.CalculateSet.ToString():
  80 + data, total := dataTable.FilterByWhere(cmd.Where)
79 response.Fields = dataTable.Fields 81 response.Fields = dataTable.Fields
80 - response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, pageData(cmd.Where.PageNumber, cmd.Where.PageSize, dataTable.Data), false), int64(len(dataTable.Data))) 82 + response.Data = domain.GripData(domain.ToFieldData(dataTable.Fields, data, false), total)
81 default: 83 default:
82 response.Load(table, dataTable, domain.ObjectMetaTable) 84 response.Load(table, dataTable, domain.ObjectMetaTable)
83 } 85 }
@@ -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"
@@ -30,31 +24,21 @@ var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com" @@ -30,31 +24,21 @@ var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com"
30 24
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
  27 +// 数控服务域名地址
  28 +var DIGITAL_SERVER_HOST = "http://digitization-server-dev.fjmaimaimai.com"
  29 +
33 var BLACK_LIST_USER int64 30 var BLACK_LIST_USER int64
34 var BLACK_LIST_COMPANY int64 31 var BLACK_LIST_COMPANY int64
35 var WHITE_LIST_USERS []int 32 var WHITE_LIST_USERS []int
36 33
37 -//var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384}  
38 -  
39 -//const CUSTOMER_ACCOUNT_DELIMITER = ","  
40 -  
41 -/***** 1.数据传输 *****/  
42 -//const HeaderCompanyId = "companyId"  
43 -//const HeaderUserId = "userId"  
44 -//const HeaderOrgId = "orgId"  
45 -//const HeaderOrgIds = "orgIds"  
46 -  
47 func init() { 34 func init() {
48 LOG_LEVEL = Configurator.DefaultString("LOG_LEVEL", LOG_LEVEL) 35 LOG_LEVEL = Configurator.DefaultString("LOG_LEVEL", LOG_LEVEL)
49 - //ALLIED_CREATION_BASIC_HOST = Configurator.DefaultString("ALLIED_CREATION_BASIC_HOST", ALLIED_CREATION_BASIC_HOST)  
50 - ALLIED_CREATION_USER_HOST = Configurator.DefaultString("ALLIED_CREATION_USER_HOST", ALLIED_CREATION_USER_HOST)  
51 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)
52 METADATA_BASTION_HOST = Configurator.DefaultString("METADATA_BASTION_HOST", METADATA_BASTION_HOST) 37 METADATA_BASTION_HOST = Configurator.DefaultString("METADATA_BASTION_HOST", METADATA_BASTION_HOST)
53 BYTE_CORE_HOST = Configurator.DefaultString("BYTE_CORE_HOST", BYTE_CORE_HOST) 38 BYTE_CORE_HOST = Configurator.DefaultString("BYTE_CORE_HOST", BYTE_CORE_HOST)
54 SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV) 39 SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV)
55 HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT) 40 HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT)
56 AUTH_SERVER_HOST = Configurator.DefaultString("AUTH_SERVER_HOST", AUTH_SERVER_HOST) 41 AUTH_SERVER_HOST = Configurator.DefaultString("AUTH_SERVER_HOST", AUTH_SERVER_HOST)
57 - OPEN_API_HOST = Configurator.DefaultString("OPEN_API_HOST", OPEN_API_HOST)  
58 SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV) 42 SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV)
59 PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON) 43 PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON)
60 CACHE_PREFIX = SERVICE_NAME + ":" + SERVICE_ENV 44 CACHE_PREFIX = SERVICE_NAME + ":" + SERVICE_ENV
@@ -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 //单位:秒  
1 package domain 1 package domain
2 2
3 type ByteLibService interface { 3 type ByteLibService interface {
  4 + // LoadDataTable 加载表数据
4 LoadDataTable(param ReqLoadDataTable) (*DataLoadDataTable, error) 5 LoadDataTable(param ReqLoadDataTable) (*DataLoadDataTable, error)
  6 + // EditTable 编辑表结构(列重名,类型修改,列拆分 ...)
5 EditTable(param ReqEditDataTable) (*DataEditDataTable, error) 7 EditTable(param ReqEditDataTable) (*DataEditDataTable, error)
  8 + // SaveTable 编辑后进行表结构保存(底层生成一份新的excel文件)
6 SaveTable(param ReqSaveTable) (*DataSaveTable, error) 9 SaveTable(param ReqSaveTable) (*DataSaveTable, error)
  10 + // GenerateTable 生成表 (主表)
7 GenerateTable(ctx *Context, param ReqGenerateTable) (*DataGenerateTable, error) 11 GenerateTable(ctx *Context, param ReqGenerateTable) (*DataGenerateTable, error)
  12 + // CopyTable 复制表
8 CopyTable(param ReqCopyTable) (*DataCopyTable, error) 13 CopyTable(param ReqCopyTable) (*DataCopyTable, error)
  14 + // AppendData 追加数据到指定表
9 AppendData(param ReqAppendData) (*DataAppendData, error) 15 AppendData(param ReqAppendData) (*DataAppendData, error)
  16 + // SplitTable 拆分表 (分表)
10 SplitTable(param ReqSplitTable) (*DataSplitTable, error) 17 SplitTable(param ReqSplitTable) (*DataSplitTable, error)
  18 + // DeleteTable 删除表
11 DeleteTable(param ReqDeleteTable) (*DataDeleteTable, error) 19 DeleteTable(param ReqDeleteTable) (*DataDeleteTable, error)
  20 + // CancelFile 取消对表的操作
12 CancelFile(param ReqCancelFile) (*DataCancelFile, error) 21 CancelFile(param ReqCancelFile) (*DataCancelFile, error)
  22 + // EditTableData 编辑表数据
13 EditTableData(param ReqEditTableData) (*DataEditTableData, error) 23 EditTableData(param ReqEditTableData) (*DataEditTableData, error)
  24 + // FieldOptionalValues 字段可选值
14 FieldOptionalValues(param ReqFieldOptionalValues) (*DataFieldOptionalValues, error) 25 FieldOptionalValues(param ReqFieldOptionalValues) (*DataFieldOptionalValues, error)
  26 + // FormulasGenerate 表达式生成 (底层生成视图)
15 FormulasGenerate(param ReqFormulasGenerate) (*DataFormulasGenerate, error) 27 FormulasGenerate(param ReqFormulasGenerate) (*DataFormulasGenerate, error)
  28 + // FormulasClear 表达式清除
16 FormulasClear(param ReqFormulasClear) (*DataFormulasClear, error) 29 FormulasClear(param ReqFormulasClear) (*DataFormulasClear, error)
17 } 30 }
18 31
1 package domain 1 package domain
2 2
3 -import "strings" 3 +import (
  4 + "strings"
  5 +)
4 6
5 type DataTable struct { 7 type DataTable struct {
6 Fields []*Field `json:"fields"` 8 Fields []*Field `json:"fields"`
@@ -113,7 +115,81 @@ func (t *DataTable) MatchFields(from []*Field) []*Field { @@ -113,7 +115,81 @@ func (t *DataTable) MatchFields(from []*Field) []*Field {
113 return from 115 return from
114 } 116 }
115 117
  118 +func (t *DataTable) FilterByWhere(where Where) (response [][]string, length int64) {
  119 + pageNumber, pageSize := where.PageNumber, where.PageSize
  120 + response = make([][]string, 0)
  121 + wrapperFilters := func(data []string, next ...func([]string) bool) ([]string, bool) {
  122 + ok := true
  123 + for i := range next {
  124 + if !next[i](data) {
  125 + ok = false
  126 + }
  127 + if !ok {
  128 + break
  129 + }
  130 + }
  131 + if !ok {
  132 + return nil, false
  133 + }
  134 + return data, true
  135 + }
  136 + filterFuncList := make([]func([]string) bool, 0)
  137 + for _, c := range where.Conditions {
  138 + var index = 0
  139 + var filed *Field
  140 + for i, f := range t.Fields {
  141 + if f.Name == c.Field.Name {
  142 + index = i
  143 + filed = f
  144 + break
  145 + }
  146 + }
  147 + if filed == nil {
  148 + continue
  149 + }
  150 + if len(c.In) > 0 {
  151 + filterFuncList = append(filterFuncList, WithInFilter(c.In, index))
  152 + }
  153 + }
  154 + for _, data := range t.Data {
  155 + if v, ok := wrapperFilters(data, filterFuncList...); ok {
  156 + response = append(response, v)
  157 + }
  158 + }
  159 + length = int64(len(response))
  160 + response = pageData(pageNumber, pageSize, response)
  161 + return
  162 +}
  163 +
116 type RangStruct struct { 164 type RangStruct struct {
117 Op string `json:"op"` 165 Op string `json:"op"`
118 Val interface{} `json:"val"` 166 Val interface{} `json:"val"`
119 } 167 }
  168 +
  169 +func pageData(pageNumber, pageSize int, data [][]string) [][]string {
  170 + if pageNumber == 0 || pageSize == 0 {
  171 + return data
  172 + }
  173 + offset := (pageNumber - 1) * pageSize
  174 + if len(data) < offset {
  175 + return [][]string{}
  176 + }
  177 + if len(data) < offset+pageSize {
  178 + pageSize = len(data) - offset
  179 + }
  180 + return data[offset : offset+pageSize]
  181 +}
  182 +
  183 +func WithInFilter(in []interface{}, index int) func(data []string) bool {
  184 + return func(data []string) bool {
  185 + if len(data) < index {
  186 + return false
  187 + }
  188 + for _, item := range in {
  189 + if data[index] == item.(string) {
  190 + return true
  191 + }
  192 + }
  193 + return false
  194 + }
  195 +}
1 package domain 1 package domain
2 2
  3 +// FileTableService 文件表服务(导入模块)
3 type FileTableService interface { 4 type FileTableService interface {
  5 + // Preview 预览(Excel文件)
4 Preview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error) 6 Preview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error)
  7 + // Edit 编辑表
5 Edit() 8 Edit()
  9 + // Flush 保存编辑状态的表元数据
6 Flush(ctx *Context, fileId int, table *Table) (interface{}, error) 10 Flush(ctx *Context, fileId int, table *Table) (interface{}, error)
  11 + // DeleteFiles 批量删除文件
7 DeleteFiles(ctx *Context, files ...*File) error 12 DeleteFiles(ctx *Context, files ...*File) error
  13 + // GenerateTable 生成主表
8 GenerateTable(ctx *Context, fileId int, tableName string) (interface{}, error) 14 GenerateTable(ctx *Context, fileId int, tableName string) (interface{}, error)
9 } 15 }
10 16
  17 +// TableService 表服务
11 type TableService interface { 18 type TableService interface {
  19 + // Preview 预览
12 Preview(ctx *Context, tableId int, where Where) (interface{}, error) 20 Preview(ctx *Context, tableId int, where Where) (interface{}, error)
  21 + // CopyTable 拷贝表
13 CopyTable(ctx *Context, tableId int, tableName string) (interface{}, error) 22 CopyTable(ctx *Context, tableId int, tableName string) (interface{}, error)
  23 + // DeleteTables 删除表
14 DeleteTables(ctx *Context, tables ...*Table) error 24 DeleteTables(ctx *Context, tables ...*Table) error
  25 + // AppendData 追加表数据
15 AppendData(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error) 26 AppendData(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
  27 + // UpdateTableStruct 更新表结构(分表)
16 UpdateTableStruct(ctx *Context, tableId int, fields []*Field, name string) (interface{}, error) 28 UpdateTableStruct(ctx *Context, tableId int, fields []*Field, name string) (interface{}, error)
  29 + // AddTableStruct 添加表结构(分表)
17 AddTableStruct(ctx *Context, parentTableId int, fields []*Field, name string) (interface{}, error) 30 AddTableStruct(ctx *Context, parentTableId int, fields []*Field, name string) (interface{}, error)
18 } 31 }
19 32
  33 +// PreviewDataTableService 具体的表预览服务
20 type PreviewDataTableService interface { 34 type PreviewDataTableService interface {
  35 + // Preview 预览
21 Preview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error) 36 Preview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error)
  37 + // RePreview 重新预览
22 RePreview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error) 38 RePreview(ctx *Context, fileId int, fields []*Field, where Where) (interface{}, error)
  39 + // CreateTemporaryFile 创建临时文件(计算集修改的时候,先创建临时文件,保存成功后覆盖原文件)
23 CreateTemporaryFile(ctx *Context, fileId int) (*File, error) 40 CreateTemporaryFile(ctx *Context, fileId int) (*File, error)
24 GetFileId() int 41 GetFileId() int
25 } 42 }
26 43
  44 +// EditDataTableService 编辑表数据(副表)
27 type EditDataTableService interface { 45 type EditDataTableService interface {
28 Edit(ctx *Context, param EditTableRequest) (*DataEditDataTable, error) 46 Edit(ctx *Context, param EditTableRequest) (*DataEditDataTable, error)
29 } 47 }
30 48
  49 +// FlushDataTableService 保存编辑状态的表
31 type FlushDataTableService interface { 50 type FlushDataTableService interface {
32 Flush(ctx *Context, fileId int, table *Table) (interface{}, error) 51 Flush(ctx *Context, fileId int, table *Table) (interface{}, error)
33 } 52 }
34 53
  54 +// DeleteFileService 删除文件服务
35 type DeleteFileService interface { 55 type DeleteFileService interface {
36 DeleteFiles(ctx *Context, files ...*File) error 56 DeleteFiles(ctx *Context, files ...*File) error
37 } 57 }
38 58
  59 +// GenerateMainTableService 生成主表服务
39 type GenerateMainTableService interface { 60 type GenerateMainTableService interface {
40 GenerateTable(ctx *Context, fileId int, tableName string) (interface{}, error) 61 GenerateTable(ctx *Context, fileId int, tableName string) (interface{}, error)
41 } 62 }
42 63
  64 +// CopyDataTableService 拷贝表服务
43 type CopyDataTableService interface { 65 type CopyDataTableService interface {
44 CopyTable(ctx *Context, tableId int, tableName string) (interface{}, error) 66 CopyTable(ctx *Context, tableId int, tableName string) (interface{}, error)
45 } 67 }
46 68
  69 +// DeleteDataTableService 删除表服务
47 type DeleteDataTableService interface { 70 type DeleteDataTableService interface {
48 DeleteTable(ctx *Context, tableId int) (interface{}, error) 71 DeleteTable(ctx *Context, tableId int) (interface{}, error)
49 DeleteTables(ctx *Context, tables ...*Table) error 72 DeleteTables(ctx *Context, tables ...*Table) error
50 } 73 }
51 74
  75 +// AppendDataToTableService 追加数据服务
52 type AppendDataToTableService interface { 76 type AppendDataToTableService interface {
53 AppendData(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error) 77 AppendData(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
54 PreflightCheck(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error) 78 PreflightCheck(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
@@ -56,10 +80,12 @@ type AppendDataToTableService interface { @@ -56,10 +80,12 @@ type AppendDataToTableService interface {
56 80
57 /************************************/ 81 /************************************/
58 82
  83 +// UpdateTableStructService 更新表结构服务(分表)
59 type UpdateTableStructService interface { 84 type UpdateTableStructService interface {
60 UpdateTableStruct(ctx *Context, tableId int, fields []*Field, name string) (interface{}, error) 85 UpdateTableStruct(ctx *Context, tableId int, fields []*Field, name string) (interface{}, error)
61 } 86 }
62 87
  88 +// AddTableStructService 添加表结构服务(分表)
63 type AddTableStructService interface { 89 type AddTableStructService interface {
64 AddTableStruct(ctx *Context, parentTableId int, fields []*Field, name string) (*Table, error) 90 AddTableStruct(ctx *Context, parentTableId int, fields []*Field, name string) (*Table, error)
65 } 91 }
@@ -14,25 +14,33 @@ const ( @@ -14,25 +14,33 @@ const (
14 TableDeleteEvent EventType = "table.delete" 14 TableDeleteEvent EventType = "table.delete"
15 QuerySetUpdateEvent EventType = "table.query.set.update" 15 QuerySetUpdateEvent EventType = "table.query.set.update"
16 QuerySetUpdateRenameEvent EventType = "table.query.set.update.rename" 16 QuerySetUpdateRenameEvent EventType = "table.query.set.update.rename"
  17 +
  18 + TableApplyOnEvent EventType = "table.apply-on"
  19 + QuerySetUpdateStatusEvent EventType = "table.query.set.update.status" // 禁用启用
  20 + QuerySetDeleteEvent EventType = "table.query.set.delete" // 删除
17 ) 21 )
18 22
  23 +// EventTable 表事件
19 type EventTable struct { 24 type EventTable struct {
20 Context *Context 25 Context *Context
21 Type EventType 26 Type EventType
22 Table *Table 27 Table *Table
23 QuerySet *QuerySet 28 QuerySet *QuerySet
  29 + Metadata map[string]interface{}
24 } 30 }
25 31
26 func NewEventTable(ctx *Context, t EventType) *EventTable { 32 func NewEventTable(ctx *Context, t EventType) *EventTable {
27 return &EventTable{ 33 return &EventTable{
28 Context: ctx, 34 Context: ctx,
29 Type: t, 35 Type: t,
  36 + Metadata: make(map[string]interface{}),
30 } 37 }
31 } 38 }
32 func (et *EventTable) WithContext(t *Context) *EventTable { 39 func (et *EventTable) WithContext(t *Context) *EventTable {
33 et.Context = t 40 et.Context = t
34 return et 41 return et
35 } 42 }
  43 +
36 func (et *EventTable) WithType(t EventType) *EventTable { 44 func (et *EventTable) WithType(t EventType) *EventTable {
37 et.Type = t 45 et.Type = t
38 return et 46 return et
@@ -48,11 +56,17 @@ func (et *EventTable) WithQuerySet(t *QuerySet) *EventTable { @@ -48,11 +56,17 @@ func (et *EventTable) WithQuerySet(t *QuerySet) *EventTable {
48 return et 56 return et
49 } 57 }
50 58
  59 +func (et *EventTable) WithMetadata(key string, values interface{}) *EventTable {
  60 + et.Metadata[key] = values
  61 + return et
  62 +}
  63 +
51 func (et *EventTable) ResolveEvent(e event.Event) { 64 func (et *EventTable) ResolveEvent(e event.Event) {
52 et.Context = e.Get("Context").(*Context) 65 et.Context = e.Get("Context").(*Context)
53 et.Type = e.Get("Type").(EventType) 66 et.Type = e.Get("Type").(EventType)
54 et.Table = e.Get("Table").(*Table) 67 et.Table = e.Get("Table").(*Table)
55 et.QuerySet = e.Get("QuerySet").(*QuerySet) 68 et.QuerySet = e.Get("QuerySet").(*QuerySet)
  69 + et.Metadata = e.Get("Metadata").(map[string]interface{})
56 } 70 }
57 71
58 func (et *EventTable) FireEvent() event.Event { 72 func (et *EventTable) FireEvent() event.Event {
@@ -61,5 +75,6 @@ func (et *EventTable) FireEvent() event.Event { @@ -61,5 +75,6 @@ func (et *EventTable) FireEvent() event.Event {
61 e["Type"] = et.Type 75 e["Type"] = et.Type
62 e["Table"] = et.Table 76 e["Table"] = et.Table
63 e["QuerySet"] = et.QuerySet 77 e["QuerySet"] = et.QuerySet
  78 + e["Metadata"] = et.Metadata
64 return event.MustFire(et.Type.ToString(), e) 79 return event.MustFire(et.Type.ToString(), e)
65 } 80 }
@@ -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 }
@@ -176,3 +176,12 @@ func (tables Tables) ToMap() map[int]*Table { @@ -176,3 +176,12 @@ func (tables Tables) ToMap() map[int]*Table {
176 } 176 }
177 return result 177 return result
178 } 178 }
  179 +
  180 +func AssertTableType(tableType string, types ...TableType) bool {
  181 + for _, item := range types {
  182 + if tableType == item.ToString() {
  183 + return true
  184 + }
  185 + }
  186 + return false
  187 +}
  1 +package digitalLib
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/core/logs"
  5 + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api"
  6 + "net/http"
  7 + "time"
  8 +)
  9 +
  10 +type DigitalLib struct {
  11 + Token string
  12 + api.BaseServiceGateway
  13 +}
  14 +
  15 +func (gateway *DigitalLib) WithToken(token string) *DigitalLib {
  16 + gateway.Token = token
  17 + return gateway
  18 +}
  19 +
  20 +func (gateway *DigitalLib) DefaultHeader() http.Header {
  21 + var header = make(map[string][]string)
  22 + header["x-mmm-accesstoken"] = []string{gateway.Token}
  23 + return header
  24 +}
  25 +
  26 +func NewDigitalLib(host string) *DigitalLib {
  27 + gt := api.NewBaseServiceGateway(host)
  28 + gt.ConnectTimeout = 360 * time.Second
  29 + gt.ReadWriteTimeout = 360 * time.Second
  30 + gt.Interceptor = func(msg string) {
  31 + //log.Logger.Info(msg)
  32 + logs.Debug(msg)
  33 + }
  34 + gt.ServiceName = "【数控中心】"
  35 + return &DigitalLib{
  36 + BaseServiceGateway: gt,
  37 + }
  38 +}
  39 +
  40 +func (gateway *DigitalLib) SyncNotice(param RequestSyncNotice) (*DataSyncNotice, error) {
  41 + url := gateway.Host() + "/api/sync/notice"
  42 + method := "post"
  43 + var data DataSyncNotice
  44 + err := gateway.FastDoRequest(url, method, param.Body, &data, api.WithHeader(gateway.DefaultHeader()))
  45 + if err != nil {
  46 + return nil, err
  47 + }
  48 + return &data, nil
  49 +}
  1 +package digitalLib
  2 +
  3 +type RequestSyncNotice struct {
  4 + Body interface{}
  5 +}
  6 +
  7 +type DataSyncNotice struct{}
@@ -14,6 +14,8 @@ type ByteCoreService struct { @@ -14,6 +14,8 @@ type ByteCoreService struct {
14 TempDataTable map[int]*domain.DataLoadDataTable 14 TempDataTable map[int]*domain.DataLoadDataTable
15 } 15 }
16 16
  17 +// ByteCore 字库底层核心
  18 +// 主表、拆分、数据读取等功能
17 var ByteCore domain.ByteLibService = &WrapByteCoreService{} //&ByteCoreService{} 19 var ByteCore domain.ByteLibService = &WrapByteCoreService{} //&ByteCoreService{}
18 20
19 var _ domain.ByteLibService = (*ByteCoreService)(nil) 21 var _ domain.ByteLibService = (*ByteCoreService)(nil)
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 "time" 7 "time"
8 ) 8 )
9 9
  10 +// AsyncEvent 同步事件
10 func AsyncEvent(e *domain.EventTable) { 11 func AsyncEvent(e *domain.EventTable) {
11 go func() { 12 go func() {
12 defer func() { 13 defer func() {
@@ -17,6 +18,6 @@ func AsyncEvent(e *domain.EventTable) { @@ -17,6 +18,6 @@ func AsyncEvent(e *domain.EventTable) {
17 e.FireEvent() 18 e.FireEvent()
18 }() 19 }()
19 log.Logger.Info("开始事件..." + e.Type.ToString()) 20 log.Logger.Info("开始事件..." + e.Type.ToString())
20 - time.Sleep(time.Millisecond * 400) 21 + time.Sleep(time.Millisecond * 10)
21 log.Logger.Info("结束事件..." + e.Type.ToString()) 22 log.Logger.Info("结束事件..." + e.Type.ToString())
22 } 23 }
@@ -14,7 +14,7 @@ type PreviewDataTableService struct { @@ -14,7 +14,7 @@ type PreviewDataTableService struct {
14 transactionContext *pgTransaction.TransactionContext 14 transactionContext *pgTransaction.TransactionContext
15 } 15 }
16 16
17 -// RePreview 重新预览 17 +// RePreview 重新预览,表头重置时,前端调用重新预览接口,重置缓存的表头行号
18 func (ptr *PreviewDataTableService) RePreview(ctx *domain.Context, fileId int, fields []*domain.Field, where domain.Where) (interface{}, error) { 18 func (ptr *PreviewDataTableService) RePreview(ctx *domain.Context, fileId int, fields []*domain.Field, where domain.Where) (interface{}, error) {
19 fileRepository, _ := repository.NewFileRepository(ptr.transactionContext) 19 fileRepository, _ := repository.NewFileRepository(ptr.transactionContext)
20 file, err := fileRepository.FindOne(map[string]interface{}{"fileId": fileId}) 20 file, err := fileRepository.FindOne(map[string]interface{}{"fileId": fileId})
@@ -14,6 +14,7 @@ type PGLogService struct { @@ -14,6 +14,7 @@ type PGLogService struct {
14 transactionContext *pgTransaction.TransactionContext 14 transactionContext *pgTransaction.TransactionContext
15 } 15 }
16 16
  17 +// NewPGLogService 服务操作日志记录
17 func NewPGLogService(transactionContext *pgTransaction.TransactionContext) (*PGLogService, error) { 18 func NewPGLogService(transactionContext *pgTransaction.TransactionContext) (*PGLogService, error) {
18 if transactionContext == nil { 19 if transactionContext == nil {
19 return nil, fmt.Errorf("transactionContext参数不能为nil") 20 return nil, fmt.Errorf("transactionContext参数不能为nil")
@@ -24,6 +25,7 @@ func NewPGLogService(transactionContext *pgTransaction.TransactionContext) (*PGL @@ -24,6 +25,7 @@ func NewPGLogService(transactionContext *pgTransaction.TransactionContext) (*PGL
24 } 25 }
25 } 26 }
26 27
  28 +// FastLog 快速记录日志
27 func FastLog(transactionContext *pgTransaction.TransactionContext, logType domain.LogType, sourceId int, logEntry Log) error { 29 func FastLog(transactionContext *pgTransaction.TransactionContext, logType domain.LogType, sourceId int, logEntry Log) error {
28 logService, _ := NewPGLogService(transactionContext) 30 logService, _ := NewPGLogService(transactionContext)
29 return logService.Log(logType, sourceId, logEntry) 31 return logService.Log(logType, sourceId, logEntry)
@@ -21,6 +21,7 @@ var ( @@ -21,6 +21,7 @@ var (
21 ErrFieldsNotMatch = func(table string) error { return fmt.Errorf("[%v]字段数量不一致或类型不匹配", table) } 21 ErrFieldsNotMatch = func(table string) error { return fmt.Errorf("[%v]字段数量不一致或类型不匹配", table) }
22 ) 22 )
23 23
  24 +// QuerySetService 查询集服务,对拆分、计算模块数据集合的处理
24 type QuerySetService struct { 25 type QuerySetService struct {
25 transactionContext *pgTransaction.TransactionContext 26 transactionContext *pgTransaction.TransactionContext
26 } 27 }
@@ -958,6 +959,10 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st @@ -958,6 +959,10 @@ func (ptr *QuerySetService) ChangeStatus(ctx *domain.Context, querySetId int, st
958 if _, err = tableRepository.Save(table); err != nil { 959 if _, err = tableRepository.Save(table); err != nil {
959 return err 960 return err
960 } 961 }
  962 +
  963 + defer func() {
  964 + AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetUpdateStatusEvent).WithTable(table).WithQuerySet(qs).WithMetadata("status", status))
  965 + }()
961 } 966 }
962 return nil 967 return nil
963 } 968 }
@@ -1075,6 +1080,7 @@ func (ptr *QuerySetService) Delete(ctx *domain.Context, querySetId int) error { @@ -1075,6 +1080,7 @@ func (ptr *QuerySetService) Delete(ctx *domain.Context, querySetId int) error {
1075 } 1080 }
1076 starrocks.DropView(starrocks.DB, t.SQLName) 1081 starrocks.DropView(starrocks.DB, t.SQLName)
1077 } 1082 }
  1083 + AsyncEvent(domain.NewEventTable(ctx, domain.QuerySetDeleteEvent).WithQuerySet(querySets[i]).WithTable(t))
1078 } 1084 }
1079 } 1085 }
1080 // 2.底层清理 1086 // 2.底层清理
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/astexpr" 5 "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain/astexpr"
6 ) 6 )
7 7
  8 +// LoadCalculateItemData 加载计算项数据,实时计算某个列的值
8 func (ptr *QuerySetService) LoadCalculateItemData(ctx *domain.Context, t *domain.Table, formula *domain.FieldFormulaExpr) (*domain.DataTable, error) { 9 func (ptr *QuerySetService) LoadCalculateItemData(ctx *domain.Context, t *domain.Table, formula *domain.FieldFormulaExpr) (*domain.DataTable, error) {
9 var ( 10 var (
10 res = &domain.DataTable{} 11 res = &domain.DataTable{}
@@ -15,6 +15,7 @@ import ( @@ -15,6 +15,7 @@ import (
15 const DefaultExpandNum = 1000 15 const DefaultExpandNum = 1000
16 const MaxExpandNum = 5000 16 const MaxExpandNum = 5000
17 17
  18 +// LoadCalculateSetData 加载计算集数据,根据排列规则,动态进行集合数据排列,返回一个二维表
18 func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) (*domain.DataTable, error) { 19 func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) (*domain.DataTable, error) {
19 var ( 20 var (
20 res = &domain.DataTable{} 21 res = &domain.DataTable{}
@@ -21,6 +21,7 @@ func NewAddTableStructService(transactionContext *pgTransaction.TransactionConte @@ -21,6 +21,7 @@ func NewAddTableStructService(transactionContext *pgTransaction.TransactionConte
21 } 21 }
22 } 22 }
23 23
  24 +// AddTableStruct 添加表结构(新建分表)
24 func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTableId int, fields []*domain.Field, name string) (*domain.Table, error) { 25 func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTableId int, fields []*domain.Field, name string) (*domain.Table, error) {
25 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext) 26 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
26 mainTable, err := tableRepository.FindOne(map[string]interface{}{"tableId": parentTableId}) 27 mainTable, err := tableRepository.FindOne(map[string]interface{}{"tableId": parentTableId})
@@ -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
@@ -43,6 +43,9 @@ func NewCircleDependError(t *domain.Table, qs *domain.QuerySet) CircleDependErro @@ -43,6 +43,9 @@ func NewCircleDependError(t *domain.Table, qs *domain.QuerySet) CircleDependErro
43 } 43 }
44 } 44 }
45 45
  46 +// TableDependencyService 表依赖服务
  47 +// 查询表所有的依赖关系
  48 +// 判断是否循环依赖
46 type TableDependencyService struct { 49 type TableDependencyService struct {
47 transactionContext *pgTransaction.TransactionContext 50 transactionContext *pgTransaction.TransactionContext
48 DetectedCycleCallBack func() 51 DetectedCycleCallBack func()
@@ -330,6 +333,9 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT @@ -330,6 +333,9 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT
330 Edges: make([]TableEdge, 0), 333 Edges: make([]TableEdge, 0),
331 Tree: tree, 334 Tree: tree,
332 } 335 }
  336 + if len(tree) == 0 || tableMap == nil {
  337 + return dependTree
  338 + }
333 339
334 for _, node := range tree { 340 for _, node := range tree {
335 t, ok := tableMap[node] 341 t, ok := tableMap[node]
@@ -348,11 +354,14 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT @@ -348,11 +354,14 @@ func NewTableDependTree(tree []int, tableMap map[int]*domain.Table) TableDependT
348 return dependTree 354 return dependTree
349 } 355 }
350 func NewTableNode(table *domain.Table) TableNode { 356 func NewTableNode(table *domain.Table) TableNode {
  357 + if table == nil {
  358 + return TableNode{}
  359 + }
351 return TableNode{ 360 return TableNode{
352 TableId: table.TableId, 361 TableId: table.TableId,
353 Type: table.TableType, 362 Type: table.TableType,
354 Name: table.Name, 363 Name: table.Name,
355 - DependencyTables: table.TableInfo.DependencyTables, 364 + DependencyTables: table.DependencyTables(),
356 } 365 }
357 } 366 }
358 func NewTableEdge(table *domain.Table, dependTable *domain.Table) TableEdge { 367 func NewTableEdge(table *domain.Table, dependTable *domain.Table) TableEdge {
@@ -23,6 +23,7 @@ func NewTableEditDataService(transactionContext *pgTransaction.TransactionContex @@ -23,6 +23,7 @@ func NewTableEditDataService(transactionContext *pgTransaction.TransactionContex
23 } 23 }
24 } 24 }
25 25
  26 +// RowEdit 行数据编辑
26 func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.EditDataRequest) (interface{}, error) { 27 func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.EditDataRequest) (interface{}, error) {
27 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext) 28 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
28 var table *domain.Table = request.Table 29 var table *domain.Table = request.Table
@@ -57,11 +58,6 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi @@ -57,11 +58,6 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi
57 if err = starrocks.BatchDelete(starrocks.DB, table.SQLName, request.RemoveList); err != nil { 58 if err = starrocks.BatchDelete(starrocks.DB, table.SQLName, request.RemoveList); err != nil {
58 return nil, err 59 return nil, err
59 } 60 }
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 } 61 }
66 for _, l := range request.UpdateList { 62 for _, l := range request.UpdateList {
67 if e := ptr.update(ctx, table, l, request.Where); e != nil { 63 if e := ptr.update(ctx, table, l, request.Where); e != nil {
@@ -24,6 +24,7 @@ func NewUpdateTableStructService(transactionContext *pgTransaction.TransactionCo @@ -24,6 +24,7 @@ func NewUpdateTableStructService(transactionContext *pgTransaction.TransactionCo
24 } 24 }
25 } 25 }
26 26
  27 +// UpdateTableStruct 更新表结构
27 func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tableId int, fields []*domain.Field, name string) (interface{}, error) { 28 func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tableId int, fields []*domain.Field, name string) (interface{}, error) {
28 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext) 29 tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
29 table, err := tableRepository.FindOne(map[string]interface{}{"tableId": tableId}) 30 table, err := tableRepository.FindOne(map[string]interface{}{"tableId": tableId})
@@ -80,16 +81,10 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl @@ -80,16 +81,10 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl
80 if _, err = ByteCore.SplitTable(domain.ReqSplitTable{FromTable: mainTable, ToSubTable: table}); err != nil { 81 if _, err = ByteCore.SplitTable(domain.ReqSplitTable{FromTable: mainTable, ToSubTable: table}); err != nil {
81 return nil, err 82 return nil, err
82 } 83 }
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 84 return struct{}{}, nil
91 } 85 }
92 86
  87 +// DependencyTables 依赖的表列表
93 func DependencyTables(ptr *pgTransaction.TransactionContext, context *domain.Context, tableId int) ([]TableNode, error) { 88 func DependencyTables(ptr *pgTransaction.TransactionContext, context *domain.Context, tableId int) ([]TableNode, error) {
94 ret := make([]TableNode, 0) 89 ret := make([]TableNode, 0)
95 // tableId 相关联的 90 // tableId 相关联的
@@ -140,29 +135,6 @@ func DependencyTables(ptr *pgTransaction.TransactionContext, context *domain.Con @@ -140,29 +135,6 @@ func DependencyTables(ptr *pgTransaction.TransactionContext, context *domain.Con
140 return ret, nil 135 return ret, nil
141 } 136 }
142 137
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 { 138 func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {
167 tableFields := mainTable.Fields(false) 139 tableFields := mainTable.Fields(false)
168 tableFieldsMap := (domain.Fields)(tableFields).ToMap() 140 tableFieldsMap := (domain.Fields)(tableFields).ToMap()
@@ -179,7 +151,6 @@ func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain. @@ -179,7 +151,6 @@ func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.
179 builder.NewDataField(v.Name, v.SQLType, v.Flag) 151 builder.NewDataField(v.Name, v.SQLType, v.Flag)
180 } else { 152 } else {
181 if f.Flag == domain.ManualField { 153 if f.Flag == domain.ManualField {
182 - //mainTable.DataFieldIndex += 1  
183 fields[i] = builder.NewDataField(f.Name, f.SQLType, domain.ManualField) 154 fields[i] = builder.NewDataField(f.Name, f.SQLType, domain.ManualField)
184 fields[i].Description = f.Description 155 fields[i].Description = f.Description
185 } 156 }
@@ -14,9 +14,6 @@ func Insert(db *gorm.DB, tableName string, fields []*domain.FieldValue) error { @@ -14,9 +14,6 @@ func Insert(db *gorm.DB, tableName string, fields []*domain.FieldValue) error {
14 value := map[string]interface{}{} 14 value := map[string]interface{}{}
15 for _, f := range fields { 15 for _, f := range fields {
16 if f.Field.Flag == domain.PKField && f.Value == "" { 16 if f.Field.Flag == domain.PKField && f.Value == "" {
17 - //continue  
18 - //id, _ := uuid.NewUUID()  
19 - // idString := id.String()  
20 // 需要调用分布式id生成 17 // 需要调用分布式id生成
21 id, _ := utils.NewSnowflakeId() 18 id, _ := utils.NewSnowflakeId()
22 idString := fmt.Sprintf("%d", id) 19 idString := fmt.Sprintf("%d", id)
@@ -24,8 +21,6 @@ func Insert(db *gorm.DB, tableName string, fields []*domain.FieldValue) error { @@ -24,8 +21,6 @@ func Insert(db *gorm.DB, tableName string, fields []*domain.FieldValue) error {
24 } 21 }
25 value[f.Field.SQLName] = f.TypeValue() 22 value[f.Field.SQLName] = f.TypeValue()
26 } 23 }
27 - //tx := db.Table(tableName).Create(value)  
28 - //return tx.Error  
29 sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB { 24 sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
30 return tx.Table(tableName).Create(value) 25 return tx.Table(tableName).Create(value)
31 }) 26 })
@@ -45,8 +40,6 @@ func Update(db *gorm.DB, tableName string, fields []*domain.FieldValue) error { @@ -45,8 +40,6 @@ func Update(db *gorm.DB, tableName string, fields []*domain.FieldValue) error {
45 if pk == nil && pk.Value != "" && pk.TypeValue() != nil { 40 if pk == nil && pk.Value != "" && pk.TypeValue() != nil {
46 return fmt.Errorf("主键不能为空") 41 return fmt.Errorf("主键不能为空")
47 } 42 }
48 - //tx := db.Table(tableName).Where("? = ?", pk.Field.SQLName, pk.Value).Updates(value)  
49 - //return tx.Error  
50 sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB { 43 sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
51 return tx.Table(tableName).Create(value) 44 return tx.Table(tableName).Create(value)
52 }) 45 })
@@ -64,8 +57,6 @@ func Delete(db *gorm.DB, tableName string, fields []*domain.FieldValue) error { @@ -64,8 +57,6 @@ func Delete(db *gorm.DB, tableName string, fields []*domain.FieldValue) error {
64 if pk == nil { 57 if pk == nil {
65 return fmt.Errorf("主键不能为空") 58 return fmt.Errorf("主键不能为空")
66 } 59 }
67 - //tx := db.Table(tableName).Delete("? = ?", pk.Field.SQLName, pk.Value)  
68 - //return tx.Error  
69 sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB { 60 sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
70 return tx.Table(tableName).Delete("? = ?", pk.Field.SQLName, pk.Value) 61 return tx.Table(tableName).Delete("? = ?", pk.Field.SQLName, pk.Value)
71 }) 62 })
@@ -222,9 +222,6 @@ func (c Condition) CastTypeByField(f *domain.Field, t string) string { @@ -222,9 +222,6 @@ func (c Condition) CastTypeByField(f *domain.Field, t string) string {
222 } 222 }
223 223
224 func formatFiled(f *domain.Field) string { 224 func formatFiled(f *domain.Field) string {
225 - //if f.SQLType == domain.Float.ToString() || f.SQLType == domain.DECIMAL279.ToString() {  
226 - // return castTypeAlias(f.SQLName, domain.DECIMALV2.ToString())  
227 - //}  
228 return f.SQLName 225 return f.SQLName
229 } 226 }
230 227
@@ -346,15 +343,6 @@ func WrapDeleteFuncWithDB(db *gorm.DB) func(QueryOptions) (int64, error) { @@ -346,15 +343,6 @@ func WrapDeleteFuncWithDB(db *gorm.DB) func(QueryOptions) (int64, error) {
346 return func(params QueryOptions) (int64, error) { 343 return func(params QueryOptions) (int64, error) {
347 query := db.Table(params.TableName) 344 query := db.Table(params.TableName)
348 queryWithoutLimitOffset(query, params) 345 queryWithoutLimitOffset(query, params)
349 - //if params.Offset > 0 {  
350 - // query.Offset(params.Offset)  
351 - //}  
352 - //if params.Limit > 0 {  
353 - // query.Limit(params.Limit)  
354 - //}  
355 - //if params.Context != nil {  
356 - // query.Where(fmt.Sprintf("context->>'companyId'='%v'", params.Context.CompanyId))  
357 - //}  
358 rows, err := query.Rows() 346 rows, err := query.Rows()
359 defer rows.Close() 347 defer rows.Close()
360 if err != nil { 348 if err != nil {
@@ -34,17 +34,6 @@ func Init() error { @@ -34,17 +34,6 @@ func Init() error {
34 } 34 }
35 35
36 func Test() { 36 func Test() {
37 - //var result [][]interface{}  
38 - //query := DB.Raw("select * from sales_performance_area_belongs").Select(&result)  
39 - //if query.Error != nil {  
40 - // log.Logger.Error(query.Error.Error())  
41 - //}  
42 - //if len(result) > 0 {  
43 - //  
44 - //}  
45 -  
46 - //rows, err := DB.Raw("select * from sales_performance_area_belongs").Rows()  
47 -  
48 rows, err := DB.Table("sales_performance_area_categorys").Rows() 37 rows, err := DB.Table("sales_performance_area_categorys").Rows()
49 if err != nil { 38 if err != nil {
50 log.Logger.Error(err.Error()) 39 log.Logger.Error(err.Error())
@@ -15,4 +15,7 @@ func RegisterEvent() { @@ -15,4 +15,7 @@ func RegisterEvent() {
15 event.On(domain.TableDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High) 15 event.On(domain.TableDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
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)
  19 + event.On(domain.TableApplyOnEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
  20 + event.On(domain.QuerySetDeleteEvent.ToString(), event.ListenerFunc(tableDataChangeHandler), event.High)
18 } 21 }