Skip to content

Commit

Permalink
[FEAT] #2 - 취업교육리스트 모집중/모집마감 필터 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
charBS0701 committed Jul 20, 2023
1 parent d0edccc commit 998c592
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/app/JobEdu/jobEduController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const { response, errResponse } = require("../../../config/response");

export const getJobEduList = async (req, res) => {
try {
const page = req.query.page || 1; // 페이지 번호가 주어지지 않은 경우 기본값은 1
const pageSize = req.query.pageSize || 10; // 페이지 크기가 주어지지 않은 경우 기본값은 10
const page = req.query.page || 1;
const pageSize = req.query.pageSize || 10;
const active_status = req.query.active_status;

const jobEduListResult = await jobEduProvider.retrieveJobEduList(
pageSize,
page
page,
active_status
);

return res.send(response(baseResponse.SUCCESS, jobEduListResult));
Expand Down
9 changes: 5 additions & 4 deletions src/app/JobEdu/jobEduDao.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const { logger } = require("../../../config/winston");
import pool from "../../../config/database";

export const selectJobEduList = async function (pageSize, offset) {
const query = `
SELECT * FROM job_educations ORDER BY posted_at DESC LIMIT ${pageSize} OFFSET ${offset}`;
export const selectJobEduList = async function (pageSize, offset, active_status) {
const query = active_status
? `SELECT * FROM job_educations WHERE active_status = ${active_status} ORDER BY posted_at DESC LIMIT ${pageSize} OFFSET ${offset}`
: `SELECT * FROM job_educations ORDER BY posted_at DESC LIMIT ${pageSize} OFFSET ${offset}`;

try {
const result = await pool.query(query);
return result.rows;
} catch (error) {
logger.error("selectJobEduList 쿼리 실패");
logger.error("selectJobEduList쿼리 실패");
throw error;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/JobEdu/jobEduProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const jobEduDao = require("./jobEduDao");

const { logger } = require("../../../config/winston");

export const retrieveJobEduList = async function (pageSize, page) {
export const retrieveJobEduList = async function (pageSize, page, active_status) {
try {
const offset = (page - 1) * pageSize;
const result = await jobEduDao.selectJobEduList(pageSize, offset);
const result = await jobEduDao.selectJobEduList(pageSize, offset, active_status);
return result;
} catch (error) {
logger.error("DB 연결 실패");
Expand Down

0 comments on commit 998c592

Please sign in to comment.