'use strict';

module.exports = app => {

    // session验证中间件
    const sessionAuth = app.middlewares.sessionAuth();
    // 创建时间自动填充中间件
    const datetimeFill = app.middlewares.datetimeFill();
    // 项目管理员判断中间件
    const projectManagerCheck = app.middlewares.projectManagerCheck();

    // 登入登出相关
    app.get('/login', 'loginController.index');
    app.get('/', 'loginController.index');
    app.get('/logout', 'loginController.logout');
    app.post('/login', 'loginController.login');

    // 用户信息初始化相关
    app.get('/boot', sessionAuth, 'bootController.index');
    app.post('/boot', sessionAuth, 'bootController.boot');

    // 控制面板相关
    app.get('/dashboard', sessionAuth, 'dashboardController.index');

    // 项目相关
    app.get('/project/info', sessionAuth, 'projectController.info');
    app.get('/project/account', sessionAuth, projectManagerCheck, 'accountController.index');
    app.get('/project/account/enable/:accountId', sessionAuth, projectManagerCheck, 'accountController.enable');
    app.get('/project/account/disable/:accountId', sessionAuth, projectManagerCheck, 'accountController.enable');
    app.post('/project/info', sessionAuth, 'projectController.saveInfo');

    // 台账管理相关
    app.get('/ledger', sessionAuth, 'ledgerController.index');
    app.post('/ledger/tender/add', sessionAuth, datetimeFill, 'ledgerController.addTender');
};
