SystemNotice.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\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. * 通知公告
  18. */
  19. class SystemNotice extends BaseController
  20. {
  21. /**
  22. * @var SystemNoticeRepository
  23. */
  24. protected $repository;
  25. /**
  26. * SystemNotice constructor.
  27. * @param App $app
  28. * @param SystemNoticeRepository $repository
  29. */
  30. public function __construct(App $app, SystemNoticeRepository $repository)
  31. {
  32. parent::__construct($app);
  33. $this->repository = $repository;
  34. }
  35. /**
  36. * 列表
  37. * @return \think\response\Json
  38. * @author xaboy
  39. * @day 2020/11/6
  40. */
  41. public function lst()
  42. {
  43. $where = $this->request->params(['keyword', 'date']);
  44. [$page, $limit] = $this->getPage();
  45. return app('json')->success($this->repository->getList($where, $page, $limit));
  46. }
  47. /**
  48. * 创建
  49. * @param SystemNoticeValidate $validate
  50. * @return \think\response\Json
  51. * @author xaboy
  52. * @day 2020/11/6
  53. */
  54. public function create(SystemNoticeValidate $validate)
  55. {
  56. $data = $this->request->params(['type', 'mer_id', 'is_trader', 'category_id', 'notice_title', 'notice_content']);
  57. $validate->check($data);
  58. $this->repository->create($data, $this->request->adminId());
  59. return app('json')->success('发布成功');
  60. }
  61. }