| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace app\admin\controller\platform;
- use app\common\controller\Backend;
- /**
- * 第三方平台列表
- *
- */
- class Vuser extends Backend
- {
- protected $relationSearch = true;
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\common\model\VideoUser();
- $videolist=[];
- $platformlist=[];
- $video=model('videolist')->field('id,name')->select();
- foreach ($video as $k => $v){
- $videolist[$v['id']]=$v['name'];
- }
- $this->view->assign('videolist', $videolist);
- }
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model
- ->where($where)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->where($where)
- ->with('user,videolist')
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 编辑
- */
- public function edit($ids = NULL)
- {
- $row = $this->model->get($ids);
- if (!$row){
- $this->error(__('No Results were found'));
- }
- if ($this->request->isPost()) {
- $params = $this->request->post("row/a");
- }
- $vid = $this->model->where('id', $ids)->value('vid');
- $this->view->assign("vid", $vid);
- return parent::edit($ids);
- }
- public function add($vid=0)
- {
- if ($this->request->isPost()) {
- $params = $this->request->post("row/a");
- $vid = $this->request->post("vid");
- $uid = $this->request->post("uid");
- if ($params) {
- $params['vid'] = $vid;
- if ($this->model->where('vid', $vid)->where('uid', $uid)->find()){
- $this->error('该短剧已拥有记录');
- }
- $params['vname'] = model('videolist')->where('id', $params['vid'])->value('name');
- $result = $this->model->save($params);
- if ($result === false) {
- $this->error($this->model->getError());
- }
- $this->success();
- }else{
- $this->error();
- }
- }
- return $this->view->fetch();
- }
- }
|