User.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\merchant\user;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\user\UserRepository;
  14. use think\App;
  15. class User extends BaseController
  16. {
  17. protected $repository;
  18. /**
  19. * 构造函数
  20. *
  21. * @param App $app 应用程序实例
  22. * @param UserRepository $repository 用户仓库实例
  23. */
  24. public function __construct(App $app, UserRepository $repository)
  25. {
  26. // 调用父类构造函数
  27. parent::__construct($app);
  28. // 设置用户仓库实例
  29. $this->repository = $repository;
  30. }
  31. /**
  32. * 获取用户列表
  33. *
  34. * @return mixed
  35. */
  36. public function getUserList()
  37. {
  38. // 获取关键字参数
  39. $keyword = $this->request->param('keyword', '');
  40. // 如果没有关键字则返回错误信息
  41. if (!$keyword)
  42. return app('json')->fail('请输入关键字');
  43. // 获取分页参数
  44. [$page, $limit] = $this->getPage();
  45. // 调用用户仓库的查询方法并返回结果
  46. return app('json')->success($this->repository->merList($keyword, $page, $limit));
  47. }
  48. }