AdminController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. AdminService::updateAdmin($originalAdmin, $post);
  53. util::ok('修改成功');
  54. }
  55. //查看员工详情 shish 2019.12.9
  56. public function actionDetail()
  57. {
  58. $id = Yii::$app->request->get('id');
  59. $admin = AdminService::getDetail($id);
  60. AdminService::valid($admin, $this->merchantId);
  61. util::success($admin);
  62. }
  63. }