SystemNotice.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\admin\system\notice;
  12. use app\common\repositories\system\notice\SystemNoticeRepository;
  13. use app\validate\admin\SystemNoticeValidate;
  14. use crmeb\basic\BaseController;
  15. use think\App;
  16. /**
  17. * Class SystemNotice
  18. * @package app\controller\merchant\system\notice
  19. * @author xaboy
  20. * @day 2020/11/6
  21. */
  22. class SystemNotice extends BaseController
  23. {
  24. /**
  25. * @var SystemNoticeRepository
  26. */
  27. protected $repository;
  28. /**
  29. * SystemNotice constructor.
  30. * @param App $app
  31. * @param SystemNoticeRepository $repository
  32. */
  33. public function __construct(App $app, SystemNoticeRepository $repository)
  34. {
  35. parent::__construct($app);
  36. $this->repository = $repository;
  37. }
  38. /**
  39. * @return \think\response\Json
  40. * @author xaboy
  41. * @day 2020/11/6
  42. */
  43. public function lst()
  44. {
  45. $where = $this->request->params(['keyword', 'date']);
  46. [$page, $limit] = $this->getPage();
  47. return app('json')->success($this->repository->getList($where, $page, $limit));
  48. }
  49. /**
  50. * @param SystemNoticeValidate $validate
  51. * @return \think\response\Json
  52. * @author xaboy
  53. * @day 2020/11/6
  54. */
  55. public function create(SystemNoticeValidate $validate)
  56. {
  57. $data = $this->request->params(['type', 'mer_id', 'is_trader', 'category_id', 'notice_title', 'notice_content']);
  58. $validate->check($data);
  59. $this->repository->create($data, $this->request->adminId());
  60. return app('json')->success('发布成功');
  61. }
  62. }