Notice.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\NoticeApi;
  5. use app\admin\validate\Notice as NoticeValidate;
  6. /**
  7. * Description of Notice
  8. *
  9. * @author sgq
  10. */
  11. class Notice extends AdminController {
  12. public function index() {
  13. return view();
  14. }
  15. public function list() {
  16. $res = NoticeApi::getList($this->request->param());
  17. return json($res);
  18. }
  19. /**
  20. * @auth {{/notice/add}}
  21. * @return type
  22. */
  23. public function add() {
  24. if ($this->request->isPost()) {
  25. try {
  26. $param = $this->request->param();
  27. validate(NoticeValidate::class)->check($param);
  28. NoticeApi::update($this->request->param());
  29. exit();
  30. } catch (\think\exception $e) {
  31. return json(["msg" => $e->getMessage()]);
  32. }
  33. }
  34. return view();
  35. }
  36. /**
  37. * @auth {{/notice/update}}
  38. * @return type
  39. */
  40. public function edit() {
  41. if ($this->request->isPost()) {
  42. try {
  43. $param = $this->request->param();
  44. validate(NoticeValidate::class)->check($param);
  45. NoticeApi::update($this->request->param());
  46. exit();
  47. } catch (\think\exception $e) {
  48. return json(["msg" => $e->getMessage()]);
  49. }
  50. }
  51. return view();
  52. }
  53. /**
  54. * @auth {{/notice/delete}}
  55. * @return type
  56. */
  57. public function delete() {
  58. if ($this->request->isPost()) {
  59. $params = $this->request->param();
  60. $id = $params["id"];
  61. }
  62. }
  63. }