作者 lyh

gx

... ... @@ -109,7 +109,7 @@ class ComController extends BaseController
$info = $deployBuild->read(['project_id'=>$this->user['project_id']]);
if(!empty($info['configuration'])){
$configuration = Arr::s2a($info['configuration']);
if(isset($configuration['is_home']) && ($configuration['is_home'] != "0")){
if(isset($configuration['is_home']) && ((int)$configuration['is_home'] != 0)){
return 1;
}
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Logic;
use App\Models\Com\UpdateNotify;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteDelete;
use Illuminate\Support\Facades\Cache;
/**
... ... @@ -159,4 +160,22 @@ class BaseLogic extends Logic
}
return $this->success();
}
/**
* @remark :删除和编辑路由时生成一条记录
* @name :setRouteDeleteSave
* @author :lyh
* @method :post
* @time :2023/9/7 9:38
*/
public function setRouteDeleteSave($param){
$routeDeleteModel = new RouteDelete();
$data = [
'project_id'=>$this->user['project_id'],
'source'=>$param['source'],
'created_at'=>date('Y-m-d H:i:s'),
'route'=>$param['route'],
];
return $routeDeleteModel->insert($data);
}
}
... ...
... ... @@ -33,20 +33,19 @@ class ProductLogic extends BaseLogic
* @time :2023/8/21 18:35
*/
public function productSave(){
//参数处理
$this->param = $this->handleSaveParam($this->param);
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$this->param['id']]);
$id = $this->editProduct();
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
$id = $this->model->insertGetId($this->param);
$id = $this->addProduct();
}
//路由映射
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//更新路由
$this->model->edit(['route'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -58,6 +57,43 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :新增产品
* @name :addProduct
* @author :lyh
* @method :post
* @time :2023/9/7 10:01
*/
public function addProduct(){
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
$id = $this->model->addReturnId($this->param);
return $id;
}
/**
* @remark :编辑产品
* @name :editProduct
* @author :lyh
* @method :post
* @time :2023/9/7 10:02
*/
public function editProduct(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['route'] != $this->param['route']){
//生成一条删除路由记录
$data = [
'source'=>RouteMap::SOURCE_PRODUCT,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
}
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$this->param['id']]);
return $id;
}
/**
* @remark :不使用save处理参数
* @name :handleSaveParam
* @author :lyh
... ... @@ -91,6 +127,7 @@ class ProductLogic extends BaseLogic
return $param;
}
/**
* @remark :删除数据
* @name :delete
... ... @@ -106,6 +143,12 @@ class ProductLogic extends BaseLogic
if($info['status'] == Product::STATUS_RECYCLE){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//生成一条删除路由记录
$data = [
'source'=>RouteMap::SOURCE_PRODUCT,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
//删除当前产品模版
$this->delProductModule($id);
$this->model->del(['id'=>$id]);
... ...
<?php
/**
* @remark :
* @name :RouteDelete.php
* @author :lyh
* @method :post
* @time :2023/9/7 9:35
*/
namespace App\Models\RouteMap;
use App\Models\Base;
class RouteDelete extends Base
{
//设置关联表名
protected $table = 'gl_route_map';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -48,7 +48,6 @@ class RouteMap extends Base
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
$title = Translate::tran($title, 'en');
}
$i=1;
$sign = generateRoute($title);
$route = $sign;
... ... @@ -77,14 +76,14 @@ class RouteMap extends Base
$where = [
'project_id' => $project_id,
'route' => $route,
// 'source' => $source
'source' => $source
];
if($source == self::SOURCE_BLOG_CATE){
$where['path'] = self::PATH_BLOG_CATE;
}
if($source == self::SOURCE_NEWS_CATE){
$where['path'] = self::PATH_NEWS_CATE;
}
// if($source == self::SOURCE_BLOG_CATE){
// $where['path'] = self::PATH_BLOG_CATE;
// }
// if($source == self::SOURCE_NEWS_CATE){
// $where['path'] = self::PATH_NEWS_CATE;
// }
$route = self::where($where)->first();
if($route){
if($route->source_id == $source_id){
... ... @@ -117,12 +116,6 @@ class RouteMap extends Base
$route_map->source = $source;
$route_map->source_id = $source_id;
$route_map->project_id = $project_id;
if($source == self::SOURCE_BLOG_CATE){
$route_map->path = self::PATH_BLOG_CATE;
}
if($source == self::SOURCE_NEWS_CATE){
$route_map->path = self::PATH_NEWS_CATE;
}
}
$route_map->route = $route;
$route_map->save();
... ...