/**
  * 创建角色
  */
 public function actionSave()
 {
     $id = $this->get('id', '');
     if (empty($id)) {
         //添加
         /**
          * @var $role \liuxy\admin\models\Role
          */
         $role = new Role();
         if ($role->load($this->request)) {
             $role->status = Role::STATUS_OK;
             if (empty($role->description)) {
                 $role->description = $role->name;
             }
             $role->insert_by = $this->user->username;
             if (!$role->insert()) {
                 $this->setError($role->getErrors());
             } else {
                 $this->setResponseData('data', ['name' => $role->name, 'id' => $role->id]);
             }
         } else {
             $this->setError(Module::t('error.load.data'));
         }
     } else {
         //更新
         /**
          * @var $role \liuxy\admin\models\Role
          */
         $role = Role::findOne(['id' => $id]);
         if ($role) {
             $role->name = $this->get('name', '');
             $role->description = $this->get('description', $role->name);
             if (!$role->update()) {
                 $this->setError($role->getErrors());
             } else {
                 //更新角色与权限对应关系
                 RolePermission::bind($id, $this->get('pids', ''), $this->user);
             }
         } else {
             $this->setError(Module::t('error.role.notexists'));
         }
     }
 }