Usergroup.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\admin\controller\send\message;
  3. use app\common\controller\Backend;
  4. use think\Controller;
  5. use think\Request;
  6. /**
  7. * 群发消息-用户组管理
  8. *
  9. * @icon fa fa-circle-o
  10. */
  11. class Usergroup extends Backend
  12. {
  13. /**
  14. * SendUserGroup模型对象
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = model('SendUserGroup');
  21. $this->view->assign("typeList", $this->model->getTypeList());
  22. }
  23. /**
  24. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法
  25. * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑
  26. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  27. */
  28. /**
  29. * 查看
  30. */
  31. public function index()
  32. {
  33. $not_in_ids = $this->request->request('not_in_ids');
  34. //设置过滤方法
  35. $this->request->filter(['strip_tags']);
  36. if ($this->request->isAjax())
  37. {
  38. //如果发送的来源是Selectpage,则转发到Selectpage
  39. if ($this->request->request('pkey_name'))
  40. {
  41. return $this->selectpage();
  42. }
  43. $not_ids = $this->request->request('not_in_ids');
  44. if(!empty($not_ids)){
  45. $whereid['id'] = ['not in',$not_ids];
  46. }else{
  47. $whereid = [];
  48. }
  49. $whereuser['status'] = ['eq',1];
  50. $whereuser['is_del'] = ['eq',0];
  51. $whereuser['create_by'] = $this->auth->id;
  52. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  53. $total = $this->model
  54. ->where($where)
  55. ->where($whereid)
  56. ->where($whereuser)
  57. ->order($sort, $order)
  58. ->count();
  59. $list = $this->model
  60. ->where($where)
  61. ->where($whereid)
  62. ->where($whereuser)
  63. ->order($sort, $order)
  64. ->limit($offset, $limit)
  65. ->select();
  66. $result = array("total" => $total, "rows" => $list);
  67. return json($result);
  68. }
  69. $this->assignconfig('not_in_ids', $not_in_ids);
  70. return $this->view->fetch();
  71. }
  72. }