作者 lyh

gx

... ... @@ -121,4 +121,24 @@ class BTemplateController extends BaseController
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :根据项目保存公共模板
* @name :savePublicTemplate
* @author :lyh
* @method :post
* @time :2023/9/18 10:58
*/
public function savePublicTemplate(BTemplateLogic $BTemplateLogic){
$this->request->validate([
'name'=>'required',
'html'=>'required',
'image'=>'required',
],[
'name.required' => '模板名称不能为空',
'html.required' => 'html不能为空',
'image.required' => '模板图片不能为空'
]);
$BTemplateLogic->savePublicTemplateHtml();
$this->response('模板保存成功');
}
}
... ...
... ... @@ -368,67 +368,10 @@ class BTemplateLogic extends BaseLogic
*/
public function getModuleType(): array
{
//前端会回传:products:1,news:2,blogs:3,productCategory:4
//定义数据结构
$data = [
"products"=>[
"category"=>[
[
"id"=>"all",
"title"=>"全部",
],
[
"id"=>"hot",
"title"=>"热销产品",
],
[
"id"=>"recommend",
"title"=>"推荐产品",
],
],
"imageType"=>[
[
"id"=>1,
"title"=>"产品图片",
],[
"id"=>2,
"title"=>"产品分类图片",
],[
"id"=>3,
"title"=>"产品图标",
]
],
],
"news"=>[
"category"=>[
[
"id"=>"all",
"name"=>"全部",
],
[
"id"=>"new",
"name"=>"最新",
],
],
],
"blogs"=>[
"category"=>[
[
"id"=>"all",
"name"=>"全部",
],
[
"id"=>"new",
"name"=>"最新",
],
],
]
];
$data = $this->model->product_type;
//产品,新闻,博客,一级分类数据
$map = [
'pid'=>0,
'project_id'=>$this->user['project_id']
];
$map = ['pid'=>0, 'project_id'=>$this->user['project_id']];
$productCategory = Category::where($map)->get();
$newCategory = NewsCategory::where($map)->get();
$blogCategory = BlogCategory::where($map)->get();
... ... @@ -451,4 +394,22 @@ class BTemplateLogic extends BaseLogic
return $this->success($data);
}
/**
* @remark :保存html
* @name :savePublicTemplateHtml
* @author :lyh
* @method :post
* @time :2023/9/18 11:19
*/
public function savePublicTemplateHtml(){
$this->param['project_id'] = $this->user['project_id'];
$this->param['operator_id'] = $this->user['manager_id'] ?? 0;
$this->param = $this->stringProcessing($this->param);
$publicTemplateModel = new Template();
$rs = $publicTemplateModel->add($this->param);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -35,8 +35,8 @@ class ProductLogic extends BaseLogic
public function productSave(){
//参数处理
$this->param = $this->handleSaveParam($this->param);
// DB::beginTransaction();
// try {
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//查看路由是否更新
$id = $this->editProductRoute($this->param['id'],$this->param['route']);
... ... @@ -50,11 +50,11 @@ class ProductLogic extends BaseLogic
//路由映射
$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();
// $this->fail('保存失败');
// }
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]);
return $this->success();
... ...
... ... @@ -99,9 +99,11 @@ class UserLoginLogic
/**
* 自动登录
* @author zbj
* @date 2023/7/25
* @remark :自动登录
* @name :autologin
* @author :lyh
* @method :post
* @time :2023/9/18 11:00
*/
public function autologin($data)
{
... ...
... ... @@ -25,18 +25,18 @@ class LoginAuthMiddleware
{
$manage = LoginLogic::manage();
if (!$manage) {
return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户未登录']);
return response(['code'=> Code::USER_LOGIN_ERROE,'message'=>'当前用户未登录']);
}
//权限
if($manage['id'] != Manage::ADMINISTRATOR_ID){ //排除超级管理员
if($manage['status'] != 1){
return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户被禁用']);
return response(['code'=> Code::USER_LOGIN_ERROE,'message'=>'当前用户被禁用']);
}
}
if($manage['gid'] != 0){
$groupInfo = $this->getGroup($manage);
if($groupInfo['status'] != 1){
return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户角色被禁用']);
return response(['code'=> Code::USER_LOGIN_ERROE,'message'=>'当前用户角色被禁用']);
}
//获取当前操作的路由name
$action = Route::currentRouteName();
... ... @@ -45,7 +45,7 @@ class LoginAuthMiddleware
$menu_id = $menuModel->read(['route_name'=>$action],['id']);
if($menu_id !== false){
if(in_array($menu_id['id'],$groupInfo['rights']) === false){
return response(['code'=>Code::USER_PERMISSION_ERROE,'msg'=>'当前用户没有权限']);
return response(['code'=>Code::USER_PERMISSION_ERROE,'message'=>'当前用户没有权限']);
}
}
}
... ...
... ... @@ -25,7 +25,7 @@ class LoginAuthMiddleware
$token = $request->header('token');
$info = Cache::get($token);
if(empty($info) || empty($token)){
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'当前用户未登录']);
return response(['code'=>Code::USER_LOGIN_ERROE,'message'=>'当前用户未登录']);
}
//0代表超级管理员
if($info['role_id'] != 0){
... ... @@ -38,7 +38,7 @@ class LoginAuthMiddleware
// 设置数据库
$project = ProjectServer::useProject($info['project_id']);
if(empty($project)){
return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
return response(['code'=>Code::USER_LOGIN_ERROE,'message'=>'数据库未配置']);
}
return $next($request);
}
... ... @@ -56,7 +56,7 @@ class LoginAuthMiddleware
$projectRoleModel = new ProjectRoleModel();
$role_info = $projectRoleModel->read(['id'=>$info['role_id']]);
if($role_info['status'] != 0){
return response(['code'=>Code::USER_LOGIN_ERROE,'当前用户角色被禁用']);
return response(['code'=>Code::USER_LOGIN_ERROE,'message'=>'当前用户角色被禁用']);
}
return $role_info;
}
... ... @@ -73,7 +73,7 @@ class LoginAuthMiddleware
$menu_id = $projectMenuModel->read(['action'=>$action],['id']);
if($menu_id !== false){
if(strpos($role_info['role_menu'], $menu_id['id']) === false){
return response(['code'=>Code::USER_PERMISSION_ERROE,'msg'=>'当前用户没有权限']);
return response(['code'=>Code::USER_PERMISSION_ERROE,'message'=>'当前用户没有权限']);
}
}
}
... ...
... ... @@ -27,5 +27,61 @@ class BTemplate extends Base
'18008059100',
'18583337995'
];
//类型数据
public $product_type = [
"products"=>[
"category"=>[
[
"id"=>"all",
"title"=>"全部",
],
[
"id"=>"hot",
"title"=>"热销产品",
],
[
"id"=>"recommend",
"title"=>"推荐产品",
],
],
"imageType"=>[
[
"id"=>1,
"title"=>"产品图片",
],[
"id"=>2,
"title"=>"产品分类图片",
],[
"id"=>3,
"title"=>"产品图标",
]
],
],
"news"=>[
"category"=>[
[
"id"=>"all",
"name"=>"全部",
],
[
"id"=>"new",
"name"=>"最新",
],
],
],
"blogs"=>[
"category"=>[
[
"id"=>"all",
"name"=>"全部",
],
[
"id"=>"new",
"name"=>"最新",
],
],
]
];
}
... ...
... ... @@ -278,6 +278,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/getTypeSetting', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getTypeSetting'])->name('template_getTypeSetting');
Route::any('/getHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getHeadFooter'])->name('template_getHeadFooter');
Route::any('/setHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setHeadFooter'])->name('template_setHeadFooter');
Route::any('/savePublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'savePublicTemplate'])->name('template_savePublicTemplate');
// 模板
Route::prefix('module')->group(function () {
//获取所有左侧模版
... ...