User.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\store\controller\data;
  3. use app\store\controller\Controller;
  4. use app\store\model\User as UserModel;
  5. use app\store\model\user\Grade as GradeModel;
  6. /**
  7. * 用户数据控制器
  8. * Class User
  9. * @package app\store\controller\data
  10. */
  11. class User extends Controller
  12. {
  13. /* @var \app\store\model\User $model */
  14. private $model;
  15. /**
  16. * 构造方法
  17. * @throws \app\common\exception\BaseException
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @throws \think\exception\DbException
  21. */
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. $this->model = new UserModel;
  26. $this->view->engine->layout(false);
  27. }
  28. /**
  29. * 用户列表
  30. * @return mixed
  31. * @param string $nickName 昵称
  32. * @param int $gender 性别
  33. * @param int $grade 会员等级
  34. * @throws \think\exception\DbException
  35. */
  36. public function lists($nickName = '', $gender = null, $grade = null)
  37. {
  38. // 会员等级列表
  39. $gradeList = GradeModel::getUsableList();
  40. // 用户列表
  41. $list = $this->model->getList($nickName, $gender, $grade);
  42. return $this->fetch('list', compact('list', 'gradeList'));
  43. }
  44. }