'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {

    // session验证中间件
    const sessionAuth = app.middlewares.sessionAuth();

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

    // 指标库
    app.get('/lib', sessionAuth, 'libController.index');
    app.post('/lib/upload', sessionAuth, 'libController.upload');
    app.get('/lib/detail/:id', sessionAuth, 'libController.detail');
    app.post('/lib/detail/get-children', sessionAuth, 'libController.getChildren');
    app.get('/lib/global/:id', sessionAuth, 'libController.global');
    app.post('/lib/updateParamValue', sessionAuth, 'libController.updateParamValue');
    app.post('/lib/getParamAndIndex', sessionAuth, 'libController.getParamAndIndex');
    app.post('/lib/delete', sessionAuth, 'libController.delete');
    app.post('/lib/enter', sessionAuth, 'libController.enter');

    // 指标模板
    app.get('/template', sessionAuth, 'templateController.index');
    app.post('/template/uploadExcel', sessionAuth, 'templateController.uploadExcel');
    app.post('/template/updateNodeMatch', sessionAuth, 'templateController.updateNodeMatch');
    app.post('/template/setIndexRule', sessionAuth, 'templateController.setIndexRule');
    app.post('/template/updateParamMatch', sessionAuth, 'templateController.updateParamMatch');

    // 指标对比
    app.get('/compare', sessionAuth, 'compareController.index');
    app.post('/compare/search', sessionAuth, 'compareController.search');
};
