171 lines
6.6 KiB
PHP
171 lines
6.6 KiB
PHP
<?php
|
|
namespace app\admin\controller\nk;
|
|
|
|
// use app\admin\controller\nk\common\Article as ArticleCommon1;
|
|
use think\db\exception\DbException as ExceptionDbException;
|
|
use think\exception\ValidateException;
|
|
use think\facade\Db;
|
|
use think\facade\View;
|
|
|
|
/**
|
|
* 教育培训 直播
|
|
*
|
|
*
|
|
CREATE TABLE `fa_article_education_live` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
|
|
`article_id` int NOT NULL COMMENT '文章id',
|
|
`lesson_period` int unsigned NOT NULL DEFAULT '0' COMMENT '课时',
|
|
`tag_ids` varchar(255) DEFAULT NULL COMMENT '文章标签id字符串',
|
|
`is_recommend` tinyint unsigned DEFAULT '0' COMMENT '是否推荐',
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `article_id_index` (`article_id`) COMMENT '文章id'
|
|
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='教育培训类直播文章扩展表';
|
|
|
|
CREATE TABLE `fa_article_education_live_series` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
|
|
`article_id` int unsigned DEFAULT NULL COMMENT '文章id',
|
|
`url` varchar(255) DEFAULT NULL COMMENT '视频地址',
|
|
`num` int unsigned NOT NULL COMMENT '第几集',
|
|
`title` varchar(255) DEFAULT NULL COMMENT '视频标题',
|
|
PRIMARY KEY (`id`),
|
|
KEY `article_id_index` (`article_id`) COMMENT '文章id'
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='教育培训视频文章扩展表';
|
|
|
|
CREATE TABLE `fa_tag` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
|
|
`tag` varchar(255) DEFAULT NULL COMMENT '标签',
|
|
`display` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '禁止显示',
|
|
PRIMARY KEY (`id`),
|
|
KEY `tag_index` (`tag`) COMMENT '标签名'
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='标签表';
|
|
|
|
*/
|
|
class EducationLive extends ArticleCommon {
|
|
const ARTICLE_EDUCATION_LIVE = 'fa_article_education_live';
|
|
const TAG = 'fa_tag';
|
|
|
|
function __construct()
|
|
{
|
|
// 课程name
|
|
// *课时
|
|
// 观看人数
|
|
$this->adminInfo = get_login_admin();
|
|
$this->category_id = 370;
|
|
$this->url=[
|
|
'/admin/nk.education_live/index?category_id='.$this->category_id,
|
|
'/admin/nk.education_live/add',
|
|
'/admin/nk.education_live/edit',
|
|
'/admin/nk.education_live/del',
|
|
'/admin/nk.education_live/read',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 查看 待完
|
|
*/
|
|
function Read() {
|
|
$param = get_params();
|
|
$id = isset($param['id']) ? $param['id'] : 0;
|
|
$detail = Db::table('fa_article')->where('id',$id)->withAttr('lesson',
|
|
function($value, $data)use($id){
|
|
return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as series_num')->where('article_id', $id)->find();
|
|
}
|
|
)->find();
|
|
|
|
// !待开发--课程集数\ 学习人数
|
|
// ->withAttr('learner',
|
|
// function($value, $data)use($id){
|
|
// return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as num')->where('article_id', $id)->find();
|
|
// }
|
|
// )
|
|
// echo '<pre>';print_r($detail);
|
|
// exit();
|
|
if (!empty($detail)) {
|
|
$detail['comment'] = Db::table('fa_article_comment')
|
|
->where('vote_id',$id)
|
|
->withAttr('user_info',function ($value,$data){
|
|
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
|
|
})->select();
|
|
View::assign('detail', $detail);
|
|
View::assign('admin_id', $this->adminInfo['id']);
|
|
return view('nk/educationlive/read',['url'=>$this->url]);
|
|
}else{
|
|
throw new \think\exception\HttpException(404, '找不到页面');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 添加
|
|
*/
|
|
function Add(){
|
|
if (request()->isAjax()) {
|
|
$params= get_params();
|
|
$params['category_id']=$this->category_id;
|
|
// unset($params['amp;']);
|
|
$this->addArticle($params, function($aid)use($params){
|
|
$params['article_id'] = $aid;
|
|
return Db::table(self::ARTICLE_EDUCATION_LIVE)->strict(false)->field(true)->insertGetId($params);
|
|
});
|
|
}else{
|
|
View::assign('editor', get_system_config('other','editor'));
|
|
View::assign('url', $this->url);
|
|
// 获取用户信息
|
|
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
|
|
View::assign('users', $this->users);
|
|
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
|
|
->field('area_id id,area_code code,area_name name')
|
|
->select();
|
|
View::assign('street', $street);
|
|
return view('nk/educationlive/add');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 编辑
|
|
*/
|
|
function Edit(){
|
|
$params= get_params();
|
|
$aid = isset($params['id']) ? $params['id'] : 0;
|
|
if (request()->isAjax()) {
|
|
$this->updateEditData($params, $aid, function($param)use($aid){
|
|
if (!empty($param['tags_id'])){
|
|
Db::table(self::ARTICLE_EDUCATION_LIVE)->where('article_id',$aid)->update(['tags_id'=>$param['tags_id']]);
|
|
}
|
|
});
|
|
|
|
}else{
|
|
|
|
$this->getEditData($params, $aid, function()use($aid){
|
|
return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as series_num')->where('article_id', $aid)->find();
|
|
});
|
|
|
|
}
|
|
return view('nk/educationlive/edit',['url'=>$this->url]);
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
function Del(){
|
|
$param = get_params();
|
|
$id = isset($param['id']) ? $param['id'] : 0;
|
|
// $type = isset($param['type']) ? $param['type'] : 0;
|
|
|
|
// 此处同时删除两个表
|
|
$res = $this->delArticle($id, function($id){
|
|
$vid = Db::table(self::ARTICLE_EDUCATION_LIVE)->where('article_id', $id)->value('id');
|
|
if (!empty($vid)) {
|
|
return Db::table(self::ARTICLE_EDUCATION_LIVE)->where('id', $vid)->delete();
|
|
}else{
|
|
return true;
|
|
}
|
|
});
|
|
|
|
if ($res["code"]==1){
|
|
return to_assign(1, $res['msg']);
|
|
}else{
|
|
return to_assign();
|
|
}
|
|
}
|
|
} |