正在显示
9 个修改的文件
包含
102 行增加
和
33 行删除
deploy/db/db_query_script.sql
0 → 100644
| 1 | +/* | ||
| 2 | + 1. 查询依赖的查询集 | ||
| 3 | +*/ | ||
| 4 | +select * from metadata.query_sets where query_set_info->>'BindTableId' in ( | ||
| 5 | + select distinct table_id::text from ( /*element_id,table_info,table_type*/ | ||
| 6 | + select json_array_elements(to_json(table_info->'dependencyTables'))::text::int element_id,table_info,table_id,table_type | ||
| 7 | + from metadata.tables where table_info->'dependencyTables'::text <>'null' and table_type in ('SubProcess','CalculateTable') | ||
| 8 | + ) a where a.element_id in (select table_id from metadata.tables where table_type in ('MainTable','SubTable','SideTable')) | ||
| 9 | + order by table_id asc | ||
| 10 | +) and context->>'operatorId' = '22' |
| @@ -46,6 +46,6 @@ require ( | @@ -46,6 +46,6 @@ require ( | ||
| 46 | replace ( | 46 | replace ( |
| 47 | github.com/extrame/xls v0.0.1 => github.com/tiptok/xls v1.0.1 | 47 | github.com/extrame/xls v0.0.1 => github.com/tiptok/xls v1.0.1 |
| 48 | //github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v0.0.0-20220421085958-9682d0ac42c1 | 48 | //github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v0.0.0-20220421085958-9682d0ac42c1 |
| 49 | - github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v1.0.0 | 49 | + github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v1.0.2 |
| 50 | 50 | ||
| 51 | ) | 51 | ) |
| 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 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" |
| @@ -11,6 +12,7 @@ import ( | @@ -11,6 +12,7 @@ import ( | ||
| 11 | ) | 12 | ) |
| 12 | 13 | ||
| 13 | func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command.TablePreviewCommand) (interface{}, error) { | 14 | func (tableService *TableService) TablePreview(ctx *domain.Context, cmd *command.TablePreviewCommand) (interface{}, error) { |
| 15 | + return nil, factory.FastError(fmt.Errorf("Backend not found. Check if any backend is down or not")) | ||
| 14 | if cmd.TableId == 0 { | 16 | if cmd.TableId == 0 { |
| 15 | return &dto.TablePreviewDto{}, nil | 17 | return &dto.TablePreviewDto{}, nil |
| 16 | } | 18 | } |
| @@ -273,8 +273,10 @@ func RoundFieldValue(f *Field, v string) string { | @@ -273,8 +273,10 @@ func RoundFieldValue(f *Field, v string) string { | ||
| 273 | return utils.AssertString(fv) //fmt.Sprintf("%v", fv) | 273 | return utils.AssertString(fv) //fmt.Sprintf("%v", fv) |
| 274 | } | 274 | } |
| 275 | // TODO:计算表 Count(日期)类型是日期类型,0 的话下面日期解析成当前时间,计算表类型需要修改 | 275 | // TODO:计算表 Count(日期)类型是日期类型,0 的话下面日期解析成当前时间,计算表类型需要修改 |
| 276 | - if fv, err := strconv.ParseFloat(v, 64); err == nil { | ||
| 277 | - return utils.AssertString(fv) | 276 | + if f.SQLType == Datetime.ToString() || f.SQLType == Date.ToString() { |
| 277 | + if fv, err := strconv.ParseFloat(v, 64); err == nil { | ||
| 278 | + return utils.AssertString(fv) | ||
| 279 | + } | ||
| 278 | } | 280 | } |
| 279 | if f.SQLType == Datetime.ToString() { | 281 | if f.SQLType == Datetime.ToString() { |
| 280 | fv, err := xtime.Parse(v) | 282 | fv, err := xtime.Parse(v) |
| @@ -445,7 +445,7 @@ func (d *DataLayoutDataTable) Expand(cell *domain.LayoutCell, length int) error | @@ -445,7 +445,7 @@ func (d *DataLayoutDataTable) Expand(cell *domain.LayoutCell, length int) error | ||
| 445 | if expandLength < length { | 445 | if expandLength < length { |
| 446 | expandLength = length | 446 | expandLength = length |
| 447 | } | 447 | } |
| 448 | - if d.MaxX+expandLength > MaxExpandNum { | 448 | + if d.MaxX+expandLength > MaxExpandNum+DefaultExpandNum { |
| 449 | return fmt.Errorf("布局元素超过限制 %d", MaxExpandNum) | 449 | return fmt.Errorf("布局元素超过限制 %d", MaxExpandNum) |
| 450 | } | 450 | } |
| 451 | copyData := make([][]string, d.MaxX+length) | 451 | copyData := make([][]string, d.MaxX+length) |
| @@ -171,7 +171,7 @@ func (repository *QuerySetRepository) Find(queryOptions map[string]interface{}) | @@ -171,7 +171,7 @@ func (repository *QuerySetRepository) Find(queryOptions map[string]interface{}) | ||
| 171 | query.Where("query_set_info->'BindTableId' in (?)", pg.In(utils.ToArrayString(v.([]int)))) | 171 | query.Where("query_set_info->'BindTableId' in (?)", pg.In(utils.ToArrayString(v.([]int)))) |
| 172 | } | 172 | } |
| 173 | if v, ok := queryOptions["sortByName"]; ok && len(v.(string)) > 0 { | 173 | if v, ok := queryOptions["sortByName"]; ok && len(v.(string)) > 0 { |
| 174 | - query.SetOrderDirect("pin_name", v.(string)) | 174 | + query.SetOrderDirect("name", v.(string))//pin_name |
| 175 | } else if v, ok := queryOptions["sortByTime"]; ok && len(v.(string)) > 0 { | 175 | } else if v, ok := queryOptions["sortByTime"]; ok && len(v.(string)) > 0 { |
| 176 | query.SetOrderDirect("created_at", v.(string)) | 176 | query.SetOrderDirect("created_at", v.(string)) |
| 177 | } else { | 177 | } else { |
| 1 | +package controllers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + _ "embed" | ||
| 5 | + "github.com/linmadan/egglib-go/core/application" | ||
| 6 | + "github.com/linmadan/egglib-go/utils/json" | ||
| 7 | + "strings" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +//go:embed errors.txt | ||
| 11 | +var errorsData []byte | ||
| 12 | + | ||
| 13 | +type CommErrorResolver struct { | ||
| 14 | + // TODO:LRU latest error list | ||
| 15 | + ErrorMapping map[string]string `json:"errorMapping"` | ||
| 16 | + errMapping map[string]error `json:"errorMapping"` | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func (r *CommErrorResolver) Resolve(err error) error { | ||
| 20 | + if err == nil { | ||
| 21 | + return nil | ||
| 22 | + } | ||
| 23 | + errMsg := err.Error() | ||
| 24 | + if r.errMapping == nil { | ||
| 25 | + return err | ||
| 26 | + } | ||
| 27 | + if v, ok := r.errMapping[errMsg]; ok { | ||
| 28 | + return v | ||
| 29 | + } | ||
| 30 | + for k, v := range r.errMapping { | ||
| 31 | + if strings.Contains(errMsg, k) { | ||
| 32 | + return v | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + return err | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +func NewCommErrorResolver() (*CommErrorResolver, error) { | ||
| 39 | + obj := &CommErrorResolver{errMapping: make(map[string]error)} | ||
| 40 | + err := json.Unmarshal(errorsData, obj) | ||
| 41 | + if err != nil { | ||
| 42 | + return nil, err | ||
| 43 | + } | ||
| 44 | + for k, v := range obj.ErrorMapping { | ||
| 45 | + obj.errMapping[k] = application.ThrowError(application.INTERNAL_SERVER_ERROR, v) | ||
| 46 | + } | ||
| 47 | + return obj, nil | ||
| 48 | +} |
pkg/port/beego/controllers/errors.txt
0 → 100644
| @@ -6,37 +6,39 @@ import ( | @@ -6,37 +6,39 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | func init() { | 8 | func init() { |
| 9 | - web.Router("/data/tables/", &controllers.TableController{}, "Post:CreateTable") | ||
| 10 | - //web.Router("/data/tables/:tableId", &controllers.TableController{}, "Put:UpdateTable") | ||
| 11 | - web.Router("/data/tables/:tableId", &controllers.TableController{}, "Get:GetTable") | ||
| 12 | - web.Router("/data/tables/prepare", &controllers.TableController{}, "Get:PrepareTable") | ||
| 13 | - web.Router("/data/tables/:tableId", &controllers.TableController{}, "Delete:RemoveTable") | ||
| 14 | - web.Router("/data/tables/", &controllers.TableController{}, "Get:ListTable") | ||
| 15 | - web.Router("/data/tables/search", &controllers.TableController{}, "Post:Search") | ||
| 16 | - web.Router("/data/tables/relation-graph", &controllers.TableController{}, "Post:RelationGraph") | ||
| 17 | - web.Router("/data/tables/apply-on", &controllers.TableController{}, "Post:ApplyOn") | ||
| 18 | - web.Router("/data/tables/valid-expr-sql", &controllers.TableController{}, "Post:ValidExprSql") | ||
| 19 | - web.Router("/data/tables/check", &controllers.TableController{}, "Post:CheckRowDuplicate") | ||
| 20 | - web.Router("/data/tables/check-row-value-duplicate", &controllers.TableController{}, "Post:CheckRowValueDuplicate") | ||
| 21 | - web.Router("/data/tables/search-appended-list", &controllers.TableController{}, "Post:SearchAppendedList") | ||
| 22 | - web.Router("/data/tables/search-sub-table-list", &controllers.TableController{}, "Post:SearchSubTableList") | ||
| 23 | - web.Router("/data/tables/search-query-set-tables", &controllers.TableController{}, "Post:SearchQuerySetTables") | ||
| 24 | - web.Router("/data/tables/dependency-graph", &controllers.TableController{}, "Post:DependencyGraph") | 9 | + tableController := &controllers.TableController{} |
| 10 | + //tableController.BaseController.ErrorResolver, _ = controllers.NewCommErrorResolver() | ||
| 11 | + web.Router("/data/tables/", tableController, "Post:CreateTable") | ||
| 12 | + //web.Router("/data/tables/:tableId", tableController, "Put:UpdateTable") | ||
| 13 | + web.Router("/data/tables/:tableId", tableController, "Get:GetTable") | ||
| 14 | + web.Router("/data/tables/prepare", tableController, "Get:PrepareTable") | ||
| 15 | + web.Router("/data/tables/:tableId", tableController, "Delete:RemoveTable") | ||
| 16 | + web.Router("/data/tables/", tableController, "Get:ListTable") | ||
| 17 | + web.Router("/data/tables/search", tableController, "Post:Search") | ||
| 18 | + web.Router("/data/tables/relation-graph", tableController, "Post:RelationGraph") | ||
| 19 | + web.Router("/data/tables/apply-on", tableController, "Post:ApplyOn") | ||
| 20 | + web.Router("/data/tables/valid-expr-sql", tableController, "Post:ValidExprSql") | ||
| 21 | + web.Router("/data/tables/check", tableController, "Post:CheckRowDuplicate") | ||
| 22 | + web.Router("/data/tables/check-row-value-duplicate", tableController, "Post:CheckRowValueDuplicate") | ||
| 23 | + web.Router("/data/tables/search-appended-list", tableController, "Post:SearchAppendedList") | ||
| 24 | + web.Router("/data/tables/search-sub-table-list", tableController, "Post:SearchSubTableList") | ||
| 25 | + web.Router("/data/tables/search-query-set-tables", tableController, "Post:SearchQuerySetTables") | ||
| 26 | + web.Router("/data/tables/dependency-graph", tableController, "Post:DependencyGraph") | ||
| 25 | 27 | ||
| 26 | - //web.Router("/data/tables/split-data-table", &controllers.TableController{}, "Post:SplitDataTable") | ||
| 27 | - //web.Router("/data/tables/batch-edit-sub-table", &controllers.TableController{}, "Post:BatchEditSubTable") | ||
| 28 | - web.Router("/data/tables/copy-data-table", &controllers.TableController{}, "Post:CopyDataTable") | ||
| 29 | - web.Router("/data/tables/update-table-struct/:tableId", &controllers.TableController{}, "Put:UpdateTableStruct") | ||
| 30 | - web.Router("/data/tables/add-sub-table", &controllers.TableController{}, "Post:AddTableStruct") | ||
| 31 | - web.Router("/data/tables/export-table", &controllers.TableController{}, "Post:ExportDataTable") | 28 | + //web.Router("/data/tables/split-data-table", tableController, "Post:SplitDataTable") |
| 29 | + //web.Router("/data/tables/batch-edit-sub-table", tableController, "Post:BatchEditSubTable") | ||
| 30 | + web.Router("/data/tables/copy-data-table", tableController, "Post:CopyDataTable") | ||
| 31 | + web.Router("/data/tables/update-table-struct/:tableId", tableController, "Put:UpdateTableStruct") | ||
| 32 | + web.Router("/data/tables/add-sub-table", tableController, "Post:AddTableStruct") | ||
| 33 | + web.Router("/data/tables/export-table", tableController, "Post:ExportDataTable") | ||
| 32 | 34 | ||
| 33 | - web.Router("/data/tables/table-preview", &controllers.TableController{}, "Post:TablePreview") | ||
| 34 | - web.Router("/data/tables/row-edit", &controllers.TableController{}, "Post:RowEdit") | 35 | + web.Router("/data/tables/table-preview", tableController, "Post:TablePreview") |
| 36 | + web.Router("/data/tables/row-edit", tableController, "Post:RowEdit") | ||
| 35 | 37 | ||
| 36 | - web.Router("/data/field-optional-values", &controllers.TableController{}, "Post:FieldOptionalValues") | ||
| 37 | - web.Router("/data/table-object-search", &controllers.TableController{}, "Post:TableObjectSearch") | 38 | + web.Router("/data/field-optional-values", tableController, "Post:FieldOptionalValues") |
| 39 | + web.Router("/data/table-object-search", tableController, "Post:TableObjectSearch") | ||
| 38 | 40 | ||
| 39 | - web.Router("/business/db-table-preview", &controllers.TableController{}, "Post:DBTablePreview") | ||
| 40 | - web.Router("/data/table-preview", &controllers.TableController{}, "Post:Preview") | 41 | + web.Router("/business/db-table-preview", tableController, "Post:DBTablePreview") |
| 42 | + web.Router("/data/table-preview", tableController, "Post:Preview") | ||
| 41 | 43 | ||
| 42 | } | 44 | } |
-
请 注册 或 登录 后发表评论