284 lines
9.9 KiB
PHP
284 lines
9.9 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 ] ]);
|
|
}
|
|
}
|
|
|
|
/***************************************视频号部分****************************************/
|
|
/**
|
|
* 视频号列表
|
|
*/
|
|
public function channellists(){
|
|
if (request()->isJson()) {
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$search_text = input('search_text', '');
|
|
$channel_type = input('channel_type', '');
|
|
$is_show = input('is_show', '');
|
|
$order = input('order', '');
|
|
$condition = [ [ 'site_id', '=', $this->site_id ] ];
|
|
if ($search_text) {
|
|
$condition[] = [ 'channel_name', 'like', '%' . $search_text . '%' ];
|
|
}
|
|
if ($channel_type) {
|
|
$condition[] = [ 'channel_type', '=', $channel_type ];
|
|
}
|
|
if ($is_show !== '') {
|
|
$condition[] = [ 'is_show', '=', $is_show ];
|
|
}
|
|
$order_by = $order ? $order : 'create_time desc';
|
|
$model = new EnterpriseModel();
|
|
$list = $model->getChannelPageList($condition, $page, $page_size, $order_by);
|
|
return $list;
|
|
} else {
|
|
return $this->fetch('enterprise/channel/lists');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 添加视频号
|
|
*/
|
|
public function channeladd()
|
|
{
|
|
$model = new EnterpriseModel();
|
|
if (request()->isJson()) {
|
|
$data = [
|
|
'site_id' => $this->site_id,
|
|
'channel_type' => input('channel_type', 'wechat'),
|
|
'channel_name' => input('channel_name', ''),
|
|
'avatar_image_type' => input('avatar_image_type', 'upload'),
|
|
'avatar_url' => input('avatar_url', ''),
|
|
'video_title' => input('video_title', ''),
|
|
'feed_id' => input('feed_id', ''),
|
|
'cover_image_type' => input('cover_image_type', 'upload'),
|
|
'cover_url' => input('cover_url', ''),
|
|
'sort' => input('sort', 0),
|
|
'is_show' => input('is_show', 1),
|
|
'feed_token' => input('feed_token', ''),
|
|
'view_count' => input('view_count', 0),
|
|
'show_view_count' => input('show_view_count', 0),
|
|
'show_follow' => input('show_follow', 0),
|
|
'create_time' => time()
|
|
];
|
|
return $model->addChannel($data);
|
|
} else {
|
|
return $this->fetch('enterprise/channel/edit');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 编辑视频号
|
|
*/
|
|
public function channeledit()
|
|
{
|
|
$channel_id = input('channel_id', 0);
|
|
$model = new EnterpriseModel();
|
|
if (request()->isJson()) {
|
|
$data = [
|
|
'channel_id' => $channel_id,
|
|
'site_id' => $this->site_id,
|
|
'channel_type' => input('channel_type', 'wechat'),
|
|
'channel_name' => input('channel_name', ''),
|
|
'avatar_image_type' => input('avatar_image_type', 'upload'),
|
|
'avatar_url' => input('avatar_url', ''),
|
|
'video_title' => input('video_title', ''),
|
|
'feed_id' => input('feed_id', ''),
|
|
'cover_image_type' => input('cover_image_type', 'upload'),
|
|
'cover_url' => input('cover_url', ''),
|
|
'sort' => input('sort', 0),
|
|
'is_show' => input('is_show', 1),
|
|
'feed_token' => input('feed_token', ''),
|
|
'view_count' => input('view_count', 0),
|
|
'show_view_count' => input('show_view_count', 0),
|
|
'show_follow' => input('show_follow', 0),
|
|
];
|
|
return $model->editChannel($data);
|
|
} else {
|
|
$this->assign('channel_id', $channel_id);
|
|
$article_info = $model->getChannelInfo([ [ 'channel_id', '=', $channel_id ] ]);
|
|
$this->assign('info', $article_info[ 'data' ]);
|
|
// 返回统一的 add.html 模板,前端会根据 channel_id 判断是否为编辑模式
|
|
return $this->fetch('enterprise/channel/edit');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除视频号
|
|
*/
|
|
public function channeldelete()
|
|
{
|
|
if (request()->isJson()) {
|
|
$channel_id = input('channel_id', 0);
|
|
$model = new EnterpriseModel();
|
|
return $model->deleteChannel([ [ 'channel_id', '=', $channel_id ], [ 'site_id', '=', $this->site_id ] ]);
|
|
}
|
|
}
|
|
} |