/**
 * Created by Zhong on 2018/1/24.
 */
import BaseController from '../../common/base/base_controller';
import InstallationDao from '../models/installation';

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

class InstallationController extends BaseController{
    getInstallation(req, res){
        let data = JSON.parse(req.body.data);
        installationDao.getInstallation(data.rationRepId, function (err, data) {
            callback(req, res, err, '', data);
        });
    }

    updateSection(req, res){
        let data = JSON.parse(req.body.data);
        installationDao.updateSection(data.updateData, function (err, data) {
            callback(req, res, err, '', data);
        });
    }

    updateFeeItem(req, res){
        let data = JSON.parse(req.body.data);
        installationDao.updateFeeItem(data.updateData, function (err, data) {
            callback(req, res, err, '', data);
        });
    }

    batchUpdateInst(req, res){
        let data = JSON.parse(req.body.data);
        installationDao.batchUpdateInst(data.rationSection, data.inst, function (err, data) {
            callback(req, res, err, '', data);
        });
    }
}

export default InstallationController;