截流自动化的商城平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CommunityArticle.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\admin\controller\community;
  3. use app\admin\logic\community\CommunityArticleLogic;
  4. use app\admin\validate\community\CommunityArticleValidate;
  5. use app\common\basics\AdminBase;
  6. use app\common\enum\CommunityArticleEnum;
  7. use app\common\server\JsonServer;
  8. /**
  9. * 种草社区文章
  10. * Class CommunityArticle
  11. * @package app\admin\controller\community
  12. */
  13. class CommunityArticle extends AdminBase
  14. {
  15. /**
  16. * @notes 文章列表
  17. * @return \think\response\Json|\think\response\View
  18. * @author 段誉
  19. * @date 2022/5/10 11:08
  20. */
  21. public function lists()
  22. {
  23. if ($this->request->isAjax()) {
  24. $get = $this->request->get();
  25. $lists = CommunityArticleLogic::lists($get);
  26. return JsonServer::success("获取成功", $lists);
  27. }
  28. return view('', [
  29. 'status' => CommunityArticleEnum::getStatusDesc()
  30. ]);
  31. }
  32. /**
  33. * @notes 审核文章
  34. * @return \think\response\Json|\think\response\View
  35. * @author 段誉
  36. * @date 2022/5/10 17:45
  37. */
  38. public function audit()
  39. {
  40. if ($this->request->isAjax()) {
  41. $post = $this->request->post();
  42. (new CommunityArticleValidate())->goCheck('audit', $post);
  43. $result = CommunityArticleLogic::audit($post);
  44. if (false === $result) {
  45. return JsonServer::error(CommunityArticleLogic::getError() ?: '操作失败');
  46. }
  47. return JsonServer::success('编辑成功');
  48. }
  49. $id = $this->request->get('id');
  50. return view('', [
  51. 'detail' => CommunityArticleLogic::detail($id)
  52. ]);
  53. }
  54. /**
  55. * @notes 文章详情
  56. * @return \think\response\Json|\think\response\View
  57. * @author 段誉
  58. * @date 2022/5/10 19:05
  59. */
  60. public function detail()
  61. {
  62. if ($this->request->isAjax()) {
  63. $get = $this->request->get();
  64. $result = CommunityArticleLogic::getRelationData($get);
  65. return JsonServer::success('', $result);
  66. }
  67. $id = $this->request->get('id');
  68. return view('', [
  69. 'detail' => CommunityArticleLogic::detail($id)
  70. ]);
  71. }
  72. /**
  73. * @notes 删除文章
  74. * @return \think\response\Json|void
  75. * @author 段誉
  76. * @date 2022/5/10 16:46
  77. */
  78. public function del()
  79. {
  80. if ($this->request->isAjax()) {
  81. (new CommunityArticleValidate())->goCheck('id');
  82. $id = $this->request->post('id');
  83. $result = CommunityArticleLogic::del($id);
  84. if (false === $result) {
  85. return JsonServer::error(CommunityArticleLogic::getError() ?: '删除失败');
  86. }
  87. return JsonServer::success('删除成功');
  88. }
  89. }
  90. }