-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project details routing, controller (Backend) task
In this PR , backend files are created for Project details controller, router and route for Phase 2
- Loading branch information
1 parent
5aabaaf
commit fe6b661
Showing
6 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,20 @@ | ||
const bmProjectDetailController = function (ProjectDetail) { | ||
const bmProjectDetails = async function _projDetail(req, res) { | ||
console.log(ProjectDetail); | ||
|
||
//projectId from the request parameters object | ||
const { projectId } = req.params; | ||
try { | ||
ProjectDetail | ||
.findById(projectId) | ||
.then(results => res.status(200).send(results)) | ||
.catch(error => res.status(500).send(error)); | ||
} catch (err) { | ||
res.json(err); | ||
} | ||
}; | ||
|
||
return { bmProjectDetails }; | ||
}; | ||
|
||
module.exports = bmProjectDetailController; |
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,33 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const { Schema } = mongoose; | ||
|
||
const projectDetail = new Schema({ | ||
projectName: { type: String, required: true, unique: true }, | ||
tools: [{ | ||
inventoryItemId: { type: Number, required: true }, | ||
title: { type: String, required: true }, | ||
image: { type: String, required: true }, | ||
rentedOnDate: { type: Date, required: true }, | ||
rentDuration: { type: String, required: true }, | ||
}], | ||
materials: [{ | ||
inventoryItemId: { type: Number, required: true }, | ||
title: { type: String, required: true }, | ||
image: { type: String, required: true }, | ||
amountTotal: { type: Number, required: true }, | ||
amountUsed: { type: Number, required: true }, | ||
}], | ||
people: [{ | ||
personId: { type: Number, required: true }, | ||
personName: { type: String, required: true }, | ||
personLastName: { type: String, required: true }, | ||
role: { type: String, required: true }, | ||
team: { type: String, required: true }, | ||
currentTask: { type: String, required: true }, | ||
totalHrs: { type: Number, required: true }, | ||
todayHrs: { type: Number, required: true }, | ||
}], | ||
}); | ||
|
||
module.exports = mongoose.model('projectDetail', projectDetail, 'projectDetail'); |
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,15 @@ | ||
const express = require('express'); | ||
|
||
const routes = function (projectDetail) { | ||
|
||
const projectRouter = express.Router(); | ||
const controller = require('../../controllers/bmdashboard/bmProjectDetailController')(projectDetail); | ||
|
||
projectRouter.route('/projects/:projectId') | ||
.get(controller.bmProjectDetails); | ||
|
||
return projectRouter; | ||
|
||
}; | ||
|
||
module.exports = routes; |
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