This repository has been archived by the owner on Jul 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feedback for Events * Fix Bugs * Fixing naming Issue * final fixes for feedback api
- Loading branch information
Showing
7 changed files
with
119 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
var context = require('../../database.js').getContext(); | ||
var feedbacks = require('../dsap/feedbacks.js')(context); | ||
|
||
module.exports = { | ||
getAllFeedbacks: getAllFeedbacks, | ||
addFeedback: addFeedback, | ||
}; | ||
|
||
function getAllFeedbacks(req, res) { | ||
feedbacks.findAllFeedbacks().then(function(list) { | ||
res.status(200).json(list) | ||
}).catch(function(error) { | ||
res.status(500).send(error); | ||
}); | ||
} | ||
|
||
|
||
function addFeedback(req, res) { | ||
var feedbackObj = req.body; | ||
feedbacks.addFeedback(feedbackObj).then(function() { | ||
res.status(200).json(); | ||
}).catch(function(error) { | ||
res.status(500).send(error); | ||
}); | ||
} |
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,17 @@ | ||
'use strict'; | ||
module.exports = function(context) { | ||
var feedbacks = context.models.feedbacks; | ||
|
||
return { | ||
findAllFeedbacks: function() { | ||
return feedbacks.findAll({ | ||
attributes: [ | ||
'id', 'feedback', 'entityId' | ||
] | ||
}); | ||
}, | ||
addFeedback: function(data) { | ||
return feedbacks.create(data); | ||
} | ||
} | ||
}; |
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,19 @@ | ||
module.exports = function(sequelize, DataTypes) { | ||
return sequelize.define('feedbacks', { | ||
id: { | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
primaryKey: true | ||
}, | ||
feedback:{ | ||
type: DataTypes.BOOLEAN //TRUE - Like, FALSE - Wrong Data | ||
} | ||
}, { | ||
freezeTableName: true, // Model tableName will be the same as the model name | ||
classMethods: { | ||
associate: function(models) { | ||
this.belongsTo(models.entities); | ||
} | ||
} | ||
}); | ||
}; |
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,35 @@ | ||
x-swagger-router-controller: feedback | ||
get: | ||
description: Returns list of all feedbacks | ||
operationId: getAllFeedbacks | ||
responses: | ||
"200": | ||
description: Success | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/definitions/Feedback' | ||
default: | ||
description: Error | ||
schema: | ||
$ref: "#/definitions/ErrorResponse" | ||
|
||
post: | ||
description: Add a new Feedback to DB | ||
operationId: addFeedback | ||
security: | ||
- DefaultSecurity: [] | ||
parameters: | ||
- name: body | ||
in: body | ||
description: Feedback data | ||
required: true | ||
schema: | ||
$ref: '#/definitions/UpdateFeedback' | ||
responses: | ||
"200": | ||
description: Success | ||
default: | ||
description: Error | ||
schema: | ||
$ref: "#/definitions/ErrorResponse" |
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