-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BO): ficher territoire wip 2 636
- Loading branch information
Showing
16 changed files
with
277 additions
and
142 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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,14 @@ | ||
const Territoire = require("../../services/Territoire"); | ||
|
||
const logger = require("../../utils/logger"); | ||
|
||
const log = logger(module.filename); | ||
|
||
module.exports = async function getOne(req, res) { | ||
log.i("IN"); | ||
const { idTerritoire } = req.params; | ||
const territoires = await Territoire.readOne(idTerritoire); | ||
//console.log("territoires", territoires); | ||
log.i("DONE"); | ||
return res.json({ territoires }); | ||
}; |
This file contains 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,3 @@ | ||
module.exports.getOne = require("./get-one"); | ||
module.exports.list = require("./list"); | ||
module.exports.update = require("./update"); |
This file contains 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,12 @@ | ||
const Territoire = require("../../services/Territoire"); | ||
|
||
const logger = require("../../utils/logger"); | ||
|
||
const log = logger(module.filename); | ||
|
||
module.exports = async function list(req, res) { | ||
log.i("IN"); | ||
const territoires = await Territoire.fetch(); | ||
log.i("DONE"); | ||
return res.json({ territoires }); | ||
}; |
This file contains 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,20 @@ | ||
const Territoire = require("../../services/Territoire"); | ||
|
||
const logger = require("../../utils/logger"); | ||
|
||
const log = logger(module.filename); | ||
|
||
module.exports = async function update(req, res) { | ||
log.i("IN"); | ||
console.log("req.params", req.decoded); | ||
const { id, territoireCode } = req.params; | ||
const { userTerritoireCode } = req.decoded; | ||
console.log("territoireCode : ", territoireCode); | ||
let response; | ||
if (userTerritoireCode === "FRA" || territoireCode === userTerritoireCode) { | ||
response = await Territoire.update(id, req.body); | ||
console.log("territoires", response); | ||
} else response = "UnAuthorized"; | ||
log.i("DONE"); | ||
return res.json({ response }); | ||
}; |
This file contains 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
This file contains 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
This file contains 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,12 @@ | ||
const express = require("express"); | ||
|
||
const router = express.Router(); | ||
|
||
const territoireController = require("../controllers/territoire"); | ||
const BOcheckJWT = require("../middlewares/bo-check-JWT"); | ||
|
||
router.get("/list", BOcheckJWT, territoireController.list); | ||
router.get("/get-one/:idTerritoire", BOcheckJWT, territoireController.getOne); | ||
router.post("/:id", BOcheckJWT, territoireController.update); | ||
|
||
module.exports = router; |
This file contains 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
This file contains 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
Oops, something went wrong.