AdminRoleController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\admin\classes\AdminClass;
  4. use bizGhs\admin\services\AdminRoleService;
  5. use bizGhs\admin\services\AdminService;
  6. use common\components\jwt;
  7. use common\components\util;
  8. use Yii;
  9. use yii\web\Controller;
  10. class AdminRoleController extends BaseController
  11. {
  12. //角色列表 ssh 2019.12.9
  13. public function actionList()
  14. {
  15. $list = AdminRoleService::getRoleList($this->mainId);
  16. util::success($list);
  17. }
  18. //添加员工 ssh 2019.12.10
  19. public function actionAdd()
  20. {
  21. $post = Yii::$app->request->post();
  22. $post['sjId'] = $this->sjId;
  23. $post['mainId'] = $this->mainId;
  24. $respond = AdminRoleService::addRole($post);
  25. util::success($respond);
  26. }
  27. //修改角色 ssh 2019.12.10
  28. public function actionUpdate()
  29. {
  30. $post = Yii::$app->request->post();
  31. $id = isset($post['id']) ? $post['id'] : 0;
  32. unset($post['id']);
  33. $role = AdminRoleService::getById($id);
  34. AdminRoleService::valid($role, $this->sjId);
  35. AdminRoleService::updateRole($role, $post);
  36. util::complete('修改成功');
  37. }
  38. //角色删除 ssh 2019.12.10
  39. public function actionDelete()
  40. {
  41. $id = Yii::$app->request->post('id', 0);
  42. $role = AdminRoleService::getById($id);
  43. AdminRoleService::valid($role, $this->sjId);
  44. AdminRoleService::deleteRole($role);
  45. util::complete('删除成功');
  46. }
  47. }