StoreProductAssist.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\api\store\product;
  12. use app\common\model\store\product\ProductAssistUser;
  13. use app\common\repositories\store\product\ProductAssistSetRepository;
  14. use app\common\repositories\store\product\ProductAssistUserRepository;
  15. use think\App;
  16. use crmeb\basic\BaseController;
  17. use app\common\repositories\store\product\ProductAssistRepository;
  18. class StoreProductAssist extends BaseController
  19. {
  20. protected $repository;
  21. protected $userInfo;
  22. /**
  23. * StoreProductPresell constructor.
  24. * @param App $app
  25. * @param repository $repository
  26. */
  27. public function __construct(App $app, ProductAssistRepository $repository)
  28. {
  29. parent::__construct($app);
  30. $this->repository = $repository;
  31. $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null;
  32. }
  33. /**
  34. * 获取资源列表
  35. *
  36. * 本函数用于根据请求参数获取特定资源的列表。支持通过类型、星级和商家ID来过滤资源。
  37. * 使用分页机制返回资源列表,以提高接口的性能和响应速度。
  38. *
  39. * @return json 返回格式化的资源列表数据
  40. */
  41. public function lst()
  42. {
  43. // 解析并获取当前请求的分页信息
  44. [$page, $limit] = $this->getPage();
  45. // 从请求中获取过滤条件,包括类型、星级和商家ID
  46. $where = $this->request->params(['type','star','mer_id']);
  47. // 调用仓库层的方法获取满足条件的资源列表,并返回给前端
  48. return app('json')->success($this->repository->getApiList($where,$page, $limit));
  49. }
  50. /**
  51. * 获取用户数量
  52. *
  53. * 本方法用于查询并返回当前应用程序中的用户总数。
  54. * 它通过依赖注入获取repository对象,并调用其getUserCount方法来获取用户数。
  55. * 最后,它使用JSON响应助手将用户数量包装在一个成功的JSON响应中返回。
  56. *
  57. * @return \Illuminate\Http\JsonResponse
  58. */
  59. public function userCount()
  60. {
  61. // 使用JSON响应助手构造一个成功的响应,包含用户数量
  62. return app('json')->success($this->repository->getUserCount());
  63. }
  64. }