mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Create Job Offer, not complete yet
This commit is contained in:
37
backend/apis/nodejs/src/models/job_offer_model.js
Normal file
37
backend/apis/nodejs/src/models/job_offer_model.js
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
This code is part of Blink
|
||||
licensed under GPLv3
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const knex = require('../utils/knex_config');
|
||||
const OrganizationAdmin = require('../models/organization_admin_model');
|
||||
|
||||
async function insert(requester, organizationId, title, description, requirements, salary, salary_frequency, location) {
|
||||
const isAdmin = OrganizationAdmin.isAdmin(requester, organizationId);
|
||||
if (isAdmin) {
|
||||
const result = await knex('JobOffer').insert({
|
||||
title,
|
||||
description,
|
||||
requirements,
|
||||
salary,
|
||||
salary_frequency,
|
||||
location,
|
||||
organization_id: organizationId
|
||||
})
|
||||
.returning('*');
|
||||
return result[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
insert
|
||||
}
|
@ -30,7 +30,7 @@ async function isAdmin(personId, organizationId) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified Person as the Organization administrator, if thr requester is already
|
||||
* Add the specified Person as the Organization administrator, if the requester is already
|
||||
* an administrator
|
||||
* @param {*} personId Id of the person to add as administrator
|
||||
* @param {*} organizationId
|
||||
@ -88,7 +88,7 @@ async function remove(personId, organizationId) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isOrganizationAdmin: isAdmin,
|
||||
isAdmin,
|
||||
insert,
|
||||
remove
|
||||
};
|
Reference in New Issue
Block a user