正在显示
13 个修改的文件
包含
214 行增加
和
43 行删除
| @@ -13,7 +13,7 @@ type CalculateItemPreviewQuery struct { | @@ -13,7 +13,7 @@ type CalculateItemPreviewQuery struct { | ||
| 13 | // 查询集合ID | 13 | // 查询集合ID |
| 14 | QuerySetId int `cname:"查询集合ID" json:"querySetId" valid:"Required"` | 14 | QuerySetId int `cname:"查询集合ID" json:"querySetId" valid:"Required"` |
| 15 | // 公式 | 15 | // 公式 |
| 16 | - Formula *domain.FieldExpr `json:"formula"` | 16 | + Formula *domain.FieldExpr `json:"formula" valid:"Required"` |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | func (dependencyGraphQuery *CalculateItemPreviewQuery) Valid(validation *validation.Validation) { | 19 | func (dependencyGraphQuery *CalculateItemPreviewQuery) Valid(validation *validation.Validation) { |
| @@ -13,6 +13,7 @@ import ( | @@ -13,6 +13,7 @@ import ( | ||
| 13 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/excel" | 13 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/excel" |
| 14 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" | 14 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" |
| 15 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" | 15 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" |
| 16 | + "strings" | ||
| 16 | "time" | 17 | "time" |
| 17 | ) | 18 | ) |
| 18 | 19 | ||
| @@ -311,6 +312,39 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear | @@ -311,6 +312,39 @@ func (querySetService *QuerySetService) SearchQuerySet(ctx *domain.Context, sear | ||
| 311 | return nil, factory.FastError(err) | 312 | return nil, factory.FastError(err) |
| 312 | } | 313 | } |
| 313 | 314 | ||
| 315 | + if len(searchQuerySetQuery.MatchName) > 0 { | ||
| 316 | + mapQuerySet := (domain.QuerySets(querySets)).ToMap() | ||
| 317 | + tmpQuerySets := make([]*domain.QuerySet, 0) | ||
| 318 | + for _, item := range querySets { | ||
| 319 | + if strings.Contains(item.Name, searchQuerySetQuery.MatchName) { | ||
| 320 | + tmpQuerySets = append(tmpQuerySets, item) | ||
| 321 | + } | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + tmpParentQuerySets := make([]*domain.QuerySet, 0) | ||
| 325 | + mapTmpParentQuerySets := (domain.QuerySets(tmpQuerySets)).ToMap() | ||
| 326 | + for _, item := range tmpQuerySets { | ||
| 327 | + var parentId = item.ParentId | ||
| 328 | + for { | ||
| 329 | + if parentId <= 0 { | ||
| 330 | + break | ||
| 331 | + } | ||
| 332 | + v, ok := mapQuerySet[parentId] | ||
| 333 | + if !ok { | ||
| 334 | + break | ||
| 335 | + } | ||
| 336 | + if _, ok := mapTmpParentQuerySets[v.QuerySetId]; !ok { | ||
| 337 | + mapTmpParentQuerySets[v.QuerySetId] = v | ||
| 338 | + tmpParentQuerySets = append(tmpParentQuerySets, v) | ||
| 339 | + } | ||
| 340 | + parentId = v.ParentId | ||
| 341 | + } | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + tmpQuerySets = append(tmpQuerySets, tmpParentQuerySets...) | ||
| 345 | + querySets = tmpQuerySets | ||
| 346 | + } | ||
| 347 | + | ||
| 314 | var result = dto.NewQuerySetDtoList(querySets) | 348 | var result = dto.NewQuerySetDtoList(querySets) |
| 315 | 349 | ||
| 316 | if err := transactionContext.CommitTransaction(); err != nil { | 350 | if err := transactionContext.CommitTransaction(); err != nil { |
| @@ -18,7 +18,7 @@ type TableObjectDto struct { | @@ -18,7 +18,7 @@ type TableObjectDto struct { | ||
| 18 | // 父级ID | 18 | // 父级ID |
| 19 | ParentId int `json:"parentId"` | 19 | ParentId int `json:"parentId"` |
| 20 | // 模块 应用于模块 1:数控中心 2:拆解模块 4:计算模块 | 20 | // 模块 应用于模块 1:数控中心 2:拆解模块 4:计算模块 |
| 21 | - //Module int `json:"module"` | 21 | + Module int `json:"module"` |
| 22 | // 标识 | 22 | // 标识 |
| 23 | Flag string `json:"flag,omitempty"` | 23 | Flag string `json:"flag,omitempty"` |
| 24 | // 启用状态 | 24 | // 启用状态 |
| @@ -34,9 +34,9 @@ func (d *TableObjectDto) Load(m *domain.Table) *TableObjectDto { | @@ -34,9 +34,9 @@ func (d *TableObjectDto) Load(m *domain.Table) *TableObjectDto { | ||
| 34 | d.Name = m.Name | 34 | d.Name = m.Name |
| 35 | d.ParentId = m.ParentId | 35 | d.ParentId = m.ParentId |
| 36 | d.SQLName = m.SQLName | 36 | d.SQLName = m.SQLName |
| 37 | - //if m.TableInfo != nil { | ||
| 38 | - // d.Module = m.TableInfo.ApplyOnModule | ||
| 39 | - //} | 37 | + if m.TableInfo != nil { |
| 38 | + d.Module = m.TableInfo.ApplyOnModule | ||
| 39 | + } | ||
| 40 | d.Fields = make([]*domain.Field, 0) | 40 | d.Fields = make([]*domain.Field, 0) |
| 41 | return d | 41 | return d |
| 42 | } | 42 | } |
| @@ -132,3 +132,13 @@ func (querySet *QuerySet) GetDependencyTables(queryComponents []*QueryComponent) | @@ -132,3 +132,13 @@ func (querySet *QuerySet) GetDependencyTables(queryComponents []*QueryComponent) | ||
| 132 | sort.Ints(res) | 132 | sort.Ints(res) |
| 133 | return res | 133 | return res |
| 134 | } | 134 | } |
| 135 | + | ||
| 136 | +type QuerySets []*QuerySet | ||
| 137 | + | ||
| 138 | +func (querySets QuerySets) ToMap() map[int]*QuerySet { | ||
| 139 | + var result = make(map[int]*QuerySet) | ||
| 140 | + for i := range querySets { | ||
| 141 | + result[querySets[i].QuerySetId] = querySets[i] | ||
| 142 | + } | ||
| 143 | + return result | ||
| 144 | +} |
| @@ -12,6 +12,7 @@ type ( | @@ -12,6 +12,7 @@ type ( | ||
| 12 | FormulaName string `json:"formulaName"` | 12 | FormulaName string `json:"formulaName"` |
| 13 | FormulaType int `json:"formulaType"` //公式类型 1.方案2.子过程 | 13 | FormulaType int `json:"formulaType"` //公式类型 1.方案2.子过程 |
| 14 | FormulaConditions []FormulaCondition `json:"formulaConditions"` | 14 | FormulaConditions []FormulaCondition `json:"formulaConditions"` |
| 15 | + FormulaCalculate *FormulaCalculate `json:"formulaCalculate"` | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | FormulasGenerateResponse struct { | 18 | FormulasGenerateResponse struct { |
| @@ -58,6 +59,25 @@ type ( | @@ -58,6 +59,25 @@ type ( | ||
| 58 | FieldSchema FieldSchema `json:"fieldSchema"` | 59 | FieldSchema FieldSchema `json:"fieldSchema"` |
| 59 | ConditionExpression string `json:"conditionExpression"` | 60 | ConditionExpression string `json:"conditionExpression"` |
| 60 | } | 61 | } |
| 62 | + | ||
| 63 | + FormulaCalculate struct { | ||
| 64 | + DatabaseTableName string `json:"databaseTableName"` | ||
| 65 | + FormulaCalculateFields []*FormulaCalculateField `json:"formulaCalculateFields"` | ||
| 66 | + FormulaGroupFields []*FormulaGroupField `json:"formulaGroupFields"` | ||
| 67 | + } | ||
| 68 | + FormulaCalculateField struct { | ||
| 69 | + DatabaseTableName string `json:"databaseTableName"` | ||
| 70 | + FieldSchema FieldSchema `json:"fieldSchema"` | ||
| 71 | + CalculateExpression string `json:"calculateExpression"` | ||
| 72 | + // 字段新的英文名称(3.汇总集4.计算项中对应的新字段名称) | ||
| 73 | + CalculateFieldName string `json:"calculateFieldName"` | ||
| 74 | + } | ||
| 75 | + FormulaGroupField struct { | ||
| 76 | + DatabaseTableName string `json:"databaseTableName"` | ||
| 77 | + FieldSchema FieldSchema `json:"fieldSchema"` | ||
| 78 | + // 字段新的英文名称(3.汇总集4.计算项中对应的新字段名称) | ||
| 79 | + GroupFieldName string `json:"groupFieldName"` | ||
| 80 | + } | ||
| 61 | ) | 81 | ) |
| 62 | 82 | ||
| 63 | func NewFormulasGenerateRequest(table *domain.Table, queryComponents []*domain.QueryComponent) FormulasGenerateRequest { | 83 | func NewFormulasGenerateRequest(table *domain.Table, queryComponents []*domain.QueryComponent) FormulasGenerateRequest { |
| @@ -77,12 +97,20 @@ func NewFormulasGenerateRequest(table *domain.Table, queryComponents []*domain.Q | @@ -77,12 +97,20 @@ func NewFormulasGenerateRequest(table *domain.Table, queryComponents []*domain.Q | ||
| 77 | } | 97 | } |
| 78 | if table.TableType == domain.SchemaTable.ToString() { | 98 | if table.TableType == domain.SchemaTable.ToString() { |
| 79 | req.FormulaType = 1 | 99 | req.FormulaType = 1 |
| 80 | - } else { | 100 | + } else if table.TableType == domain.SubProcessTable.ToString() { |
| 81 | req.FormulaType = 2 | 101 | req.FormulaType = 2 |
| 102 | + } else if table.TableType == domain.CalculateTable.ToString() { | ||
| 103 | + req.FormulaType = 3 | ||
| 104 | + } else if table.TableType == domain.CalculateItem.ToString() { | ||
| 105 | + req.FormulaType = 4 | ||
| 82 | } | 106 | } |
| 83 | 107 | ||
| 84 | - for i := range queryComponents { | ||
| 85 | - req.FormulaConditions = append(req.FormulaConditions, NewFormulaCondition(queryComponents[i])) | 108 | + if req.FormulaType == 1 || req.FormulaType == 2 { |
| 109 | + for i := range queryComponents { | ||
| 110 | + req.FormulaConditions = append(req.FormulaConditions, NewFormulaCondition(queryComponents[i])) | ||
| 111 | + } | ||
| 112 | + } else { | ||
| 113 | + req.FormulaCalculate = NewFormulaCalculate(table, queryComponents[0]) | ||
| 86 | } | 114 | } |
| 87 | 115 | ||
| 88 | return req | 116 | return req |
| @@ -104,6 +132,51 @@ func NewFormulaCondition(queryComponent *domain.QueryComponent) FormulaCondition | @@ -104,6 +132,51 @@ func NewFormulaCondition(queryComponent *domain.QueryComponent) FormulaCondition | ||
| 104 | return res | 132 | return res |
| 105 | } | 133 | } |
| 106 | 134 | ||
| 135 | +func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryComponent) *FormulaCalculate { | ||
| 136 | + var res = &FormulaCalculate{ | ||
| 137 | + DatabaseTableName: "", | ||
| 138 | + FormulaGroupFields: make([]*FormulaGroupField, 0), | ||
| 139 | + FormulaCalculateFields: make([]*FormulaCalculateField, 0), | ||
| 140 | + } | ||
| 141 | + if queryComponent.Formula != nil { | ||
| 142 | + formula := queryComponent.Formula | ||
| 143 | + res.DatabaseTableName = formula.TableFields[0].TableSqlName | ||
| 144 | + res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{ | ||
| 145 | + DatabaseTableName: res.DatabaseTableName, | ||
| 146 | + FieldSchema: NewFieldSchemaFromField(table.DataFields[0]), | ||
| 147 | + CalculateExpression: formula.ExprSql, | ||
| 148 | + CalculateFieldName: table.DataFields[0].SQLName, | ||
| 149 | + }) | ||
| 150 | + } | ||
| 151 | + if queryComponent.Aggregation != nil { | ||
| 152 | + res.DatabaseTableName = queryComponent.MasterTable.SQLName | ||
| 153 | + for _, f := range queryComponent.Aggregation.ValueFields { | ||
| 154 | + tableField, ok := table.MatchField(&domain.Field{Name: f.Field.Name}) | ||
| 155 | + if !ok { | ||
| 156 | + continue | ||
| 157 | + } | ||
| 158 | + res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{ | ||
| 159 | + DatabaseTableName: queryComponent.MasterTable.SQLName, | ||
| 160 | + FieldSchema: NewFieldSchemaFromField(f.Field), | ||
| 161 | + CalculateExpression: f.Expr.ExprSql, | ||
| 162 | + CalculateFieldName: tableField.SQLName, | ||
| 163 | + }) | ||
| 164 | + } | ||
| 165 | + for _, f := range queryComponent.Aggregation.RowFields { | ||
| 166 | + tableField, ok := table.MatchField(&domain.Field{Name: f.Field.Name}) | ||
| 167 | + if !ok { | ||
| 168 | + continue | ||
| 169 | + } | ||
| 170 | + res.FormulaGroupFields = append(res.FormulaGroupFields, &FormulaGroupField{ | ||
| 171 | + DatabaseTableName: queryComponent.MasterTable.SQLName, | ||
| 172 | + FieldSchema: NewFieldSchemaFromField(f.Field), | ||
| 173 | + GroupFieldName: tableField.SQLName, | ||
| 174 | + }) | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | + return res | ||
| 178 | +} | ||
| 179 | + | ||
| 107 | func NewFormulaSelectFields(t *domain.QueryComponentTable) FormulaSelectFields { | 180 | func NewFormulaSelectFields(t *domain.QueryComponentTable) FormulaSelectFields { |
| 108 | var res = FormulaSelectFields{ | 181 | var res = FormulaSelectFields{ |
| 109 | DatabaseTableName: t.SQLName, | 182 | DatabaseTableName: t.SQLName, |
| @@ -162,6 +235,17 @@ func NewFieldSchema(f domain.TableField) FieldSchema { | @@ -162,6 +235,17 @@ func NewFieldSchema(f domain.TableField) FieldSchema { | ||
| 162 | return res | 235 | return res |
| 163 | } | 236 | } |
| 164 | 237 | ||
| 238 | +func NewFieldSchemaFromField(f *domain.Field) FieldSchema { | ||
| 239 | + var res = FieldSchema{ | ||
| 240 | + FieldZhName: f.Name, | ||
| 241 | + FieldEnName: f.SQLName, | ||
| 242 | + FieldType: f.SQLType, | ||
| 243 | + FieldDescription: "", | ||
| 244 | + IsAllowNull: true, | ||
| 245 | + } | ||
| 246 | + return res | ||
| 247 | +} | ||
| 248 | + | ||
| 165 | func NewFormulaDataHandleRule(s domain.SelectExprGroup) FormulaDataHandleRule { | 249 | func NewFormulaDataHandleRule(s domain.SelectExprGroup) FormulaDataHandleRule { |
| 166 | var res = FormulaDataHandleRule{ | 250 | var res = FormulaDataHandleRule{ |
| 167 | RuleType: 1, | 251 | RuleType: 1, |
| @@ -7,7 +7,6 @@ import ( | @@ -7,7 +7,6 @@ import ( | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/bytelib" | 8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/api/bytelib" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/excel" | 9 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/excel" |
| 10 | - "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" | ||
| 11 | ) | 10 | ) |
| 12 | 11 | ||
| 13 | type ByteCoreService struct { | 12 | type ByteCoreService struct { |
| @@ -129,24 +128,24 @@ func (ptr *ByteCoreService) FieldOptionalValues(param domain.ReqFieldOptionalVal | @@ -129,24 +128,24 @@ func (ptr *ByteCoreService) FieldOptionalValues(param domain.ReqFieldOptionalVal | ||
| 129 | 128 | ||
| 130 | func (ptr *ByteCoreService) FormulasGenerate(param domain.ReqFormulasGenerate) (*domain.DataFormulasGenerate, error) { | 129 | func (ptr *ByteCoreService) FormulasGenerate(param domain.ReqFormulasGenerate) (*domain.DataFormulasGenerate, error) { |
| 131 | apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST) | 130 | apiByteLib := bytelib.NewApiByteLib(constant.BYTE_CORE_HOST) |
| 132 | - if param.QuerySet.Type == domain.CalculateItem.ToString() { | ||
| 133 | - if err := starrocks.Exec(starrocks.DB, | ||
| 134 | - starrocks.CreateViewSql(param.Table.SQLName, param.Table.DataFields, | ||
| 135 | - starrocks.CalculateItemViewSql(¶m.QueryComponents[0].Formula.FieldExpr), | ||
| 136 | - )); err != nil { | ||
| 137 | - return nil, err | ||
| 138 | - } | ||
| 139 | - return &domain.DataFormulasGenerate{}, nil | ||
| 140 | - } | ||
| 141 | - if param.QuerySet.Type == domain.CalculateTable.ToString() { | ||
| 142 | - if err := starrocks.Exec(starrocks.DB, | ||
| 143 | - starrocks.CreateViewSql(param.Table.SQLName, param.Table.DataFields, | ||
| 144 | - starrocks.CalculateTableViewSql(param.QueryComponents[0].MasterTable.SQLName, ¶m.QueryComponents[0].Aggregation.Aggregation), | ||
| 145 | - )); err != nil { | ||
| 146 | - return nil, err | ||
| 147 | - } | ||
| 148 | - return &domain.DataFormulasGenerate{}, nil | ||
| 149 | - } | 131 | + //if param.QuerySet.Type == domain.CalculateItem.ToString() { |
| 132 | + // if err := starrocks.Exec(starrocks.DB, | ||
| 133 | + // starrocks.CreateViewSql(param.Table.SQLName, param.Table.DataFields, | ||
| 134 | + // starrocks.CalculateItemViewSql(¶m.QueryComponents[0].Formula.FieldExpr), | ||
| 135 | + // )); err != nil { | ||
| 136 | + // return nil, err | ||
| 137 | + // } | ||
| 138 | + // return &domain.DataFormulasGenerate{}, nil | ||
| 139 | + //} | ||
| 140 | + //if param.QuerySet.Type == domain.CalculateTable.ToString() { | ||
| 141 | + // if err := starrocks.Exec(starrocks.DB, | ||
| 142 | + // starrocks.CreateViewSql(param.Table.SQLName, param.Table.DataFields, | ||
| 143 | + // starrocks.CalculateTableViewSql(param.QueryComponents[0].MasterTable.SQLName, ¶m.QueryComponents[0].Aggregation.Aggregation), | ||
| 144 | + // )); err != nil { | ||
| 145 | + // return nil, err | ||
| 146 | + // } | ||
| 147 | + // return &domain.DataFormulasGenerate{}, nil | ||
| 148 | + //} | ||
| 150 | return apiByteLib.FormulasGenerate(param) | 149 | return apiByteLib.FormulasGenerate(param) |
| 151 | } | 150 | } |
| 152 | 151 |
| @@ -368,7 +368,13 @@ func (l *CreateQuerySetLog) OperateType() string { | @@ -368,7 +368,13 @@ func (l *CreateQuerySetLog) OperateType() string { | ||
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | func (l *CreateQuerySetLog) LogType() string { | 370 | func (l *CreateQuerySetLog) LogType() string { |
| 371 | - if l.Qs.Type == domain.SchemaTable.ToString() || l.Qs.Type == domain.SubProcessTable.ToString() { | 371 | + if l.Qs.Type == domain.SchemaTable.ToString() { |
| 372 | + return domain.QuerySetLog.ToString() | ||
| 373 | + } | ||
| 374 | + if l.Qs.Type == domain.SubProcessTable.ToString() { | ||
| 375 | + return domain.QuerySetLog.ToString() | ||
| 376 | + } | ||
| 377 | + if l.Qs.Type == domain.CalculateTable.ToString() { | ||
| 372 | return domain.QuerySetLog.ToString() | 378 | return domain.QuerySetLog.ToString() |
| 373 | } | 379 | } |
| 374 | return domain.FormulaLog.ToString() | 380 | return domain.FormulaLog.ToString() |
| @@ -390,7 +396,13 @@ func (l *RenameQuerySetLog) OperateType() string { | @@ -390,7 +396,13 @@ func (l *RenameQuerySetLog) OperateType() string { | ||
| 390 | } | 396 | } |
| 391 | 397 | ||
| 392 | func (l *RenameQuerySetLog) LogType() string { | 398 | func (l *RenameQuerySetLog) LogType() string { |
| 393 | - if l.Qs.Type == domain.SchemaTable.ToString() || l.Qs.Type == domain.SubProcessTable.ToString() { | 399 | + if l.Qs.Type == domain.SchemaTable.ToString() { |
| 400 | + return domain.QuerySetLog.ToString() | ||
| 401 | + } | ||
| 402 | + if l.Qs.Type == domain.SubProcessTable.ToString() { | ||
| 403 | + return domain.QuerySetLog.ToString() | ||
| 404 | + } | ||
| 405 | + if l.Qs.Type == domain.CalculateTable.ToString() { | ||
| 394 | return domain.QuerySetLog.ToString() | 406 | return domain.QuerySetLog.ToString() |
| 395 | } | 407 | } |
| 396 | return domain.FormulaLog.ToString() | 408 | return domain.FormulaLog.ToString() |
| @@ -420,6 +432,9 @@ func (l *DeleteQuerySetLog) LogType() string { | @@ -420,6 +432,9 @@ func (l *DeleteQuerySetLog) LogType() string { | ||
| 420 | if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() { | 432 | if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() { |
| 421 | return domain.QuerySetLog.ToString() | 433 | return domain.QuerySetLog.ToString() |
| 422 | } | 434 | } |
| 435 | + if qs.Type == domain.CalculateTable.ToString() { | ||
| 436 | + return domain.QuerySetLog.ToString() | ||
| 437 | + } | ||
| 423 | return domain.FormulaLog.ToString() | 438 | return domain.FormulaLog.ToString() |
| 424 | } | 439 | } |
| 425 | 440 | ||
| @@ -450,6 +465,9 @@ func (l *CopyQuerySetLog) LogType() string { | @@ -450,6 +465,9 @@ func (l *CopyQuerySetLog) LogType() string { | ||
| 450 | if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() { | 465 | if qs.Type == domain.SchemaTable.ToString() || qs.Type == domain.SubProcessTable.ToString() { |
| 451 | return domain.QuerySetLog.ToString() | 466 | return domain.QuerySetLog.ToString() |
| 452 | } | 467 | } |
| 468 | + if qs.Type == domain.CalculateTable.ToString() { | ||
| 469 | + return domain.QuerySetLog.ToString() | ||
| 470 | + } | ||
| 453 | return domain.FormulaLog.ToString() | 471 | return domain.FormulaLog.ToString() |
| 454 | } | 472 | } |
| 455 | 473 |
| @@ -561,7 +561,7 @@ func formulaEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryCompone | @@ -561,7 +561,7 @@ func formulaEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryCompone | ||
| 561 | return res | 561 | return res |
| 562 | } | 562 | } |
| 563 | if oldQC.Formula.ExprSql != newQC.Formula.ExprSql { | 563 | if oldQC.Formula.ExprSql != newQC.Formula.ExprSql { |
| 564 | - res = append(res, NewFastSourceLog(domain.QuerySetLog, sourceId, &EditFormulaLog{ | 564 | + res = append(res, NewFastSourceLog(domain.FormulaLog, sourceId, &EditFormulaLog{ |
| 565 | LogEntry: entry, | 565 | LogEntry: entry, |
| 566 | OperationType: domain.EditCalculateItem, | 566 | OperationType: domain.EditCalculateItem, |
| 567 | Old: oldQC.Formula.ExprHuman, | 567 | Old: oldQC.Formula.ExprHuman, |
| @@ -588,12 +588,23 @@ func aggregationEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryCom | @@ -588,12 +588,23 @@ func aggregationEditLog(ctx *domain.Context, querySet *domain.QuerySet, queryCom | ||
| 588 | for _, f := range oldQC.Aggregation.AggregationFields() { | 588 | for _, f := range oldQC.Aggregation.AggregationFields() { |
| 589 | mapOldAgFields[f.DisplayName] = f | 589 | mapOldAgFields[f.DisplayName] = f |
| 590 | } | 590 | } |
| 591 | + mapNewAgFields := make(map[string]*domain.AggregationField) | ||
| 592 | + for _, f := range newQC.Aggregation.AggregationFields() { | ||
| 593 | + mapNewAgFields[f.DisplayName] = f | ||
| 594 | + } | ||
| 591 | changList := make([]string, 0) | 595 | changList := make([]string, 0) |
| 592 | for _, f := range newQC.Aggregation.AggregationFields() { | 596 | for _, f := range newQC.Aggregation.AggregationFields() { |
| 593 | if v, ok := mapOldAgFields[f.DisplayName]; ok { | 597 | if v, ok := mapOldAgFields[f.DisplayName]; ok { |
| 594 | if f.Diff(v) { | 598 | if f.Diff(v) { |
| 595 | changList = append(changList, fmt.Sprintf("%s修改为%s", v.Info(), f.Info())) | 599 | changList = append(changList, fmt.Sprintf("%s修改为%s", v.Info(), f.Info())) |
| 596 | } | 600 | } |
| 601 | + } else { | ||
| 602 | + changList = append(changList, fmt.Sprintf("增加%s", f.Info())) | ||
| 603 | + } | ||
| 604 | + } | ||
| 605 | + for _, f := range oldQC.Aggregation.AggregationFields() { | ||
| 606 | + if _, ok := mapNewAgFields[f.DisplayName]; !ok { | ||
| 607 | + changList = append(changList, fmt.Sprintf("删除%s", f.Info())) | ||
| 597 | } | 608 | } |
| 598 | } | 609 | } |
| 599 | 610 |
| @@ -160,7 +160,7 @@ func (repository *QuerySetRepository) Find(queryOptions map[string]interface{}) | @@ -160,7 +160,7 @@ func (repository *QuerySetRepository) Find(queryOptions map[string]interface{}) | ||
| 160 | query.SetWhereByQueryOption("type = ?", "type") | 160 | query.SetWhereByQueryOption("type = ?", "type") |
| 161 | query.SetWhereByQueryOption("flag = ?", "flag") | 161 | query.SetWhereByQueryOption("flag = ?", "flag") |
| 162 | query.SetWhereByQueryOption("status = ?", "status") | 162 | query.SetWhereByQueryOption("status = ?", "status") |
| 163 | - query.SetWhereByQueryOption(fmt.Sprintf("name like '%%%v%%'", queryOptions["matchName"]), "matchName") | 163 | + //query.SetWhereByQueryOption(fmt.Sprintf("name like '%%%v%%'", queryOptions["matchName"]), "matchName") |
| 164 | if v, ok := queryOptions["types"]; ok && len(v.([]string)) > 0 { | 164 | if v, ok := queryOptions["types"]; ok && len(v.([]string)) > 0 { |
| 165 | query.Where("type in (?)", pg.In(v)) | 165 | query.Where("type in (?)", pg.In(v)) |
| 166 | } | 166 | } |
| @@ -68,7 +68,8 @@ func CreateRequestLogFilter(console bool) func(ctx *context.Context) { | @@ -68,7 +68,8 @@ func CreateRequestLogFilter(console bool) func(ctx *context.Context) { | ||
| 68 | 68 | ||
| 69 | func JwtFilter() func(ctx *context.Context) { | 69 | func JwtFilter() func(ctx *context.Context) { |
| 70 | return func(ctx *context.Context) { | 70 | return func(ctx *context.Context) { |
| 71 | - token := ctx.Request.Header.Get("Authorization") | 71 | + //token := ctx.Request.Header.Get("Authorization") |
| 72 | + token := ctx.Request.Header.Get("x-mmm-accesstoken") | ||
| 72 | if len(token) > 0 { | 73 | if len(token) > 0 { |
| 73 | token = strings.TrimPrefix(token, "Bearer ") | 74 | token = strings.TrimPrefix(token, "Bearer ") |
| 74 | userToken := &domain.UserToken{} | 75 | userToken := &domain.UserToken{} |
| @@ -50,18 +50,20 @@ func ParseContext(c beego.BaseController) *domain.Context { | @@ -50,18 +50,20 @@ func ParseContext(c beego.BaseController) *domain.Context { | ||
| 50 | if ok { | 50 | if ok { |
| 51 | // cache user info | 51 | // cache user info |
| 52 | key := cache.KeyCompanyUser(companyId, userId) | 52 | key := cache.KeyCompanyUser(companyId, userId) |
| 53 | - if cacheItem, ok := cache.DefaultCache.Get(key); ok { | ||
| 54 | - v := cacheItem.(*authlib.DataUserMe) | ||
| 55 | - userName = v.User.NickName | ||
| 56 | - } else { | ||
| 57 | - requestToken, _ := userToken.GenerateToken() | ||
| 58 | - authLib := authlib.NewApiAuthLib(constant.AUTH_SERVER_HOST).WithToken(requestToken) | ||
| 59 | - userInfo, err := authLib.MeInfo(authlib.RequestUserMeQuery{}) | ||
| 60 | - if err != nil || userInfo == nil || userInfo.User == nil { | ||
| 61 | - goto END | 53 | + if userToken.UserId != 0 { |
| 54 | + if cacheItem, ok := cache.DefaultCache.Get(key); ok { | ||
| 55 | + v := cacheItem.(*authlib.DataUserMe) | ||
| 56 | + userName = v.User.NickName | ||
| 57 | + } else { | ||
| 58 | + requestToken, _ := userToken.GenerateToken() | ||
| 59 | + authLib := authlib.NewApiAuthLib(constant.AUTH_SERVER_HOST).WithToken(requestToken) | ||
| 60 | + userInfo, err := authLib.MeInfo(authlib.RequestUserMeQuery{}) | ||
| 61 | + if err != nil || userInfo == nil || userInfo.User == nil { | ||
| 62 | + goto END | ||
| 63 | + } | ||
| 64 | + userName = userInfo.User.NickName | ||
| 65 | + cache.DefaultCache.SetDefault(key, userInfo) | ||
| 62 | } | 66 | } |
| 63 | - userName = userInfo.User.NickName | ||
| 64 | - cache.DefaultCache.SetDefault(key, userInfo) | ||
| 65 | } | 67 | } |
| 66 | // assign user | 68 | // assign user |
| 67 | companyId = int(userToken.CompanyId) | 69 | companyId = int(userToken.CompanyId) |
| @@ -91,6 +91,17 @@ func (controller *LogController) QuerySetLog() { | @@ -91,6 +91,17 @@ func (controller *LogController) QuerySetLog() { | ||
| 91 | ResponseGrid(controller.BaseController, total, data, err) | 91 | ResponseGrid(controller.BaseController, total, data, err) |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | +func (controller *LogController) FormulaLog() { | ||
| 95 | + logService := service.NewLogService(nil) | ||
| 96 | + cmd := &command.SearchLogCommand{} | ||
| 97 | + controller.Unmarshal(cmd) | ||
| 98 | + cmd.LogType = domain.FormulaLog.ToString() | ||
| 99 | + cmd.SortByLogId = "DESC" | ||
| 100 | + cmd.Context = ParseContext(controller.BaseController) | ||
| 101 | + total, data, err := logService.SearchLog(cmd) | ||
| 102 | + ResponseGrid(controller.BaseController, total, data, err) | ||
| 103 | +} | ||
| 104 | + | ||
| 94 | func (controller *LogController) VerifiedStepLog() { | 105 | func (controller *LogController) VerifiedStepLog() { |
| 95 | logService := service.NewLogService(nil) | 106 | logService := service.NewLogService(nil) |
| 96 | cmd := &command.SearchLogCommand{} | 107 | cmd := &command.SearchLogCommand{} |
| @@ -15,4 +15,5 @@ func init() { | @@ -15,4 +15,5 @@ func init() { | ||
| 15 | web.Router("/data/logs/table-operate-Log", &controllers.LogController{}, "Post:TableOperateLog") | 15 | web.Router("/data/logs/table-operate-Log", &controllers.LogController{}, "Post:TableOperateLog") |
| 16 | web.Router("/data/logs/verified-step-Log", &controllers.LogController{}, "Post:VerifiedStepLog") | 16 | web.Router("/data/logs/verified-step-Log", &controllers.LogController{}, "Post:VerifiedStepLog") |
| 17 | web.Router("/data/logs/query-set-log", &controllers.LogController{}, "Post:QuerySetLog") | 17 | web.Router("/data/logs/query-set-log", &controllers.LogController{}, "Post:QuerySetLog") |
| 18 | + web.Router("/data/logs/formula-log", &controllers.LogController{}, "Post:FormulaLog") | ||
| 18 | } | 19 | } |
-
请 注册 或 登录 后发表评论