/**
 * Created by Zhong on 2018/1/9.
 */

import BaseController from '../../common/base/base_controller';
import SearchDao from '../models/searchModel';

let searchDao = new SearchDao();
let callback = function (req, res, err, message, data) {
    res.json({error: err, message: message, data: data});
};

class SearchController extends BaseController{
    getRationItem(req, res){
        let data = JSON.parse(req.body.data);
        searchDao.getRationItem(req.session.sessionUser.id, req.session.sessionCompilation._id, data.rationRepIds, data.code, null, function (err, data) {
            callback(req, res, err, '', data);
        });
    }

    findRation(req, res){
        let data = JSON.parse(req.body.data);
        searchDao.findRation(req.session.sessionUser.id, req.session.sessionCompilation._id, data.rationRepId, data.keyword, data.skip, function (err, data) {
            callback(req, res, err, '', data);
        });
    }
}

export default SearchController;