123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace app\admin\controller\role;
- use app\admin\controller\BaseController;
- use app\admin\server\role\RoleServer;
- class Role extends BaseController
- {
- /**
- * Notes:获取角色列表
- * @return \support\Response
- * User: ZQ
- * Date: 2022/9/13
- */
- public function getRoleList()
- {
- [$page, $limit] = $this->getPage();
- $keywords = $this->request->get('keywords');
- $result = RoleServer::getRoleList($page, $limit, $keywords);
- return json_success($result, '成功');
- }
- /**
- * Notes:获取所有角色
- * @return \support\Response
- * User: ZQ
- * Date: 2022/9/19
- */
- public function getRoleAll()
- {
- $result = RoleServer::getRoleAll();
- return json_success($result, '成功');
- }
- /**
- * Notes:修改角色
- * @return \support\Response
- * User: ZQ
- * Date: 2022/9/13
- */
- public function updateRole()
- {
- $role_id = $this->request->post('role_id');
- $role_name = $this->request->post('role_name','');
- $role_rules = $this->request->post('role_rules','');
- $role_info = $this->request->post('role_info','');
- $role_is_show = $this->request->post('role_is_show');
- $this->validateCheck('role\RoleValidate', ['role_id' => $role_id, 'role_name' => $role_name, 'role_rules' => $role_rules], 'update');
- $result = RoleServer::updateRole($role_id, $role_name, $role_rules, $role_info, $role_is_show);
- return json_success($result, '修改成功');
- }
- /**
- * Notes:删除角色
- * @return \support\Response
- * User: ZQ
- * Date: 2022/9/13
- */
- public function delRole()
- {
- $role_id = $this->request->get('role_id');
- $this->validateCheck('role\RoleValidate', ['role_id' => $role_id], 'info');
- $result = RoleServer::delRole($role_id);
- if ($result){
- return json_success($result, '删除成功');
- }else{
- throw new \Exception('删除失败!');
- }
- }
- /**
- * Notes:添加角色
- * @return \support\Response
- * User: ZQ
- * Date: 2022/9/13
- */
- public function addRole()
- {
- $role_name = $this->request->post('role_name');
- $role_rules = $this->request->post('role_rules','');
- $role_info = $this->request->post('role_info','');
- $role_is_show = $this->request->post('role_is_show');
- $this->validateCheck('role\RoleValidate', ['role_name' => $role_name, 'role_rules' => $role_rules, 'role_is_show' => $role_is_show], 'create');
- $result = RoleServer::insertRole($role_name, $role_rules, $role_info, $role_is_show);
- return json_success($result, '添加成功');
- }
- /**
- * Notes:查询角色详情
- * @return \support\Response
- * User: ZQ
- * Date: 2022/9/13
- */
- public function roleInfo()
- {
- $role_id = $this->request->get('role_id');
- $this->validateCheck('role\RoleValidate', ['role_id' => $role_id], 'info');
- $result = RoleServer::roleInfo($role_id);
- return json_success($result, '成功');
- }
- /**
- * Notes:角色启用禁用
- * @return \support\Response
- * User: ZQ
- * Date: 2022/9/13
- */
- public function updateStatus()
- {
- $role_id = $this->request->get('role_id');
- $role_is_show = $this->request->get('role_is_show');
- $this->validateCheck('role\RoleValidate', ['role_id' => $role_id], 'info');
- $result = RoleServer::updateStatus($role_id, $role_is_show);
- return json_success($result, '修改成功');
- }
- }
|