first commit
This commit is contained in:
174
controllers/procjustification.js
Normal file
174
controllers/procjustification.js
Normal file
@ -0,0 +1,174 @@
|
||||
|
||||
const ProcJustificationAdapter=require('../adapter/procjustificationadapter.js');
|
||||
const procjustificationadapter = new ProcJustificationAdapter();
|
||||
const Controllers = require('./controller.js');
|
||||
const controllers = new Controllers();
|
||||
var apireshandler = controllers.getApiResultDefined();
|
||||
const baseurlsap="http://"+process.env.HOSTSAP+"/sapapi/index.php/api";
|
||||
const apikeysap = "befea63a-7c47-4323-afea-968a3168fe0a";
|
||||
const request = require('request');
|
||||
var fs = require('fs');
|
||||
|
||||
exports.getListPr = ( req, res ) => {
|
||||
try{
|
||||
procjustificationadapter.queryPrList(req,function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [21] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.setNewProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
procjustificationadapter.queryNewProcJustification(req,function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [21] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.updateProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
let ext=req.body.filename.split(".")[1];
|
||||
let filename = req.body.filecategory+'_'+req.nik+'_' + Date.now() + "."+ ext;
|
||||
fs.rename(process.env.BASEPATH+'/assets/procjustification/'+req.body.filename, process.env.BASEPATH+'/assets/procjustification/'+filename, function(err) {
|
||||
if ( err ) {
|
||||
procjustificationadapter.sendResponse(500,err, res);
|
||||
}
|
||||
else{
|
||||
procjustificationadapter.queryUpdateProcJustification(req, filename, function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [66] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.InquiryProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
let ext=req.body.filename.split(".")[1];
|
||||
let filename = req.body.filecategory+'_'+req.nik+'_' + Date.now() + "."+ ext;
|
||||
fs.rename(process.env.BASEPATH+'/assets/procjustification/'+req.body.filename, process.env.BASEPATH+'/assets/procjustification/'+filename, function(err) {
|
||||
if ( err ) {
|
||||
procjustificationadapter.sendResponse(statusCode,err, res);
|
||||
}
|
||||
else{
|
||||
procjustificationadapter.queryInquiryProcJustification(req, filename, function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [66] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.deleteProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
procjustificationadapter.queryDeleteProcJustification(req,function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [82] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.SignedProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
procjustificationadapter.querySignedProcJustification(req,function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [96] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.detailProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
procjustificationadapter.queryProcJustificationDetail(req,function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [82] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.procJustificationList = ( req, res ) => {
|
||||
try{
|
||||
|
||||
procjustificationadapter.queryProcJustificationList(req,function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [82] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.updateStatusProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
procjustificationadapter.queryUpdateStatusProcJustification(req,function(err,data){
|
||||
let statusCode = data!=null ? data.meta.code : 200 ;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode,data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [82] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user