|
@@ -1,10 +1,9 @@
|
|
|
<?php
|
|
|
namespace app\Nutrition\controller;
|
|
|
+use app\common\model\DatumIntro;
|
|
|
use app\common\model\VideoIntro;
|
|
|
use app\common\model\VideoUrl;
|
|
|
use library\Controller;
|
|
|
-use library\tools\Data;
|
|
|
-use think\Db;
|
|
|
use app\common\model\VideoCate as VCM;
|
|
|
/**
|
|
|
* 资料管理
|
|
@@ -80,54 +79,6 @@ class UserDatum extends Controller
|
|
|
$this->_form($this->table, 'form');
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 禁用
|
|
|
- * @auth true
|
|
|
- * @menu true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function forbidden()
|
|
|
- {
|
|
|
- $this->_save($this->table, ['status' => '0']);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 启用
|
|
|
- * @auth true
|
|
|
- * @menu true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function enable()
|
|
|
- {
|
|
|
- $this->_save($this->table, ['status' => 1]);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除资料
|
|
|
- * @auth true
|
|
|
- * @menu true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function del()
|
|
|
- {
|
|
|
- $this->_save($this->table, ['is_deleted' => 1]);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 表单数据处理
|
|
@@ -137,20 +88,7 @@ class UserDatum extends Controller
|
|
|
*/
|
|
|
protected function _form_filter(&$data)
|
|
|
{
|
|
|
- if($this->request->isGet() && in_array($this->request->action(),['add','edit'])){
|
|
|
- $all_cate = VCM::where(['is_deleted'=>0])->order('sort desc ,id desc')->select();
|
|
|
- $this->cate_tree = make_tree($all_cate);
|
|
|
- }
|
|
|
|
|
|
- if($this->request->isPost() && in_array($this->request->action(),['add','edit'])) {
|
|
|
- $select_label = [];
|
|
|
- if(isset($data['serve_label']) && !empty($data['serve_label'])){
|
|
|
- foreach ($data['serve_label'] as $key=>$value){
|
|
|
- if($value) $select_label[] = $key;
|
|
|
- }
|
|
|
- }
|
|
|
- if(!empty($select_label)) $data['label'] = ','.implode(',',$select_label);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
protected function _form_result($result){
|
|
@@ -171,20 +109,19 @@ class UserDatum extends Controller
|
|
|
{
|
|
|
if ($this->request->isGet()) {
|
|
|
$id = $this->request->get('id');
|
|
|
- $has_series = VideoUrl::where('rel_id',$id)->column('video_id');
|
|
|
- $user_video = \app\common\model\UserVideo::where(['id' => $id])->find()->toArray();
|
|
|
- $series_list = VideoIntro::where(['is_deleted'=>0,'type'=>2])->where('id','not in',$has_series)->column('title','id');
|
|
|
- $this->fetch('', ['vo' => $user_video,'series_list'=>$series_list]);
|
|
|
+ $has_series = DatumIntro::where('rel_id',$id)->column('video_id');
|
|
|
+ $user_datum = \app\common\model\UserDatum::where(['id' => $id])->find()->toArray();
|
|
|
+ $series_list = DatumIntro::where(['is_deleted'=>0,'type'=>2])->where('id','not in',$has_series)->column('title','id');
|
|
|
+ $this->fetch('', ['vo' => $user_datum,'series_list'=>$series_list]);
|
|
|
} else {
|
|
|
$id = input('post.id');
|
|
|
$series_id = input('post.series_id');
|
|
|
$sort = input('post.sort');
|
|
|
$is_vip = input('post.is_vip');
|
|
|
- $user_video = \app\common\model\UserVideo::where(['id' => $id])->find()->toArray();
|
|
|
- VideoUrl::create([
|
|
|
- 'video_id'=>$series_id,
|
|
|
- 'cover'=>$user_video['cover'],
|
|
|
- 'url'=>$user_video['video_url'],
|
|
|
+ $user_video = \app\common\model\UserDatum::where(['id' => $id])->find()->toArray();
|
|
|
+ \app\common\model\DatumUrl::create([
|
|
|
+ 'datum_id'=>$series_id,
|
|
|
+ 'url'=>$user_video['datum_url'],
|
|
|
'sort'=>$sort,
|
|
|
'is_vip'=>$is_vip,
|
|
|
'source'=>2,
|