...
|
...
|
@@ -2,6 +2,10 @@ package table |
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"github.com/jinzhu/copier"
|
|
|
"github.com/samber/lo"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr"
|
|
|
|
...
|
...
|
@@ -69,3 +73,53 @@ func newWhere(conditions []*types.Condition) *bytelib.TableQueryWhere { |
|
|
}
|
|
|
return where
|
|
|
}
|
|
|
|
|
|
func (l *SearchTableFieldOptionalValuesLogic) getLocal(req *types.SearchTableFieldOptionalValuesRequest) (resp *types.SearchTableFieldOptionalValuesResponse, err error) {
|
|
|
conn := l.svcCtx.DefaultDBConn()
|
|
|
//查询表数据
|
|
|
objectTable, err := l.svcCtx.ObjectTableRepository.FindOneByTableId(l.ctx, conn, req.ObjectId)
|
|
|
if err != nil || objectTable.Id <= 0 {
|
|
|
return nil, xerr.NewErrMsg("表不存在")
|
|
|
}
|
|
|
if !objectTable.IsLocal {
|
|
|
return nil, xerr.NewErrMsg("未保存到本地存储")
|
|
|
}
|
|
|
//查询表字段
|
|
|
objectField, err := l.svcCtx.ObjectFieldRepository.FindOne(l.ctx, conn, int64(req.ObjectId))
|
|
|
if err != nil || objectField.Id <= 0 {
|
|
|
return nil, xerr.NewErrMsg("表字段不存在")
|
|
|
}
|
|
|
conditions := make([]*domain.TableDataCondition, 0)
|
|
|
_ = copier.Copy(&conditions, req.Condition)
|
|
|
//替换中文字段
|
|
|
for _, item := range conditions {
|
|
|
replace := false
|
|
|
for _, field := range objectField.Fields {
|
|
|
if field.Name == item.FieldName {
|
|
|
item.FieldName = field.SQLName
|
|
|
replace = true
|
|
|
}
|
|
|
}
|
|
|
if !replace {
|
|
|
return nil, xerr.NewErrMsg("字段" + item.FieldName + "不存在")
|
|
|
}
|
|
|
}
|
|
|
//表数据
|
|
|
_, list, err := l.svcCtx.ObjectTableDataRepository.Find(l.ctx, conn, req.ObjectId, &domain.ObjectTableDataQuery{
|
|
|
Conditions: conditions,
|
|
|
})
|
|
|
fmt.Println(list)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsg("查询表数据失败")
|
|
|
}
|
|
|
resp = &types.SearchTableFieldOptionalValuesResponse{
|
|
|
Values: make([]string, 0),
|
|
|
Total: 0,
|
|
|
}
|
|
|
if len(list) > 0 {
|
|
|
lo.ForEach(list, func(item map[string]interface{}, index int) {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
return resp, nil
|
|
|
} |
...
|
...
|
|