-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtopic.js
59 lines (57 loc) · 1.32 KB
/
topic.js
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
// 引入 models
const models = require('../models');
const code = require('../lib/code');
const Sequelize = require('sequelize');
const Op = Sequelize.Op;
/**
* 专题列表
*/
listAction = async (request) => {
try{
const data = await models.nideshop_topic.findAndCountAll({
attributes: ['id', 'title', 'price_info', 'scene_pic_url', 'subtitle'],
limit: request.query.limit,
offset: (request.query.page - 1) * request.query.limit,
});
return {
results: data,
dataBaseError: false
}
}
catch(e) {
return { results: e, dataBaseError: true}
}
}
/**
* 列表详情, 下方还有四个专题推荐
*/
detailAction = async (request) => {
try{
const id = request.query.id
let data = [];
data = await models.nideshop_topic.findAndCountAll({
where: {
"id": id
},
});
const recommendList = await models.nideshop_topic.findAndCountAll({
attributes: ['id', 'title', 'price_info', 'scene_pic_url', 'subtitle'],
limit: request.query.limit,
offset: (request.query.page - 1) * request.query.limit,
});
return {
results: {
data,
recommendList
},
dataBaseError: false
}
}
catch(e) {
return { results: e, dataBaseError: true}
}
}
module.exports = {
listAction,
detailAction
}