/**
 * 控制面板相关控制器
 *
 * @author CaiAoLin
 * @date 2017/6/2
 * @version
 */
import BaseController from "../../common/base/base_controller";
import MessageModel from "../models/message_model";
let config = require("../../../config/config.js");

class DashboardController extends BaseController {

    /**
     * 一级菜单显示
     *
     * @var {string}
     */
    static parentTitle = '后台管理';

    /**
     * 一级菜单
     *
     * @var {string}
     */
    static parentIndex = 'manager';


    /**
     * 控制面板首页
     *
     * @param {object} request
     * @param {object} response
     * @return {void}
     */
    async index(request, response) {
        // 获取已发布的通知
        let messageModel = new MessageModel();
        let messageList = await messageModel.getList({status: 1}, 1, 5, {release_time: -1});

        let renderData = {
            parentTitle: DashboardController.parentTitle,
            parentIndex: DashboardController.parentIndex,
            layout: 'users/views/layout/layout',
            messageList: messageList,
            LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
        };
        response.render('users/views/dashboard/index', renderData);
    }

}

export default DashboardController;