Skip to content

Commit

Permalink
[FEAT] #2 - 취업교육 상세페이지 조회 API
Browse files Browse the repository at this point in the history
  • Loading branch information
charBS0701 committed Jul 20, 2023
1 parent b34b7e7 commit d1e5dd9
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 16 deletions.
10 changes: 10 additions & 0 deletions src/app/JobEdu/jobEduController.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ export const getJobEduListCount = async (req, res) => {

return res.send(response(baseResponse.SUCCESS, jobEduListCountResult));
};

export const getJobEduById = async (req, res) => {
const jobEduId = req.params.jobEduId;

if (!jobEduId) return res.send(errResponse(baseResponse.JOBEDU_ID_EMPTY));

const jobEduByIdResult = await jobEduProvider.retrieveJobEduById(jobEduId);

return res.send(response(baseResponse.SUCCESS, jobEduByIdResult));
}
31 changes: 22 additions & 9 deletions src/app/JobEdu/jobEduDao.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,28 @@ export const selectJobEduList = async function (perPage, offset) {
};

export const selectJobEduListCount = async function () {
const query = `
const query = `
select count(*) as total_count from job_educations;
`;

try {
const result = await pool.query(query);
return result;
} catch (error) {
logger.error("쿼리 실패");
throw error;
}
};
try {
const result = await pool.query(query);
return result;
} catch (error) {
logger.error("쿼리 실패");
throw error;
}
};

export const selectJobEduById = async function (jobEduId) {
const query = `
SELECT * FROM job_educations WHERE job_edu_id = ${jobEduId};`;

try {
const result = await pool.query(query);
return result.rows[0];
} catch (error) {
logger.error("쿼리 실패");
throw error;
}
};
12 changes: 12 additions & 0 deletions src/app/JobEdu/jobEduProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ export const retrieveJobEduListCount = async function () {
throw error;
}
};

export const retrieveJobEduById = async function (jobEduId) {
try {
const result = await jobEduDao.selectJobEduById(jobEduId);

return result;
} catch (error) {
logger.error("DB 연결 실패");
logger.error(error);
throw error;
}
}
21 changes: 14 additions & 7 deletions src/app/JobEdu/jobEduRoute.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
module.exports = function(app){
const jobEdu = require('./jobEduController');
module.exports = function (app) {
const jobEdu = require("./jobEduController");

// 1. 취업교육 목록 API
app.get('/app/jobEdu', jobEdu.getJobEduList);
// 1. 취업교육 목록 API
app.get("/app/jobEdu", jobEdu.getJobEduList);

// 2. 취업교육 상세 조회 API
app.get("/app/jobEdu/:jobEduId", jobEdu.getJobEduById);


// 취업지원 목록 개수 API
app.get('/app/jobEdu/count', jobEdu.getJobEduListCount)

};

/*
내부 사용 API
*/

// 취업지원 목록 개수 API
app.get("/app/jobEdu/count", jobEdu.getJobEduListCount);
};

0 comments on commit d1e5dd9

Please sign in to comment.