作者 赵彬吉
正在显示 34 个修改的文件 包含 1030 行增加59 行删除
... ... @@ -79,7 +79,13 @@ class ProjectImport extends Command
//读取csv文件
$line_of_text = [];
try {
$file_handle = fopen($task->file_url, 'r');
$opts = [
'http' => [
'method' => 'GET',
'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
]
];
$file_handle = fopen($task->file_url, 'r', null, stream_context_create($opts));
while (!feof($file_handle)) {
$line_of_text[] = fgetcsv($file_handle, 0, ',');
}
... ... @@ -183,7 +189,7 @@ class ProjectImport extends Command
protected function get_code_type($file)
{
$list = array('GBK', 'UTF-8');
$str = file_get_contents($file);
$str = curl_c($file, false);
foreach ($list as $item) {
$tmp = mb_convert_encoding($str, $item, $item);
if (md5($tmp) == md5($str)) {
... ...
... ... @@ -268,6 +268,14 @@ class HtmlCollect extends Command
$check_vc_b && $source[] = $check_vc_b;
}
//a标签下载资源
preg_match_all('/<a\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_a);
$down = $result_a[2] ?? [];
foreach ($down as $vd) {
$check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url);
$check_vd && $source[] = $check_vd;
}
return $source;
}
... ... @@ -286,7 +294,7 @@ class HtmlCollect extends Command
(empty($host) || $host == $web_url_domain || $host == $home_url)
&& $path
&& (strpos($path, '.') !== false)
&& (end($path_arr) != 'html')
&& (!in_array(end($path_arr), ['html', 'php', 'com', 'xml']))
) {
$source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first();
if (!$source) {
... ...
<?php
/**
* @remark :
* @name :CustomModuleCategoryController.php
* @author :lyh
* @method :post
* @time :2023/12/4 15:54
*/
namespace App\Http\Controllers\Bside\CustomModule;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic;
use App\Models\CustomModule\CustomModuleCategory;
class CustomModuleCategoryController extends BaseController
{
/**
* @remark :获取自定义模块列表
* @name :ModuleList
* @author :lyh
* @method :post
* @time :2023/12/4 15:43
*/
public function lists(CustomModuleCategory $customModuleCategory){
$this->request->validate([
'module_id'=>['required'],
],[
'module_id.required' => 'module_id不能为空',
]);
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :添加/编辑分类时获取分类列表
* @name :getCateList
* @author :lyh
* @method :post
* @time :2023/12/5 17:11
*/
public function getCateList(CustomModuleCategoryLogic $logic){
$list = $logic->getCateList();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :获取当前数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/12/4 16:09
*/
public function info(CustomModuleCategoryLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $logic->categoryInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/12/4 15:45
*/
public function save(CustomModuleCategoryLogic $logic){
$this->request->validate([
'name'=>['required'],
'route'=>['required'],
'module_id'=>['required']
],[
'name.required' => '分类名称不能为空',
'route.required' => '分类路由不能为空',
'module_id.required' => '所选模块id不能为空'
]);
$logic->categorySave();
$this->response('success');
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2023/12/4 16:14
*/
public function del(CustomModuleCategoryLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$logic->categoryDel();
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleContentController.php
* @author :lyh
* @method :post
* @time :2023/12/4 15:55
*/
namespace App\Http\Controllers\Bside\CustomModule;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
use App\Models\CustomModule\CustomModuleContent;
class CustomModuleContentController extends BaseController
{
/**
* @remark :获取自定义模块列表
* @name :ModuleList
* @author :lyh
* @method :post
* @time :2023/12/4 15:43
*/
public function lists(CustomModuleContent $customModuleContent){
$this->request->validate([
'module_id'=>['required'],
],[
'module_id.required' => 'module_id不能为空',
]);
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取当前数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/12/4 16:09
*/
public function info(CustomModuleContentLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$info = $logic->getCustomModuleContentInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/12/4 15:45
*/
public function save(CustomModuleContentLogic $logic){
$this->request->validate([
'name'=>['required'],
'route'=>['required'],
'module_id'=>['required']
],[
'name.required' => '分类名称不能为空',
'route.required' => '分类路由不能为空',
'module_id.required' => '所选模块id不能为空'
]);
$logic->customModuleContentSave();
$this->response('success');
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2023/12/4 16:14
*/
public function del(CustomModuleContentLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$logic->customModuleContentDel();
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleController.php
* @author :lyh
* @method :post
* @time :2023/12/4 15:42
*/
namespace App\Http\Controllers\Bside\CustomModule;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleLogic;
use App\Models\CustomModule\CustomModule;
/**
* @remark :自定义模块
* @name :CustomModuleController
* @author :lyh
* @method :post
* @time :2023/12/4 15:42
*/
class CustomModuleController extends BaseController
{
/**
* @remark :获取自定义模块列表
* @name :ModuleList
* @author :lyh
* @method :post
* @time :2023/12/4 15:43
*/
public function lists(CustomModule $customModule){
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModule->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取当前数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/12/4 16:09
*/
public function info(CustomModuleLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$info = $logic->getCustomModuleInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/12/4 15:45
*/
public function save(CustomModuleLogic $logic){
$this->request->validate([
'name'=>['required'],
],[
'name.required' => '模块名称不能为空',
]);
$logic->customModuleSave();
$this->response('success');
}
/**
* @remark :删除
* @name :del
* @author :lyh
* @method :post
* @time :2023/12/5 9:53
*/
public function del(CustomModuleLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$logic->customModuleDel();
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleExtentController.php
* @author :lyh
* @method :post
* @time :2023/12/4 15:58
*/
namespace App\Http\Controllers\Bside\CustomModule;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleExtendLogic;
use App\Models\CustomModule\CustomModuleExtend;
class CustomModuleExtentController extends BaseController
{
/**
* @remark :获取自定义模块列表
* @name :ModuleList
* @author :lyh
* @method :post
* @time :2023/12/4 15:43
*/
public function list(CustomModuleExtend $customModuleExtend){
$this->map['project_id'] = $this->user['project_id'];
$lists = $customModuleExtend->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取当前数据详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/12/4 16:09
*/
public function info(CustomModuleExtendLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$info = $logic->getCustomModuleExtendInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/12/4 15:45
*/
public function save(CustomModuleExtendLogic $logic){
$logic->customModuleExtendSave();
$this->response('success');
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2023/12/4 16:14
*/
public function del(CustomModuleExtendLogic $logic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$logic->customModuleExtendDel();
$this->response('success');
}
}
... ...
... ... @@ -21,11 +21,11 @@ class NavController extends BaseController
/**
* 列表数据
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author:dc
* @time 2023/5/8 16:37
* @remark :获取列表数据
* @name :index
* @author :lyh
* @method :post
* @time :2023/12/4 15:00
*/
public function index(BNav $nav){
$this->map['project_id'] = $this->user['project_id'];
... ... @@ -42,6 +42,19 @@ class NavController extends BaseController
}
/**
* @remark :获取当前id下的所有子集
* @name :getSubList
* @author :lyh
* @method :post
* @time :2023/12/4 15:04
*/
public function getSubList(NavLogic $logic){
$data = $logic->getSubList();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
... ...
... ... @@ -36,7 +36,6 @@ class NewsController extends BaseController
$user = new User();
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['seo_mate'] =
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = $user->getName($v['operator_id']);
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic;
use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic;
use App\Models\Template\BModuleProject;
/**
... ... @@ -22,15 +23,14 @@ class BTemplateModuleController extends BaseController
* @method :post
* @time :2023/6/29 11:33
*/
public function lists(BTemplateModuleLogic $BTemplateModuleLogic){
public function lists(BTemplateModuleLogic $bTemplateModuleLogic,BTemplateModuleProjectLogic $bTemplateModuleProjectLogic){
if(!isset($this->map['test_model'])){
$this->map['test_model'] = ['in',[0,1]];
}
$data = [];
$list = $BTemplateModuleLogic->ModuleList($this->map,$this->order);
$list = $bTemplateModuleLogic->ModuleList($this->map,$this->order);
$data['list'] = $list;
$moduleProjectModel = new BModuleProject();
$module_list = $moduleProjectModel->list(['project_id'=>$this->user['project_id']]);
$module_list = $bTemplateModuleProjectLogic->ModuleList(['project_id'=>$this->user['project_id']]);
$data['module_list'] = $module_list;
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -195,6 +195,9 @@ class ImageController extends Controller
//保存路径
$url = $this->config['root'].$this->path;
$image_type = $files->getClientOriginalExtension();
if(strlen($image_type) > 7){
$this->response('不支持当前格式',Code::SYSTEM_ERROR);
}
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//上传到cos
if($this->upload_location == 1){
... ...
... ... @@ -35,7 +35,7 @@ class OnlineCheckLogic extends BaseLogic
$optimizeInfo = $optimizeModel->read(['project_id'=>$this->param['id']]);
//查看当前用户是否有权限审核
if($this->param['type'] == 'optimist'){
if(($info['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){
if(($optimizeInfo['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){
$this->fail('你无权限提交审核');
}
}else{
... ... @@ -43,7 +43,7 @@ class OnlineCheckLogic extends BaseLogic
if($info['optimist_status'] != 1){
$this->fail('请先优化师审核');
}
if($info['qa_mid'] != 0 && $info['qa_mid'] != $this->manager['id']){
if(($info['qa_mid'] != 0) && ($info['qa_mid'] != $this->manager['id'])){
$this->fail('你无权限提交审核');
}
if(isset($this->param['project_type']) && !empty($this->param['project_type'])){
... ... @@ -72,9 +72,9 @@ class OnlineCheckLogic extends BaseLogic
if($info !== false){
$this->fail('已提交,请勿重复提交');
}else{
$projectModel = new Project();
//提交审核修改状态为审核中
$projectModel->edit(['status'=>1],['id'=>$this->param['id']]);
if(($this->param['optimist_mid'] == 0) || ($this->param['qa_mid'] == 0)){
$this->fail('请先选择优化师和品控,在提交审核');
}
//组装数据
$data = [
'project_id' => $this->param['id'],
... ... @@ -88,6 +88,9 @@ class OnlineCheckLogic extends BaseLogic
$this->fail('error');
}
}
$projectModel = new Project();
//提交审核修改状态为审核中
$projectModel->edit(['status'=>1],['id'=>$this->param['id']]);
return $this->success();
}
}
... ...
... ... @@ -379,7 +379,7 @@ class BTemplateLogic extends BaseLogic
}
}
$this->addUpdateNotify($type,$route);
return $this->curlDelRoute($route);
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
}
/**
... ...
... ... @@ -22,6 +22,19 @@ class BTemplateModuleProjectLogic extends BaseLogic
}
/**
* @remark :获取左侧模块列表
* @name :ModuleList
* @author :lyh
* @method :post
* @time :2023/6/29 13:35
*/
public function ModuleList($map,$order = 'created_at',$filed = ['id','name','sort','status','image','html']){
$map['status'] = 0;
$lists = $this->model->list($map,$order,$filed);
return $this->success($lists);
}
/**
* @remark :保存私有化左侧模块
* @name :moduleProjectSave
* @author :lyh
... ...
... ... @@ -113,7 +113,7 @@ class CustomTemplateLogic extends BaseLogic
}
//通知
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']);
$this->curlDelRoute($info['url']);
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$info['url']]);
return $this->success();
}
... ... @@ -213,7 +213,7 @@ class CustomTemplateLogic extends BaseLogic
}
if($info['url'] != $route){
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
$this->curlDelRoute($info['url']);
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
}
return true;
}
... ... @@ -259,7 +259,7 @@ class CustomTemplateLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'url']);
$this->curlDelRoute($info['url']);
$this->curlDelRoute(['route'=>$info['url']]);
return $this->success();
}
... ...
... ... @@ -284,21 +284,52 @@ class VisualizationLogic extends BaseLogic
$type = $this->getType($this->param['source'],$this->param['source_id']);
try {
if(in_array($type,$page_array)){//定制页面
$this->saveVisualizationHtml();
}else{
$this->saveTemplateHtml();
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :保存定制界面
* @name :saveVisualizationHtml
* @author :lyh
* @method :post
* @time :2023/12/5 15:42
*/
public function saveVisualizationHtml(){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
'template_id'=>0
'source'=>$this->param['source'], 'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'], 'template_id'=>0
]);
if($templateInfo === false){
$this->param['project_id'] = $this->user['project_id'];
$this->param['template_id'] = 0;
// $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
// $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);
// $param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
// $param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$param['html'] = $this->param['html'];
$bTemplateModel->edit($param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);
}
}else{
return $this->success();
}
/**
* @remark :非定制界面保存数据
* @name :saveTemplateHtml
* @author :lyh
* @method :post
* @time :2023/12/5 15:44
*/
public function saveTemplateHtml(){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
... ... @@ -319,12 +350,6 @@ class VisualizationLogic extends BaseLogic
$this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :通知首页更新
... ... @@ -357,12 +382,12 @@ class VisualizationLogic extends BaseLogic
$newsInfo = $newsModel->read(['id'=>$source_id],['url']);
$route = $newsInfo['url'];
}else{
$type = 0;
$type = 'all';
$route = 'all';
}
}
$this->addUpdateNotify($type,$route);
return $this->curlDelRoute($route);
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
}
/**
... ...
... ... @@ -169,8 +169,10 @@ class BaseLogic extends Logic
* @method :post
* @time :2023/11/30 14:43
*/
public function curlDelRoute($route){
$url = $this->user['domain'].'api/delHtml/?project_id='.$this->user['project_id'].'&route='.$route;
public function curlDelRoute($data){
$data['project_id'] = $this->user['project_id'];
$str = http_build_query($data);
$url = $this->user['domain'].'api/delHtml/?'.$str;
curlGet($url);
return $this->success();
}
... ...
... ... @@ -113,7 +113,7 @@ class BlogCategoryLogic extends BaseLogic
$info = $this->model->read(['id'=>$id],['id','alias']);
if($info['alias'] != $route){
$this->addUpdateNotify(RouteMap::SOURCE_BLOG_CATE,$route);
$this->curlDelRoute($info['alias']);
$this->curlDelRoute(['route'=>$info['alias'],'new_route'=>$route]);
}
return true;
}
... ... @@ -306,7 +306,7 @@ class BlogCategoryLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
$this->curlDelRoute($info['alias']);
$this->curlDelRoute(['route'=>$info['alias']]);
return $this->success();
}
... ...
... ... @@ -63,7 +63,7 @@ class BlogLogic extends BaseLogic
$info = $this->model->read(['id'=>$id],['id','url']);
if($info['url'] != $route){
$this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route);
$this->curlDelRoute($info['url']);
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
}
return true;
}
... ... @@ -155,7 +155,7 @@ class BlogLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
$this->curlDelRoute($info['url']);
$this->curlDelRoute(['route'=>$info['url']]);
return $this->success();
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleCategoryLogic.php
* @author :lyh
* @method :post
* @time :2023/12/4 16:07
*/
namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\RouteMap\RouteMap;
class CustomModuleCategoryLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new CustomModuleCategory();
}
/**
* @remark :添加/编辑获取分类列表
* @name :getCateList
* @author :lyh
* @method :post
* @time :2023/12/5 17:12
*/
public function getCateList(){
$this->param['status'] = 0;
if(isset($this->param['id']) && !empty($this->param['id'])){
$str = [];
//排序掉当前id下所有子集
$str = $this->getAllSub($this->param['id'],$str);
$str[] = (int)$this->param['id'];
$this->param['id'] = ['not in',$str];
}
$menu = array();
$list = $this->model->list($this->param);
if(!empty($list)){
foreach ($list as $k => $v){
if($v['pid'] == 0){
$v['sub'] = _get_child($v['id'],$list);
$menu[] = $v;
}
}
}
return $this->success($menu);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
* @remark :获取当前数据详情
* @name :getCustomModuleInfo
* @author :lyh
* @method :post
* @time :2023/12/4 16:10
*/
public function categoryInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
* @remark :保存数据
* @name :ModuleSave
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function categorySave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->categoryEdit();
}else{
$this->categoryAdd();
}
return $this->success();
}
/**
* @remark :添加分类
* @name :categoryAdd
* @author :lyh
* @method :post
* @time :2023/12/5 10:55
*/
public function categoryAdd(){
try {
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
$this->edit(['url' => $route], ['id' => $id]);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑分类
* @name :categoryEdit
* @author :lyh
* @method :post
* @time :2023/12/5 10:55
*/
public function categoryEdit(){
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $this->param['id'], $this->user['project_id']);
$this->editNewsRoute($this->param['id'],$route);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请连续管理员');
}
return $this->success();
}
/**
* @remark :查看是否编辑路由
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 11:05
*/
public function editNewsRoute($id, $route)
{
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'route']);
if ($info['route'] != $route) {
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
}
return true;
}
/**
* @name :(添加分类时处理子集分类)addProcessingSon
* @author :lyh
* @method :post
* @time :2023/6/13 11:34
*/
public function addProcessingSon($cate_id){
if(isset($this->param['pid']) && !empty($this->param['pid'])) {
$this->param['pid'] = 0;
}
//判断为子分类时
if($this->param['pid'] != 0) {
//查看当前上级分类下是否有其他分类
$cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);
if ($cate_info === false) {
//查看当前上一级分类下是否有关联模块内容
$newsModel = new NewsModel();
$news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
if ($news_count > 0) {
$replacement = ',' . $cate_id . ',';
$old = ',' . $this->param['pid'] . ',';
//更新所有商品到当前分类
$newsModel->where('category_id', 'like', '%' . $old . '%')
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
}
}
}
return $this->success();
}
/**
* @remark :删除数据
* @name :ModuleDel
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function categoryDel(){
$info = $this->model->read(['pid' => $this->param['id']], ['id', 'route']);
if($info === false){
$this->fail('当前分类拥有下级');
}
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('系统错误,请连续管理员');
}
return $this->success();
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleContentLogic.php
* @author :lyh
* @method :post
* @time :2023/12/4 16:06
*/
namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModuleContent;
class CustomModuleContentLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new CustomModuleContent();
}
/**
* @remark :获取当前数据详情
* @name :getCustomModuleInfo
* @author :lyh
* @method :post
* @time :2023/12/4 16:10
*/
public function getCustomModuleContentInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
* @remark :保存数据
* @name :ModuleSave
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleContentSave(){
}
/**
* @remark :删除数据
* @name :ModuleDel
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleContentDel(){
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleExtendLogic.php
* @author :lyh
* @method :post
* @time :2023/12/4 16:07
*/
namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModuleExtend;
class CustomModuleExtendLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new CustomModuleExtend();
}
/**
* @remark :获取当前数据详情
* @name :getCustomModuleInfo
* @author :lyh
* @method :post
* @time :2023/12/4 16:10
*/
public function getCustomModuleExtendInfo(){
}
/**
* @remark :保存数据
* @name :ModuleSave
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleExtendSave(){
}
/**
* @remark :删除数据
* @name :ModuleDel
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleExtendDel(){
}
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleLogic.php
* @author :lyh
* @method :post
* @time :2023/12/4 15:46
*/
namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
class CustomModuleLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new CustomModule();
}
/**
* @remark :获取当前数据详情
* @name :getCustomModuleInfo
* @author :lyh
* @method :post
* @time :2023/12/4 16:10
*/
public function getCustomModuleInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
* @remark :保存数据
* @name :ModuleSave
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleSave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->moduleEdit();
}else{
$this->moduleAdd();
}
return $this->success();
}
/**
* @remark :新增
* @name :moduleAdd
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleAdd(){
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑
* @name :moduleEdit
* @author :lyh
* @method :post
* @time :2023/12/5 9:39
*/
public function moduleEdit(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :删除数据
* @name :ModuleDel
* @author :lyh
* @method :post
* @time :2023/12/4 15:47
*/
public function customModuleDel(){
//查看当前模块是否拥有数据
$contentModel = new CustomModuleContent();
$contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']);
if($contentInfo !== false){
$this->fail('当前模块拥有内容不允许删除');
}
$categoryModel = new CustomModuleCategory();
$categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']);
if($categoryInfo !== false){
$this->fail('当前模块拥有分类不允许删除');
}
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -26,6 +26,52 @@ class NavLogic extends BaseLogic
$this->model = new BNav();
}
/**
* @remark :获取当前id下所有子集
* @name :getSubList
* @author :lyh
* @method :post
* @time :2023/12/4 15:11
*/
public function getSubList(){
//编辑时
if(isset($this->param['id']) && !empty($this->param['id'])) {
$str = [];
//排序掉当前id下所有子集
$str = $this->getAllSub($this->param['id'], $str);
$str[] = $this->param['id'];
$this->param['id'] = ['not in', $str];
}
$this->param['project_id'] = $this->user['project_id'];
$list = $this->model->list($this->param);
$data = array();
foreach ($list as $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $list);
$data[] = $v;
}
}
return $this->success($data);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>1],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
* @remark :保存数据
... ... @@ -71,10 +117,10 @@ class NavLogic extends BaseLogic
if($this->param['pid'] == $info['id']){
$this->fail('不允许成为自己的上级');
}
$pid_info = $this->model->read(['pid'=>$this->param['id']]);
if(($pid_info !== false) && $this->param['pid'] != $info['pid']){
$this->fail('当前菜单拥有子集不允许修改上级');
}
// $pid_info = $this->model->read(['pid'=>$this->param['id']]);
// if(($pid_info !== false) && $this->param['pid'] != $info['pid']){
// $this->fail('当前菜单拥有子集不允许修改上级');
// }
return $this->success();
}
... ...
... ... @@ -123,7 +123,7 @@ class NewsCategoryLogic extends BaseLogic
$info = $this->model->read(['id'=>$id],['id','alias']);
if($info['alias'] != $route){
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
$this->curlDelRoute($info['alias']);
$this->curlDelRoute(['route'=>$info['alias'],'new_route'=>$route]);
}
return true;
}
... ... @@ -287,7 +287,7 @@ class NewsCategoryLogic extends BaseLogic
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$info = $this->model->read(['id'=>$id],['id','alias']);
$this->curlDelRoute($info['alias']);
$this->curlDelRoute(['route'=>$info['alias']]);
return $this->success();
}
... ...
... ... @@ -95,7 +95,7 @@ class NewsLogic extends BaseLogic
$info = $this->model->read(['id' => $id], ['id', 'url']);
if ($info['url'] != $route) {
$this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
$this->curlDelRoute($info['url']);
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
}
return true;
}
... ... @@ -267,7 +267,7 @@ class NewsLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'url']);
$this->curlDelRoute($info['url']);
$this->curlDelRoute(['route'=>$info['url']]);
return $this->success();
}
... ...
... ... @@ -233,7 +233,7 @@ class CategoryLogic extends BaseLogic
$info = $this->model->read(['id'=>$id],['id','route']);
if($info['route'] != $route){
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_CATE,$route);
$this->curlDelRoute($info['route']);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
}
return true;
}
... ... @@ -278,7 +278,7 @@ class CategoryLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$this->curlDelRoute($info['route']);
$this->curlDelRoute(['route'=>$info['route']]);
return $this->success();
}
... ...
... ... @@ -185,7 +185,7 @@ class KeywordLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$this->curlDelRoute($info['route']);
$this->curlDelRoute(['route'=>$info['route']]);
return $this->success();
}
... ...
... ... @@ -294,7 +294,7 @@ class ProductLogic extends BaseLogic
$info = $this->model->read(['id'=>$id]);
if($info['route'] != $route){
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT,$route);
$this->curlDelRoute($info['route']);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
}
return $route;
}
... ... @@ -341,7 +341,7 @@ class ProductLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$this->curlDelRoute($info['route']);
$this->curlDelRoute(['route'=>$info['route']]);
return $this->success();
}
... ... @@ -648,6 +648,32 @@ class ProductLogic extends BaseLogic
'description' => $data[10]??''
];
//处理描述切换栏
$describe = [];
if($data[11]){
//处理描述切换栏中的图片
$describe = json_decode($data[11],true);
foreach ($describe as &$v_desc){
preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $v_desc['text'], $result_desc);
if($result_desc[2]??[]){
foreach ($result_desc[2] as $vdesc_img){
$v_desc['text'] = str_replace($vdesc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_img)),$v_desc['text']);
}
}
//处理描述切换栏中的视频
preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $v_desc['text'], $result_desc_video);
if($result_desc_video[2]??[]){
foreach ($result_desc_video[2] as $vdesc_video){
$v_desc['text'] = str_replace($vdesc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_video)),$v_desc['text']);
}
}
}
}
$id = $this->model->addReturnId(
[
'project_id' => $project_id,
... ... @@ -659,6 +685,7 @@ class ProductLogic extends BaseLogic
'keyword_id' => $keyword_id,
'intro' => $intro,
'content' => $content,
'describe' => Arr::a2s($describe),
'seo_mate' => Arr::a2s($seo_mate),
'created_uid' => $user_id,
'status' => Product::STATUS_ON
... ...
... ... @@ -14,4 +14,6 @@ use App\Models\Base;
class CustomModule extends Base
{
protected $table = 'gl_custom_module';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -14,4 +14,6 @@ use App\Models\Base;
class CustomModuleCategory extends Base
{
protected $table = 'gl_custom_module_category';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -14,4 +14,6 @@ use App\Models\Base;
class CustomModuleContent extends Base
{
protected $table = 'gl_custom_module_content';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleLabel.php
* @name :CustomModuleExtend.php
* @author :lyh
* @method :post
* @time :2023/11/6 10:05
* @time :2023/12/4 15:42
*/
namespace App\Models\CustomModule;
use App\Models\Base;
class CustomModuleLabel extends Base
class CustomModuleExtend extends Base
{
protected $table = 'gl_custom_module_label';
protected $table = 'gl_custom_module_extent';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -38,6 +38,11 @@ class RouteMap extends Base
const SOURCE_NAV = 'nav';
//自定义模块
const SOURCE_MODULE = 'module_';
//自定义模块分类
const SOURCE_MODULE_CATE = 'module_cate_';
/**
* 生成路由标识
* @param $title
... ...
... ... @@ -364,6 +364,7 @@ Route::middleware(['bloginauth'])->group(function () {
// 导航栏编辑
Route::prefix('nav')->group(function () {
Route::get('/', [\App\Http\Controllers\Bside\Nav\NavController::class, 'index'])->name('nav');
Route::any('/get', [\App\Http\Controllers\Bside\Nav\NavController::class, 'getSubList'])->name('nav_getSubList');
Route::post('/create', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_create');
Route::post('/update', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_update');
Route::delete('/delete', [\App\Http\Controllers\Bside\Nav\NavController::class, 'delete'])->name('nav_delete');
... ... @@ -422,6 +423,28 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('language')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists');
});
//自定义模板
Route::prefix('custom')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
Route::prefix('category')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'lists'])->name('custom_category_lists');
Route::any('/getCateList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'getCateList'])->name('custom_category_getCateList');
Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'info'])->name('custom_category_info');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'save'])->name('custom_category_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'del'])->name('custom_category_del');
});
Route::prefix('content')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'lists'])->name('custom_content_lists');
Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info');
Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del');
});
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...