Commit fb0a97d6 authored by Mahdi Sellami's avatar Mahdi Sellami

added case worker administration resource

parent 2265cbc9
......@@ -17,6 +17,8 @@ tags:
description: Decision of an administration case
- name: verification
description: Verification of a decision of an administration case
- name: administration
description: administration of the applications
paths:
/leistungen:
get:
......@@ -30,7 +32,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/inline_response_200'
$ref: '#/components/schemas/Services'
x-swagger-router-controller: Info
/leistungen/{leikaId}:
get:
......@@ -166,6 +168,42 @@ paths:
schema:
$ref: '#/components/schemas/Verification'
x-swagger-router-controller: Verification
/admin/verfahren/all:
get:
tags:
- administration
summary: Find all applications
operationId: getAllApplications
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Applications'
x-swagger-router-controller: Administration
/admin/verfahren/{verfahrensId}/complete:
put:
tags:
- administration
summary: Set the status of an application to completed
operationId: setApplicationStatusToCompleted
parameters:
- name: verfahrensId
in: path
required: true
style: simple
explode: false
schema:
type: string
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Verfahren'
x-swagger-router-controller: Administration
components:
schemas:
Service:
......@@ -341,7 +379,7 @@ components:
personId: personId
prename: prename
email: email
inline_response_200:
Services:
properties:
services:
type: array
......@@ -361,6 +399,78 @@ components:
fullText: fullText
serviceDescription: serviceDescription
responsibleAuthority: responsibleAuthority
Applications:
properties:
services:
type: array
items:
$ref: '#/components/schemas/Verfahren'
example:
applications:
- dataObjects:
- dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
- dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
statusDescription: statusDescription
statusLastChangeDate: 2000-01-23T04:56:07.000+00:00
statusId: statusId
leikaId: leikaId
verfahrensId: verfahrensId
decisionJustification: decisionJustification
responsibleAuthority: responsibleAuthority
decisionDate: 2000-01-23T04:56:07.000+00:00
applicant:
address:
zip: zip
country: country
city: city
street: street
houseno: houseno
surname: surname
personId: personId
prename: prename
email: email
- dataObjects:
- dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
- dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
statusDescription: statusDescription
statusLastChangeDate: 2000-01-23T04:56:07.000+00:00
statusId: statusId
leikaId: leikaId
verfahrensId: verfahrensId
decisionJustification: decisionJustification
responsibleAuthority: responsibleAuthority
decisionDate: 2000-01-23T04:56:07.000+00:00
applicant:
address:
zip: zip
country: country
city: city
street: street
houseno: houseno
surname: surname
personId: personId
prename: prename
email: email
body:
properties:
type:
......
'use strict';
var utils = require('../utils/writer.js');
var Administration = require('../service/AdministrationService');
module.exports.getAllApplications = function getAllApplications (req, res, next) {
Administration.getAllApplications()
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.setApplicationStatusToCompleted = function setApplicationStatusToCompleted (req, res, next, verfahrensId) {
Administration.setApplicationStatusToCompleted(verfahrensId)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
......@@ -26,7 +26,7 @@ http.createServer(app).listen(serverPort, function () {
//Set up mongoose connection
var mongoose = require('mongoose');
var mongoDB = config.get('dbConfig.host');
mongoose.connect(mongoDB, { useNewUrlParser: true, useUnifiedTopology: true });
mongoose.connect(mongoDB, { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false });
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
......
'use strict';
const Application = require('../models/application');
/**
* Request all pending applications
*
* returns list of Verfahren
**/
exports.getAllApplications = function() {
return new Promise(function(resolve, reject) {
const applicationRecords = Application.find({});
resolve(applicationRecords);
});
}
exports.setApplicationStatusToCompleted = function(verfahrensId) {
return new Promise(function(resolve, reject) {
const filter = {verfahrensId: verfahrensId};
const update = {statusId: 'bearbeitet', statusDescription: 'Ihr Antrag wurde bearbeitet', statusLastChangeDate: new Date().toLocaleDateString('de-DE')};
const applicationRecord = Application.findOneAndUpdate(filter, update, function (err, result) {
return result
});
resolve(applicationRecord);
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment