Contact.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\operate\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 活动
  7. * Class Activity
  8. * @package app\operate\controller
  9. */
  10. class Contact extends Controller
  11. {
  12. protected $table = 'Contact';
  13. /**
  14. * 列表
  15. * @auth true
  16. * @menu true
  17. * @throws \think\Exception
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @throws \think\exception\DbException
  21. * @throws \think\exception\PDOException
  22. */
  23. public function index()
  24. {
  25. $this->title = '列表';
  26. $where = [];
  27. $where[] = ['f.is_deleted','=',0];
  28. if($title = input('name')) $where[] = ['f.name','like','%'.$title.'%'];
  29. $query = $this->_query($this->table)->alias('f')
  30. ->field('f.*')
  31. ->where($where)
  32. ->order('sort desc,f.id asc')->page();
  33. }
  34. /**
  35. * 添加
  36. * @auth true
  37. * @menu true
  38. * @throws \think\Exception
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. * @throws \think\exception\DbException
  42. * @throws \think\exception\PDOException
  43. */
  44. public function add()
  45. {
  46. $this->title = '添加';
  47. $this->_form($this->table, 'form');
  48. }
  49. /**
  50. * 编辑
  51. * @auth true
  52. * @menu true
  53. * @throws \think\Exception
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @throws \think\exception\DbException
  57. * @throws \think\exception\PDOException
  58. */
  59. public function edit()
  60. {
  61. $this->title = '编辑';
  62. $this->_form($this->table, 'form');
  63. }
  64. /**
  65. * 删除
  66. * @auth true
  67. * @throws \think\Exception
  68. * @throws \think\exception\PDOException
  69. */
  70. public function del()
  71. {
  72. $this->_save($this->table, ['is_deleted' => '1']);
  73. }
  74. /**
  75. * 删除
  76. * @auth true
  77. * @throws \think\Exception
  78. * @throws \think\exception\PDOException
  79. */
  80. public function remove()
  81. {
  82. $this->_save($this->table, ['is_deleted' => '1']);
  83. }
  84. }