suggest.js
1.92 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* 个人中心意见反馈
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/01
*/
'use strict';
const suggestModel = require('../models/suggest');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const _ = require('lodash');
const suggestData = (req, res, next) => {
let udid = req.sessionID || 'yoho';
let page = req.query.page || 1;
let limit = 10;
suggestModel.suggestData(udid, page, limit).then((result) => {
res.render('suggest', {
module: 'home',
page: 'suggest',
pageHeader: _.assign(headerModel.setNav({
navTitle: '意见反馈'
}), {
navBtn: false
}),
title: '意见反馈',
pageFooter: true,
suggestContent: result
});
}).catch(next);
};
const upAndDown = (req, res, next) => {
let uid = req.user.uid || 8039759;
let udid = req.sessionID || 'yoho';
let reliable = req.body.reliable || 1;
let suggestId = req.body.suggest_id;
suggestModel.upAndDown(uid, udid, reliable, suggestId).then((result) => {
res.json(result);
}).catch(next);
};
const suggestSub = (req, res) => {
res.render('suggest-sub', {
module: 'home',
page: 'suggest',
pageHeader: _.assign(headerModel.setNav({
navTitle: '反馈问题'
}), {
navBtn: false,
suggestSub: true
}),
title: '反馈问题',
pageFooter: true
});
};
const saveSuggest = (req, res, next) => {
let uid = req.user.uid || 8039759;
let content = req.body.content;
let image = req.body.image;
let suggestType = req.body.suggest_type || 2;
suggestModel.saveSuggest(uid, content, image, suggestType).then((result) => {
res.json(result);
}).catch(next);
};
module.exports = {
suggestData,
upAndDown,
suggestSub,
saveSuggest
};