-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
824 additions
and
186 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 |
---|---|---|
|
@@ -62,5 +62,4 @@ | |
"allowImportExportEverywhere": true, | ||
"ecmaVersion": 11 | ||
} | ||
} | ||
|
||
} |
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
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
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,34 @@ | ||
export const up = (queryInterface, Sequelize) => queryInterface.createTable('Requests', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
requesterId: { | ||
type: Sequelize.INTEGER | ||
}, | ||
tripId: { | ||
type: Sequelize.BIGINT | ||
}, | ||
status: { | ||
type: Sequelize.STRING | ||
}, | ||
lineManagerId: { | ||
type: Sequelize.INTEGER | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
/** | ||
* @exports | ||
* @class | ||
* @param {object} queryInterface | ||
*/ | ||
export function down(queryInterface) { return queryInterface.dropTable('Requests'); } |
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,28 @@ | ||
export const up = (queryInterface, Sequelize) => queryInterface.createTable('Locations', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
country: { | ||
type: Sequelize.STRING | ||
}, | ||
city: { | ||
type: Sequelize.STRING | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
/** | ||
* @exports | ||
* @class | ||
* @param {object} queryInterface | ||
*/ | ||
export function down(queryInterface) { return queryInterface.dropTable('Locations'); } |
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,7 @@ | ||
export default (sequelize, DataTypes) => { | ||
const Location = sequelize.define('Location', { | ||
country: DataTypes.STRING, | ||
city: DataTypes.STRING | ||
}, {}); | ||
return Location; | ||
}; |
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,13 @@ | ||
export default (sequelize, DataTypes) => { | ||
const Request = sequelize.define('Request', { | ||
requesterId: DataTypes.INTEGER, | ||
tripId: DataTypes.BIGINT, | ||
status: DataTypes.STRING, | ||
lineManagerId: DataTypes.INTEGER | ||
}, {}); | ||
Request.associate = (models) => { | ||
Request.belongsTo(models.Users, { foreignKey: 'requesterId', targetKey: 'id' }); | ||
Request.belongsTo(models.Trip, { foreignKey: 'tripId', targetKey: 'tripId' }); | ||
}; | ||
return Request; | ||
}; |
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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
export default (sequelize, DataTypes) => { | ||
const Trip = sequelize.define('Trip', { | ||
userId: DataTypes.INTEGER, | ||
tripType: DataTypes.STRING, | ||
departure: DataTypes.STRING, | ||
destination: DataTypes.STRING, | ||
travelDate: DataTypes.DATE, | ||
tripId: DataTypes.BIGINT, | ||
userId: DataTypes.INTEGER, | ||
originId: DataTypes.INTEGER, | ||
destinationId: DataTypes.INTEGER, | ||
departureDate: DataTypes.DATE, | ||
returnDate: DataTypes.DATE, | ||
travelReasons: DataTypes.STRING, | ||
accommodation: DataTypes.STRING, | ||
status: DataTypes.STRING | ||
accommodationId: DataTypes.INTEGER | ||
}, {}); | ||
Trip.associate = (models) => { | ||
// associations can be defined here | ||
Trip.belongsTo(models.Users, { foreignKey: 'userId', as: 'user', targetKey: 'id' }); | ||
Trip.belongsTo(models.Users, { foreignKey: 'userId', targetKey: 'id' }); | ||
Trip.belongsTo(models.Location, { foreignKey: 'originId', targetKey: 'id' }); | ||
Trip.belongsTo(models.Location, { foreignKey: 'destinationId', targetKey: 'id' }); | ||
}; | ||
return Trip; | ||
}; |
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
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,65 @@ | ||
export const up = (queryInterface) => queryInterface.bulkInsert('Locations', [ | ||
{ | ||
country: 'Rwanda', | ||
city: 'Kigali', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Rwanda', | ||
city: 'Gisenyi', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Uganda', | ||
city: 'Kampala', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Uganda', | ||
city: 'Entebee', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Kenya', | ||
city: 'Nairobi', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Kenya', | ||
city: 'Mombasa', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Nigeria', | ||
city: 'Lagos', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Tanzania', | ||
city: 'Dodoma', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
country: 'Tanzania', | ||
city: 'Dar es salaam', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
} | ||
], {}); | ||
export const down = () => { | ||
/* | ||
Add reverting commands here. | ||
Return a promise to correctly handle asynchronicity. | ||
Example: | ||
return queryInterface.bulkDelete('People', null, {}); | ||
*/ | ||
}; |
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,26 @@ | ||
import models from '../models'; | ||
|
||
const { Location } = models; | ||
|
||
/** | ||
* | ||
* | ||
* @class LocationService | ||
*/ | ||
class LocationService { | ||
/** | ||
* find Location | ||
* @static | ||
* @param {object} property | ||
* @memberof LocationService | ||
* @returns {object} data | ||
*/ | ||
static findLocationByProperty(property) { | ||
return Location.findOne({ | ||
where: { ...property } | ||
}); | ||
} | ||
} | ||
|
||
|
||
export default LocationService; |
Oops, something went wrong.