Auth.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 权限管理
  7. */
  8. namespace app\popupshop\controller;
  9. use app\common\controller\Manage;
  10. use app\common\model\SystemMember;
  11. use app\fastshop\model\Auth as AppAuth;
  12. use think\facade\Request;
  13. class Auth extends Manage
  14. {
  15. public function initialize()
  16. {
  17. parent::initialize();
  18. if($this->user->parent_id){
  19. $this->error('无权限,你非【创始人】身份');
  20. }
  21. $this->assign('pathMaps', [['name'=>'员工管理','url'=>'javascript:;']]);
  22. }
  23. /**
  24. * 员工管理
  25. */
  26. public function index(){
  27. $view['list'] = SystemMember::where(['bind_member_miniapp_id' => $this->member_miniapp_id,'parent_id' => $this->user->id])->order('id desc')->paginate(20);
  28. return view()->assign($view);
  29. }
  30. /**
  31. * 权限编辑
  32. */
  33. public function edit(){
  34. if(request()->isPost()){
  35. $data = [
  36. 'id' => Request::param('id/d'),
  37. 'types' => Request::param('types/d',0),
  38. 'member_miniapp_id' => $this->member_miniapp_id
  39. ];
  40. $result = AppAuth::edit($data);
  41. if($result){
  42. return json(['code'=>200,'msg'=>'修改成功','url' => url('auth/index')]);
  43. }else{
  44. return json(['code'=>0,'msg'=>'修改失败']);
  45. }
  46. }else{
  47. $id = Request::param('id/d',0);
  48. $info = SystemMember::where(['bind_member_miniapp_id' => $this->member_miniapp_id,'id' => $id])->find();
  49. if(!$info){
  50. return $this->error("404 NOT FOUND");
  51. }
  52. $view['info'] = $info;
  53. $view['auth'] = AppAuth::where(['member_miniapp_id' => $this->member_miniapp_id,'member_id' => $id])->find();
  54. return view()->assign($view);
  55. }
  56. }
  57. }