TopSearch.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. namespace app\nutrition\controller;
  3. use library\Controller;
  4. /**
  5. * 商品热搜管理
  6. * Class TopSearch
  7. * @package app\mall\controller
  8. */
  9. class TopSearch extends Controller
  10. {
  11. /**
  12. * 绑定数据表
  13. * @var string
  14. */
  15. protected $table = 'TopSearch';
  16. /**
  17. * 商品热搜列表
  18. * @auth true
  19. * @menu true
  20. * @throws \think\Exception
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. * @throws \think\exception\DbException
  24. * @throws \think\exception\PDOException
  25. */
  26. public function index()
  27. {
  28. $this->title = '热搜列表';
  29. $this->type_desc = $type_desc = [
  30. 0=>"全部",
  31. 1=>'视频',
  32. 2=>'图文',
  33. 3=>'资料',
  34. 4=>'新闻',
  35. 5=>'需求',
  36. 6=>'问答',
  37. 7=>'商品',
  38. 8=>'招聘',
  39. 9=>'供应商',
  40. 10=>'供应商产品',
  41. ];
  42. $query = $this->_query($this->table)->where('is_deleted',0);
  43. $query->like('title');
  44. $query->order('num desc, sort desc,id desc')->page();
  45. }
  46. /**
  47. * 数据列表处理
  48. * @auth true
  49. * @menu true
  50. * @param array $data
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. * @throws \think\exception\DbException
  54. */
  55. protected function _index_page_filter(&$data)
  56. {
  57. }
  58. /**
  59. * 添加商品热搜
  60. * @auth true
  61. * @menu true
  62. * @throws \think\Exception
  63. * @throws \think\db\exception\DataNotFoundException
  64. * @throws \think\db\exception\ModelNotFoundException
  65. * @throws \think\exception\DbException
  66. * @throws \think\exception\PDOException
  67. */
  68. public function add()
  69. {
  70. $this->title = '添加';
  71. $this->_form($this->table, 'form');
  72. }
  73. /**
  74. * 编辑商品热搜
  75. * @auth true
  76. * @menu true
  77. * @throws \think\Exception
  78. * @throws \think\db\exception\DataNotFoundException
  79. * @throws \think\db\exception\ModelNotFoundException
  80. * @throws \think\exception\DbException
  81. * @throws \think\exception\PDOException
  82. */
  83. public function edit()
  84. {
  85. $this->title = '编辑';
  86. $this->_form($this->table, 'form');
  87. }
  88. /**
  89. * 启用
  90. * @auth true
  91. * @menu true
  92. * @throws \think\Exception
  93. * @throws \think\exception\PDOException
  94. */
  95. public function enable()
  96. {
  97. $this->_save($this->table, ['status' => 1]);
  98. }
  99. /**
  100. * 禁用
  101. * @auth true
  102. * @menu true
  103. * @throws \think\Exception
  104. * @throws \think\db\exception\DataNotFoundException
  105. * @throws \think\db\exception\ModelNotFoundException
  106. * @throws \think\exception\DbException
  107. * @throws \think\exception\PDOException
  108. */
  109. public function forbidden()
  110. {
  111. $this->_save($this->table, ['status' => '0']);
  112. }
  113. /**
  114. * 删除
  115. * @auth true
  116. * @menu true
  117. * @throws \think\Exception
  118. * @throws \think\exception\PDOException
  119. */
  120. public function del()
  121. {
  122. $this->_save($this->table, ['is_deleted' => 1]);
  123. }
  124. /**
  125. * 表单数据处理
  126. * @auth true
  127. * @menu true
  128. * @param array $data
  129. */
  130. protected function _form_filter(&$data)
  131. {
  132. $data['create_at'] = date('Y-m-d H:i:s');
  133. }
  134. }