ProjectRoleLogic.php 2.3 KB
<?php

namespace App\Http\Logic\Aside\User;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\User\ProjectMenu as ProjectMenuModel;
use App\Models\User\ProjectRole;

class ProjectRoleLogic extends BaseLogic
{
    const STATUS_ONE = 0;

    public function __construct()
    {
        parent::__construct();

        $this->model = new ProjectRole();
        $this->param = $this->requestAll;
    }

    /**
     * @name :菜单列表
     * @return void
     * @author :liyuhang
     * @method
     */
    public function role_get_menu(){
        $menuModel = new ProjectMenuModel();
        $this->param['status'] = $this::STATUS_ONE;
        $lists = $menuModel->list($this->param,'id');
        $menu = array();
        if(!empty($lists)){
            foreach ($lists as $k => $v){
                $v = (array)$v;
                if ($v['pid'] == 0) {
                    $v['sub'] = _get_child($v['id'], $lists);
                    $menu[]   = $v;
                }
            }
        }
        $this->success($menu);
    }
    /**
     * @name :详情
     * @return void
     * @author :liyuhang
     * @method
     */
    public function role_info(){
        $info = $this->model->read($this->param);
        if($info === false){
            $this->fail('当前数据不存在');
        }
        $this->success($info);
    }

    /**
     * @name :添加角色
     * @return void
     * @author :liyuhang
     * @method
     */
    public function role_add(){
        $rs = $this->model->add($this->param);
        if($rs === false){
            $this->fail('添加失败');
        }
        $this->success();
    }

    /**
     * @name :编辑角色
     * @return void
     * @author :liyuhang
     * @method
     */
    public function role_edit(){
        $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
        if($rs === false){
            $this->fail('编辑失败');
        }
        $this->success();
    }

    /**
     * @name :删除角色
     * @return void
     * @author :liyuhang
     * @method
     */
    public function role_del(){
        $this->param['id'] = ['in',$this->param['id']];
        $rs = $this->model->del($this->param);
        if($rs === false){
            $this->fail('编辑失败');
        }
        $this->success();
    }
}