Topicdongtai.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use Think\Db;
  5. /**
  6. * 圈子动态
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Topicdongtai extends Backend
  11. {
  12. /**
  13. * Topicdongtai模型对象
  14. * @var \app\admin\model\Topicdongtai
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Topicdongtai;
  21. $this->view->assign("isHiddenList", $this->model->getIsHiddenList());
  22. $this->view->assign("isShowRealList", $this->model->getIsShowRealList());
  23. $this->view->assign("typeList", $this->model->getTypeList());
  24. $this->view->assign("auitStatusList", $this->model->getAuitStatusList());
  25. }
  26. public function import()
  27. {
  28. parent::import();
  29. }
  30. /**
  31. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  32. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  33. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  34. */
  35. /**
  36. * 查看
  37. */
  38. public function index()
  39. {
  40. //当前是否为关联查询
  41. $this->relationSearch = true;
  42. //设置过滤方法
  43. $this->request->filter(['strip_tags', 'trim']);
  44. if ($this->request->isAjax()) {
  45. //如果发送的来源是Selectpage,则转发到Selectpage
  46. if ($this->request->request('keyField')) {
  47. return $this->selectpage();
  48. }
  49. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  50. $list = $this->model
  51. ->with(['topichub','user'])
  52. ->where($where)
  53. ->where(['mt_topic_dongtai.status' => 0])
  54. ->order($sort, $order)
  55. ->paginate($limit);
  56. foreach ($list as $row) {
  57. $row->getRelation('topichub')->visible(['name']);
  58. $row->getRelation('user')->visible(['nickname','mobile']);
  59. }
  60. $result = array("total" => $list->total(), "rows" => $list->items());
  61. return json($result);
  62. }
  63. return $this->view->fetch();
  64. }
  65. /**
  66. * 删除
  67. */
  68. public function del($ids = "")
  69. {
  70. if (!$this->request->isPost()) {
  71. $this->error(__("Invalid parameters"));
  72. }
  73. $ids = $ids ? $ids : $this->request->post("ids");
  74. $rs = Db::name('topic_dongtai')->where(['id' => $ids])->setField('status', 1);
  75. $this->success('删除成功');
  76. }
  77. }