User.php 1.4 KB

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