UserHistory.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\user;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\user\UserHistoryRepository as repository;
  14. use think\App;
  15. class UserHistory extends BaseController
  16. {
  17. /**
  18. * @var repository
  19. */
  20. protected $repository;
  21. /**
  22. * UserHistory constructor.
  23. * @param App $app
  24. * @param repository $repository
  25. */
  26. public function __construct(App $app, repository $repository)
  27. {
  28. parent::__construct($app);
  29. $this->repository = $repository;
  30. }
  31. public function lst()
  32. {
  33. [$page, $limit] = $this->getPage();
  34. $type = $this->request->param('type',1);
  35. $uid = $this->request->uid();
  36. $data = $this->repository->getApiList($page,$limit,$uid,$type);
  37. return app('json')->success($data);
  38. }
  39. /**
  40. * @return mixed
  41. * @author Qinii
  42. */
  43. public function deleteHistory($id)
  44. {
  45. if(!$this->repository->getSearch(['uid' => $this->request->uid(),'history_id' => $id]))
  46. return app('json')->fail('信息不存在');
  47. $this->repository->delete($id);
  48. return app('json')->success('浏览记录已删除');
  49. }
  50. /**
  51. * @return mixed
  52. * @author Qinii
  53. */
  54. public function deleteHistoryBatch()
  55. {
  56. $params = $this->request->param('history_id');
  57. if(!$params) return app('json')->fail('参数不能为空');
  58. $this->repository->deleteBatch($this->request->uid(),$params);
  59. return app('json')->success('浏览记录已删除');
  60. }
  61. }