1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /**
- * Created by CSL on 2017-10-10.
- */
- const uuidV1 = require('uuid/v1');
- let logger = require("../../../logs/log_helper").logger;
- let mongoose = require('mongoose');
- let stdLabourCoesModel = mongoose.model('std_labour_coes');
- let projectLabourCoesModel = mongoose.model('labour_coes');
- module.exports = {
- newProjectLabourCoe: newProjectLabourCoe,
- getProjectLabourCoe: getProjectLabourCoe,
- getStdLabourCoe: getStdLabourCoe
- };
- async function newProjectLabourCoe(data) {
- let stdLC = await getStdLabourCoe(data.libID);
- let doc={
- ID: uuidV1(),
- projectID: data.projectID,
- name: data.name,
- libID: stdLC.ID,
- libName: stdLC.libName,
- coes: stdLC.coes
- };
- console.log(doc);
- await projectLabourCoesModel.create(doc);
- let newLC = {ID: doc.ID, name: doc.name};
- return newLC;
- };
- async function getProjectLabourCoe(ID) {
- let projLC = await projectLabourCoesModel.findOne({ID:ID});
- return projLC;
- };
- async function getStdLabourCoe(libID) {
- let stdLC = await stdLabourCoesModel.findOne({ID:libID});
- return stdLC;
- };
|