search.js
641 Bytes
/**
* 产品搜索 controller
* @author 陈轩 <xuan.chen@yoho.cn>
*/
'use strict';
const model = require('../models/search.js');
/* 搜索 页面 */
exports.index = (req, res) => {
const view = {
module: 'product',
page: 'search'
};
res.render('search', view);
};
/* 查询 产品列表 */
exports.fetchProducts = (req, res, next) => {
const params = {
uid: req.user.uid, // mock data
page: req.query.page || 1,
order: req.query.order || 1,
query: req.query.query
};
model.products(params)
.then(result => res.json(result))
.catch(next);
};