AdminController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace business\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\admin\services\AdminService;
  5. use common\components\jwt;
  6. use common\components\util;
  7. use Yii;
  8. use yii\web\Controller;
  9. class AdminController extends BaseController
  10. {
  11. public $withoutLogin = [];
  12. //获取登陆员工的权限 shish 2019.11.24
  13. public function actionLoginAuth()
  14. {
  15. $auth = AdminService::getAuth();
  16. util::success($auth);
  17. }
  18. //员工列表 shish 2019.12.8
  19. public function actionList()
  20. {
  21. $get = Yii::$app->request->get();
  22. $where['merchantId'] = $this->merchantId;
  23. $list = AdminService::getAdminList($where);
  24. util::success($list);
  25. }
  26. //添加员工 shish 2019.12.8
  27. public function actionAdd()
  28. {
  29. $post = Yii::$app->request->post();
  30. $post['merchantId'] = $this->merchantId;
  31. $admin = AdminService::addAdmin($post);
  32. $id = $admin['id'];
  33. $info = AdminService::getDetail($id);
  34. util::success($info);
  35. }
  36. //删除员工 shish 2019.12.9
  37. public function actionDelete()
  38. {
  39. $id = Yii::$app->request->get('id');
  40. $admin = AdminClass::getById($id);
  41. AdminService::valid($admin, $this->merchantId);
  42. AdminService::deleteAdmin($admin, $this->adminId);
  43. util::ok();
  44. }
  45. //修改员工 shish 2019.12.9
  46. public function actionUpdate()
  47. {
  48. $post = Yii::$app->request->post();
  49. $id = isset($post['id']) && is_numeric($post['id']) ? $post['id'] : 0;
  50. unset($post['id']);
  51. $originalAdmin = AdminService::getById($id);
  52. $admin = AdminService::updateAdmin($originalAdmin, $post);
  53. $info = AdminService::getDetail($id);
  54. util::success($info);
  55. }
  56. //查看员工详情 shish 2019.12.9
  57. public function actionDetail()
  58. {
  59. $id = Yii::$app->request->get('id');
  60. $admin = AdminService::getDetail($id);
  61. AdminService::valid($admin, $this->merchantId);
  62. util::success($admin);
  63. }
  64. }