SystemNotice.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\controller\admin\system\notice;
  3. use app\common\repositories\system\notice\SystemNoticeRepository;
  4. use app\validate\admin\SystemNoticeValidate;
  5. use ln\basic\BaseController;
  6. use think\App;
  7. /**
  8. * Class SystemNotice
  9. * @package app\controller\merchant\system\notice
  10. * @author zfy
  11. * @day 2020/11/6
  12. */
  13. class SystemNotice extends BaseController
  14. {
  15. /**
  16. * @var SystemNoticeRepository
  17. */
  18. protected $repository;
  19. /**
  20. * SystemNotice constructor.
  21. * @param App $app
  22. * @param SystemNoticeRepository $repository
  23. */
  24. public function __construct(App $app, SystemNoticeRepository $repository)
  25. {
  26. parent::__construct($app);
  27. $this->repository = $repository;
  28. }
  29. /**
  30. * @return \think\response\Json
  31. * @author zfy
  32. * @day 2020/11/6
  33. */
  34. public function lst()
  35. {
  36. $where = $this->request->params(['keyword', 'date']);
  37. [$page, $limit] = $this->getPage();
  38. return app('json')->success($this->repository->getList($where, $page, $limit));
  39. }
  40. /**
  41. * @param SystemNoticeValidate $validate
  42. * @return \think\response\Json
  43. * @author zfy
  44. * @day 2020/11/6
  45. */
  46. public function create(SystemNoticeValidate $validate)
  47. {
  48. $data = $this->request->params(['type', 'mer_id', 'is_trader', 'category_id', 'notice_title', 'notice_content']);
  49. $validate->check($data);
  50. $this->repository->create($data, $this->request->adminId());
  51. return app('json')->success('发布成功');
  52. }
  53. }