Group.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // |
  4. // +----------------------------------------------------------------------
  5. // |
  6. // +----------------------------------------------------------------------
  7. // |
  8. // +----------------------------------------------------------------------
  9. // |
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 会员组管理
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\controller\user;
  15. use app\admin\model\user\UserGroup;
  16. use app\common\controller\Backend;
  17. class Group extends Backend
  18. {
  19. protected $modelValidate = true;
  20. //初始化
  21. protected function initialize()
  22. {
  23. parent::initialize();
  24. $this->modelClass = new UserGroup;
  25. }
  26. /**
  27. * 会员组列表
  28. */
  29. public function index()
  30. {
  31. if ($this->request->isAjax()) {
  32. //如果发送的来源是Selectpage,则转发到Selectpage
  33. if ($this->request->request('keyField')) {
  34. return $this->selectpage();
  35. }
  36. [$page, $limit, $where, $sort, $order] = $this->buildTableParames();
  37. $count = $this->modelClass
  38. ->withCount('user')
  39. ->where($where)
  40. ->order($sort, $order)
  41. ->count();
  42. $data = $this->modelClass
  43. ->withCount('user')
  44. ->where($where)
  45. ->order($sort, $order)
  46. ->page($page, $limit)
  47. ->select();
  48. $result = ["code" => 0, 'count' => $count, 'data' => $data];
  49. return json($result);
  50. }
  51. return $this->fetch();
  52. }
  53. }