A continuation of HomeBox the inventory and organization system built for the Home User
ProductBarcode: rename API call from getproductfromean to products/search-from-barcode
Crumb Owl4a4bf9a175ee
diff --git a/backend/app/api/handlers/v1/v1_ctrl_product_search.go b/backend/app/api/handlers/v1/v1_ctrl_product_search.goindex 922fa67d..73378be5 100644--- a/backend/app/api/handlers/v1/v1_ctrl_product_search.go+++ b/backend/app/api/handlers/v1/v1_ctrl_product_search.go@@ -94,7 +94,7 @@ type BARCODESPIDER_COMResponse struct {// @Produce json// @Param data query string false "barcode to be searched"// @Success 200 {object} []repo.BarcodeProduct-// @Router /v1/getproductfromean [GET]+// @Router /v1/products/search-from-barcode [GET]// @Security Bearerfunc (ctrl *V1Controller) HandleProductSearchFromBarcode(conf config.BarcodeAPIConf) errchain.HandlerFunc {type query struct {diff --git a/backend/app/api/routes.go b/backend/app/api/routes.goindex 91840946..74f8595f 100644--- a/backend/app/api/routes.go+++ b/backend/app/api/routes.go@@ -157,8 +157,9 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllRa.mwRoles(RoleModeOr, authroles.RoleUser.String(), authroles.RoleAttachments.String()),}+ r.Get("/products/search-from-barcode", chain.ToHandlerFunc(v1Ctrl.HandleProductSearchFromBarcode(a.conf.Barcode), userMW...))+r.Get("/qrcode", chain.ToHandlerFunc(v1Ctrl.HandleGenerateQRCode(), assetMW...))- r.Get("/getproductfromean", chain.ToHandlerFunc(v1Ctrl.HandleProductSearchFromBarcode(a.conf.Barcode), userMW...))r.Get("/items/{id}/attachments/{attachment_id}",chain.ToHandlerFunc(v1Ctrl.HandleItemAttachmentGet(), assetMW...),diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.goindex 3df008bb..65ab97a9 100644--- a/backend/app/api/static/docs/docs.go+++ b/backend/app/api/static/docs/docs.go@@ -195,41 +195,6 @@ const docTemplate = `{}}},- "/v1/getproductfromean": {- "get": {- "security": [- {- "Bearer": []- }- ],- "produces": [- "application/json"- ],- "tags": [- "Items"- ],- "summary": "Search EAN from Barcode",- "parameters": [- {- "type": "string",- "description": "barcode to be searched",- "name": "data",- "in": "query"- }- ],- "responses": {- "200": {- "description": "OK",- "schema": {- "type": "array",- "items": {- "$ref": "#/definitions/repo.BarcodeProduct"- }- }- }- }- }- },"/v1/groups": {"get": {"security": [@@ -1846,6 +1811,41 @@ const docTemplate = `{}}},+ "/v1/products/search-from-barcode": {+ "get": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Items"+ ],+ "summary": "Search EAN from Barcode",+ "parameters": [+ {+ "type": "string",+ "description": "barcode to be searched",+ "name": "data",+ "in": "query"+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/definitions/repo.BarcodeProduct"+ }+ }+ }+ }+ }+ },"/v1/qrcode": {"get": {"security": [diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.jsonindex 1c01d28e..764c05bd 100644--- a/backend/app/api/static/docs/swagger.json+++ b/backend/app/api/static/docs/swagger.json@@ -193,41 +193,6 @@}}},- "/v1/getproductfromean": {- "get": {- "security": [- {- "Bearer": []- }- ],- "produces": [- "application/json"- ],- "tags": [- "Items"- ],- "summary": "Search EAN from Barcode",- "parameters": [- {- "type": "string",- "description": "barcode to be searched",- "name": "data",- "in": "query"- }- ],- "responses": {- "200": {- "description": "OK",- "schema": {- "type": "array",- "items": {- "$ref": "#/definitions/repo.BarcodeProduct"- }- }- }- }- }- },"/v1/groups": {"get": {"security": [@@ -1844,6 +1809,41 @@}}},+ "/v1/products/search-from-barcode": {+ "get": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Items"+ ],+ "summary": "Search EAN from Barcode",+ "parameters": [+ {+ "type": "string",+ "description": "barcode to be searched",+ "name": "data",+ "in": "query"+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/definitions/repo.BarcodeProduct"+ }+ }+ }+ }+ }+ },"/v1/qrcode": {"get": {"security": [diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yamlindex 9d4bc3a9..cf9eae6a 100644--- a/backend/app/api/static/docs/swagger.yaml+++ b/backend/app/api/static/docs/swagger.yaml@@ -1572,27 +1572,6 @@ paths:summary: Currencytags:- Base- /v1/getproductfromean:- get:- parameters:- - description: barcode to be searched- in: query- name: data- type: string- produces:- - application/json- responses:- "200":- description: OK- schema:- items:- $ref: '#/definitions/repo.BarcodeProduct'- type: array- security:- - Bearer: []- summary: Search EAN from Barcode- tags:- - Items/v1/groups:get:produces:@@ -2585,6 +2564,27 @@ paths:summary: Test Notifiertags:- Notifiers+ /v1/products/search-from-barcode:+ get:+ parameters:+ - description: barcode to be searched+ in: query+ name: data+ type: string+ produces:+ - application/json+ responses:+ "200":+ description: OK+ schema:+ items:+ $ref: '#/definitions/repo.BarcodeProduct'+ type: array+ security:+ - Bearer: []+ summary: Search EAN from Barcode+ tags:+ - Items/v1/qrcode:get:parameters:diff --git a/docs/en/api/openapi-2.0.json b/docs/en/api/openapi-2.0.jsonindex 1c01d28e..764c05bd 100644--- a/docs/en/api/openapi-2.0.json+++ b/docs/en/api/openapi-2.0.json@@ -193,41 +193,6 @@}}},- "/v1/getproductfromean": {- "get": {- "security": [- {- "Bearer": []- }- ],- "produces": [- "application/json"- ],- "tags": [- "Items"- ],- "summary": "Search EAN from Barcode",- "parameters": [- {- "type": "string",- "description": "barcode to be searched",- "name": "data",- "in": "query"- }- ],- "responses": {- "200": {- "description": "OK",- "schema": {- "type": "array",- "items": {- "$ref": "#/definitions/repo.BarcodeProduct"- }- }- }- }- }- },"/v1/groups": {"get": {"security": [@@ -1844,6 +1809,41 @@}}},+ "/v1/products/search-from-barcode": {+ "get": {+ "security": [+ {+ "Bearer": []+ }+ ],+ "produces": [+ "application/json"+ ],+ "tags": [+ "Items"+ ],+ "summary": "Search EAN from Barcode",+ "parameters": [+ {+ "type": "string",+ "description": "barcode to be searched",+ "name": "data",+ "in": "query"+ }+ ],+ "responses": {+ "200": {+ "description": "OK",+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/definitions/repo.BarcodeProduct"+ }+ }+ }+ }+ }+ },"/v1/qrcode": {"get": {"security": [diff --git a/docs/en/api/openapi-2.0.yaml b/docs/en/api/openapi-2.0.yamlindex 9d4bc3a9..cf9eae6a 100644--- a/docs/en/api/openapi-2.0.yaml+++ b/docs/en/api/openapi-2.0.yaml@@ -1572,27 +1572,6 @@ paths:summary: Currencytags:- Base- /v1/getproductfromean:- get:- parameters:- - description: barcode to be searched- in: query- name: data- type: string- produces:- - application/json- responses:- "200":- description: OK- schema:- items:- $ref: '#/definitions/repo.BarcodeProduct'- type: array- security:- - Bearer: []- summary: Search EAN from Barcode- tags:- - Items/v1/groups:get:produces:@@ -2585,6 +2564,27 @@ paths:summary: Test Notifiertags:- Notifiers+ /v1/products/search-from-barcode:+ get:+ parameters:+ - description: barcode to be searched+ in: query+ name: data+ type: string+ produces:+ - application/json+ responses:+ "200":+ description: OK+ schema:+ items:+ $ref: '#/definitions/repo.BarcodeProduct'+ type: array+ security:+ - Bearer: []+ summary: Search EAN from Barcode+ tags:+ - Items/v1/qrcode:get:parameters:diff --git a/frontend/components/Item/BarcodeModal.vue b/frontend/components/Item/BarcodeModal.vueindex fb99d645..d0b3bf2d 100644--- a/frontend/components/Item/BarcodeModal.vue+++ b/frontend/components/Item/BarcodeModal.vue@@ -152,7 +152,7 @@async function retrieveProductInfo(barcode: string) {products.value = null;searching.value = true;- const result = await api.actions.getEAN(barcode);+ const result = await api.products.searchFromBarcode(barcode);searching.value = false;if(result.error)diff --git a/frontend/lib/api/classes/actions.ts b/frontend/lib/api/classes/actions.tsindex 1a8f94bc..6b74c467 100644--- a/frontend/lib/api/classes/actions.ts+++ b/frontend/lib/api/classes/actions.ts@@ -31,8 +31,4 @@ export class ActionsAPI extends BaseAPI {url: route("/actions/create-missing-thumbnails"),});}-- getEAN(productEAN: string) {- return this.http.get<ItemCreate>({ url: route(`/getproductfromean`, { productEAN }) });- }}diff --git a/frontend/lib/api/classes/product.ts b/frontend/lib/api/classes/product.tsnew file mode 100644index 00000000..32097227--- /dev/null+++ b/frontend/lib/api/classes/product.ts@@ -0,0 +1,8 @@+import { BaseAPI, route } from "../base";+import type { BarcodeProduct } from "../types/data-contracts";++export class ProductAPI extends BaseAPI {+ searchFromBarcode(productEAN: string) {+ return this.http.get<BarcodeProduct[]>({ url: route(`/products/search-from-barcode`, { productEAN }) });+ }+}\ No newline at end of filediff --git a/frontend/lib/api/user.ts b/frontend/lib/api/user.tsindex eccafeaf..ffaede3d 100644--- a/frontend/lib/api/user.ts+++ b/frontend/lib/api/user.ts@@ -10,6 +10,7 @@ import { AssetsApi } from "./classes/assets";import { ReportsAPI } from "./classes/reports";import { NotifiersAPI } from "./classes/notifiers";import { MaintenanceAPI } from "./classes/maintenance";+import { ProductAPI } from "./classes/product";import type { Requests } from "~~/lib/requests";export class UserClient extends BaseAPI {@@ -24,6 +25,7 @@ export class UserClient extends BaseAPI {assets: AssetsApi;reports: ReportsAPI;notifiers: NotifiersAPI;+ products: ProductAPI;constructor(requests: Requests, attachmentToken: string) {super(requests, attachmentToken);@@ -39,6 +41,7 @@ export class UserClient extends BaseAPI {this.assets = new AssetsApi(requests);this.reports = new ReportsAPI(requests);this.notifiers = new NotifiersAPI(requests);+ this.products = new ProductAPI(requests);Object.freeze(this);}