-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotice.js
More file actions
42 lines (30 loc) · 1.08 KB
/
notice.js
File metadata and controls
42 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var express = require('express');
var router = express.Router();
var auth = require('../auth')
var mysql = require('../mysql');
require('date-utils');
module.exports = router;
router.get('/',auth,async (req, res) => {
var page = req.query.page || 0;
try{
var selectRow = ['noticeId','title','createdAt']
var select = 'SELECT ?? FROM notice LIMIT ?,?'
var result = await mysql.do(select,[selectRow,page*20,20]);
return res.json(result);
}catch(e){
return res.status(400).json({message: '잠시 후 다시 시도해주세요.'});
}
});
router.get('/detail',auth,async (req, res) => {
var noticeId = req.query.noticeId;
if(!noticeId)
return res.status(400).end();
try{
var selectRow = ['noticeId','title','createdAt','content']
var select = 'SELECT ?? FROM notice WHERE noticeId = ?'
var result = await mysql.do(select,[selectRow,noticeId]);
return res.json(result);
}catch(e){
return res.status(400).json({message: '잠시 후 다시 시도해주세요.'});
}
});