suggest.js
1.87 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
/**
* 个人中心意见反馈
* @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');
exports.suggestData = (req, res, next) => {
let uid = req.user.uid;
let udid = req.sessionID || 'yoho';
let page = req.query.page || 1;
let limit = 10;
req.ctx(suggestModel).suggestData(uid, 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);
};
exports.upAndDown = (req, res, next) => {
let uid = req.user.uid;
let udid = req.sessionID;
let reliable = req.body.reliable || 1;
let suggestId = req.body.suggest_id;
req.ctx(suggestModel).upAndDown(uid, udid, reliable, suggestId).then((result) => {
res.json(result);
}).catch(next);
};
exports.suggestSub = (req, res) => {
res.render('suggest-sub', {
module: 'home',
page: 'suggest',
pageHeader: _.assign(headerModel.setNav({
navTitle: '反馈问题'
}), {
navBtn: false,
suggestSub: true
}),
title: '反馈问题',
pageFooter: true
});
};
exports.saveSuggest = (req, res, next) => {
let uid = req.user.uid;
let content = req.body.content;
let image = req.body.image;
let suggestType = req.body.suggest_type || 2;
req.ctx(suggestModel).saveSuggest(uid, content, image, suggestType).then((result) => {
res.json(result);
}).catch(next);
};