Article.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\store\controller;
  15. use library\Controller;
  16. /**
  17. * 文章管理
  18. * Class CategoryLabel
  19. * @package app\store\controller
  20. */
  21. class Article extends Controller
  22. {
  23. /**
  24. * 绑定数据表
  25. * @var string
  26. */
  27. protected $table = 'q_article';
  28. /**
  29. * 文章管理
  30. * @auth true
  31. * @menu true
  32. * @throws \think\Exception
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. * @throws \think\exception\DbException
  36. * @throws \think\exception\PDOException
  37. */
  38. public function index()
  39. {
  40. $this->title = '文章管理';
  41. $query = $this->_query($this->table)->like('title')->equal('is_show');
  42. $query->where('is_del',1)->order('id desc')->page();
  43. }
  44. /**
  45. * 添加
  46. * @auth true
  47. * @throws \think\Exception
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. * @throws \think\exception\DbException
  51. * @throws \think\exception\PDOException
  52. */
  53. public function add()
  54. {
  55. $this->create_at = date('Y-m-d H:i:s');
  56. $this->_form($this->table, 'form');
  57. }
  58. /**
  59. * 编辑
  60. * @auth true
  61. * @throws \think\Exception
  62. * @throws \think\db\exception\DataNotFoundException
  63. * @throws \think\db\exception\ModelNotFoundException
  64. * @throws \think\exception\DbException
  65. * @throws \think\exception\PDOException
  66. */
  67. public function edit()
  68. {
  69. $this->_form($this->table, 'form');
  70. }
  71. /**
  72. * 禁用
  73. * @auth true
  74. * @throws \think\Exception
  75. * @throws \think\exception\PDOException
  76. */
  77. public function forbid()
  78. {
  79. $this->_save($this->table, ['is_show' => '0']);
  80. }
  81. /**
  82. * 启用
  83. * @auth true
  84. * @throws \think\Exception
  85. * @throws \think\exception\PDOException
  86. */
  87. public function resume()
  88. {
  89. $this->_save($this->table, ['is_show' => '1']);
  90. }
  91. /**
  92. * 删除
  93. * @auth true
  94. * @throws \think\Exception
  95. * @throws \think\exception\PDOException
  96. */
  97. public function del()
  98. {
  99. $this->_save($this->table, ['is_del' => '0']);
  100. }
  101. }