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

CommunityTopic.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace app\admin\controller\community;
  3. use app\admin\logic\community\CommunityCategoryLogic;
  4. use app\admin\logic\community\CommunityTopicLogic;
  5. use app\admin\validate\community\CommunityTopicValidate;
  6. use app\common\basics\AdminBase;
  7. use app\common\server\JsonServer;
  8. /**
  9. * 种草社区话题
  10. * Class CommunityTopic
  11. * @package app\admin\controller\content
  12. */
  13. class CommunityTopic extends AdminBase
  14. {
  15. /**
  16. * @notes 获取话题列表
  17. * @return \think\response\Json|\think\response\View
  18. * @throws \think\db\exception\DbException
  19. * @author 段誉
  20. * @date 2022/4/28 10:41
  21. */
  22. public function lists()
  23. {
  24. if ($this->request->isAjax()) {
  25. $get = $this->request->get();
  26. $lists = CommunityTopicLogic::lists($get);
  27. return JsonServer::success("获取成功", $lists);
  28. }
  29. return view('', ['cate' => CommunityCategoryLogic::getCategory()]);
  30. }
  31. /**
  32. * @notes 新增话题
  33. * @return \think\response\Json|\think\response\View
  34. * @author 段誉
  35. * @date 2022/4/28 10:39
  36. */
  37. public function add()
  38. {
  39. if ($this->request->isAjax()) {
  40. $post = $this->request->post();
  41. $post['del'] = 0;
  42. (new CommunityTopicValidate())->goCheck('add', $post);
  43. CommunityTopicLogic::add($post);
  44. return JsonServer::success('新增成功');
  45. }
  46. return view('', ['cate' => CommunityCategoryLogic::getCategory()]);
  47. }
  48. /**
  49. * @notes 编辑话题
  50. * @return \think\response\Json|\think\response\View
  51. * @author 段誉
  52. * @date 2022/4/28 10:40
  53. */
  54. public function edit()
  55. {
  56. if ($this->request->isAjax()) {
  57. $post = $this->request->post();
  58. $post['del'] = 0;
  59. (new CommunityTopicValidate())->goCheck('edit', $post);
  60. CommunityTopicLogic::edit($post);
  61. return JsonServer::success('编辑成功');
  62. }
  63. $id = $this->request->get('id');
  64. return view('', [
  65. 'detail' => CommunityTopicLogic::detail($id),
  66. 'cate' => CommunityCategoryLogic::getCategory()
  67. ]);
  68. }
  69. /**
  70. * @notes 删除话题
  71. * @return \think\response\Json
  72. * @author 段誉
  73. * @date 2022/4/28 10:40
  74. */
  75. public function del()
  76. {
  77. if ($this->request->isAjax()) {
  78. (new CommunityTopicValidate())->goCheck('id');
  79. $id = $this->request->post('id');
  80. $result = CommunityTopicLogic::del($id);
  81. if (false === $result) {
  82. return JsonServer::error(CommunityTopicLogic::getError() ?: '删除失败');
  83. }
  84. return JsonServer::success('删除成功');
  85. }
  86. }
  87. /**
  88. * @notes 设置显示z状态
  89. * @return \think\response\Json
  90. * @author 段誉
  91. * @date 2022/4/28 10:41
  92. */
  93. public function status()
  94. {
  95. if ($this->request->isAjax()) {
  96. (new CommunityTopicValidate())->goCheck('status');
  97. $post = $this->request->post();
  98. CommunityTopicLogic::setStatus($post);
  99. return JsonServer::success('操作成功');
  100. }
  101. return JsonServer::success('异常');
  102. }
  103. }