Repository navigation
editar producto / direcciones #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76be9a9
editar producto / direcciones
Lianyang1234 89dda5c
parte de benja y correciones de code rabbit
Lianyang1234 3eb5ef1
coderabbit parte 2
Lianyang1234 d6374eb
Merge remote-tracking branch 'origin/dev' into OM-175
Lianyang1234 b07484b
error de visible
Lianyang1234 f6e6db1
cambios rutas
Lianyang1234 b1120b3
Merge branch 'dev' into OM-175
Andoumeda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
src/modules/commerce/addresses/controllers/addresses.controllers.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| //addresses.controllers.js | ||
| import { | ||
| createStoreAddressService, | ||
| deleteStoreAddressService, | ||
| getStoreAddressByIdService, | ||
| getStoreAddressesService, | ||
| updateStoreAddressService, | ||
| } from "../services/addresses.services.js"; | ||
|
|
||
| const getErrorStatusCode = (error) => error.statusCode || error.status || 500; | ||
|
|
||
| // crea una direccion para el comercio autenticado | ||
| export const createStoreAddress = async (req, res) => { | ||
| try { | ||
| const { id_store } = req.params; | ||
|
|
||
| const address = await createStoreAddressService( | ||
| req.user?.id_user, | ||
| id_store, | ||
| req.body | ||
| ); | ||
|
|
||
| return res.status(201).json({ | ||
| success: true, | ||
| message: "Direccion del comercio creada exitosamente", | ||
| data: address, | ||
| }); | ||
| } catch (error) { | ||
| return res.status(getErrorStatusCode(error)).json({ | ||
| success: false, | ||
| message: error.message || "Error interno del servidor", | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| // devuelve la lista de direcciones del comercio autenticado | ||
| export const getStoreAddresses = async (req, res) => { | ||
| try { | ||
| const { id_store } = req.params; | ||
|
|
||
| const addresses = await getStoreAddressesService( | ||
| req.user?.id_user, | ||
| id_store | ||
| ); | ||
|
|
||
| return res.status(200).json({ | ||
| success: true, | ||
| data: addresses, | ||
| }); | ||
| } catch (error) { | ||
| return res.status(getErrorStatusCode(error)).json({ | ||
| success: false, | ||
| message: error.message || "Error interno del servidor", | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| // devuelve una direccion puntual del comercio autenticado | ||
| export const getStoreAddressById = async (req, res) => { | ||
| try { | ||
| const { id_store, id_address } = req.params; | ||
|
|
||
| const address = await getStoreAddressByIdService( | ||
| req.user?.id_user, | ||
| id_store, | ||
| id_address | ||
| ); | ||
|
|
||
| return res.status(200).json({ | ||
| success: true, | ||
| data: address, | ||
| }); | ||
| } catch (error) { | ||
| return res.status(getErrorStatusCode(error)).json({ | ||
| success: false, | ||
| message: error.message || "Error interno del servidor", | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| // actualiza una direccion puntual del comercio autenticado | ||
| export const updateStoreAddress = async (req, res) => { | ||
| try { | ||
| const { id_store, id_address } = req.params; | ||
|
|
||
| const address = await updateStoreAddressService( | ||
| req.user?.id_user, | ||
| id_store, | ||
| id_address, | ||
| req.body | ||
| ); | ||
|
|
||
| return res.status(200).json({ | ||
| success: true, | ||
| message: "Direccion del comercio actualizada exitosamente", | ||
| data: address, | ||
| }); | ||
| } catch (error) { | ||
| return res.status(getErrorStatusCode(error)).json({ | ||
| success: false, | ||
| message: error.message || "Error interno del servidor", | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| // desactiva una direccion puntual del comercio autenticado | ||
| export const deleteStoreAddress = async (req, res) => { | ||
| try { | ||
| const { id_store, id_address } = req.params; | ||
|
|
||
| const address = await deleteStoreAddressService( | ||
| req.user?.id_user, | ||
| id_store, | ||
| id_address | ||
| ); | ||
|
|
||
| return res.status(200).json({ | ||
| success: true, | ||
| message: "Direccion del comercio desactivada correctamente", | ||
| data: address, | ||
| }); | ||
| } catch (error) { | ||
| return res.status(getErrorStatusCode(error)).json({ | ||
| success: false, | ||
| message: error.message || "Error interno del servidor", | ||
| }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //addresses.routes.js | ||
| import { Router } from "express"; | ||
| import authenticate from "../../../../config/jwt.config.js"; | ||
| import { | ||
| createStoreAddress, | ||
| deleteStoreAddress, | ||
| getStoreAddressById, | ||
| getStoreAddresses, | ||
| updateStoreAddress, | ||
| } from "../controllers/addresses.controllers.js"; | ||
|
|
||
| const router = Router(); | ||
|
|
||
| // crea una nueva direccion para el comercio | ||
| router.post("/:id_store/addresses", authenticate, createStoreAddress); | ||
| // lista las direcciones activas del comercio | ||
| router.get("/:id_store/addresses", authenticate, getStoreAddresses); | ||
| // obtiene una direccion puntual del comercio | ||
| router.get("/:id_store/addresses/:id_address", authenticate, getStoreAddressById); | ||
| // edita una direccion puntual del comercio | ||
| router.put("/:id_store/addresses/:id_address", authenticate, updateStoreAddress); | ||
| // desactiva una direccion puntual del comercio | ||
| router.delete("/:id_store/addresses/:id_address", authenticate, deleteStoreAddress); | ||
|
|
||
| export default router; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posible cambio breaking de contrato en la ruta de product-tags.
En Line 38 el prefijo quedó en
/api/product-tags. Si clientes ya consumen la ruta anterior (p. ej./products/tags), esto rompe integración sin compatibilidad temporal ni aviso de migración.💡 Sugerencia para compatibilidad backward temporal
+app.use("/products/tags", productTagRoutes); // compatibilidad transitoria app.use("/api/product-tags", productTagRoutes);🤖 Prompt for AI Agents