Mark.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\data\controller\news;
  3. use app\data\model\DataNewsMark;
  4. use think\admin\Controller;
  5. /**
  6. * 文章标签管理
  7. * Class Mark
  8. * @package app\data\controller\news
  9. */
  10. class Mark extends Controller
  11. {
  12. /**
  13. * 文章标签管理
  14. * @auth true
  15. * @throws \think\db\exception\DataNotFoundException
  16. * @throws \think\db\exception\DbException
  17. * @throws \think\db\exception\ModelNotFoundException
  18. */
  19. public function index()
  20. {
  21. $this->title = '文章标签管理';
  22. $query = $this->_query(DataNewsMark::class);
  23. $query->like('name')->equal('status')->dateBetween('create_at');
  24. $query->where(['deleted' => 0])->order('sort desc,id desc')->page();
  25. }
  26. /**
  27. * 添加文章标签
  28. * @auth true
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. */
  33. public function add()
  34. {
  35. $this->_form(DataNewsMark::class, 'form');
  36. }
  37. /**
  38. * 编辑文章标签
  39. * @auth true
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\DbException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. */
  44. public function edit()
  45. {
  46. $this->_form(DataNewsMark::class, 'form');
  47. }
  48. /**
  49. * 修改文章标签状态
  50. * @auth true
  51. * @throws \think\db\exception\DbException
  52. */
  53. public function state()
  54. {
  55. $this->_save(DataNewsMark::class, $this->_vali([
  56. 'status.in:0,1' => '状态值范围异常!',
  57. 'status.require' => '状态值不能为空!',
  58. ]));
  59. }
  60. /**
  61. * 删除文章标签
  62. * @auth true
  63. * @throws \think\db\exception\DbException
  64. */
  65. public function remove()
  66. {
  67. $this->_delete(DataNewsMark::class);
  68. }
  69. }