Vuser.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\admin\controller\platform;
  3. use app\common\controller\Backend;
  4. /**
  5. * 第三方平台列表
  6. *
  7. */
  8. class Vuser extends Backend
  9. {
  10. protected $relationSearch = true;
  11. protected $model = null;
  12. public function _initialize()
  13. {
  14. parent::_initialize();
  15. $this->model = new \app\common\model\VideoUser();
  16. $videolist=[];
  17. $platformlist=[];
  18. $video=model('videolist')->field('id,name')->select();
  19. foreach ($video as $k => $v){
  20. $videolist[$v['id']]=$v['name'];
  21. }
  22. $this->view->assign('videolist', $videolist);
  23. }
  24. /**
  25. * 查看
  26. */
  27. public function index()
  28. {
  29. //设置过滤方法
  30. $this->request->filter(['strip_tags']);
  31. if ($this->request->isAjax()) {
  32. //如果发送的来源是Selectpage,则转发到Selectpage
  33. if ($this->request->request('keyField')) {
  34. return $this->selectpage();
  35. }
  36. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  37. $total = $this->model
  38. ->where($where)
  39. ->order($sort, $order)
  40. ->count();
  41. $list = $this->model
  42. ->where($where)
  43. ->with('user,videolist')
  44. ->order($sort, $order)
  45. ->limit($offset, $limit)
  46. ->select();
  47. $result = array("total" => $total, "rows" => $list);
  48. return json($result);
  49. }
  50. return $this->view->fetch();
  51. }
  52. /**
  53. * 编辑
  54. */
  55. public function edit($ids = NULL)
  56. {
  57. $row = $this->model->get($ids);
  58. if (!$row){
  59. $this->error(__('No Results were found'));
  60. }
  61. if ($this->request->isPost()) {
  62. $params = $this->request->post("row/a");
  63. }
  64. $vid = $this->model->where('id', $ids)->value('vid');
  65. $this->view->assign("vid", $vid);
  66. return parent::edit($ids);
  67. }
  68. public function add($vid=0)
  69. {
  70. if ($this->request->isPost()) {
  71. $params = $this->request->post("row/a");
  72. $vid = $this->request->post("vid");
  73. $uid = $this->request->post("uid");
  74. if ($params) {
  75. $params['vid'] = $vid;
  76. if ($this->model->where('vid', $vid)->where('uid', $uid)->find()){
  77. $this->error('该短剧已拥有记录');
  78. }
  79. $params['vname'] = model('videolist')->where('id', $params['vid'])->value('name');
  80. $result = $this->model->save($params);
  81. if ($result === false) {
  82. $this->error($this->model->getError());
  83. }
  84. $this->success();
  85. }else{
  86. $this->error();
  87. }
  88. }
  89. return $this->view->fetch();
  90. }
  91. }