作者 Administrator

合并分支 'test' 到 'master'

Test



查看合并请求 !4
... ... @@ -162,6 +162,97 @@
- [ ] 10W ..
- [ ] 保存单个文件、压缩 | 保存多个文件、压缩
## 表达式解析
### 表达式类型说明
- ValueExprAST: 值表达式(数值,字符串) e.g. 1 、 2011-1-1 、字符串
```json
{
"exprType":"ValueExprAST",
"val":"",
"str":"业绩2"
}
```
- FieldExprAST: 字段表达式(处理的字段) e.g. 生产明细.业绩
```json
{
"exprType":"FieldExprAST",
"str":"业绩1",
"field":{
"tableId":1,
"tableName":"测试ABC",
"tableSqlName":"table_abc_test",
"fieldName":"业绩",
"fieldSqlName":"ye_ji_1",
"fieldSqlType":"Float"
}
}
```
- BinaryExprAST: 二元表达式 e.g. 1 + 2 、 100 * 生产明细.业绩
```json
{
"exprType":"BinaryExprAST",
"op":"/",
"lhs":{},
"rhs":{}
}
```
- FunCallerExprAST:函数表达式 e.g. sum(arg1,arg2,arg3)
```json
{
"arrayFlag": false,
"exprType": "FunCallerExprAST",
"name": "sum",
"args": []
}
```
### 用例
- 输入表达式 `SUM(1/COUNTIFS(【业绩】,【业绩】))`
```json
{
"arrayFlag":false,
"exprType":"FunCallerExprAST",
"name":"sum",
"args":[
{
"exprType":"BinaryExprAST",
"op":"/",
"lhs":{
"exprType":"ValueExprAST",
"val":"",
"str":"1"
},
"rhs":{
"arrayFlag":false,
"exprType":"FunCallerExprAST",
"name":"countifs",
"args":[
{
"exprType":"FieldExprAST",
"str":"业绩1",
"field":{
"tableId":1,
"tableName":"测试ABC",
"tableSqlName":"table_abc_test",
"fieldName":"业绩",
"fieldSqlName":"ye_ji_1",
"fieldSqlType":"Float"
}
},
{
"exprType":"ValueExprAST",
"val":"",
"str":"业绩2"
}
]
}
}
]
}
```
## 讨论事项
- [ ] 校验动作,参数模型讨论
... ...
... ... @@ -19,7 +19,14 @@ type AppendDataToTableCommand struct {
}
func (cmd *AppendDataToTableCommand) Valid(validation *validation.Validation) {
newMappingFields := make([]*domain.MappingField, 0)
for i := range cmd.MappingFields {
if len(cmd.MappingFields[i].VerifiedFileFieldName) == 0 {
continue
}
newMappingFields = append(newMappingFields, cmd.MappingFields[i])
}
cmd.MappingFields = newMappingFields
}
func (cmd *AppendDataToTableCommand) ValidateCommand() error {
... ...
... ... @@ -190,6 +190,9 @@ func (fileService *FileService) AppendDataToTable(ctx *domain.Context, cmd *comm
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
if len(cmd.MappingFields) == 0 {
return nil, factory.FastError(fmt.Errorf("请选择对应字段"))
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -212,6 +215,33 @@ func (fileService *FileService) AppendDataToTable(ctx *domain.Context, cmd *comm
return result, nil
}
// AppendDataToTable 追加数据
func (fileService *FileService) AppendDataToTablePreflightCheck(ctx *domain.Context, cmd *command.AppendDataToTableCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
generateMainTableService, _ := factory.CreateAppendDataToTableService(transactionContext)
result, err := generateMainTableService.PreflightCheck(ctx, cmd.FileId, cmd.TableId, cmd.MappingFields)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
// ExportFile 文件下载
func (fileService *FileService) ExportFile(ctx *domain.Context, cmd *command.ExportFileCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
... ...
... ... @@ -17,7 +17,7 @@ type QuerySetDetailDto struct {
TableId int `json:"tableId"`
}
func (d *QuerySetDetailDto) Load(m *domain.QuerySet) *QuerySetDetailDto {
func (d *QuerySetDetailDto) Load(m *domain.QuerySet, mapTables map[int]*domain.Table) *QuerySetDetailDto {
d.QuerySetId = m.QuerySetId
d.Type = m.Type
d.Flag = m.Flag
... ... @@ -26,7 +26,12 @@ func (d *QuerySetDetailDto) Load(m *domain.QuerySet) *QuerySetDetailDto {
if m.QuerySetInfo != nil {
d.TableId = m.QuerySetInfo.BindTableId
}
for i := range d.QueryComponents {
for i, q := range d.QueryComponents {
if q.MasterTable != nil && q.MasterTable.TableId != 0 {
if t, ok := mapTables[q.MasterTable.TableId]; ok {
d.QueryComponents[i].MasterTable = domain.NewQueryComponentTable(t)
}
}
if d.QueryComponents[i].Aggregation != nil {
d.QueryComponents[i].Aggregation.Aggregation.AllFields = d.QueryComponents[i].Aggregation.AggregationFields()
}
... ...
... ... @@ -159,7 +159,17 @@ func (querySetService *QuerySetService) GetQuerySet(ctx *domain.Context, getQuer
if err != nil {
return nil, factory.FastError(err)
}
return (&dto.QuerySetDetailDto{}).Load(querySet), nil
tableRepository, _, _ := factory.FastPgTable(transactionContext, 0)
dependencyTables := querySet.GetDependencyTables(querySet.QueryComponents)
var tables domain.Tables
if len(dependencyTables) > 0 {
_, tables, err = tableRepository.Find(map[string]interface{}{"context": ctx, "tableIds": dependencyTables})
if err != nil {
return nil, factory.FastError(err)
}
}
return (&dto.QuerySetDetailDto{}).Load(querySet, tables.ToMap()), nil
}
// 返回查询集合服务列表
... ...
package domain
import (
"encoding/json"
"fmt"
)
const (
TypeFunCallerExprAST = "FunCallerExprAST"
TypeBinaryExprAST = "BinaryExprAST"
TypeFieldExprAST = "FieldExprAST"
TypeValueExprAST = "ValueExprAST"
)
type ExprAST interface {
toStr() string
}
type ValueExprAST struct {
ExprType string `json:"exprType"`
Val string `json:"val"`
Str string `json:"str"`
}
type FieldExprAST struct {
ExprType string `json:"exprType"`
Str string `json:"str"`
Field *TableField `json:"field"`
}
type BinaryExprAST struct {
ExprType string `json:"exprType"`
Op string `json:"op"`
Lhs ExprAST `json:"lhs"`
Rhs ExprAST `json:"rhs"`
}
type FunCallerExprAST struct {
ArrayFlag bool `json:"arrayFlag"`
ExprType string `json:"exprType"`
Name string `json:"name"`
Args []ExprAST `json:"args"`
}
func (n ValueExprAST) toStr() string {
return fmt.Sprintf(
"ValueExprAST:%s",
n.Str,
)
}
func (n FieldExprAST) toStr() string {
return fmt.Sprintf(
"FieldExprAST:%s",
n.Str,
)
}
func (b BinaryExprAST) toStr() string {
return fmt.Sprintf(
"BinaryExprAST: (%s %s %s)",
b.Op,
b.Lhs.toStr(),
b.Rhs.toStr(),
)
}
func (n FunCallerExprAST) toStr() string {
return fmt.Sprintf(
"FunCallerExprAST:%s",
n.Name,
)
}
type CloneFunCallerExprAST struct {
ArrayFlag bool `json:"arrayFlag"`
Name string `json:"name"`
Arg []json.RawMessage `json:"args"`
}
type CloneBinaryExprAST struct {
Op string `json:"op"`
Lhs json.RawMessage `json:"lhs"`
Rhs json.RawMessage `json:"rhs"`
}
func AstExprUnmarshalJSON(data []byte) (interface{}, error) {
var m = make(map[string]interface{})
if err := json.Unmarshal(data, &m); err != nil {
return nil, err
}
value, err := unmarshalMapInterface(m, data)
if err != nil {
return data, err
}
return value, nil
}
func unmarshalMapInterface(m map[string]interface{}, rawData []byte) (interface{}, error) {
t, ok := m["exprType"]
if !ok {
return nil, nil
}
if t == TypeFunCallerExprAST {
expr := &CloneFunCallerExprAST{}
if err := json.Unmarshal(rawData, expr); err != nil {
return nil, err
}
exprReturn := &FunCallerExprAST{Name: expr.Name, ExprType: TypeFunCallerExprAST}
for i := range expr.Arg {
subExpr, err := AstExprUnmarshalJSON(expr.Arg[i])
if err != nil {
return nil, err
}
if subExpr == nil {
continue
}
exprReturn.Args = append(exprReturn.Args, subExpr.(ExprAST))
}
return exprReturn, nil
}
if t == TypeBinaryExprAST {
expr := &CloneBinaryExprAST{}
if err := json.Unmarshal(rawData, expr); err != nil {
return nil, err
}
exprReturn := &BinaryExprAST{Op: expr.Op, ExprType: TypeBinaryExprAST}
if len(expr.Lhs) > 0 {
subExpr, err := AstExprUnmarshalJSON(expr.Lhs)
if err != nil {
return nil, err
}
if subExpr != nil {
exprReturn.Lhs = subExpr.(ExprAST)
}
}
if len(expr.Rhs) > 0 {
subExpr, err := AstExprUnmarshalJSON(expr.Rhs)
if err != nil {
return nil, err
}
if subExpr != nil {
exprReturn.Rhs = subExpr.(ExprAST)
}
}
return exprReturn, nil
}
if t == TypeFieldExprAST {
expr := &FieldExprAST{ExprType: TypeFieldExprAST}
if err := json.Unmarshal(rawData, expr); err != nil {
return nil, err
}
return expr, nil
}
if t == TypeValueExprAST {
expr := &ValueExprAST{ExprType: TypeValueExprAST}
if err := json.Unmarshal(rawData, expr); err != nil {
return nil, err
}
return expr, nil
}
return nil, fmt.Errorf("unkonw expr type '%v'", t)
}
... ...
package domain
import (
"github.com/linmadan/egglib-go/utils/json"
"github.com/stretchr/testify/assert"
"testing"
)
func TestAstExprUnmarshalJSON(t *testing.T) {
inputs := []struct {
data ExprAST
}{
{
data: &FunCallerExprAST{
Name: "if",
ExprType: TypeFunCallerExprAST,
Args: []ExprAST{
&BinaryExprAST{
ExprType: TypeBinaryExprAST,
Op: "<",
Lhs: &FieldExprAST{
ExprType: TypeFieldExprAST,
Str: "table.count",
},
Rhs: &FieldExprAST{
ExprType: TypeFieldExprAST,
Str: "100",
},
},
&FieldExprAST{
ExprType: TypeFieldExprAST,
Str: "200",
},
&FieldExprAST{
ExprType: TypeFieldExprAST,
Str: "300",
},
},
},
},
{
data: &FunCallerExprAST{
Name: "sum",
ExprType: TypeFunCallerExprAST,
Args: []ExprAST{
&BinaryExprAST{
ExprType: TypeBinaryExprAST,
Op: "/",
Lhs: &ValueExprAST{
ExprType: TypeValueExprAST,
Str: "1",
},
Rhs: &FunCallerExprAST{
ExprType: TypeFunCallerExprAST,
Name: "countifs",
Args: []ExprAST{
&FieldExprAST{
ExprType: TypeFieldExprAST,
Str: "业绩1",
Field: &TableField{
TableId: 1,
TableName: "测试ABC",
TableSqlName: "table_abc_test",
FieldName: "业绩",
FieldSqlName: "ye_ji_1",
FieldSQLType: "Float",
},
},
&ValueExprAST{
ExprType: TypeValueExprAST,
Str: "业绩2",
},
},
},
},
},
},
},
}
for _, input := range inputs {
data, err := json.Marshal(input.data)
if err != nil {
t.Fatal(err)
}
v, err := AstExprUnmarshalJSON(data)
if err != nil {
t.Fatal(err)
}
if v != nil {
}
assert.Equal(t, input.data, v)
}
}
... ...
... ... @@ -50,6 +50,7 @@ type DeleteDataTableService interface {
type AppendDataToTableService interface {
AppendData(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
PreflightCheck(ctx *Context, fileId int, tableId int, mappingFields []*MappingField) (interface{}, error)
}
/************************************/
... ...
... ... @@ -18,6 +18,8 @@ type LogEntry struct {
Level string `json:"level"`
// 日志时间
LogTime string `json:"logTime"`
// 追加文件ID (操作类型 主表生成、数据导入时有效)
AppendFileId int `json:"appendFileId,omitempty"`
// 错误信息
Error string `json:"error"`
ctx *Context `json:"-"`
... ... @@ -40,6 +42,11 @@ func (l LogEntry) OperateType() string {
return l.OperationType
}
func (l *LogEntry) WithAppendFileId(fileId int) LogEntry {
l.AppendFileId = fileId
return *l
}
func NewLogEntry(fileOrTableName string, objectType string, operationType OperationType, ctx *Context) LogEntry {
return LogEntry{
ObjectName: fileOrTableName,
... ...
... ... @@ -163,3 +163,13 @@ func TableTypesToStringList(list ...TableType) []string {
}
return result
}
type Tables []*Table
func (tables Tables) ToMap() map[int]*Table {
var result = make(map[int]*Table)
for i := range tables {
result[tables[i].TableId] = tables[i]
}
return result
}
... ...
... ... @@ -139,9 +139,11 @@ func NewTable(tableType domain.TableType, fileName string, dataFields []*domain.
if table.TableType == domain.CalculateTable.ToString() || table.TableType == domain.CalculateItem.ToString() {
table.PK = nil
}
builder := NewDataFieldsBuilder()
table.DataFieldIndex = len(dataFields)
for i, field := range dataFields {
table.DataFields = append(table.DataFields, DataField(field.Name, field.SQLType, domain.MainTableField, i+1))
for _, field := range dataFields {
//table.DataFields = append(table.DataFields, DataField(field.Name, field.SQLType, domain.MainTableField, i+1))
table.DataFields = append(table.DataFields, builder.NewDataField(field.Name, field.SQLType, domain.MainTableField))
}
table.ManualFields = make([]*domain.Field, 0)
table.CreatedAt = time.Now()
... ... @@ -197,6 +199,44 @@ func DataField(name string, sqlType string, flag int, index int) *domain.Field {
}
}
type DataFieldsBuilder struct {
mapPinFields map[string]int
}
func NewDataFieldsBuilder() *DataFieldsBuilder {
builder := &DataFieldsBuilder{
mapPinFields: make(map[string]int),
}
return builder
}
func (builder *DataFieldsBuilder) NewDataField(name string, sqlType string, flag int) *domain.Field {
var index = 0
pinName := pin(name)
index = builder.AddPinItem(pinName)
return &domain.Field{
Index: index,
Name: name,
SQLName: fmt.Sprintf("%v_%d", pinName, index),
SQLType: sqlType,
Description: "",
Flag: flag,
}
}
func (builder *DataFieldsBuilder) AddPinItem(pin string) int {
var index = 1
for {
key := fmt.Sprintf("%v_%d", pin, index)
if _, ok := builder.mapPinFields[key]; !ok {
builder.mapPinFields[key] = index
break
}
index++
}
return index
}
func pin(name string) string {
pinyin := tool_funs.ToPinYin(name, "_")
newPinyin := bytes.NewBuffer(nil)
... ...
... ... @@ -37,8 +37,9 @@ func (ptr *GenerateMainTableService) GenerateTable(ctx *domain.Context, fileId i
return nil, err
}
// 日志
entry := domain.NewLogEntry(tableName, domain.MainTable.ToString(), domain.GenerateMainTable, ctx)
if err = FastLog(ptr.transactionContext, domain.CommonLog, mainTable.TableId, &GenerateMainTableLog{
LogEntry: domain.NewLogEntry(tableName, domain.MainTable.ToString(), domain.GenerateMainTable, ctx),
LogEntry: (&entry).WithAppendFileId(file.FileId),
FileName: file.FileInfo.Name,
}); err != nil {
return nil, err
... ...
... ... @@ -295,8 +295,10 @@ func (ptr *QuerySetService) PreviewPrepare(ctx *domain.Context, querySetId int,
dependencyTables := querySet.GetDependencyTables(queryComponents)
if querySet.Type == domain.CalculateTable.ToString() {
aggregationFields := append(queryComponents[0].Aggregation.RowFields, queryComponents[0].Aggregation.ValueFields...)
for index, f := range aggregationFields {
fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index))
builder := NewDataFieldsBuilder()
for _, f := range aggregationFields {
//fields = append(fields, DataField(f.DisplayName, f.Field.SQLType, domain.MainTableField, index))
fields = append(fields, builder.NewDataField(f.DisplayName, f.Field.SQLType, domain.MainTableField))
}
} else {
masterTable := queryComponents[0].MasterTable
... ... @@ -723,7 +725,9 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateItemTable(ctx *domain.Context
//if queryComponent.Formula.MixTableModel() {
// queryComponent.Formula.Complete()
//}
field := DataField(querySet.Name, domain.String.ToString(), domain.MainTableField, 1)
builder := NewDataFieldsBuilder()
//field := DataField(querySet.Name, domain.String.ToString(), domain.MainTableField, 1)
field := builder.NewDataField(querySet.Name, domain.String.ToString(), domain.MainTableField)
if len(queryComponent.Formula.TableFields) > 0 {
field.SQLType = queryComponent.Formula.TableFields[0].FieldSQLType
}
... ... @@ -768,13 +772,15 @@ func (ptr *QuerySetService) CreateOrUpdateCalculateTable(ctx *domain.Context, qu
return nil, fmt.Errorf("行、值不能同时为空")
}
selectedFields := make([]string, 0)
for index, f := range aggregationFields {
builder := NewDataFieldsBuilder()
for _, f := range aggregationFields {
// 数值类型转浮点类型, 兼容类似表达式 1 * 1.1
sqlType := f.Field.SQLType
if f.Field.SQLType == domain.Int.ToString() || f.Field.SQLType == domain.BigInt.ToString() {
sqlType = domain.Float.ToString()
}
fields = append(fields, DataField(f.DisplayName, sqlType, domain.MainTableField, index))
//fields = append(fields, DataField(f.DisplayName, sqlType, domain.MainTableField, index))
fields = append(fields, builder.NewDataField(f.DisplayName, sqlType, domain.MainTableField))
selectedFields = append(selectedFields, f.Field.Name)
}
queryComponent.Aggregation.SelectFields = selectedFields
... ...
... ... @@ -37,7 +37,7 @@ func (ptr *AddTableStructService) AddTableStruct(ctx *domain.Context, parentTabl
return nil, fmt.Errorf("表名称重复")
}
fields = MappingFields(mainTable, fields)
fields = MappingFieldsV2(mainTable, fields)
dataFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.MainTableField})
manualFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.ManualField})
table := NewTable(domain.SubTable, name, fields, mainTable.RowCount).WithContext(ctx).WithPrefix(string(domain.SubTable))
... ...
... ... @@ -49,8 +49,9 @@ func (ptr *AppendDataToTableService) AppendData(ctx *domain.Context, fileId int,
}
// 日志
entry := domain.NewLogEntry(table.Name, domain.MainTable.ToString(), domain.AppendData, ctx)
if err = FastLog(ptr.transactionContext, domain.CommonLog, table.TableId, &AppendDataToTableLog{
LogEntry: domain.NewLogEntry(table.Name, domain.MainTable.ToString(), domain.AppendData, ctx),
LogEntry: (&entry).WithAppendFileId(fileId),
File: file,
Table: table,
SubTables: subTables,
... ... @@ -90,6 +91,39 @@ func (ptr *AppendDataToTableService) AppendData(ctx *domain.Context, fileId int,
}, nil
}
// PreflightCheck 预检
func (ptr *AppendDataToTableService) PreflightCheck(ctx *domain.Context, fileId int, tableId int, mappingFields []*domain.MappingField) (interface{}, error) {
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
table, err := tableRepository.FindOne(map[string]interface{}{"tableId": tableId})
if err != nil {
return nil, fmt.Errorf("表不存在")
}
inSourceId := []int{table.TableId}
if table.ParentId != 0 {
inSourceId = append(inSourceId, table.ParentId)
}
logRepository, _ := repository.NewLogRepository(ptr.transactionContext)
_, logs, err := logRepository.Find(map[string]interface{}{
"inSourceId": inSourceId,
"inOperationType": []string{domain.GenerateMainTable.ToString(), domain.AppendData.ToString()},
"limit": 500,
})
if err != nil {
return nil, err
}
for _, log := range logs {
if log.Entry.AppendFileId == fileId {
return map[string]interface{}{
"fileAppended": true,
}, nil
}
}
return map[string]interface{}{
"fileAppended": false,
}, nil
}
func NewAppendDataToTableService(transactionContext *pgTransaction.TransactionContext) (*AppendDataToTableService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -36,7 +36,7 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl
return nil, fmt.Errorf("主表不存在")
}
fields = MappingFields(mainTable, fields)
fields = MappingFieldsV2(mainTable, fields)
reserves, deletes, adds := domain.FieldsChange(table.Fields(false), fields)
dataFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.MainTableField})
manualFields := (domain.Fields)(fields).Select(map[string]interface{}{"flag": domain.ManualField})
... ... @@ -81,9 +81,33 @@ func (ptr *UpdateTableStructService) UpdateTableStruct(ctx *domain.Context, tabl
return struct{}{}, nil
}
func MappingFields(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {
//func MappingFields(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {
// tableFields := mainTable.Fields(false)
// tableFieldsMap := (domain.Fields)(tableFields).ToMap()
// for i := range fields {
// f := fields[i]
// if v, ok := tableFieldsMap[f.Name]; ok {
// fields[i].Name = v.Name
// fields[i].SQLName = v.SQLName
// fields[i].Index = v.Index
// fields[i].SQLType = v.SQLType
// fields[i].Description = f.Description
// fields[i].Flag = v.Flag
// } else {
// if f.Flag == domain.ManualField && f.Index == 0 {
// mainTable.DataFieldIndex += 1
// fields[i] = DataField(f.Name, f.SQLType, domain.ManualField, mainTable.DataFieldIndex)
// fields[i].Description = f.Description
// }
// }
// }
// return fields
//}
func MappingFieldsV2(mainTable *domain.Table, fields []*domain.Field) []*domain.Field {
tableFields := mainTable.Fields(false)
tableFieldsMap := (domain.Fields)(tableFields).ToMap()
builder := NewDataFieldsBuilder()
for i := range fields {
f := fields[i]
if v, ok := tableFieldsMap[f.Name]; ok {
... ... @@ -93,10 +117,11 @@ func MappingFields(mainTable *domain.Table, fields []*domain.Field) []*domain.Fi
fields[i].SQLType = v.SQLType
fields[i].Description = f.Description
fields[i].Flag = v.Flag
builder.NewDataField(v.Name, v.SQLType, v.Flag)
} else {
if f.Flag == domain.ManualField && f.Index == 0 {
mainTable.DataFieldIndex += 1
fields[i] = DataField(f.Name, f.SQLType, domain.ManualField, mainTable.DataFieldIndex)
//mainTable.DataFieldIndex += 1
fields[i] = builder.NewDataField(f.Name, f.SQLType, domain.ManualField)
fields[i].Description = f.Description
}
}
... ...
... ... @@ -144,6 +144,9 @@ func (repository *LogRepository) Find(queryOptions map[string]interface{}) (int6
if v, ok := queryOptions["inSourceId"]; ok && len(v.([]int)) > 0 {
query.Where("source_id in (?)", pg.In(v.([]int)))
}
if v, ok := queryOptions["inOperationType"]; ok && len(v.([]string)) > 0 {
query.Where("entry->>'operationType' in (?)", pg.In(v.([]string)))
}
if v, ok := queryOptions["matchContent"]; ok && len(v.(string)) > 0 {
query.WhereGroup(func(query *orm.Query) (*orm.Query, error) {
matchContent := v.(string)
... ...
... ... @@ -138,6 +138,14 @@ func (controller *FileController) AppendDataToTable() {
controller.Response(data, err)
}
func (controller *FileController) AppendDataToTablePreflightCheck() {
fileService := service.NewFileService(nil)
cmd := &command.AppendDataToTableCommand{}
controller.Unmarshal(cmd)
data, err := fileService.AppendDataToTablePreflightCheck(ParseContext(controller.BaseController), cmd)
controller.Response(data, err)
}
func (controller *FileController) CancelVerifyingFile() {
fileService := service.NewFileService(nil)
cmd := &command.CancelVerifyingFileCommand{}
... ...
... ... @@ -24,4 +24,5 @@ func init() {
web.Router("/data/flush-data-table", &controllers.FileController{}, "Post:FlushDataTable")
web.Router("/data/generate-main-table", &controllers.FileController{}, "Post:GenerateMainTable")
web.Router("/data/append-data-to-table", &controllers.FileController{}, "Post:AppendDataToTable")
web.Router("/data/append-data-preflight-check", &controllers.FileController{}, "Post:AppendDataToTablePreflightCheck")
}
... ...