Auth.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\fastshop\controller;
  9. use app\common\controller\Manage;
  10. use app\common\model\SystemMember;
  11. class Auth extends Manage
  12. {
  13. public function initialize()
  14. {
  15. parent::initialize();
  16. if($this->user->parent_id){
  17. $this->error('无权限,你非【创始人】身份');
  18. }
  19. $this->assign('pathMaps', [['name'=>'员工管理','url'=>'javascript:;']]);
  20. }
  21. /**
  22. * 员工管理
  23. */
  24. public function index(){
  25. $view['list'] = SystemMember::where(['bind_member_miniapp_id' => $this->member_miniapp_id,'parent_id' => $this->user->id])->order('id desc')->paginate(20);
  26. return view()->assign($view);
  27. }
  28. /**
  29. * 权限编辑
  30. */
  31. public function edit(){
  32. if(request()->isPost()){
  33. $data = [
  34. 'id' => input('post.id/d','','htmlspecialchars'),
  35. 'types' => input('post.types/d','','htmlspecialchars'),
  36. 'member_miniapp_id' => $this->member_miniapp_id
  37. ];
  38. $result = model('Auth')->edit($data);
  39. if($result){
  40. return json(['code'=>200,'msg'=>'修改成功','url' => url('auth/index')]);
  41. }else{
  42. return json(['code'=>0,'msg'=>'修改失败']);
  43. }
  44. }else{
  45. $id = input('id/d');
  46. $info = model('Member')->where(['bind_member_miniapp_id' => $this->member_miniapp_id,'id' => $id])->find();
  47. if(!$info){
  48. return $this->error("404 NOT FOUND");
  49. }
  50. $view['info'] = $info;
  51. $view['auth'] = model('Auth')->where(['member_miniapp_id' => $this->member_miniapp_id,'member_id' => $id])->find();
  52. return view()->assign($view);
  53. }
  54. }
  55. }