|
@@ -1,18 +1,19 @@
|
|
|
const router = require('express').Router();
|
|
|
const paramsCheck = require('../middleware/paramsCheck');
|
|
|
const checkLogin = require('../middleware/checkLogin');
|
|
|
+const apiErrHandle = require('../until/apiErrHandle');
|
|
|
const c_recommend = require("../controller/c_recommend");
|
|
|
const field = require('../maps/field');
|
|
|
const code = require('../maps/rcodeMap');
|
|
|
const progress = require('../maps/progress')
|
|
|
-router.get('/recommends',async (req,res)=>{
|
|
|
- try{
|
|
|
+router.get('/recommends', async (req, res) => {
|
|
|
+ try {
|
|
|
let results = await c_recommend.list();
|
|
|
res.json({
|
|
|
rcode: code.ok,
|
|
|
data: results
|
|
|
})
|
|
|
- }catch (error) {
|
|
|
+ } catch (error) {
|
|
|
if (error.rcode !== code.customError) {
|
|
|
console.log(error);
|
|
|
}
|
|
@@ -22,14 +23,14 @@ router.get('/recommends',async (req,res)=>{
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
-router.get('/homer',async (req,res)=>{
|
|
|
- try{
|
|
|
+router.get('/homer', async (req, res) => {
|
|
|
+ try {
|
|
|
let results = await c_recommend.homeRecommends();
|
|
|
res.json({
|
|
|
rcode: code.ok,
|
|
|
data: results
|
|
|
})
|
|
|
- }catch (error) {
|
|
|
+ } catch (error) {
|
|
|
if (error.rcode !== code.customError) {
|
|
|
console.log(error);
|
|
|
}
|
|
@@ -41,48 +42,48 @@ router.get('/homer',async (req,res)=>{
|
|
|
});
|
|
|
|
|
|
|
|
|
-router.post('/recommend/add',
|
|
|
+router.post('/add',
|
|
|
checkLogin(field.adminType),
|
|
|
paramsCheck({
|
|
|
- post:{
|
|
|
- recommendName:{required:true},
|
|
|
- descript:{required:true},
|
|
|
+ post: {
|
|
|
+ recommendName: {required: true},
|
|
|
+ descript: {required: true},
|
|
|
}
|
|
|
}),
|
|
|
- async (req,res)=>{
|
|
|
- try{
|
|
|
- let results = await c_recommend.addRecommend(req.body.recommendName,req.body.descript ,req.body.zIndex,req.body.imgUrl);
|
|
|
- res.json({
|
|
|
- rcode: code.ok,
|
|
|
- data: results
|
|
|
- })
|
|
|
- }catch (error) {
|
|
|
- if (error.rcode !== code.customError) {
|
|
|
- console.log(error);
|
|
|
+ async (req, res) => {
|
|
|
+ try {
|
|
|
+ let results = await c_recommend.addRecommend(req.body.recommendName, req.body.descript, req.body.zIndex, req.body.imgUrl);
|
|
|
+ res.json({
|
|
|
+ rcode: code.ok,
|
|
|
+ data: results
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ if (error.rcode !== code.customError) {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ res.json({
|
|
|
+ rcode: error.rcode || code.serverError,
|
|
|
+ msg: error.msg || error.message
|
|
|
+ });
|
|
|
}
|
|
|
- res.json({
|
|
|
- rcode: error.rcode || code.serverError,
|
|
|
- msg: error.msg || error.message
|
|
|
- });
|
|
|
- }
|
|
|
-});
|
|
|
+ });
|
|
|
|
|
|
-router.post('/recommend/flights',
|
|
|
+router.post('/flights',
|
|
|
checkLogin(field.adminType),
|
|
|
paramsCheck({
|
|
|
- post:{
|
|
|
- recommendId:{required:true},
|
|
|
- flights:{required:true},
|
|
|
+ post: {
|
|
|
+ recommendId: {required: true},
|
|
|
+ flights: {required: true},
|
|
|
}
|
|
|
}),
|
|
|
- async (req,res)=>{
|
|
|
- try{
|
|
|
- let results = await c_recommend.addFlights(req.body.recommendId,req.body.flights);
|
|
|
+ async (req, res) => {
|
|
|
+ try {
|
|
|
+ let results = await c_recommend.addFlights(req.body.recommendId, req.body.flights);
|
|
|
res.json({
|
|
|
rcode: code.ok,
|
|
|
data: results
|
|
|
})
|
|
|
- }catch (error) {
|
|
|
+ } catch (error) {
|
|
|
if (error.rcode !== code.customError) {
|
|
|
console.log(error);
|
|
|
}
|
|
@@ -93,5 +94,16 @@ router.post('/recommend/flights',
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+router.post('/search', async (req, res) => {
|
|
|
+ try {
|
|
|
+ let results = await c_recommend.list();
|
|
|
+ res.json({
|
|
|
+ rcode: code.ok,
|
|
|
+ data: results
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ apiErrHandle('搜索航班', res, error);
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
module.exports = router;
|