ArticleCateController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller\article;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\article\ArticleCateLists;
  17. use app\adminapi\logic\article\ArticleCateLogic;
  18. use app\adminapi\validate\article\ArticleCateValidate;
  19. /**
  20. * 资讯分类管理控制器
  21. * Class ArticleCateController
  22. * @package app\adminapi\controller\article
  23. */
  24. class ArticleCateController extends BaseAdminController
  25. {
  26. /**
  27. * @notes 查看资讯分类列表
  28. * @return \think\response\Json
  29. * @author heshihu
  30. * @date 2022/2/21 17:11
  31. */
  32. public function lists()
  33. {
  34. return $this->dataLists(new ArticleCateLists());
  35. }
  36. /**
  37. * @notes 添加资讯分类
  38. * @return \think\response\Json
  39. * @author heshihu
  40. * @date 2022/2/21 17:31
  41. */
  42. public function add()
  43. {
  44. $params = (new ArticleCateValidate())->post()->goCheck('add');
  45. ArticleCateLogic::add($params);
  46. return $this->success('添加成功', [], 1, 1);
  47. }
  48. /**
  49. * @notes 编辑资讯分类
  50. * @return \think\response\Json
  51. * @author heshihu
  52. * @date 2022/2/21 17:49
  53. */
  54. public function edit()
  55. {
  56. $params = (new ArticleCateValidate())->post()->goCheck('edit');
  57. $result = ArticleCateLogic::edit($params);
  58. if (true === $result) {
  59. return $this->success('编辑成功', [], 1, 1);
  60. }
  61. return $this->fail(ArticleCateLogic::getError());
  62. }
  63. /**
  64. * @notes 删除资讯分类
  65. * @return \think\response\Json
  66. * @author heshihu
  67. * @date 2022/2/21 17:52
  68. */
  69. public function delete()
  70. {
  71. $params = (new ArticleCateValidate())->post()->goCheck('delete');
  72. ArticleCateLogic::delete($params);
  73. return $this->success('删除成功', [], 1, 1);
  74. }
  75. /**
  76. * @notes 资讯分类详情
  77. * @return \think\response\Json
  78. * @author heshihu
  79. * @date 2022/2/21 17:54
  80. */
  81. public function detail()
  82. {
  83. $params = (new ArticleCateValidate())->goCheck('detail');
  84. $result = ArticleCateLogic::detail($params);
  85. return $this->data($result);
  86. }
  87. /**
  88. * @notes 更改资讯分类状态
  89. * @return \think\response\Json
  90. * @author heshihu
  91. * @date 2022/2/21 10:15
  92. */
  93. public function updateStatus()
  94. {
  95. $params = (new ArticleCateValidate())->post()->goCheck('status');
  96. $result = ArticleCateLogic::updateStatus($params);
  97. if (true === $result) {
  98. return $this->success('修改成功', [], 1, 1);
  99. }
  100. return $this->fail(ArticleCateLogic::getError());
  101. }
  102. /**
  103. * @notes 获取文章分类
  104. * @return \think\response\Json
  105. * @throws \think\db\exception\DataNotFoundException
  106. * @throws \think\db\exception\DbException
  107. * @throws \think\db\exception\ModelNotFoundException
  108. * @author 段誉
  109. * @date 2022/10/13 10:54
  110. */
  111. public function all()
  112. {
  113. $result = ArticleCateLogic::getAllData();
  114. return $this->data($result);
  115. }
  116. }