Tag.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. namespace app\user\controller;
  3. use app\common\model\LabelMessage;
  4. use library\Controller;
  5. use think\Db;
  6. /**
  7. * 会员分组管理
  8. * Class Tag
  9. * @package app\user\controller
  10. */
  11. class Tag extends Controller
  12. {
  13. /**
  14. * 绑定数据表
  15. * @var string
  16. */
  17. protected $table = 'UserTag';
  18. /**
  19. * 分组管理
  20. * @auth true
  21. * @menu true
  22. * @throws \think\Exception
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @throws \think\exception\PDOException
  27. */
  28. public function index()
  29. {
  30. $this->title = '标签管理';
  31. $query = $this->_query($this->table)->order('id asc')->page();
  32. }
  33. /**
  34. * 数据列表处理
  35. * @auth true
  36. * @menu true
  37. * @param array $data
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\ModelNotFoundException
  40. * @throws \think\exception\DbException
  41. */
  42. protected function _index_page_filter(&$data)
  43. {
  44. }
  45. /**
  46. * 添加分组
  47. * @auth true
  48. * @menu true
  49. * @throws \think\Exception
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\ModelNotFoundException
  52. * @throws \think\exception\DbException
  53. * @throws \think\exception\PDOException
  54. */
  55. public function add()
  56. {
  57. $this->title = '添加分组';
  58. $this->_form($this->table, 'form');
  59. }
  60. /**
  61. * 编辑分组
  62. * @auth true
  63. * @menu true
  64. * @throws \think\Exception
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\ModelNotFoundException
  67. * @throws \think\exception\DbException
  68. * @throws \think\exception\PDOException
  69. */
  70. public function edit()
  71. {
  72. $this->title = '编辑分组';
  73. $this->_form($this->table, 'form');
  74. }
  75. /**
  76. * 删除
  77. * @auth true
  78. * @menu true
  79. * @throws \think\Exception
  80. * @throws \think\exception\PDOException
  81. */
  82. public function del()
  83. {
  84. $this->_save($this->table, ['is_deleted' => 1]);
  85. }
  86. public function send()
  87. {
  88. $this->_form($this->table, 'send');
  89. }
  90. /**
  91. * 表单数据处理
  92. * @auth true
  93. * @menu true
  94. * @param array $data
  95. */
  96. protected function _form_filter(&$data)
  97. {
  98. if($this->request->isPost() && $this->request->action() == 'send')
  99. {
  100. if(!$data['label_id'] || !$data['content']) $this->error('参数错误');
  101. LabelMessage::create(['label_id'=>$data['label_id'],'content'=>$data['content']]);
  102. }
  103. }
  104. }