Mark.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\data\controller\news;
  3. use app\data\model\DataNewsMark;
  4. use think\admin\Controller;
  5. use think\admin\helper\QueryHelper;
  6. /**
  7. * 文章标签管理
  8. * Class Mark
  9. * @package app\data\controller\news
  10. */
  11. class Mark extends Controller
  12. {
  13. /**
  14. * 文章标签管理
  15. * @auth true
  16. * @return void
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public function index()
  22. {
  23. DataNewsMark::mQuery()->layTable(function () {
  24. $this->title = '文章标签管理';
  25. }, function (QueryHelper $query) {
  26. $query->where(['deleted' => 0]);
  27. $query->like('name')->equal('status')->dateBetween('create_at');
  28. });
  29. }
  30. /**
  31. * 添加文章标签
  32. * @auth true
  33. */
  34. public function add()
  35. {
  36. DataNewsMark::mForm('form');
  37. }
  38. /**
  39. * 编辑文章标签
  40. * @auth true
  41. */
  42. public function edit()
  43. {
  44. DataNewsMark::mForm('form');
  45. }
  46. /**
  47. * 表单结果处理
  48. * @param bool $state
  49. * @return void
  50. */
  51. protected function _form_result(bool $state)
  52. {
  53. if ($state) {
  54. $this->success('修改标签成功', "javascript:$('#TagsData').trigger('reload')");
  55. }
  56. }
  57. /**
  58. * 修改文章标签状态
  59. * @auth true
  60. */
  61. public function state()
  62. {
  63. DataNewsMark::mSave();
  64. }
  65. /**
  66. * 删除文章标签
  67. * @auth true
  68. */
  69. public function remove()
  70. {
  71. DataNewsMark::mDelete();
  72. }
  73. }