From 1670b1b997cd99d7b5f9cd4c10c18a76ae9740de Mon Sep 17 00:00:00 2001 From: Filippov Alex Date: Mon, 22 Jan 2024 22:22:15 +0530 Subject: [PATCH] technical debt --- api/api.swagger3.yaml | 4 +-- api/stub/server.go | 30 +++++++++---------- api/stub/types.go | 10 +++---- db/entity_storage.go | 6 +--- static_source/admin/src/api/stub.ts | 10 +++---- .../card_items/entity_storage/index.vue | 4 +-- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/api/api.swagger3.yaml b/api/api.swagger3.yaml index 0ddbe0a85..7b0224463 100644 --- a/api/api.swagger3.yaml +++ b/api/api.swagger3.yaml @@ -4292,7 +4292,7 @@ components: format: uint64 description: The number of results returned on a page ids: - name: ids + name: ids[] in: query required: false schema: @@ -4316,7 +4316,7 @@ components: type: string format: date-time entityIds: - name: entityId + name: entityId[] in: query required: false schema: diff --git a/api/stub/server.go b/api/stub/server.go index 6b369933a..4e65b4d99 100644 --- a/api/stub/server.go +++ b/api/stub/server.go @@ -606,11 +606,11 @@ func (w *ServerInterfaceWrapper) ActionServiceGetActionList(ctx echo.Context) er return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err)) } - // ------------- Optional query parameter "ids" ------------- + // ------------- Optional query parameter "ids[]" ------------- - err = runtime.BindQueryParameter("form", true, false, "ids", ctx.QueryParams(), ¶ms.Ids) + err = runtime.BindQueryParameter("form", true, false, "ids[]", ctx.QueryParams(), ¶ms.Ids) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids[]: %s", err)) } // Invoke the callback with all the unmarshalled arguments @@ -1173,11 +1173,11 @@ func (w *ServerInterfaceWrapper) ConditionServiceGetConditionList(ctx echo.Conte return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err)) } - // ------------- Optional query parameter "ids" ------------- + // ------------- Optional query parameter "ids[]" ------------- - err = runtime.BindQueryParameter("form", true, false, "ids", ctx.QueryParams(), ¶ms.Ids) + err = runtime.BindQueryParameter("form", true, false, "ids[]", ctx.QueryParams(), ¶ms.Ids) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids[]: %s", err)) } // Invoke the callback with all the unmarshalled arguments @@ -2333,11 +2333,11 @@ func (w *ServerInterfaceWrapper) EntityStorageServiceGetEntityStorageList(ctx ec return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter endDate: %s", err)) } - // ------------- Optional query parameter "entityId" ------------- + // ------------- Optional query parameter "entityId[]" ------------- - err = runtime.BindQueryParameter("form", true, false, "entityId", ctx.QueryParams(), ¶ms.EntityId) + err = runtime.BindQueryParameter("form", true, false, "entityId[]", ctx.QueryParams(), ¶ms.EntityId) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter entityId: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter entityId[]: %s", err)) } // Invoke the callback with all the unmarshalled arguments @@ -3488,11 +3488,11 @@ func (w *ServerInterfaceWrapper) ScriptServiceGetScriptList(ctx echo.Context) er return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err)) } - // ------------- Optional query parameter "ids" ------------- + // ------------- Optional query parameter "ids[]" ------------- - err = runtime.BindQueryParameter("form", true, false, "ids", ctx.QueryParams(), ¶ms.Ids) + err = runtime.BindQueryParameter("form", true, false, "ids[]", ctx.QueryParams(), ¶ms.Ids) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids[]: %s", err)) } // ------------- Optional query parameter "query" ------------- @@ -3914,11 +3914,11 @@ func (w *ServerInterfaceWrapper) TriggerServiceGetTriggerList(ctx echo.Context) return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter limit: %s", err)) } - // ------------- Optional query parameter "ids" ------------- + // ------------- Optional query parameter "ids[]" ------------- - err = runtime.BindQueryParameter("form", true, false, "ids", ctx.QueryParams(), ¶ms.Ids) + err = runtime.BindQueryParameter("form", true, false, "ids[]", ctx.QueryParams(), ¶ms.Ids) if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids: %s", err)) + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter ids[]: %s", err)) } // Invoke the callback with all the unmarshalled arguments diff --git a/api/stub/types.go b/api/stub/types.go index 4e06754bd..986935503 100644 --- a/api/stub/types.go +++ b/api/stub/types.go @@ -1410,7 +1410,7 @@ type ActionServiceGetActionListParams struct { Limit *ListLimit `form:"limit,omitempty" json:"limit,omitempty"` // Ids The number of results returned on a page - Ids *Ids `form:"ids,omitempty" json:"ids,omitempty"` + Ids *Ids `form:"ids[],omitempty" json:"ids[],omitempty"` } // ActionServiceSearchActionParams defines parameters for ActionServiceSearchAction. @@ -1534,7 +1534,7 @@ type ConditionServiceGetConditionListParams struct { Limit *ListLimit `form:"limit,omitempty" json:"limit,omitempty"` // Ids The number of results returned on a page - Ids *Ids `form:"ids,omitempty" json:"ids,omitempty"` + Ids *Ids `form:"ids[],omitempty" json:"ids[],omitempty"` } // ConditionServiceSearchConditionParams defines parameters for ConditionServiceSearchCondition. @@ -1797,7 +1797,7 @@ type EntityStorageServiceGetEntityStorageListParams struct { Limit *ListLimit `form:"limit,omitempty" json:"limit,omitempty"` StartDate *StartDate `form:"startDate,omitempty" json:"startDate,omitempty"` EndDate *EndDate `form:"endDate,omitempty" json:"endDate,omitempty"` - EntityId *EntityIds `form:"entityId,omitempty" json:"entityId,omitempty"` + EntityId *EntityIds `form:"entityId[],omitempty" json:"entityId[],omitempty"` } // ImageServiceAddImageParams defines parameters for ImageServiceAddImage. @@ -2038,7 +2038,7 @@ type ScriptServiceGetScriptListParams struct { Limit *ListLimit `form:"limit,omitempty" json:"limit,omitempty"` // Ids The number of results returned on a page - Ids *Ids `form:"ids,omitempty" json:"ids,omitempty"` + Ids *Ids `form:"ids[],omitempty" json:"ids[],omitempty"` Query *Query `form:"query,omitempty" json:"query,omitempty"` } @@ -2123,7 +2123,7 @@ type TriggerServiceGetTriggerListParams struct { Limit *ListLimit `form:"limit,omitempty" json:"limit,omitempty"` // Ids The number of results returned on a page - Ids *Ids `form:"ids,omitempty" json:"ids,omitempty"` + Ids *Ids `form:"ids[],omitempty" json:"ids[],omitempty"` } // TriggerServiceSearchTriggerParams defines parameters for TriggerServiceSearchTrigger. diff --git a/db/entity_storage.go b/db/entity_storage.go index f785ffb71..412fc723c 100644 --- a/db/entity_storage.go +++ b/db/entity_storage.go @@ -85,11 +85,7 @@ func (n *EntityStorages) List(ctx context.Context, limit, offset int, orderBy, s q := n.Db.WithContext(ctx).Model(&EntityStorage{}) if len(entityIds) > 0 { - var ids = make([]string, 0, len(entityIds)) - for _, id := range entityIds { - ids = append(ids, id.String()) - } - q = q.Where("entity_id in (?)", ids) + q = q.Where("entity_id in (?)", entityIds) } if startDate != nil { diff --git a/static_source/admin/src/api/stub.ts b/static_source/admin/src/api/stub.ts index af06d7128..adc289c46 100644 --- a/static_source/admin/src/api/stub.ts +++ b/static_source/admin/src/api/stub.ts @@ -1813,7 +1813,7 @@ export class Api extends HttpClient @@ -2445,7 +2445,7 @@ export class Api extends HttpClient @@ -3822,7 +3822,7 @@ export class Api extends HttpClient @@ -5172,7 +5172,7 @@ export class Api extends HttpClient extends HttpClient diff --git a/static_source/admin/src/views/Dashboard/card_items/entity_storage/index.vue b/static_source/admin/src/views/Dashboard/card_items/entity_storage/index.vue index 1d483fc21..60f2eba50 100644 --- a/static_source/admin/src/views/Dashboard/card_items/entity_storage/index.vue +++ b/static_source/admin/src/views/Dashboard/card_items/entity_storage/index.vue @@ -42,7 +42,7 @@ interface Params { page?: number; limit?: number; sort?: string; - entityId?: string; + entityId?: string[]; startDate?: string; endDate?: string; } @@ -189,7 +189,7 @@ const getList = debounce( async () => { if (props.item?.payload.entityStorage?.entityIds?.length ) { if (selectedEntities.value.length == 0) { - params.entityId = props.item?.payload.entityStorage?.entityIds.join(",") + params.entityId = props.item?.payload.entityStorage } else { params.entityId = selectedEntities.value }