/**
 * Created by Zhong on 2017/12/21.
 */

const express = require('express');
const CompleViewController = require('../controllers/compleViewController');
const CompleSectionTreeController = require('../controllers/compleSectionTreeController');
const CompleRationController = require('../controllers/compleRationController');
const GljController = require('../../complementary_glj_lib/controllers/gljController');
const SearchController = require('../controllers/searchController');

let router = express.Router();
let compleViewController = new CompleViewController();
let compleSectionTreeController = new CompleSectionTreeController();
let compleRationController = new CompleRationController();
let gljController = new GljController();
let searchController = new SearchController();

module.exports = function (app) {
    app.get('/complementaryRation/ration/:userID', compleViewController.init, compleViewController.redirectRation);
    app.get('/complementaryRation/glj/:userID', compleViewController.init, compleViewController.redirectGljList);
    app.get('/complementaryRation/coe/:userID', compleViewController.init, compleViewController.redirectCoeList);
    app.get('/complementaryRation/installation/:userID', compleViewController.init, compleViewController.redirectInstallation);
    router.get('/initData', compleViewController.init, compleViewController.prepareInitData);

    router.post('/getRationLib', compleViewController.init, compleViewController.getRationLib);
    router.post('/getRationLibs', compleViewController.init, compleViewController.getRationLibs);

    router.post('/getNewTreeID', compleSectionTreeController.init, compleSectionTreeController.getNewTreeID);
    router.post('/getRationTree', compleSectionTreeController.init, compleSectionTreeController.getRationTree);
    router.post('/updateRationSection', compleSectionTreeController.init, compleSectionTreeController.updateRationSection);

    router.post('/getRationItems', compleRationController.init, compleRationController.getRationItems);
    router.post('/mixUpdateRationItems', compleRationController.init, compleRationController.mixUpdateRationItems);

    router.post('/getGljDistType', gljController.init, gljController.getGljDistType);
    router.post('/getGljTree', gljController.init, gljController.getGljTree);
    router.post('/getGljItems', gljController.init, gljController.getGljItems);
    router.post('/getGljItemsOccupied', compleRationController.init, compleRationController.getGljItemsOccupied);
    router.post('/getRationsCodes', compleRationController.init, compleRationController.getRationsCodes);
    router.post('/getGljItemsByIds', compleRationController.init, compleRationController.getGljItemsByIds);
    router.post('/getGljItemsByCodes', compleRationController.init, compleRationController.getGljItemsByCodes);

    router.post('/getCoeList', compleRationController.init, compleRationController.getCoeList);
    router.post('/saveCoeList', compleRationController.init, compleRationController.saveCoeList);
    router.post('/getCoeItemsByIDs', compleRationController.init, compleRationController.getCoeItemsByIDs);
    router.post('/getCoeItemsByNos', compleRationController.init, compleRationController.getCoeItemsByNos);

    //安装增加费
    router.post('/getInstallation', compleRationController.init, compleRationController.getInstallation);
    router.post('/updateFeeItem', compleRationController.init, compleRationController.updateFeeItem);
    router.post('/updateInstallSection', compleRationController.init, compleRationController.updateInstallSection);
    router.post('/batchUpdateInst', compleRationController.init, compleRationController.batchUpdateInst);

    //造价书定额库
    router.post('/getRationItem', searchController.init, searchController.getRationItem);
    router.post('/findRation', searchController.init, searchController.findRation);
    router.post('/getRationGljItemsBySection', compleRationController.init, compleRationController.getRationGljItemsBySection);

    app.use('/complementaryRation/api', router);
};