AdminRoleController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace shop\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\admin\services\AdminRoleService;
  5. use biz\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. //角色列表 shish 2019.12.9
  13. public function actionList()
  14. {
  15. $list = AdminRoleService::getRoleList($this->merchantId);
  16. util::success($list);
  17. }
  18. //添加员工 shish 2019.12.10
  19. public function actionAdd()
  20. {
  21. $post = Yii::$app->request->post();
  22. $post['merchantId'] = $this->merchantId;
  23. $respond = AdminRoleService::addRole($post);
  24. util::success($respond);
  25. }
  26. //修改角色 shish 2019.12.10
  27. public function actionUpdate()
  28. {
  29. $post = Yii::$app->request->post();
  30. $id = isset($post['id']) ? $post['id'] : 0;
  31. unset($post['id']);
  32. $role = AdminRoleService::getById($id);
  33. AdminRoleService::valid($role, $this->merchantId);
  34. AdminRoleService::updateRole($role, $post);
  35. util::complete('修改成功');
  36. }
  37. //角色删除 shish 2019.12.10
  38. public function actionDelete()
  39. {
  40. $id = Yii::$app->request->post('id', 0);
  41. $role = AdminRoleService::getById($id);
  42. AdminRoleService::valid($role, $this->merchantId);
  43. AdminRoleService::deleteRole($role);
  44. util::complete('删除成功');
  45. }
  46. }