174 lines
5.5 KiB
PHP
174 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace addon\personnel\shop\controller;
|
|
|
|
use app\shop\controller\BaseShop;
|
|
use addon\personnel\model\Enterprise as EnterpriseModel;
|
|
use app\model\upload\Upload;
|
|
//去除判断为空 add lucky
|
|
error_reporting(E_ALL ^ E_NOTICE );
|
|
/**
|
|
* 直播间
|
|
*/
|
|
class Enterprise extends BaseShop
|
|
{
|
|
public function lists()
|
|
{
|
|
if (request()->isJson()) {
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$search_text = input('search_text', '');
|
|
$condition = [ [ 'pn.site_id', '=', $this->site_id ]];
|
|
$condition[] = [ 'pn.files_title', 'like', '%' . $search_text . '%' ];
|
|
$order_by = 'pn.createtime desc';
|
|
$model = new EnterpriseModel();
|
|
$list = $model->getFilesPageList($condition, $page, $page_size, $order_by);
|
|
return $list;
|
|
} else {
|
|
return $this->fetch('enterprise/lists');
|
|
}
|
|
}
|
|
/**
|
|
* 文件添加
|
|
*/
|
|
public function add()
|
|
{
|
|
$model = new EnterpriseModel();
|
|
if (request()->isJson()) {
|
|
$files_data = [
|
|
'site_id' => $this->site_id,
|
|
'files_title' => input('files_title', ''),
|
|
'files_url' => input('files_url', ''),
|
|
'size' => input('size', ''),
|
|
'category_id'=>input('category_id', 0)
|
|
];
|
|
return $model->addFiles($files_data);
|
|
} else {
|
|
return $this->fetch('enterprise/add');
|
|
}
|
|
}
|
|
/**
|
|
* 编辑
|
|
*/
|
|
public function edit()
|
|
{
|
|
$files_id = input('files_id', 0);
|
|
$model = new EnterpriseModel();
|
|
if (request()->isJson()) {
|
|
$files_data = [
|
|
'files_id' => $files_id,
|
|
'site_id' => $this->site_id,
|
|
'files_title' => input('files_title', ''),
|
|
'files_url' => input('files_url', ''),
|
|
'size' => input('size', ''),
|
|
];
|
|
return $model->editFiles($files_data);
|
|
} else {
|
|
$this->assign('files_id', $files_id);
|
|
$article_info = $model->getFilesInfo([ [ 'files_id', '=', $files_id ] ]);
|
|
$this->assign('info', $article_info[ 'data' ]);
|
|
return $this->fetch('enterprise/edit');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 文件删除
|
|
*/
|
|
public function delete()
|
|
{
|
|
if (request()->isJson()) {
|
|
$files_id = input('files_id', 0);
|
|
$model = new EnterpriseModel();
|
|
return $model->deleteFiles([ [ 'files_id', '=', $files_id ] ]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 上传文件
|
|
*/
|
|
public function uploadfile()
|
|
{
|
|
$upload_model = new Upload();
|
|
$site_id = request()->siteid();
|
|
$name = input("name", "");
|
|
$extend_type = [ 'pdf' ];
|
|
$param = array (
|
|
"name" => "file",
|
|
"extend_type" => $extend_type
|
|
);
|
|
$file = request()->file($param[ "name" ]);
|
|
|
|
$site_id = max($site_id, 0);
|
|
$result = $upload_model->setPath("common/filepdf/" . $site_id . "/")->file($param);
|
|
if($result['code'] == 10067){
|
|
$result['data']['size'] = round($_FILES['file']['size']/(1024*1024),2);
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
/***************************************视频部分****************************************/
|
|
public function videolists(){
|
|
if (request()->isJson()) {
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$search_text = input('search_text', '');
|
|
$condition = [ [ 'site_id', '=', $this->site_id ]];
|
|
$condition[] = [ 'video_title', 'like', '%' . $search_text . '%' ];
|
|
|
|
$order_by = 'createtime desc';
|
|
$model = new EnterpriseModel();
|
|
$list = $model->getVideoPageList($condition, $page, $page_size, $order_by);
|
|
return $list;
|
|
} else {
|
|
return $this->fetch('enterprise/video/lists');
|
|
}
|
|
}
|
|
|
|
public function videoadd()
|
|
{
|
|
$model = new EnterpriseModel();
|
|
if (request()->isJson()) {
|
|
$data = [
|
|
'site_id' => $this->site_id,
|
|
'video_title' => input('video_title', ''),
|
|
'video_url' => input('video_url', ''),
|
|
'images' => input('cover_img', '')
|
|
];
|
|
return $model->addVideo($data);
|
|
} else {
|
|
return $this->fetch('enterprise/video/add');
|
|
}
|
|
}
|
|
public function videoedit()
|
|
{
|
|
$video_id = input('video_id', 0);
|
|
$model = new EnterpriseModel();
|
|
if (request()->isJson()) {
|
|
$files_data = [
|
|
'video_id' => $video_id,
|
|
'site_id' => $this->site_id,
|
|
'video_title' => input('video_title', ''),
|
|
'video_url' => input('video_url', ''),
|
|
'images' => input('cover_img', '')
|
|
];
|
|
return $model->editVideo($files_data);
|
|
} else {
|
|
$this->assign('video_id', $video_id);
|
|
$article_info = $model->getVideoInfo([ [ 'video_id', '=', $video_id ] ]);
|
|
$this->assign('info', $article_info[ 'data' ]);
|
|
return $this->fetch('enterprise/video/add');
|
|
}
|
|
}
|
|
|
|
public function videodelete()
|
|
{
|
|
if (request()->isJson()) {
|
|
$video_id = input('video_id', 0);
|
|
$model = new EnterpriseModel();
|
|
return $model->deleteVideo([ [ 'video_id', '=', $video_id],['site_id','=',$this->site_id] ]);
|
|
}
|
|
}
|
|
} |