作者 李美松

Merge branch 'develop' into lms

... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Controllers\Controller;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Requests\Bside\Nav\NavRequest;
use App\Http\Requests\Scene;
use App\Models\Project\DeployBuild;
... ... @@ -225,4 +226,15 @@ class BaseController extends Controller
$url = $info['test_domain'].'api/updateHtmlNotify?model='.$param;
return http_get($url);
}
public function getProjectDomain(){
$project = (new ProjectLogic())->getInfo($this->user['project_id']);
if(!empty($project['deploy_optimize']['domain'])){
return $project['deploy_optimize']['domain'];
}
if(!empty($project['deploy_build']['test_domain'])){
return $project['deploy_build']['test_domain'];
}
return '';
}
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\Blog\BlogCategoryLogic;
use App\Http\Requests\Bside\Blog\BlogCategoryRequest;
use App\Models\Blog\Blog as BlogModel;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\RouteMap;
class BlogCategoryController extends BaseController
{
... ... @@ -25,6 +26,8 @@ class BlogCategoryController extends BaseController
$blogModel = new BlogModel();
foreach ($lists['list'] as $k => $v){
$v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $v['id'], $this->user['project_id']);
$v['url'] = $this->getProjectDomain() . RouteMap::PATH_BLOG_CATE . '/' . $v['alias'];
$lists['list'][$k] = $v;
}
}
... ... @@ -43,6 +46,8 @@ class BlogCategoryController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $blogCategoryLogic->info_blog_category();
$info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $info['id'], $this->user['project_id']);
$info['url'] = $this->getProjectDomain() . RouteMap::PATH_BLOG_CATE . '/' . $info['alias'];
$this->response('success',Code::SUCCESS,$info);
}
/**
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Logic\Bside\Blog\BlogLabelLogic;
use App\Http\Logic\Bside\Blog\BlogLogic;
use App\Http\Requests\Bside\Blog\BlogRequest;
use App\Models\Blog\Blog as BlogModel;
use App\Models\RouteMap;
class BlogController extends BaseController
{
... ... @@ -30,6 +31,8 @@ class BlogController extends BaseController
$v = $blogCategoryLogic->get_category_name($v);
//获取标签名称
$v = $blogLabelLogic->get_label_name($v);
$v['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']);
$v['url'] = $this->getProjectDomain() . $v['route'];
$lists['list'][$k] = $v;
}
}
... ... @@ -58,6 +61,8 @@ class BlogController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $blogLogic->blog_info();
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
$info['url'] = $this->getProjectDomain() . $info['route'];
$this->response('success',Code::SUCCESS,$info);
}
/**
... ...
... ... @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\News\NewsCategoryLogic;
use App\Http\Requests\Bside\News\NewsCategoryRequest;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap;
class NewsCategoryController extends BaseController
{
... ... @@ -25,6 +26,8 @@ class NewsCategoryController extends BaseController
$newsModel = new NewsModel();
foreach ($lists['list'] as $k => $v){
$v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $v['id'], $this->user['project_id']);
$v['url'] = $this->getProjectDomain() . RouteMap::PATH_NEWS_CATE . '/' . $v['alias'];
$lists['list'][$k] = $v;
}
}
... ... @@ -43,6 +46,8 @@ class NewsCategoryController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $newsCategoryLogic->info_news_category();
$info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $info['id'], $this->user['project_id']);
$info['url'] = $this->getProjectDomain() . RouteMap::PATH_NEWS_CATE . '/' . $info['alias'];
$this->response('success',Code::SUCCESS,$info);
}
/**
... ...
... ... @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\News\NewsCategoryLogic;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Http\Requests\Bside\News\NewsRequest;
use App\Models\News\News as NewsModel;
use App\Models\RouteMap;
/**
... ... @@ -28,6 +29,8 @@ class NewsController extends BaseController
if(!empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v = $newsCategoryLogic->get_category_name($v);
$v['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']);
$v['url'] = $this->getProjectDomain() . $v['route'];
$lists['list'][$k] = $v;
}
}
... ... @@ -55,6 +58,8 @@ class NewsController extends BaseController
'id.required' => 'ID不能为空',
]);
$info = $newsLogic->news_info();
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']);
$info['url'] = $this->getProjectDomain() . $info['route'];
$this->response('success',Code::SUCCESS,$info);
}
/**
... ...
... ... @@ -28,8 +28,8 @@ class ProjectCountryController extends BaseController
* @method :post
* @time :2023/4/28 17:53
*/
public function edit(ProjectCountryLogic $projectCountryLogic){
$projectCountryLogic->country_edit();
public function save(ProjectCountryLogic $projectCountryLogic){
$projectCountryLogic->country_save();
$this->response('success');
}
}
... ...
... ... @@ -9,6 +9,7 @@ use App\Http\Logic\Bside\User\UserLogic;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\Blog\Blog as BlogModel;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap;
use Illuminate\Support\Facades\DB;
class BlogCategoryLogic extends BaseLogic
... ... @@ -77,6 +78,9 @@ class BlogCategoryLogic extends BaseLogic
}
}
}
RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $cate_id, $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -104,6 +108,7 @@ class BlogCategoryLogic extends BaseLogic
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']);
return $this->success();
}
... ... @@ -152,6 +157,7 @@ class BlogCategoryLogic extends BaseLogic
if($rs !== false){
$this->response('当前分类拥有博客');
}
RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $v, $this->user['project_id']);
}
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
... ...
... ... @@ -75,7 +75,7 @@ class BlogLogic extends BaseLogic
$this->param['image'] = $data;
}
$rs = $this->model->insertGetId($this->param);
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']);
RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -108,7 +108,7 @@ class BlogLogic extends BaseLogic
if(isset($this->param['image']) && is_file($this->param['image'])){
$this->param['image'] = $this->upload();
}
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
$this->edit($this->param,['id'=>$this->param['id']]);
DB::commit();
}catch (\Exception $e){
... ... @@ -185,6 +185,11 @@ class BlogLogic extends BaseLogic
try {
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
foreach ($ids as $id){
RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
}
DB::commit();
}catch (Exception $e){
DB::rollBack();
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Models\BCustom;
use App\Models\Inquiry;
use App\Models\RouteMap;
use Illuminate\Support\Facades\DB;
/**
* 自定义页面
... ... @@ -23,6 +24,15 @@ class CustomLogic extends BaseLogic
$this->model = new BCustom();
}
public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
{
$data = parent::getList($map, $sort, $columns, $limit);
foreach ($data['list'] as &$v){
$v['route'] = RouteMap::getRoute(RouteMap::SOURCE_PAGE, $v['id'], $this->project['id']);
$v['url'] = $this->getProjectDomain() . $v['route'];
}
return $this->success($data);
}
/**
* @param $param
... ... @@ -36,7 +46,18 @@ class CustomLogic extends BaseLogic
{
$param['html'] = '';
$id = parent::save($param);
DB::beginTransaction();
try {
$id = parent::save($param);
//路由映射
RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_PAGE, $id['id'], $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败');
}
$data = $this->getInfo($id['id']);
... ... @@ -55,12 +76,20 @@ class CustomLogic extends BaseLogic
*/
public function delete($ids, $map = [])
{
parent::delete($ids, $map); // TODO: Change the autogenerated stub
// 删除路由
RouteMap::delRoute(RouteMap::SOURCE_CUSTOM,$ids,$this->user['project_id']);
DB::beginTransaction();
try {
foreach ($ids as $id) {
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
}
parent::delete($ids);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('删除失败');
}
return $this->success();
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap;
use Illuminate\Support\Facades\DB;
class NewsCategoryLogic extends BaseLogic
... ... @@ -87,6 +88,7 @@ class NewsCategoryLogic extends BaseLogic
}
}
}
RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $cate_id, $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -113,6 +115,7 @@ class NewsCategoryLogic extends BaseLogic
}
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']);
return $this->success();
}
... ... @@ -149,6 +152,7 @@ class NewsCategoryLogic extends BaseLogic
if($rs !== false){
$this->fail('当前分类拥有商品');
}
RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $v, $this->user['project_id']);
}
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
... ...
... ... @@ -67,7 +67,7 @@ class NewsLogic extends BaseLogic
$this->param['image'] = $data;
}
$rs = $this->model->insertGetId($this->param);
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -100,7 +100,7 @@ class NewsLogic extends BaseLogic
$this->param['image'] = $this->upload();
}
//设置路由
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']);
RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']);
$this->edit($this->param,['id'=>$this->param['id']]);
DB::commit();
}catch (\exception $e){
... ... @@ -174,6 +174,10 @@ class NewsLogic extends BaseLogic
try {
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
foreach ($ids as $id){
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
}
DB::commit();
}catch (Exception $e){
DB::rollBack();
... ...
... ... @@ -34,8 +34,14 @@ class ProjectCountryLogic extends BaseLogic
* @method :post
* @time :2023/4/28 17:42
*/
public function country_edit(){
$rs = $this->model->edit($this->param,['project_id'=>$this->user['project_id']]);
public function country_save(){
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}else{
$rs = $this->model->edit($this->param,['project_id'=>$this->user['project_id']]);
}
if($rs === false){
$this->fail('当前数据不存在');
}
... ...
... ... @@ -36,7 +36,7 @@ class CustomRequest extends FormRequest
'keywords' => [],//'required','max:200'
'description' => [],//'required','max:250'
// 'html' => ['required'],
'url' => ['required','max:200','url'],
'url' => ['required','max:200'],
'status' => ['required','in:0,1'],
];
... ...
... ... @@ -5,6 +5,8 @@ namespace App\Models;
use App\Helper\Translate;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use function MongoDB\select_server;
/**
* 路由映射表
... ... @@ -23,12 +25,15 @@ class RouteMap extends Model
const SOURCE_PRODUCT_CATE = 'product_category';
const SOURCE_PRODUCT_KEYWORD = 'product_keyword';
const SOURCE_PAGE = 'page'; //单页面
//路由类型
const SOURCE_BLOG = 'blog';
const SOURCE_BLOG_CATE = 'blog_category';
const SOURCE_NEWS = 'news';
// 自定义界面
const SOURCE_CUSTOM = 'custom';
const SOURCE_NEWS_CATE = 'news_category';
//路由二级目录
const PATH_NEWS_CATE = 'news_catalog';
const PATH_BLOG_CATE = 'blog_catalog';
/**
* 生成路由标识
* @param $title
... ... @@ -70,9 +75,20 @@ class RouteMap extends Model
if(in_array($route, $fixed)){
return true;
}
$route = self::where('project_id', $project_id)->where('route', $route)->first();
$where = [
'project_id' => $project_id,
'route' => $route,
'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;
}
$route = self::where($where)->first();
if($route){
if($route->source == $source && $route->source_id == $source_id){
if($route->source_id == $source_id){
return false;
}
return true;
... ... @@ -102,6 +118,12 @@ class RouteMap extends Model
$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();
... ...
... ... @@ -115,7 +115,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('country')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'lists'])->name('web_setting_country_lists');
Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info');
Route::any('/edit', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'edit'])->name('web_setting_country_edit');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'save'])->name('web_setting_country_save');
});
//客服设置
Route::prefix('service')->group(function () {
... ...