<?php
// +----------------------------------------------------------------------
// | RXThinkCMF框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | Author: 牧羊人 <1175401194@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;


use app\admin\model\Menu;
use app\admin\service\ActionService;
use app\common\controller\Backend;
use think\facade\View;

/**
 * 用户行为-控制器
 * @author 牧羊人
 * @since 2020/7/3
 * Class Action
 * @package app\admin\controller
 */
class Action extends Backend
{
    /**
     * 初始化
     * @author 牧羊人
     * @since 2020/7/3
     */
    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->model = new \app\admin\model\Action();
        $this->service = new ActionService();
    }

    /**
     * 数据列表页
     * @return mixed
     * @since 2020/7/3
     * @author 牧羊人
     */
    public function index()
    {
        // 行为类型
        View::assign("typeList", config("admin.action_type"));
        return parent::index(); // TODO: Change the autogenerated stub
    }

    /**
     * 添加或编辑
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author 牧羊人
     * @since 2020/7/3
     */
    public function edit()
    {
        // 行为类型
        View::assign("typeList", config("admin.action_type"));
        // 模块列表
        $menuMod = new Menu();
        View::assign("moduleList", $menuMod->where("type", 3)->where("mark", 1)->select()->toArray());
        // 执行类型
        View::assign("executionList", config("admin.action_execution"));
        return parent::edit(); // TODO: Change the autogenerated stub
    }
}