-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
5dc3996
commit b34b7e7
Showing
4 changed files
with
80 additions
and
24 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 |
---|---|---|
@@ -1,14 +1,39 @@ | ||
const jobEduProvider = require("./jobEduProvider"); | ||
const baseResponse = require("../../../config/baseResponseStatus"); | ||
const {response, errResponse} = require("../../../config/response"); | ||
const { response, errResponse } = require("../../../config/response"); | ||
|
||
export const getJobEduList = async (req, res) => { | ||
try { | ||
const jobEduListResult = await jobEduProvider.retrieveJobEduList(); | ||
|
||
return res.send(response(baseResponse.SUCCESS, jobEduListResult)); | ||
} catch (error) { | ||
console.error(error); | ||
return res.send(errResponse(baseResponse.DB_ERROR)); | ||
} | ||
}; | ||
try { | ||
// 페이지 크기 | ||
let perPage = req.query.perPage; | ||
// 페이지 번호 | ||
let page = req.query.page; | ||
|
||
// 페이지 크기가 없으면 10으로 설정 | ||
if (perPage == undefined || typeof perPage == "undefined" || perPage == null) { | ||
perPage = 10; | ||
} else { | ||
perPage = parseInt(perPage); | ||
} | ||
|
||
// 페이지 번호가 없으면 0으로 설정 | ||
if (page == undefined || typeof page == "undefined" || page == null) { | ||
page = 0; | ||
} else { | ||
page = parseInt(page); | ||
} | ||
|
||
const jobEduListResult = await jobEduProvider.retrieveJobEduList(perPage, page); | ||
|
||
return res.send(response(baseResponse.SUCCESS, jobEduListResult)); | ||
} catch (error) { | ||
console.error(error); | ||
return res.send(errResponse(baseResponse.DB_ERROR)); | ||
} | ||
}; | ||
|
||
export const getJobEduListCount = async (req, res) => { | ||
const jobEduListCountResult = await jobEduProvider.retrieveJobEduListCount(); | ||
|
||
return res.send(response(baseResponse.SUCCESS, jobEduListCountResult)); | ||
}; |
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,16 +1,29 @@ | ||
const { logger } = require("../../../config/winston"); | ||
import pool from "../../../config/database"; | ||
|
||
export const selectJobEduList = async function () { | ||
export const selectJobEduList = async function (perPage, offset) { | ||
const query = ` | ||
select * from job_educations limit 3; | ||
`; | ||
SELECT * FROM job_educations ORDER BY posted_at DESC LIMIT ${perPage} OFFSET ${offset}`; | ||
|
||
try { | ||
const result = await pool.query(query); | ||
return result; | ||
return result.rows; | ||
} catch (error) { | ||
logger.error("쿼리 실패"); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const selectJobEduListCount = async function () { | ||
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; | ||
} | ||
}; |
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