Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
32 个修改的文件
包含
904 行增加
和
414 行删除
| @@ -68,13 +68,13 @@ class UpdateRoute extends Command | @@ -68,13 +68,13 @@ class UpdateRoute extends Command | ||
| 68 | */ | 68 | */ |
| 69 | public function getProductKeyword(){ | 69 | public function getProductKeyword(){ |
| 70 | $keywordModel = new Keyword(); | 70 | $keywordModel = new Keyword(); |
| 71 | - $lists = $keywordModel->list(['route'=>null]); | 71 | + $lists = $keywordModel->list(['route'=>'']); |
| 72 | if(!empty($lists)){ | 72 | if(!empty($lists)){ |
| 73 | foreach ($lists as $v){ | 73 | foreach ($lists as $v){ |
| 74 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | 74 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; |
| 75 | - $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], 75); | 75 | + $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']); |
| 76 | $this->curlDelRoute(['new_route'=>$route]); | 76 | $this->curlDelRoute(['new_route'=>$route]); |
| 77 | - $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); | 77 | + $this->model->edit(['route'=>$route],['id'=>$v['id']]); |
| 78 | echo date('Y-m-d H:i:s') . 'end :'.$route . PHP_EOL; | 78 | echo date('Y-m-d H:i:s') . 'end :'.$route . PHP_EOL; |
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :CustomModuleController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/12/4 15:42 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Aside\CustomModule; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Aside\BaseController; | ||
| 14 | +use App\Http\Logic\Aside\CustomModule\CustomModuleLogic; | ||
| 15 | +use App\Models\CustomModule\CustomModule; | ||
| 16 | +use App\Services\ProjectServer; | ||
| 17 | +use Illuminate\Support\Facades\DB; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * @remark :自定义模块 | ||
| 21 | + * @name :CustomModuleController | ||
| 22 | + * @author :lyh | ||
| 23 | + * @method :post | ||
| 24 | + * @time :2023/12/4 15:42 | ||
| 25 | + */ | ||
| 26 | +class CustomModuleController extends BaseController | ||
| 27 | +{ | ||
| 28 | + /** | ||
| 29 | + * @remark :获取自定义模块列表 | ||
| 30 | + * @name :ModuleList | ||
| 31 | + * @author :lyh | ||
| 32 | + * @method :post | ||
| 33 | + * @time :2023/12/4 15:43 | ||
| 34 | + */ | ||
| 35 | + public function lists(){ | ||
| 36 | + ProjectServer::useProject($this->param['project_id']); | ||
| 37 | + $customModule = new CustomModule(); | ||
| 38 | + $this->map['status'] = 0; | ||
| 39 | + $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order); | ||
| 40 | + DB::disconnect('custom_mysql'); | ||
| 41 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :获取当前数据详情 | ||
| 46 | + * @name :info | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2023/12/4 16:09 | ||
| 50 | + */ | ||
| 51 | + public function info(CustomModuleLogic $logic){ | ||
| 52 | + $this->request->validate([ | ||
| 53 | + 'id'=>['required'], | ||
| 54 | + ],[ | ||
| 55 | + 'id.required' => 'ID不能为空', | ||
| 56 | + ]); | ||
| 57 | + $info = $logic->getCustomModuleInfo(); | ||
| 58 | + $this->response('success',Code::SUCCESS,$info); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * @remark :保存数据 | ||
| 63 | + * @name :save | ||
| 64 | + * @author :lyh | ||
| 65 | + * @method :post | ||
| 66 | + * @time :2023/12/4 15:45 | ||
| 67 | + */ | ||
| 68 | + public function save(CustomModuleLogic $logic){ | ||
| 69 | + $this->request->validate([ | ||
| 70 | + 'name'=>['required'], | ||
| 71 | + ],[ | ||
| 72 | + 'name.required' => '模块名称不能为空', | ||
| 73 | + ]); | ||
| 74 | + $logic->customModuleSave(); | ||
| 75 | + $this->response('success'); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * @remark :删除 | ||
| 80 | + * @name :del | ||
| 81 | + * @author :lyh | ||
| 82 | + * @method :post | ||
| 83 | + * @time :2023/12/5 9:53 | ||
| 84 | + */ | ||
| 85 | + public function del(CustomModuleLogic $logic){ | ||
| 86 | + $this->request->validate([ | ||
| 87 | + 'id'=>['required'], | ||
| 88 | + ],[ | ||
| 89 | + 'id.required' => 'ID不能为空', | ||
| 90 | + ]); | ||
| 91 | + $logic->customModuleDel(); | ||
| 92 | + $this->response('success'); | ||
| 93 | + } | ||
| 94 | +} |
| @@ -7,6 +7,7 @@ use App\Helper\Arr; | @@ -7,6 +7,7 @@ use App\Helper\Arr; | ||
| 7 | use App\Helper\Common; | 7 | use App\Helper\Common; |
| 8 | use App\Http\Controllers\Bside\BaseController; | 8 | use App\Http\Controllers\Bside\BaseController; |
| 9 | use App\Http\Logic\Bside\User\UserLogic; | 9 | use App\Http\Logic\Bside\User\UserLogic; |
| 10 | +use App\Models\CustomModule\CustomModule; | ||
| 10 | use App\Models\Project\DeployBuild; | 11 | use App\Models\Project\DeployBuild; |
| 11 | use App\Models\Project\Project; | 12 | use App\Models\Project\Project; |
| 12 | use App\Models\RouteMap\RouteMap; | 13 | use App\Models\RouteMap\RouteMap; |
| @@ -53,6 +54,24 @@ class ComController extends BaseController | @@ -53,6 +54,24 @@ class ComController extends BaseController | ||
| 53 | $this->response('当前用户菜单列表',Code::SUCCESS,$menu); | 54 | $this->response('当前用户菜单列表',Code::SUCCESS,$menu); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 57 | + /** | ||
| 58 | + * @remark :获取当前菜单的自定义模块 | ||
| 59 | + * @name :getProjectCustomMenu | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2023/12/13 16:48 | ||
| 63 | + */ | ||
| 64 | + public function getCustomMenu(){ | ||
| 65 | + $customModel = new CustomModule(); | ||
| 66 | + $list = $customModel->list(['status'=>0],['sort','id']); | ||
| 67 | + if(!empty($list)){ | ||
| 68 | + foreach ($list as $k=>$v){ | ||
| 69 | + $v['sub'] = [$v['name'].'管理',$v['name'].'分类']; | ||
| 70 | + $list[$k] = $v; | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + $this->response('success',Code::SUCCESS,$list); | ||
| 74 | + } | ||
| 56 | 75 | ||
| 57 | /** | 76 | /** |
| 58 | * @name :获取当前项目详情 | 77 | * @name :获取当前项目详情 |
| @@ -78,14 +97,18 @@ class ComController extends BaseController | @@ -78,14 +97,18 @@ class ComController extends BaseController | ||
| 78 | $code = $this->getIsHome(); | 97 | $code = $this->getIsHome(); |
| 79 | $projectRoleModel = new ProjectRoleModel(); | 98 | $projectRoleModel = new ProjectRoleModel(); |
| 80 | $info = $projectRoleModel->read(['id'=>$this->user['role_id']]); | 99 | $info = $projectRoleModel->read(['id'=>$this->user['role_id']]); |
| 81 | - if($code != 1){ | ||
| 82 | - $info['role_menu'] = trim(str_replace(',11,',',',','.$info['role_menu'].','),','); | 100 | + if($info === false){ |
| 101 | + $this->fail('当前登录角色不存在'); | ||
| 102 | + }else{ | ||
| 103 | + if($code != 1){ | ||
| 104 | + $info['role_menu'] = trim(str_replace(',11,',',',','.$info['role_menu'].','),','); | ||
| 105 | + } | ||
| 106 | + $this->map = [ | ||
| 107 | + 'status'=>0, | ||
| 108 | + 'is_role'=>0, | ||
| 109 | + 'id'=>['in',explode(',',$info['role_menu'])] | ||
| 110 | + ]; | ||
| 83 | } | 111 | } |
| 84 | - $this->map = [ | ||
| 85 | - 'status'=>0, | ||
| 86 | - 'is_role'=>0, | ||
| 87 | - 'id'=>['in',explode(',',$info['role_menu'])] | ||
| 88 | - ]; | ||
| 89 | return $this->map; | 112 | return $this->map; |
| 90 | } | 113 | } |
| 91 | 114 | ||
| @@ -114,9 +137,6 @@ class ComController extends BaseController | @@ -114,9 +137,6 @@ class ComController extends BaseController | ||
| 114 | * @time :2023/9/6 11:30 | 137 | * @time :2023/9/6 11:30 |
| 115 | */ | 138 | */ |
| 116 | public function getIsHome(){ | 139 | public function getIsHome(){ |
| 117 | - if(isset($this->user['manager_id'])){ | ||
| 118 | - return 1; | ||
| 119 | - } | ||
| 120 | $deployBuild = new DeployBuild(); | 140 | $deployBuild = new DeployBuild(); |
| 121 | $info = $deployBuild->read(['project_id'=>$this->user['project_id']]); | 141 | $info = $deployBuild->read(['project_id'=>$this->user['project_id']]); |
| 122 | if(!empty($info['configuration'])){ | 142 | if(!empty($info['configuration'])){ |
| @@ -127,19 +127,9 @@ class BaseController extends Controller | @@ -127,19 +127,9 @@ class BaseController extends Controller | ||
| 127 | * @param bool $objectData | 127 | * @param bool $objectData |
| 128 | * @return JsonResponse | 128 | * @return JsonResponse |
| 129 | */ | 129 | */ |
| 130 | - function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse | 130 | + function success($data) :array |
| 131 | { | 131 | { |
| 132 | - if ($objectData) { | ||
| 133 | - $data = (object)$data; | ||
| 134 | - } | ||
| 135 | - $code = Code::fromValue($code); | ||
| 136 | - $response = [ | ||
| 137 | - 'code' => $code->value, | ||
| 138 | - 'data' => $data, | ||
| 139 | - 'message' => $code->description, | ||
| 140 | - ]; | ||
| 141 | - $this->header['token'] = $this->token; | ||
| 142 | - return response()->json($response,200,$this->header); | 132 | + return $data; |
| 143 | } | 133 | } |
| 144 | 134 | ||
| 145 | /** | 135 | /** |
| @@ -13,6 +13,7 @@ use App\Enums\Common\Code; | @@ -13,6 +13,7 @@ use App\Enums\Common\Code; | ||
| 13 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic; | 14 | use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic; |
| 15 | use App\Models\CustomModule\CustomModuleCategory; | 15 | use App\Models\CustomModule\CustomModuleCategory; |
| 16 | +use App\Models\User\User; | ||
| 16 | 17 | ||
| 17 | class CustomModuleCategoryController extends BaseController | 18 | class CustomModuleCategoryController extends BaseController |
| 18 | { | 19 | { |
| @@ -14,6 +14,7 @@ use App\Http\Controllers\Bside\BaseController; | @@ -14,6 +14,7 @@ use App\Http\Controllers\Bside\BaseController; | ||
| 14 | use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; | 14 | use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; |
| 15 | use App\Models\CustomModule\CustomModuleCategory; | 15 | use App\Models\CustomModule\CustomModuleCategory; |
| 16 | use App\Models\CustomModule\CustomModuleContent; | 16 | use App\Models\CustomModule\CustomModuleContent; |
| 17 | +use App\Models\User\User; | ||
| 17 | 18 | ||
| 18 | class CustomModuleContentController extends BaseController | 19 | class CustomModuleContentController extends BaseController |
| 19 | { | 20 | { |
| @@ -31,9 +32,15 @@ class CustomModuleContentController extends BaseController | @@ -31,9 +32,15 @@ class CustomModuleContentController extends BaseController | ||
| 31 | 'module_id.required' => 'module_id不能为空', | 32 | 'module_id.required' => 'module_id不能为空', |
| 32 | ]); | 33 | ]); |
| 33 | $this->map['project_id'] = $this->user['project_id']; | 34 | $this->map['project_id'] = $this->user['project_id']; |
| 34 | - $lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order); | ||
| 35 | - foreach ($lists as $v){ | ||
| 36 | - //获取分类名称 | 35 | + $lists = $customModuleContent->lists($this->map,$this->page,$this->row,$this->order = ['sort','id']); |
| 36 | + if(!empty($lists)){ | ||
| 37 | + $data = $this->getAllCategoryName(); | ||
| 38 | + foreach ($lists['list'] as $k=>$v){ | ||
| 39 | + $v['category_name'] = $this->categoryName($v['category_id'],$data); | ||
| 40 | + $v['image_link'] = getImageUrl($v['image']); | ||
| 41 | + $v['operator_name'] = (new User())->getName($v['operator_id']); | ||
| 42 | + $lists['list'][$k] = $v; | ||
| 43 | + } | ||
| 37 | } | 44 | } |
| 38 | $this->response('success',Code::SUCCESS,$lists); | 45 | $this->response('success',Code::SUCCESS,$lists); |
| 39 | } | 46 | } |
| @@ -52,7 +59,27 @@ class CustomModuleContentController extends BaseController | @@ -52,7 +59,27 @@ class CustomModuleContentController extends BaseController | ||
| 52 | foreach ($list as $v){ | 59 | foreach ($list as $v){ |
| 53 | $data[$v['id']] = $v['name']; | 60 | $data[$v['id']] = $v['name']; |
| 54 | } | 61 | } |
| 55 | - return $this->success($data); | 62 | + return $data; |
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * @remark :获取分类名称 | ||
| 67 | + * @name :categoryName | ||
| 68 | + * @author :lyh | ||
| 69 | + * @method :post | ||
| 70 | + * @time :2023/9/14 13:58 | ||
| 71 | + */ | ||
| 72 | + public function categoryName($category_id,$data){ | ||
| 73 | + $category_name = ''; | ||
| 74 | + if(!empty($category_id) && !empty($data)){ | ||
| 75 | + foreach ($category_id as $v){ | ||
| 76 | + if(isset($data[$v])){ | ||
| 77 | + $category_name .= $data[$v].','; | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + $category_name = trim($category_name,','); | ||
| 81 | + } | ||
| 82 | + return $category_name; | ||
| 56 | } | 83 | } |
| 57 | 84 | ||
| 58 | /** | 85 | /** |
| @@ -131,4 +158,23 @@ class CustomModuleContentController extends BaseController | @@ -131,4 +158,23 @@ class CustomModuleContentController extends BaseController | ||
| 131 | $logic->contentDel(); | 158 | $logic->contentDel(); |
| 132 | $this->response('success'); | 159 | $this->response('success'); |
| 133 | } | 160 | } |
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * @remark :排序 | ||
| 164 | + * @name :sort | ||
| 165 | + * @author :lyh | ||
| 166 | + * @method :post | ||
| 167 | + * @time :2023/12/15 17:46 | ||
| 168 | + */ | ||
| 169 | + public function sort(CustomModuleContentLogic $logic){ | ||
| 170 | + $this->request->validate([ | ||
| 171 | + 'id'=>['required'], | ||
| 172 | + 'sort'=>['required'] | ||
| 173 | + ],[ | ||
| 174 | + 'id.required' => 'ID不能为空', | ||
| 175 | + 'sort.required' => '排序不能为空', | ||
| 176 | + ]); | ||
| 177 | + $logic->contentSort(); | ||
| 178 | + $this->response('success'); | ||
| 179 | + } | ||
| 134 | } | 180 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Controllers\Bside\Inquiry; | 3 | namespace App\Http\Controllers\Bside\Inquiry; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use App\Enums\Common\Code; | ||
| 6 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 7 | use App\Http\Logic\Bside\Inquiry\InquiryLogic; | 8 | use App\Http\Logic\Bside\Inquiry\InquiryLogic; |
| 8 | use App\Models\Inquiry\InquiryForm; | 9 | use App\Models\Inquiry\InquiryForm; |
| @@ -31,7 +32,7 @@ class InquiryController extends BaseController | @@ -31,7 +32,7 @@ class InquiryController extends BaseController | ||
| 31 | } | 32 | } |
| 32 | $item['field_text'] = $field_text; | 33 | $item['field_text'] = $field_text; |
| 33 | } | 34 | } |
| 34 | - return $this->success($data); | 35 | + $this->response('success',Code::SUCCESS,$data); |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | public function index(InquiryLogic $logic) | 38 | public function index(InquiryLogic $logic) |
| @@ -43,7 +44,7 @@ class InquiryController extends BaseController | @@ -43,7 +44,7 @@ class InquiryController extends BaseController | ||
| 43 | }else{ | 44 | }else{ |
| 44 | $data = $logic->getApiList(); | 45 | $data = $logic->getApiList(); |
| 45 | } | 46 | } |
| 46 | - return $this->success($data); | 47 | + $this->response('success',Code::SUCCESS,$data); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | public function info(Request $request, InquiryLogic $logic){ | 50 | public function info(Request $request, InquiryLogic $logic){ |
| @@ -60,8 +61,7 @@ class InquiryController extends BaseController | @@ -60,8 +61,7 @@ class InquiryController extends BaseController | ||
| 60 | }else{ | 61 | }else{ |
| 61 | $data = $logic->getInfo($this->param['id']); | 62 | $data = $logic->getInfo($this->param['id']); |
| 62 | } | 63 | } |
| 63 | - | ||
| 64 | - return $this->success($data); | 64 | + $this->response('success',Code::SUCCESS,$data); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | public function delete(Request $request, InquiryLogic $logic) | 67 | public function delete(Request $request, InquiryLogic $logic) |
| @@ -79,7 +79,7 @@ class InquiryController extends BaseController | @@ -79,7 +79,7 @@ class InquiryController extends BaseController | ||
| 79 | $logic->delete($this->param['ids']); | 79 | $logic->delete($this->param['ids']); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | - return $this->success(); | 82 | + $this->response('success'); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | /** | 85 | /** |
| @@ -141,6 +141,6 @@ class InquiryController extends BaseController | @@ -141,6 +141,6 @@ class InquiryController extends BaseController | ||
| 141 | } | 141 | } |
| 142 | $fileurl = Storage::disk('runtime')->url($file); | 142 | $fileurl = Storage::disk('runtime')->url($file); |
| 143 | // return Storage::disk('runtime')->download($file); //直接下载 | 143 | // return Storage::disk('runtime')->download($file); //直接下载 |
| 144 | - return $this->success(['url' => $fileurl]); | 144 | + $this->response('success',Code::SUCCESS,['url' => $fileurl]); |
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| @@ -102,7 +102,7 @@ class MailController extends BaseController | @@ -102,7 +102,7 @@ class MailController extends BaseController | ||
| 102 | $arr[] = $v['mail_id']; | 102 | $arr[] = $v['mail_id']; |
| 103 | } | 103 | } |
| 104 | $mailModel = new MailModel(); | 104 | $mailModel = new MailModel(); |
| 105 | - $mail_list = $mailModel->list(['id'=>['not in',$arr]]); | 105 | + $mail_list = $mailModel->list(['id'=>['not in',$arr],'user_list'=>['like',','.$this->user['id'].',']]); |
| 106 | $data = []; | 106 | $data = []; |
| 107 | foreach ($mail_list as $k => $v){ | 107 | foreach ($mail_list as $k => $v){ |
| 108 | $data[] = [ | 108 | $data[] = [ |
| @@ -66,7 +66,6 @@ class NavController extends BaseController | @@ -66,7 +66,6 @@ class NavController extends BaseController | ||
| 66 | $request->validated(); | 66 | $request->validated(); |
| 67 | $logic->navSave(); | 67 | $logic->navSave(); |
| 68 | $this->response('success'); | 68 | $this->response('success'); |
| 69 | - | ||
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | 71 |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside\Product; | 3 | namespace App\Http\Controllers\Bside\Product; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Code; | ||
| 5 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 6 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 7 | use App\Http\Logic\Bside\Product\AttrLogic; | 8 | use App\Http\Logic\Bside\Product\AttrLogic; |
| @@ -26,7 +27,7 @@ class AttrController extends BaseController | @@ -26,7 +27,7 @@ class AttrController extends BaseController | ||
| 26 | } | 27 | } |
| 27 | $sort = ['id' => 'desc']; | 28 | $sort = ['id' => 'desc']; |
| 28 | $data = $logic->getList($map, $sort, ['id', 'title', 'attrs'],$this->row); | 29 | $data = $logic->getList($map, $sort, ['id', 'title', 'attrs'],$this->row); |
| 29 | - return $this->success($data); | 30 | + $this->response('success',Code::SUCCESS,$data); |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | public function info(Request $request, AttrLogic $logic){ | 33 | public function info(Request $request, AttrLogic $logic){ |
| @@ -36,14 +37,14 @@ class AttrController extends BaseController | @@ -36,14 +37,14 @@ class AttrController extends BaseController | ||
| 36 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| 37 | ]); | 38 | ]); |
| 38 | $data = $logic->getInfo($this->param['id']); | 39 | $data = $logic->getInfo($this->param['id']); |
| 39 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'attrs'])); | 40 | + $this->response('success',Code::SUCCESS,Arr::twoKeepKeys($data, ['id', 'title', 'attrs'])); |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | public function save(AttrRequest $request, AttrLogic $logic) | 43 | public function save(AttrRequest $request, AttrLogic $logic) |
| 43 | { | 44 | { |
| 44 | $request->validated(); | 45 | $request->validated(); |
| 45 | $data = $logic->attrSave(); | 46 | $data = $logic->attrSave(); |
| 46 | - return $this->success($data); | 47 | + $this->response('success',Code::SUCCESS,$data); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | public function delete(Request $request, AttrLogic $logic) | 50 | public function delete(Request $request, AttrLogic $logic) |
| @@ -55,7 +56,7 @@ class AttrController extends BaseController | @@ -55,7 +56,7 @@ class AttrController extends BaseController | ||
| 55 | ]); | 56 | ]); |
| 56 | 57 | ||
| 57 | $data = $logic->delete($this->param['ids']); | 58 | $data = $logic->delete($this->param['ids']); |
| 58 | - return $this->success($data); | 59 | + $this->response('success',Code::SUCCESS,$data); |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | } | 62 | } |
| @@ -110,7 +110,7 @@ class CategoryController extends BaseController | @@ -110,7 +110,7 @@ class CategoryController extends BaseController | ||
| 110 | 'id.required' => 'ID不能为空' | 110 | 'id.required' => 'ID不能为空' |
| 111 | ]); | 111 | ]); |
| 112 | $data = $logic->getCateInfo($this->param['id']); | 112 | $data = $logic->getCateInfo($this->param['id']); |
| 113 | - return $this->success($data); | 113 | + $this->response('success',Code::SUCCESS,$data); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | /** | 116 | /** |
| @@ -159,6 +159,6 @@ class CategoryController extends BaseController | @@ -159,6 +159,6 @@ class CategoryController extends BaseController | ||
| 159 | 'ids.required' => 'ID不能为空' | 159 | 'ids.required' => 'ID不能为空' |
| 160 | ]); | 160 | ]); |
| 161 | $data = $logic->categoryDelete(); | 161 | $data = $logic->categoryDelete(); |
| 162 | - return $this->success($data); | 162 | + $this->response('success',Code::SUCCESS,$data); |
| 163 | } | 163 | } |
| 164 | } | 164 | } |
| @@ -37,7 +37,7 @@ class DescribeController extends BaseController | @@ -37,7 +37,7 @@ class DescribeController extends BaseController | ||
| 37 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| 38 | ]); | 38 | ]); |
| 39 | $data = $logic->getInfo($this->param['id']); | 39 | $data = $logic->getInfo($this->param['id']); |
| 40 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at'])); | 40 | + $this->response('success',Code::SUCCESS,Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at'])); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| @@ -51,7 +51,7 @@ class DescribeController extends BaseController | @@ -51,7 +51,7 @@ class DescribeController extends BaseController | ||
| 51 | { | 51 | { |
| 52 | $request->validated(); | 52 | $request->validated(); |
| 53 | $logic->describeSave(); | 53 | $logic->describeSave(); |
| 54 | - return $this->success(); | 54 | + $this->response('success'); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | public function delete(Request $request, DescribeLogic $logic) | 57 | public function delete(Request $request, DescribeLogic $logic) |
| @@ -61,9 +61,8 @@ class DescribeController extends BaseController | @@ -61,9 +61,8 @@ class DescribeController extends BaseController | ||
| 61 | ],[ | 61 | ],[ |
| 62 | 'ids.required' => 'ID不能为空' | 62 | 'ids.required' => 'ID不能为空' |
| 63 | ]); | 63 | ]); |
| 64 | - | ||
| 65 | $data = $logic->delete($this->param['ids']); | 64 | $data = $logic->delete($this->param['ids']); |
| 66 | - return $this->success($data); | 65 | + $this->response('success',Code::SUCCESS,$data); |
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | } | 68 | } |
| @@ -66,7 +66,7 @@ class KeywordController extends BaseController | @@ -66,7 +66,7 @@ class KeywordController extends BaseController | ||
| 66 | 'id.required' => 'ID不能为空' | 66 | 'id.required' => 'ID不能为空' |
| 67 | ]); | 67 | ]); |
| 68 | $data = $logic->getKeywordInfo(); | 68 | $data = $logic->getKeywordInfo(); |
| 69 | - return $this->success($data); | 69 | + $this->response('success',Code::SUCCESS,$data); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | /** | 72 | /** |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Controllers\Bside\RankData; | 3 | namespace App\Http\Controllers\Bside\RankData; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use App\Enums\Common\Code; | ||
| 6 | use App\Helper\Arr; | 7 | use App\Helper\Arr; |
| 7 | use App\Helper\GoogleSpeedApi; | 8 | use App\Helper\GoogleSpeedApi; |
| 8 | use App\Helper\QuanqiusouApi; | 9 | use App\Helper\QuanqiusouApi; |
| @@ -30,7 +31,7 @@ class RankDataController extends BaseController | @@ -30,7 +31,7 @@ class RankDataController extends BaseController | ||
| 30 | public function index(RankDataLogic $logic) | 31 | public function index(RankDataLogic $logic) |
| 31 | { | 32 | { |
| 32 | $data = $logic->index(); | 33 | $data = $logic->index(); |
| 33 | - return $this->success($data); | 34 | + $this->response('success',Code::SUCCESS,$data); |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | /** | 37 | /** |
| @@ -42,7 +43,7 @@ class RankDataController extends BaseController | @@ -42,7 +43,7 @@ class RankDataController extends BaseController | ||
| 42 | */ | 43 | */ |
| 43 | public function keywords_rank_list(RankDataLogic $logic){ | 44 | public function keywords_rank_list(RankDataLogic $logic){ |
| 44 | $data = $logic->keywords_rank_list(); | 45 | $data = $logic->keywords_rank_list(); |
| 45 | - return $this->success($data); | 46 | + $this->response('success',Code::SUCCESS,$data); |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | 49 | ||
| @@ -73,7 +74,7 @@ class RankDataController extends BaseController | @@ -73,7 +74,7 @@ class RankDataController extends BaseController | ||
| 73 | }else{ | 74 | }else{ |
| 74 | $data = []; | 75 | $data = []; |
| 75 | } | 76 | } |
| 76 | - return $this->success($data); | 77 | + $this->response('success',Code::SUCCESS,$data); |
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | /** | 80 | /** |
| @@ -121,7 +122,7 @@ class RankDataController extends BaseController | @@ -121,7 +122,7 @@ class RankDataController extends BaseController | ||
| 121 | } | 122 | } |
| 122 | $fileurl = Storage::disk('runtime')->url($file); | 123 | $fileurl = Storage::disk('runtime')->url($file); |
| 123 | // return Storage::disk('runtime')->download($file); //直接下载 | 124 | // return Storage::disk('runtime')->download($file); //直接下载 |
| 124 | - return $this->success(['url' => $fileurl]); | 125 | + $this->response('success',Code::SUCCESS,['url' => $fileurl]); |
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | /** | 128 | /** |
| @@ -169,7 +170,8 @@ class RankDataController extends BaseController | @@ -169,7 +170,8 @@ class RankDataController extends BaseController | ||
| 169 | } | 170 | } |
| 170 | $fileurl = Storage::disk('runtime')->url($file); | 171 | $fileurl = Storage::disk('runtime')->url($file); |
| 171 | // return Storage::disk('runtime')->download($file); //直接下载 | 172 | // return Storage::disk('runtime')->download($file); //直接下载 |
| 172 | - return $this->success(['url' => $fileurl]); | 173 | + |
| 174 | + $this->response('success',Code::SUCCESS,['url' => $fileurl]); | ||
| 173 | } | 175 | } |
| 174 | 176 | ||
| 175 | /** | 177 | /** |
| @@ -221,6 +223,6 @@ class RankDataController extends BaseController | @@ -221,6 +223,6 @@ class RankDataController extends BaseController | ||
| 221 | $data['position'] = $res['position']; | 223 | $data['position'] = $res['position']; |
| 222 | } | 224 | } |
| 223 | } | 225 | } |
| 224 | - return $this->success($data); | 226 | + $this->response('success',Code::SUCCESS,$data); |
| 225 | } | 227 | } |
| 226 | } | 228 | } |
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | namespace App\Http\Controllers\Bside\Route; | 4 | namespace App\Http\Controllers\Bside\Route; |
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | +use App\Enums\Common\Code; | ||
| 7 | use App\Http\Controllers\Bside\BaseController; | 8 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Models\RouteMap\RouteMap; | 9 | use App\Models\RouteMap\RouteMap; |
| 9 | use Illuminate\Http\Request; | 10 | use Illuminate\Http\Request; |
| @@ -23,8 +24,7 @@ class RouteController extends BaseController | @@ -23,8 +24,7 @@ class RouteController extends BaseController | ||
| 23 | $source = $request->input('source'); | 24 | $source = $request->input('source'); |
| 24 | $source_id = $request->input('source_id'); | 25 | $source_id = $request->input('source_id'); |
| 25 | $project_id = $this->user['project_id']; | 26 | $project_id = $this->user['project_id']; |
| 26 | - | ||
| 27 | $route = RouteMap::generateRoute($title, $source, $source_id, $project_id); | 27 | $route = RouteMap::generateRoute($title, $source, $source_id, $project_id); |
| 28 | - return $this->success(['route' => $route]); | 28 | + $this->response('success',Code::SUCCESS,['route' => $route]); |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| @@ -36,12 +36,15 @@ class BTemplateLogController extends BaseController | @@ -36,12 +36,15 @@ class BTemplateLogController extends BaseController | ||
| 36 | unset($this->map['template_id']); | 36 | unset($this->map['template_id']); |
| 37 | $this->map['project_id'] = $this->user['project_id']; | 37 | $this->map['project_id'] = $this->user['project_id']; |
| 38 | $this->map['source'] = 1; | 38 | $this->map['source'] = 1; |
| 39 | + $this->map['is_custom'] = 0; | ||
| 39 | $lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']); | 40 | $lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']); |
| 40 | if(!empty($lists['list'])){ | 41 | if(!empty($lists['list'])){ |
| 41 | $templateModel = new Template(); | 42 | $templateModel = new Template(); |
| 42 | $userModel = new User(); | 43 | $userModel = new User(); |
| 43 | foreach ($lists['list'] as $k => $v){ | 44 | foreach ($lists['list'] as $k => $v){ |
| 44 | - $v['template_name'] = $templateModel->read(['id'=>$v['template_id']],['name'])['name']; | 45 | + if(!empty($v['template_id'])){ |
| 46 | + $v['template_name'] = $templateModel->read(['id'=>$v['template_id']],['name'])['name']; | ||
| 47 | + } | ||
| 45 | $v['operator_name'] = $userModel->getName($v['operator_id']); | 48 | $v['operator_name'] = $userModel->getName($v['operator_id']); |
| 46 | $lists['list'][$k] = $v; | 49 | $lists['list'][$k] = $v; |
| 47 | } | 50 | } |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside\User; | 3 | namespace App\Http\Controllers\Bside\User; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Code; | ||
| 5 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 6 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 7 | use App\Http\Logic\Bside\User\DeptLogic; | 8 | use App\Http\Logic\Bside\User\DeptLogic; |
| @@ -26,7 +27,7 @@ class DeptController extends BaseController | @@ -26,7 +27,7 @@ class DeptController extends BaseController | ||
| 26 | } | 27 | } |
| 27 | $sort = ['id' => 'desc']; | 28 | $sort = ['id' => 'desc']; |
| 28 | $data = $logic->getList($map, $sort, ['id', 'pid', 'title'],0); | 29 | $data = $logic->getList($map, $sort, ['id', 'pid', 'title'],0); |
| 29 | - return $this->success(Arr::listToTree($data)); | 30 | + $this->response('success',Code::SUCCESS,Arr::listToTree($data)); |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | public function info(Request $request, DeptLogic $logic){ | 33 | public function info(Request $request, DeptLogic $logic){ |
| @@ -36,13 +37,13 @@ class DeptController extends BaseController | @@ -36,13 +37,13 @@ class DeptController extends BaseController | ||
| 36 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| 37 | ]); | 38 | ]); |
| 38 | $data = $logic->getInfo($this->param['id']); | 39 | $data = $logic->getInfo($this->param['id']); |
| 39 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'manager_uids', 'remark'])); | 40 | + $this->response('success',Code::SUCCESS,Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'manager_uids', 'remark'])); |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | public function save(DeptRequest $request, DeptLogic $logic) | 43 | public function save(DeptRequest $request, DeptLogic $logic) |
| 43 | { | 44 | { |
| 44 | $data = $logic->save($this->param); | 45 | $data = $logic->save($this->param); |
| 45 | - return $this->success($data); | 46 | + $this->response('success',Code::SUCCESS,$data); |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | public function delete(DeptLogic $logic) | 49 | public function delete(DeptLogic $logic) |
| @@ -54,6 +55,6 @@ class DeptController extends BaseController | @@ -54,6 +55,6 @@ class DeptController extends BaseController | ||
| 54 | ]); | 55 | ]); |
| 55 | 56 | ||
| 56 | $data = $logic->delete($this->param['ids']); | 57 | $data = $logic->delete($this->param['ids']); |
| 57 | - return $this->success($data); | 58 | + $this->response('success',Code::SUCCESS,$data); |
| 58 | } | 59 | } |
| 59 | } | 60 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :CustomModuleLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/12/4 15:46 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Aside\CustomModule; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 13 | +use App\Models\CustomModule\CustomModule; | ||
| 14 | +use App\Models\CustomModule\CustomModuleCategory; | ||
| 15 | +use App\Models\CustomModule\CustomModuleContent; | ||
| 16 | +use App\Services\ProjectServer; | ||
| 17 | +use Illuminate\Support\Facades\DB; | ||
| 18 | + | ||
| 19 | +class CustomModuleLogic extends BaseLogic | ||
| 20 | +{ | ||
| 21 | + public function __construct() | ||
| 22 | + { | ||
| 23 | + parent::__construct(); | ||
| 24 | + $this->param = $this->requestAll; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @remark :获取当前数据详情 | ||
| 29 | + * @name :getCustomModuleInfo | ||
| 30 | + * @author :lyh | ||
| 31 | + * @method :post | ||
| 32 | + * @time :2023/12/4 16:10 | ||
| 33 | + */ | ||
| 34 | + public function getCustomModuleInfo(){ | ||
| 35 | + ProjectServer::useProject($this->param['project_id']); | ||
| 36 | + $info = (new CustomModule())->read($this->param); | ||
| 37 | + if($info === false){ | ||
| 38 | + $this->fail('当前数据不存在或已被删除'); | ||
| 39 | + } | ||
| 40 | + DB::disconnect('custom_mysql'); | ||
| 41 | + return $this->success($info); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :保存数据 | ||
| 46 | + * @name :ModuleSave | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2023/12/4 15:47 | ||
| 50 | + */ | ||
| 51 | + public function customModuleSave(){ | ||
| 52 | + $this->param = $this->handleParam($this->param); | ||
| 53 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 54 | + $this->moduleEdit(); | ||
| 55 | + }else{ | ||
| 56 | + $this->moduleAdd(); | ||
| 57 | + } | ||
| 58 | + return $this->success(); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * @name :(参数处理)paramProcessing | ||
| 63 | + * @author :lyh | ||
| 64 | + * @method :post | ||
| 65 | + * @time :2023/6/13 11:30 | ||
| 66 | + */ | ||
| 67 | + public function handleParam($param) | ||
| 68 | + { | ||
| 69 | + $param['operator_id'] = $this->manager['id']; | ||
| 70 | + if(!isset($param['id']) || empty($param['id'])){ | ||
| 71 | + $param['project_id'] = $this->param['project_id']; | ||
| 72 | + } | ||
| 73 | + return $this->success($param); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * @remark :新增 | ||
| 78 | + * @name :moduleAdd | ||
| 79 | + * @author :lyh | ||
| 80 | + * @method :post | ||
| 81 | + * @time :2023/12/5 9:39 | ||
| 82 | + */ | ||
| 83 | + public function moduleAdd(){ | ||
| 84 | + ProjectServer::useProject($this->param['project_id']); | ||
| 85 | + $rs = (new CustomModule())->add($this->param); | ||
| 86 | + if($rs === false){ | ||
| 87 | + $this->fail('系统错误,请联系管理员'); | ||
| 88 | + } | ||
| 89 | + DB::disconnect('custom_mysql'); | ||
| 90 | + return $this->success(); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * @remark :编辑 | ||
| 95 | + * @name :moduleEdit | ||
| 96 | + * @author :lyh | ||
| 97 | + * @method :post | ||
| 98 | + * @time :2023/12/5 9:39 | ||
| 99 | + */ | ||
| 100 | + public function moduleEdit(){ | ||
| 101 | + ProjectServer::useProject($this->param['project_id']); | ||
| 102 | + $rs = (new CustomModule())->edit($this->param,['id'=>$this->param['id']]); | ||
| 103 | + if($rs === false){ | ||
| 104 | + $this->fail('系统错误,请联系管理员'); | ||
| 105 | + } | ||
| 106 | + DB::disconnect('custom_mysql'); | ||
| 107 | + return $this->success(); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * @remark :删除数据 | ||
| 112 | + * @name :ModuleDel | ||
| 113 | + * @author :lyh | ||
| 114 | + * @method :post | ||
| 115 | + * @time :2023/12/4 15:47 | ||
| 116 | + */ | ||
| 117 | + public function customModuleDel(){ | ||
| 118 | + ProjectServer::useProject($this->param['project_id']); | ||
| 119 | + //查看当前模块是否拥有数据 | ||
| 120 | + $contentModel = new CustomModuleContent(); | ||
| 121 | + $contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']); | ||
| 122 | + if($contentInfo !== false){ | ||
| 123 | + $this->fail('当前模块拥有内容不允许删除'); | ||
| 124 | + } | ||
| 125 | + $categoryModel = new CustomModuleCategory(); | ||
| 126 | + $categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']); | ||
| 127 | + if($categoryInfo !== false){ | ||
| 128 | + $this->fail('当前模块拥有分类不允许删除'); | ||
| 129 | + } | ||
| 130 | + $rs = (new CustomModule())->del($this->param); | ||
| 131 | + if($rs === false){ | ||
| 132 | + $this->fail('系统错误,请联系管理员'); | ||
| 133 | + } | ||
| 134 | + DB::disconnect('custom_mysql'); | ||
| 135 | + return $this->success(); | ||
| 136 | + } | ||
| 137 | +} |
| @@ -706,7 +706,7 @@ class ProjectLogic extends BaseLogic | @@ -706,7 +706,7 @@ class ProjectLogic extends BaseLogic | ||
| 706 | public function saveOtherProject(){ | 706 | public function saveOtherProject(){ |
| 707 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 707 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 708 | if($rs === false){ | 708 | if($rs === false){ |
| 709 | - $this->fail('系统错误,请联系管理员'); | 709 | + $this->fail('保存失败,请联系管理员'); |
| 710 | } | 710 | } |
| 711 | return $this->success($this->param); | 711 | return $this->success($this->param); |
| 712 | } | 712 | } |
| @@ -55,8 +55,7 @@ class BTemplateLogLogic extends BaseLogic | @@ -55,8 +55,7 @@ class BTemplateLogLogic extends BaseLogic | ||
| 55 | } | 55 | } |
| 56 | try { | 56 | try { |
| 57 | $data = $this->setParam($info); | 57 | $data = $this->setParam($info); |
| 58 | - $BTemplateModel = new BTemplate(); | ||
| 59 | - $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); | 58 | + $bTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]); |
| 60 | $commonData = $this->setCommonParam($info); | 59 | $commonData = $this->setCommonParam($info); |
| 61 | $commonTemplateModel = new BTemplateCommon(); | 60 | $commonTemplateModel = new BTemplateCommon(); |
| 62 | $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]); | 61 | $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]); |
| @@ -10,6 +10,7 @@ use App\Models\News\NewsCategory; | @@ -10,6 +10,7 @@ use App\Models\News\NewsCategory; | ||
| 10 | use App\Models\Product\Category; | 10 | use App\Models\Product\Category; |
| 11 | use App\Models\Product\Product; | 11 | use App\Models\Product\Product; |
| 12 | use App\Models\Project\PageSetting; | 12 | use App\Models\Project\PageSetting; |
| 13 | +use App\Models\Project\Project; | ||
| 13 | use App\Models\RouteMap\RouteMap; | 14 | use App\Models\RouteMap\RouteMap; |
| 14 | use App\Models\Service\Service as ServiceSettingModel; | 15 | use App\Models\Service\Service as ServiceSettingModel; |
| 15 | use App\Models\Template\BTemplateCommon; | 16 | use App\Models\Template\BTemplateCommon; |
| @@ -61,99 +62,144 @@ class BTemplateLogic extends BaseLogic | @@ -61,99 +62,144 @@ class BTemplateLogic extends BaseLogic | ||
| 61 | * @time :2023/6/29 9:44 | 62 | * @time :2023/6/29 9:44 |
| 62 | */ | 63 | */ |
| 63 | public function getTemplate(){ | 64 | public function getTemplate(){ |
| 64 | - $bSettingModel = new Setting(); | ||
| 65 | - $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 66 | - if($info === false){ | ||
| 67 | - $this->fail('请先选择模版'); | ||
| 68 | - } | ||
| 69 | - if($this->param['source'] == $this->model::SOURCE_HOME){//首页 | ||
| 70 | - $TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']); | 65 | + $template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id |
| 66 | + $data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0); | ||
| 67 | + return $this->success($data); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @remark :获取可视化装修的html | ||
| 72 | + * @name :getTemplateHtml | ||
| 73 | + * @author :lyh | ||
| 74 | + * @method :post | ||
| 75 | + * @time :2023/12/13 10:47 | ||
| 76 | + */ | ||
| 77 | + public function getHtml($template_id,$source,$source_id,$is_custom){ | ||
| 78 | + $templateInfo = $this->webTemplateInfo($template_id,$source,$source_id,$is_custom); | ||
| 79 | + if($templateInfo === false){ | ||
| 80 | + if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据 | ||
| 81 | + $html = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制 | ||
| 82 | + return $this->success(['html'=>$html,'template_id'=>$template_id]); | ||
| 83 | + } | ||
| 84 | + $mainInfo = $this->getCommonMain($source,$source_id,$is_custom);//获取中间部分代码 | ||
| 71 | }else{ | 85 | }else{ |
| 72 | - $TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']); | 86 | + if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码 |
| 87 | + $type = $this->getCustomizedType($source, $source_id);//定制获取头部底部类型 | ||
| 88 | + $commonInfo = $this->getCommonPage(0,$this->user['project_id'],$type);//获取定制头部 | ||
| 89 | + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); | ||
| 90 | + return $this->success(['html'=>$html,'template_id'=>$template_id]); | ||
| 91 | + } | ||
| 92 | + $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; | ||
| 73 | } | 93 | } |
| 74 | - return $this->success($TemplateInfo); | 94 | + $commonInfo = $this->getCommonPage($source,$source_id,$template_id);//获取头部 |
| 95 | + $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. | ||
| 96 | + $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; | ||
| 97 | + $html = $this->getHeadFooter($html); | ||
| 98 | + return $this->success(['html'=>$html,'template_id'=>$template_id]); | ||
| 75 | } | 99 | } |
| 76 | 100 | ||
| 77 | /** | 101 | /** |
| 78 | - * @remark :根据参数获取数据详情 | ||
| 79 | - * @name :webTemplateInfo | 102 | + * @remark :返回整个html截取代码 |
| 103 | + * @name :handleAllHtml | ||
| 80 | * @author :lyh | 104 | * @author :lyh |
| 81 | * @method :post | 105 | * @method :post |
| 82 | - * @time :2023/7/25 16:41 | 106 | + * @time :2023/12/13 15:39 |
| 83 | */ | 107 | */ |
| 84 | - public function webTemplateInfo($template_id,$source,$source_id){ | ||
| 85 | - //查看当前模板是否已编辑保存web_template | ||
| 86 | - $TemplateInfo = $this->model->read([ | ||
| 87 | - 'template_id'=>$template_id, | ||
| 88 | - 'source'=>$source, | ||
| 89 | - 'project_id'=>$this->user['project_id'], | ||
| 90 | - 'source_id'=>$source_id, | ||
| 91 | - ]); | ||
| 92 | - return $this->success($TemplateInfo); | 108 | + public function handleAllHtml($commonInfo,$html){ |
| 109 | + if(!empty($commonInfo)){ | ||
| 110 | + $html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html); | ||
| 111 | + $html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html); | ||
| 112 | + $html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html); | ||
| 113 | + $html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html); | ||
| 114 | + } | ||
| 115 | + return $html; | ||
| 93 | } | 116 | } |
| 94 | 117 | ||
| 95 | /** | 118 | /** |
| 96 | - * @remark :处理首页数据 | ||
| 97 | - * @name :homeHtml | 119 | + * @remark :页面是否为定制页面获取初始代码 |
| 120 | + * @name :watchProjectIsCustomized | ||
| 98 | * @author :lyh | 121 | * @author :lyh |
| 99 | * @method :post | 122 | * @method :post |
| 100 | - * @time :2023/7/25 16:36 | 123 | + * @time :2023/12/13 10:55 |
| 101 | */ | 124 | */ |
| 102 | - public function homeHtml($info,$source,$source_id){ | ||
| 103 | - //查看当前模板是否已编辑保存web_template | ||
| 104 | - $TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id); | ||
| 105 | - if($TemplateInfo === false){ | ||
| 106 | - //获取模板详情 | ||
| 107 | - $ATemplateModel = new Template(); | ||
| 108 | - $TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); | ||
| 109 | - }else{ | ||
| 110 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 111 | - $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 112 | - if($commonInfo !== false){ | ||
| 113 | - $TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. | ||
| 114 | - $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html']; | 125 | + public function isCustomizedPage($source,$source_id) |
| 126 | + { | ||
| 127 | + $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 | ||
| 128 | + //查看当前页面是否定制,是否开启可视化 | ||
| 129 | + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 | ||
| 130 | + if (in_array($type, $page_array)) {//是定制界面 | ||
| 131 | + //TODO::获取初始代码 | ||
| 132 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 133 | + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$type]); | ||
| 134 | + if($customHtmlInfo === false){ | ||
| 135 | + $this->fail('定制页面,请先上传代码块'); | ||
| 115 | } | 136 | } |
| 116 | - $ATemplateModel = new Template(); | ||
| 117 | - $ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']],['name','image']); | ||
| 118 | - $TemplateInfo['name'] = $ATemplateInfo['name']; | ||
| 119 | - $TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']); | 137 | + return $customHtmlInfo['main_html']; |
| 120 | } | 138 | } |
| 121 | - $TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']); | ||
| 122 | - return $this->success($TemplateInfo); | 139 | + return []; |
| 123 | } | 140 | } |
| 124 | 141 | ||
| 125 | /** | 142 | /** |
| 126 | - * @remark :处理其他页数据 | ||
| 127 | - * @name :ProductHtml | 143 | + * @remark :定制界面根据source+source_id获取type类型 |
| 144 | + * @name :getType | ||
| 128 | * @author :lyh | 145 | * @author :lyh |
| 129 | * @method :post | 146 | * @method :post |
| 130 | - * @time :2023/7/25 16:40 | 147 | + * @time :2023/11/16 11:20 |
| 131 | */ | 148 | */ |
| 132 | - public function otherHtml($info,$source,$source_id){ | ||
| 133 | - $homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0); | ||
| 134 | - if($homeTemplateInfo === false){ | ||
| 135 | - $this->fail('请先装修首页'); | 149 | + public function getCustomizedType($source,$source_id){ |
| 150 | + $type = BTemplate::TYPE_ONE; | ||
| 151 | + if($source == BTemplate::SOURCE_PRODUCT){ | ||
| 152 | + if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;} | ||
| 136 | } | 153 | } |
| 137 | - //查看当前模板是否已编辑保存web_template | ||
| 138 | - $TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id); | ||
| 139 | - if($TemplateInfo === false){ | ||
| 140 | - $mainInfo = $this->getCommonMain($source,$source_id); | ||
| 141 | - $main_html = $mainInfo['main_html']; | ||
| 142 | - $main_style = $mainInfo['main_css']; | ||
| 143 | - $TemplateInfo['template_id'] = $info['template_id']; | ||
| 144 | - }else{ | ||
| 145 | - $main_html = $TemplateInfo['main_html']; | ||
| 146 | - $main_style = $TemplateInfo['main_css']; | 154 | + if($source == BTemplate::SOURCE_BLOG){ |
| 155 | + if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;} | ||
| 147 | } | 156 | } |
| 148 | - $commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']); | ||
| 149 | - if($commonInfo !== false){ | ||
| 150 | - $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other']. | ||
| 151 | - $commonInfo['head_html'].$main_html.$commonInfo['footer_html']; | ||
| 152 | - }else{ | ||
| 153 | - $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $main_style, $homeTemplateInfo['html']); | ||
| 154 | - $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $main_html, $html); | 157 | + if($source == BTemplate::SOURCE_NEWS){ |
| 158 | + if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;} | ||
| 159 | + } | ||
| 160 | + return $type; | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * @remark :获取当前项目设置的模版 | ||
| 165 | + * @name :getSettingTemplate | ||
| 166 | + * @author :lyh | ||
| 167 | + * @method :post | ||
| 168 | + * @time :2023/12/13 10:48 | ||
| 169 | + */ | ||
| 170 | + public function getSettingTemplate($source,$source_id){ | ||
| 171 | + if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目 | ||
| 172 | + $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 | ||
| 173 | + //查看当前页面是否定制,是否开启可视化 | ||
| 174 | + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 | ||
| 175 | + if (in_array($type, $page_array)) {//是定制界面 | ||
| 176 | + return 0; | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + $bSettingModel = new Setting(); | ||
| 180 | + $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 181 | + if($info === false){ | ||
| 182 | + $this->fail('请先选择模版'); | ||
| 155 | } | 183 | } |
| 156 | - $TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据 | 184 | + return $info['template_id']; |
| 185 | + } | ||
| 186 | + | ||
| 187 | + /** | ||
| 188 | + * @remark :根据参数获取数据详情 | ||
| 189 | + * @name :webTemplateInfo | ||
| 190 | + * @author :lyh | ||
| 191 | + * @method :post | ||
| 192 | + * @time :2023/7/25 16:41 | ||
| 193 | + */ | ||
| 194 | + public function webTemplateInfo($template_id,$source,$source_id,$is_custom = 0){ | ||
| 195 | + //查看当前模板是否已编辑保存web_template | ||
| 196 | + $TemplateInfo = $this->model->read([ | ||
| 197 | + 'template_id'=>$template_id, | ||
| 198 | + 'source'=>$source, | ||
| 199 | + 'project_id'=>$this->user['project_id'], | ||
| 200 | + 'source_id'=>$source_id, | ||
| 201 | + 'is_custom'=>$is_custom | ||
| 202 | + ]); | ||
| 157 | return $this->success($TemplateInfo); | 203 | return $this->success($TemplateInfo); |
| 158 | } | 204 | } |
| 159 | 205 | ||
| @@ -164,12 +210,16 @@ class BTemplateLogic extends BaseLogic | @@ -164,12 +210,16 @@ class BTemplateLogic extends BaseLogic | ||
| 164 | * @method :post | 210 | * @method :post |
| 165 | * @time :2023/10/24 15:58 | 211 | * @time :2023/10/24 15:58 |
| 166 | */ | 212 | */ |
| 167 | - public function getCommonMain($source,$source_id){ | 213 | + public function getCommonMain($source,$source_id,$is_custom){ |
| 168 | $data = []; | 214 | $data = []; |
| 169 | - if ($source == 2) {if ($source_id != 0) {$type = 2;} else {$type = 3;}} | ||
| 170 | - if ($source == 3) {if ($source_id != 0) {$type = 4;} else {$type = 5;}} | ||
| 171 | - if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}} | ||
| 172 | - if ($source == 5) {$type = 8;} | 215 | + if($is_custom == BTemplate::SOURCE_CUSTOM){ |
| 216 | + if($source_id != 0){$type = BTemplate::TYPE_SIX;}else{$type = BTemplate::TYPE_SEVEN;} | ||
| 217 | + }else{ | ||
| 218 | + if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}} | ||
| 219 | + if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}} | ||
| 220 | + if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}} | ||
| 221 | + if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;} | ||
| 222 | + } | ||
| 173 | //查询有没有公共详情模板 | 223 | //查询有没有公共详情模板 |
| 174 | $bTemplateMainModel = new BTemplateMain(); | 224 | $bTemplateMainModel = new BTemplateMain(); |
| 175 | $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]); | 225 | $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]); |
| @@ -201,23 +251,23 @@ class BTemplateLogic extends BaseLogic | @@ -201,23 +251,23 @@ class BTemplateLogic extends BaseLogic | ||
| 201 | 'template_id' => $template_id, | 251 | 'template_id' => $template_id, |
| 202 | 'project_id' => $this->user['project_id'] | 252 | 'project_id' => $this->user['project_id'] |
| 203 | ]; | 253 | ]; |
| 204 | - if ($source == 2) {//产品页 | ||
| 205 | - if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 206 | - else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 207 | - if ($source == 3) {//博客页 | ||
| 208 | - if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 209 | - else {$data['type'] = 5;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 210 | - if ($source == 4) {//新闻页 | ||
| 211 | - if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 212 | - else {$data['type'] = 7;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 213 | - if ($source == 5) {//聚合页 | ||
| 214 | - $data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | 254 | + if ($source == BTemplate::SOURCE_PRODUCT) {//产品页 |
| 255 | + if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 256 | + else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 257 | + if ($source == BTemplate::SOURCE_BLOG) {//博客页 | ||
| 258 | + if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 259 | + else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 260 | + if ($source == BTemplate::SOURCE_NEWS) {//新闻页 | ||
| 261 | + if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 262 | + else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}} | ||
| 263 | + if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页 | ||
| 264 | + $data['type'] = BTemplate::TYPE_EIGHT;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} | ||
| 215 | } | 265 | } |
| 216 | } | 266 | } |
| 217 | //获取首页公共的头部和底部 | 267 | //获取首页公共的头部和底部 |
| 218 | if(!isset($commonInfo) || $commonInfo === false){ | 268 | if(!isset($commonInfo) || $commonInfo === false){ |
| 219 | $commonTemplateModel = new BTemplateCommon(); | 269 | $commonTemplateModel = new BTemplateCommon(); |
| 220 | - $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); | 270 | + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]); |
| 221 | } | 271 | } |
| 222 | return $commonInfo; | 272 | return $commonInfo; |
| 223 | } | 273 | } |
| @@ -230,86 +280,220 @@ class BTemplateLogic extends BaseLogic | @@ -230,86 +280,220 @@ class BTemplateLogic extends BaseLogic | ||
| 230 | * @time :2023/6/29 11:05 | 280 | * @time :2023/6/29 11:05 |
| 231 | */ | 281 | */ |
| 232 | public function templateSave(){ | 282 | public function templateSave(){ |
| 233 | - //演示项目,不允许其他号码编辑 | ||
| 234 | - if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$this->model->mobile)) && ($this->param['source'] == 1)){ | ||
| 235 | - $this->fail('演示项目仅支持演示功能,无法更改首页'); | ||
| 236 | - } | ||
| 237 | - //查询当前模版是否已保存 | ||
| 238 | - DB::beginTransaction(); | ||
| 239 | - try { | ||
| 240 | - $info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']); | ||
| 241 | - //字符串截取 | ||
| 242 | - $this->param = $this->stringProcessing($this->param); | ||
| 243 | - //保存头部信息 | ||
| 244 | - $this->saveCommonTemplate($this->param); | ||
| 245 | - $param = $this->templateSaveParam($this->param);//组装数据 | ||
| 246 | - if($info === false){ | ||
| 247 | - $this->model->add($param); | ||
| 248 | - }else{ | ||
| 249 | - $this->model->edit($param,['id'=>$info['id']]); | 283 | + //演示项目不允许修改 |
| 284 | + $this->showProjectNoEdit($this->param['source']); | ||
| 285 | +// DB::beginTransaction(); | ||
| 286 | +// try { | ||
| 287 | + $this->param = $this->handleDefaultString($this->param);//设置默认字符 | ||
| 288 | + $templateInfo = $this->webTemplateInfo($this->param['template_id'],$this->param['source'], | ||
| 289 | + $this->param['source_id'],$this->param['is_custom']); | ||
| 290 | + if($templateInfo === false){//执行新增 | ||
| 291 | + $this->templateAddHtml($this->param['html'], $this->param['source'], $this->param['source_id'], | ||
| 292 | + $this->param['template_id'], $this->param['section_list_id'], $this->param['is_custom']); | ||
| 293 | + }else{//执行编辑 | ||
| 294 | + $this->templateEditHtml($this->param['html'],$this->param['source'],$this->param['source_id'], | ||
| 295 | + $this->param['template_id'],$this->param['section_list_id'], $this->param['is_custom']); | ||
| 250 | } | 296 | } |
| 251 | - //写入操作模版记录 | ||
| 252 | - $this->setTemplateLog($this->param); | ||
| 253 | - DB::commit(); | ||
| 254 | - }catch (\Exception $e){ | ||
| 255 | - DB::rollBack(); | ||
| 256 | - $this->fail('系统错误,请联系管理员'); | ||
| 257 | - } | 297 | + //更新头部信息 |
| 298 | + $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']); | ||
| 299 | + $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']); | ||
| 300 | +// DB::commit(); | ||
| 301 | +// }catch (\Exception $e){ | ||
| 302 | +// DB::rollBack(); | ||
| 303 | +// $this->fail('系统错误,请联系管理员'); | ||
| 304 | +// } | ||
| 258 | //通知更新 | 305 | //通知更新 |
| 259 | - $this->homeOrProduct($this->param['source'],$this->param['source_id']); | 306 | + $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']); |
| 260 | return $this->success(); | 307 | return $this->success(); |
| 261 | } | 308 | } |
| 262 | 309 | ||
| 263 | /** | 310 | /** |
| 264 | - * @remark :保存头部公共数据 | ||
| 265 | - * @name :saveCommonTemplate | 311 | + * @remark :保存数据时设置默认字符 |
| 312 | + * @name :saveDefaultString | ||
| 266 | * @author :lyh | 313 | * @author :lyh |
| 267 | * @method :post | 314 | * @method :post |
| 268 | - * @time :2023/10/13 14:27 | 315 | + * @time :2023/12/15 10:30 |
| 269 | */ | 316 | */ |
| 270 | - public function saveCommonTemplate($param){ | ||
| 271 | - $type = $this->getType($param['source'],$param['source_id']); | ||
| 272 | - $templateCommonModel = new BTemplateCommon(); | ||
| 273 | - $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]); | 317 | + public function handleDefaultString($param){ |
| 318 | + if(!isset($param['template_id'])){ | ||
| 319 | + $param['template_id'] = 0; | ||
| 320 | + } | ||
| 321 | + if(!isset($param['is_custom'])){ | ||
| 322 | + $param['is_custom'] = 0; | ||
| 323 | + } | ||
| 324 | + if(!isset($param['section_list_id'])){ | ||
| 325 | + $param['section_list_id'] = ''; | ||
| 326 | + } | ||
| 327 | + return $this->success($param); | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + /** | ||
| 331 | + * @remark :可视化添加数据 | ||
| 332 | + * @name :templateAddHtml | ||
| 333 | + * @author :lyh | ||
| 334 | + * @method :post | ||
| 335 | + * @time :2023/12/15 10:15 | ||
| 336 | + */ | ||
| 337 | + public function templateAddHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){ | ||
| 274 | $data = [ | 338 | $data = [ |
| 275 | - 'head_html'=>$param['head_html'], | ||
| 276 | - 'head_css'=>$param['head_css'], | ||
| 277 | - 'footer_html'=>$param['footer_html'], | ||
| 278 | - 'footer_css'=>$param['footer_css'], | 339 | + 'source'=>$source, 'source_id'=>$source_id,'type'=>BTemplate::PAGE_HTML, |
| 340 | + 'template_id'=>$template, 'project_id'=>$this->user['project_id'], | ||
| 341 | + 'section_list_id'=>$section_list_id,'is_custom'=>$is_custom, | ||
| 279 | ]; | 342 | ]; |
| 280 | - $footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 281 | - $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 282 | - if($info === false){ | ||
| 283 | - $data['template_id'] = $param['template_id']; | ||
| 284 | - $data['project_id'] = $this->user['project_id']; | ||
| 285 | - $data['type'] = $type; | 343 | + $data = $this->handleVisualizationParam($html,$source,$source_id,$data); |
| 344 | + $this->model->add($data); | ||
| 345 | + return true; | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + /** | ||
| 349 | + * @remark :可视化更新html | ||
| 350 | + * @name :templateEditHtml | ||
| 351 | + * @author :lyh | ||
| 352 | + * @method :post | ||
| 353 | + * @time :2023/12/15 10:26 | ||
| 354 | + */ | ||
| 355 | + public function templateEditHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){ | ||
| 356 | + $condition = [ | ||
| 357 | + 'source'=>$source, 'source_id'=>$source_id, | ||
| 358 | + 'is_custom'=>$is_custom, 'template_id'=>$template | ||
| 359 | + ]; | ||
| 360 | + $data = [ | ||
| 361 | + 'section_list_id'=>$section_list_id | ||
| 362 | + ]; | ||
| 363 | + $data = $this->handleVisualizationParam($html,$source,$source_id,$data); | ||
| 364 | + $this->model->edit($data,$condition); | ||
| 365 | + return true; | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + /** | ||
| 369 | + * @remark :处理可视化数据 | ||
| 370 | + * @name :handleProjectParam | ||
| 371 | + * @author :lyh | ||
| 372 | + * @method :post | ||
| 373 | + * @time :2023/12/15 10:59 | ||
| 374 | + */ | ||
| 375 | + public function handleVisualizationParam($html,$source, $source_id,$data){ | ||
| 376 | + if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目 | ||
| 377 | + $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型 | ||
| 378 | + //查看当前页面是否定制,是否开启可视化 | ||
| 379 | + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 | ||
| 380 | + if (in_array($type, $page_array)) {//当前页面是定制界面 | ||
| 381 | + $data['html'] = $html; | ||
| 382 | + $data['type'] = BTemplate::ALL_HTML; | ||
| 383 | + }else{ | ||
| 384 | + $mainInfo = $this->handleTemplateHtml($html); | ||
| 385 | + $data['main_html'] = $mainInfo['main_html']; | ||
| 386 | + $data['main_css'] = $mainInfo['main_css']; | ||
| 387 | + } | ||
| 388 | + }else{ | ||
| 389 | + $mainInfo = $this->handleTemplateHtml($html); | ||
| 390 | + $data['main_html'] = $mainInfo['main_html']; | ||
| 391 | + $data['main_css'] = $mainInfo['main_css']; | ||
| 392 | + } | ||
| 393 | + return $data; | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + | ||
| 397 | + /** | ||
| 398 | + * @remark :保存公共头部底部 | ||
| 399 | + * @name :saveCommonHtml | ||
| 400 | + * @author :lyh | ||
| 401 | + * @method :post | ||
| 402 | + * @time :2023/12/13 17:05 | ||
| 403 | + */ | ||
| 404 | + public function saveCommonHtml($html,$source,$source_id,$template_id){ | ||
| 405 | + $type = $this->getType($source,$source_id,$template_id);//获取头部类型1-9(首页到自定义页面) | ||
| 406 | + $templateCommonModel = new BTemplateCommon(); | ||
| 407 | + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在 | ||
| 408 | + $handleInfo = $this->handleCommonParam($html); | ||
| 409 | + if($commonInfo === false){ | ||
| 410 | + $data = [ | ||
| 411 | + 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 412 | + 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 413 | + 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'], | ||
| 414 | + ]; | ||
| 286 | $templateCommonModel->add($data); | 415 | $templateCommonModel->add($data); |
| 287 | }else{ | 416 | }else{ |
| 288 | - $templateCommonModel->edit($data,['id'=>$info['id']]); | 417 | + $data = [ |
| 418 | + 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 419 | + 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 420 | + ]; | ||
| 421 | + $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); | ||
| 289 | } | 422 | } |
| 290 | //更新所有界面的other | 423 | //更新所有界面的other |
| 291 | - $templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$param['template_id']]); | ||
| 292 | - return $this->success(); | 424 | + return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]); |
| 293 | } | 425 | } |
| 294 | 426 | ||
| 295 | /** | 427 | /** |
| 428 | + * @remark :演示项目不允许修改首页 | ||
| 429 | + * @name :showProject | ||
| 430 | + * @author :lyh | ||
| 431 | + * @method :post | ||
| 432 | + * @time :2023/12/12 11:27 | ||
| 433 | + */ | ||
| 434 | + public function showProjectNoEdit($source){ | ||
| 435 | + //演示项目,不允许其他号码编辑 | ||
| 436 | + if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$this->model->mobile)) && ($source == BTemplate::SOURCE_HOME)){ | ||
| 437 | + $this->fail('演示项目仅支持演示功能,无法更改首页'); | ||
| 438 | + } | ||
| 439 | + return true; | ||
| 440 | + } | ||
| 441 | + | ||
| 442 | + /** | ||
| 443 | + * @remark :保存时字符串处理 | ||
| 444 | + * @name :handleCommonParam | ||
| 445 | + * @author :lyh | ||
| 446 | + * @method :post | ||
| 447 | + * @time :2023/6/29 15:35 | ||
| 448 | + */ | ||
| 449 | + public function handleCommonParam($html){ | ||
| 450 | + //字符串截取 | ||
| 451 | + $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); | ||
| 452 | + $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); | ||
| 453 | + $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'); | ||
| 454 | + $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | ||
| 455 | + $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 456 | + $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 457 | + return $this->success($param); | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + /** | ||
| 461 | + * @remark :保存时字符串处理 | ||
| 462 | + * @name :handleSaveParam | ||
| 463 | + * @author :lyh | ||
| 464 | + * @method :post | ||
| 465 | + * @time :2023/6/29 15:35 | ||
| 466 | + */ | ||
| 467 | + public function handleTemplateHtml($html){ | ||
| 468 | + //字符串截取 | ||
| 469 | + $param['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); | ||
| 470 | + $param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | ||
| 471 | + return $this->success($param); | ||
| 472 | + } | ||
| 473 | + /** | ||
| 296 | * @remark :获取设置的类型 | 474 | * @remark :获取设置的类型 |
| 297 | * @name :getType | 475 | * @name :getType |
| 298 | * @author :lyh | 476 | * @author :lyh |
| 299 | * @method :post | 477 | * @method :post |
| 300 | * @time :2023/10/21 17:29 | 478 | * @time :2023/10/21 17:29 |
| 301 | */ | 479 | */ |
| 302 | - public function getType($source,$source_id){ | 480 | + public function getType($source,$source_id,$template_id){ |
| 303 | $type = 1;//首页公共头部底部 | 481 | $type = 1;//首页公共头部底部 |
| 482 | + if($template_id == 0){//保存上传的代码块时,默认为独立头部 | ||
| 483 | + $this->user['configuration']['is_head'] == 1; | ||
| 484 | + } | ||
| 304 | //查看页面是否设置自定义头部底部 | 485 | //查看页面是否设置自定义头部底部 |
| 305 | if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | 486 | if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { |
| 306 | $pageSettingModel = new PageSetting(); | 487 | $pageSettingModel = new PageSetting(); |
| 307 | $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | 488 | $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); |
| 308 | if ($pageInfo !== false) { | 489 | if ($pageInfo !== false) { |
| 309 | - if ($source == 2) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = 2;}} else {if ($pageInfo['product_list'] != 0) {$type = 3;}}} | ||
| 310 | - if ($source == 3) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = 4;}} else {if ($pageInfo['blog_list'] != 0) {$type = 5;}}} | ||
| 311 | - if ($source == 4) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = 6;}} else {if ($pageInfo['news_list'] != 0) {$type = 7;}}} | ||
| 312 | - if ($source == 5) {if ($pageInfo['polymerization'] != 0) {$type = 8;}} | 490 | + if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}} |
| 491 | + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}} | ||
| 492 | + if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}} | ||
| 493 | + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}} | ||
| 494 | + if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}} | ||
| 495 | + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}} | ||
| 496 | + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}} | ||
| 313 | } | 497 | } |
| 314 | } | 498 | } |
| 315 | return $type; | 499 | return $type; |
| @@ -322,22 +506,24 @@ class BTemplateLogic extends BaseLogic | @@ -322,22 +506,24 @@ class BTemplateLogic extends BaseLogic | ||
| 322 | * @method :post | 506 | * @method :post |
| 323 | * @time :2023/8/23 11:16 | 507 | * @time :2023/8/23 11:16 |
| 324 | */ | 508 | */ |
| 325 | - public function setTemplateLog($param){ | 509 | + public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){ |
| 326 | $data = [ | 510 | $data = [ |
| 327 | - 'template_id'=>$param['template_id'], | 511 | + 'template_id'=>$template_id, |
| 328 | 'project_id'=>$this->user['project_id'], | 512 | 'project_id'=>$this->user['project_id'], |
| 329 | 'operator_id'=>$this->user['id'], | 513 | 'operator_id'=>$this->user['id'], |
| 330 | - 'text'=>$param['html'], | ||
| 331 | - 'source'=>$param['source'], | ||
| 332 | - 'source_id'=>$param['source_id'], | ||
| 333 | - 'head_html'=>$param['head_html'], | ||
| 334 | - 'head_css'=>$param['head_css'], | ||
| 335 | - 'main_html'=>$param['main_html'], | ||
| 336 | - 'main_css'=>$param['main_css'], | ||
| 337 | - 'footer_html'=>$param['footer_html'], | ||
| 338 | - 'footer_css'=>$param['footer_css'], | 514 | + 'text'=>$html, |
| 515 | + 'type'=>$type, | ||
| 516 | + 'is_custom'=>$is_custom, | ||
| 517 | + 'source'=>$source, | ||
| 518 | + 'source_id'=>$source_id, | ||
| 519 | + 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'), | ||
| 520 | + 'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'), | ||
| 521 | + 'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), | ||
| 522 | + 'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | ||
| 523 | + 'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | ||
| 524 | + 'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | ||
| 339 | ]; | 525 | ]; |
| 340 | - $footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s')); | 526 | + $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); |
| 341 | $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | 527 | $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); |
| 342 | $bTemplateLogModel = new BTemplateLog(); | 528 | $bTemplateLogModel = new BTemplateLog(); |
| 343 | return $bTemplateLogModel->add($data); | 529 | return $bTemplateLogModel->add($data); |
| @@ -350,52 +536,30 @@ class BTemplateLogic extends BaseLogic | @@ -350,52 +536,30 @@ class BTemplateLogic extends BaseLogic | ||
| 350 | * @method :post | 536 | * @method :post |
| 351 | * @time :2023/7/31 16:05 | 537 | * @time :2023/7/31 16:05 |
| 352 | */ | 538 | */ |
| 353 | - public function homeOrProduct($source,$source_id = ''){ | ||
| 354 | - if($source == BTemplate::SOURCE_HOME){ | ||
| 355 | - $type = 'index'; | ||
| 356 | - $route = 'index'; | ||
| 357 | - //路由映射 | ||
| 358 | - RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); | ||
| 359 | - }else{ | ||
| 360 | - //其他界面通知更新 | ||
| 361 | - if($source == 2 && $source_id != 0){ | 539 | + public function homeOrProduct($source,$source_id = '',$is_custom = 0){ |
| 540 | + if($is_custom == 0){ | ||
| 541 | + if($source == BTemplate::SOURCE_HOME){ | ||
| 542 | + RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); | ||
| 543 | + $type = RouteMap::SOURCE_INDEX; | ||
| 544 | + }elseif($source == BTemplate::SOURCE_PRODUCT){ | ||
| 362 | $type = RouteMap::SOURCE_PRODUCT; | 545 | $type = RouteMap::SOURCE_PRODUCT; |
| 363 | - $productModel = new Product(); | ||
| 364 | - $productInfo = $productModel->read(['id'=>$source_id],['route']); | ||
| 365 | - $route = $productInfo['route']; | ||
| 366 | - }elseif($source == 3 && $source_id != 0){ | 546 | + }elseif($source == BTemplate::SOURCE_BLOG){ |
| 367 | $type = RouteMap::SOURCE_BLOG; | 547 | $type = RouteMap::SOURCE_BLOG; |
| 368 | - $blogModel = new Blog(); | ||
| 369 | - $blogInfo = $blogModel->read(['id'=>$source_id],['url']); | ||
| 370 | - $route = $blogInfo['url']; | ||
| 371 | - }elseif($source == 4 && $source_id != 0){ | 548 | + }elseif($source == BTemplate::SOURCE_NEWS){ |
| 372 | $type = RouteMap::SOURCE_NEWS; | 549 | $type = RouteMap::SOURCE_NEWS; |
| 373 | - $newsModel = new News(); | ||
| 374 | - $newsInfo = $newsModel->read(['id'=>$source_id],['url']); | ||
| 375 | - $route = $newsInfo['url']; | ||
| 376 | }else{ | 550 | }else{ |
| 377 | $type = 'all'; | 551 | $type = 'all'; |
| 378 | - $route = 'all'; | ||
| 379 | } | 552 | } |
| 553 | + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); | ||
| 554 | + }else{ | ||
| 555 | + $type = RouteMap::SOURCE_MODULE; | ||
| 556 | + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); | ||
| 380 | } | 557 | } |
| 381 | $this->addUpdateNotify($type,$route); | 558 | $this->addUpdateNotify($type,$route); |
| 382 | return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); | 559 | return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); |
| 383 | } | 560 | } |
| 384 | 561 | ||
| 385 | /** | 562 | /** |
| 386 | - * @remark :处理保存模版数据 | ||
| 387 | - * @name :templateParam | ||
| 388 | - * @author :lyh | ||
| 389 | - * @method :post | ||
| 390 | - * @time :2023/7/21 16:30 | ||
| 391 | - */ | ||
| 392 | - public function templateSaveParam($param){ | ||
| 393 | - $param['project_id'] = $this->user['project_id']; | ||
| 394 | - unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']); | ||
| 395 | - return $this->success($param); | ||
| 396 | - } | ||
| 397 | - | ||
| 398 | - /** | ||
| 399 | * @remark :拼接获取公共头部底部 | 563 | * @remark :拼接获取公共头部底部 |
| 400 | * @name :getHeadFooter | 564 | * @name :getHeadFooter |
| 401 | * @author :lyh | 565 | * @author :lyh |
| @@ -419,13 +583,13 @@ class BTemplateLogic extends BaseLogic | @@ -419,13 +583,13 @@ class BTemplateLogic extends BaseLogic | ||
| 419 | } | 583 | } |
| 420 | 584 | ||
| 421 | /** | 585 | /** |
| 422 | - * @remark :字符串处理 | ||
| 423 | - * @name :StringProcessing | 586 | + * @remark :保存时字符串处理 |
| 587 | + * @name :handleSaveParam | ||
| 424 | * @author :lyh | 588 | * @author :lyh |
| 425 | * @method :post | 589 | * @method :post |
| 426 | * @time :2023/6/29 15:35 | 590 | * @time :2023/6/29 15:35 |
| 427 | */ | 591 | */ |
| 428 | - public function stringProcessing($param){ | 592 | + public function handleSaveParam($param){ |
| 429 | //字符串截取 | 593 | //字符串截取 |
| 430 | $param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); | 594 | $param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); |
| 431 | $param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); | 595 | $param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); |
| @@ -433,6 +597,10 @@ class BTemplateLogic extends BaseLogic | @@ -433,6 +597,10 @@ class BTemplateLogic extends BaseLogic | ||
| 433 | $param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'); | 597 | $param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'); |
| 434 | $param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | 598 | $param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); |
| 435 | $param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | 599 | $param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'); |
| 600 | + if(!isset($param['is_custom'])){ | ||
| 601 | + $param['is_custom'] = BTemplate::SOURCE_NO_CUSTOM; | ||
| 602 | + } | ||
| 603 | + $param['type'] = BTemplate::PAGE_HTML;//不显示整个HTML | ||
| 436 | return $this->success($param); | 604 | return $this->success($param); |
| 437 | } | 605 | } |
| 438 | 606 | ||
| @@ -444,7 +612,6 @@ class BTemplateLogic extends BaseLogic | @@ -444,7 +612,6 @@ class BTemplateLogic extends BaseLogic | ||
| 444 | * @time :2023/7/27 15:08 | 612 | * @time :2023/7/27 15:08 |
| 445 | */ | 613 | */ |
| 446 | public function getModule($type){ | 614 | public function getModule($type){ |
| 447 | - //获取公共主题头部底部 | ||
| 448 | $mainModel = new TemplateTypeMain(); | 615 | $mainModel = new TemplateTypeMain(); |
| 449 | $info = $mainModel->read(['type'=>$type]); | 616 | $info = $mainModel->read(['type'=>$type]); |
| 450 | return $info['main_html']; | 617 | return $info['main_html']; |
| @@ -529,7 +696,7 @@ class BTemplateLogic extends BaseLogic | @@ -529,7 +696,7 @@ class BTemplateLogic extends BaseLogic | ||
| 529 | $this->param['test_model'] = 2;//未审核模版 | 696 | $this->param['test_model'] = 2;//未审核模版 |
| 530 | $this->param['operator_id'] = $this->user['manager_id'] ?? 0; | 697 | $this->param['operator_id'] = $this->user['manager_id'] ?? 0; |
| 531 | $this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s'); | 698 | $this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s'); |
| 532 | - $this->param = $this->stringProcessing($this->param); | 699 | + $this->param = $this->handleSaveParam($this->param); |
| 533 | $publicTemplateModel = new Template(); | 700 | $publicTemplateModel = new Template(); |
| 534 | $rs = $publicTemplateModel->add($this->param); | 701 | $rs = $publicTemplateModel->add($this->param); |
| 535 | if($rs === false){ | 702 | if($rs === false){ |
| @@ -551,20 +718,8 @@ class BTemplateLogic extends BaseLogic | @@ -551,20 +718,8 @@ class BTemplateLogic extends BaseLogic | ||
| 551 | if($bSettingInfo === false){ | 718 | if($bSettingInfo === false){ |
| 552 | $this->fail('请先设置模板'); | 719 | $this->fail('请先设置模板'); |
| 553 | } | 720 | } |
| 554 | - //获取首页公共部分 | ||
| 555 | - $templateCommonModel = new BTemplateCommon(); | ||
| 556 | - $commonInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 557 | - if($commonInfo === false){ | ||
| 558 | - $this->fail('已装修的项目使用当前功能时,可视化保存首页数据一次,未装修首页请先装修首页'); | ||
| 559 | - } | ||
| 560 | - //判断当前项目是否有设置独立头部的权限 | ||
| 561 | - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 562 | - //有权限时,获取独立头部 | ||
| 563 | - $commonTypeInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | ||
| 564 | - if($commonTypeInfo !== false){ | ||
| 565 | - $commonInfo = $commonTypeInfo; | ||
| 566 | - } | ||
| 567 | - } | 721 | + $is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版 |
| 722 | + $commonInfo = $this->getTypeCommonHtml($bSettingInfo['template_id'],$is_custom); | ||
| 568 | //获取设置的默认中间部分 | 723 | //获取设置的默认中间部分 |
| 569 | $bTemplateMainModel = new BTemplateMain(); | 724 | $bTemplateMainModel = new BTemplateMain(); |
| 570 | $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | 725 | $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); |
| @@ -582,6 +737,31 @@ class BTemplateLogic extends BaseLogic | @@ -582,6 +737,31 @@ class BTemplateLogic extends BaseLogic | ||
| 582 | } | 737 | } |
| 583 | 738 | ||
| 584 | /** | 739 | /** |
| 740 | + * @remark :根据type获取html | ||
| 741 | + * @name :getHeaderFooter | ||
| 742 | + * @author :lyh | ||
| 743 | + * @method :post | ||
| 744 | + * @time :2023/12/15 18:06 | ||
| 745 | + */ | ||
| 746 | + public function getTypeCommonHtml($template_id,$is_custom){ | ||
| 747 | + //获取首页公共部分 | ||
| 748 | + $templateCommonModel = new BTemplateCommon(); | ||
| 749 | + $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 750 | + //判断当前项目是否有设置独立头部的权限 | ||
| 751 | + if($is_custom == BTemplate::SOURCE_CUSTOM){ | ||
| 752 | + return $this->success($commonInfo); | ||
| 753 | + } | ||
| 754 | + if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 755 | + //有权限时,获取独立头部 | ||
| 756 | + $commonTypeInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | ||
| 757 | + if($commonTypeInfo !== false){ | ||
| 758 | + $commonInfo = $commonTypeInfo; | ||
| 759 | + } | ||
| 760 | + } | ||
| 761 | + return $this->success($commonInfo); | ||
| 762 | + } | ||
| 763 | + | ||
| 764 | + /** | ||
| 585 | * @remark :保存详情模板数据 | 765 | * @remark :保存详情模板数据 |
| 586 | * @name :saveDetail | 766 | * @name :saveDetail |
| 587 | * @author :lyh | 767 | * @author :lyh |
| @@ -594,6 +774,7 @@ class BTemplateLogic extends BaseLogic | @@ -594,6 +774,7 @@ class BTemplateLogic extends BaseLogic | ||
| 594 | if($bSettingInfo === false){ | 774 | if($bSettingInfo === false){ |
| 595 | $this->fail('请先设置模板'); | 775 | $this->fail('请先设置模板'); |
| 596 | } | 776 | } |
| 777 | + $is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版 | ||
| 597 | $data = [ | 778 | $data = [ |
| 598 | 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'), | 779 | 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'), |
| 599 | 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'), | 780 | 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'), |
| @@ -601,37 +782,53 @@ class BTemplateLogic extends BaseLogic | @@ -601,37 +782,53 @@ class BTemplateLogic extends BaseLogic | ||
| 601 | $data['section_list_id'] = $this->param['section_list_id']; | 782 | $data['section_list_id'] = $this->param['section_list_id']; |
| 602 | //保存中间部分 | 783 | //保存中间部分 |
| 603 | $bTemplateMainModel = new BTemplateMain(); | 784 | $bTemplateMainModel = new BTemplateMain(); |
| 604 | - $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]); | 785 | + $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]); |
| 605 | if($mainInfo === false){ | 786 | if($mainInfo === false){ |
| 606 | $data['project_id'] = $this->user['project_id']; | 787 | $data['project_id'] = $this->user['project_id']; |
| 607 | $data['type'] = $this->param['type']; | 788 | $data['type'] = $this->param['type']; |
| 789 | + $data['is_custom'] = $is_custom; | ||
| 608 | $bTemplateMainModel->add($data); | 790 | $bTemplateMainModel->add($data); |
| 609 | }else{ | 791 | }else{ |
| 610 | $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); | 792 | $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); |
| 611 | } | 793 | } |
| 794 | + $this->saveDetailCommonHtml($is_custom,$this->param['type'],$bSettingInfo['template_id'],$this->param['html']); | ||
| 795 | + return $this->success(); | ||
| 796 | + } | ||
| 797 | + | ||
| 798 | + /** | ||
| 799 | + * @remark :保存详情页模版头部底部 | ||
| 800 | + * @name :saveDetailCommonHtml | ||
| 801 | + * @author :lyh | ||
| 802 | + * @method :post | ||
| 803 | + * @time :2023/12/15 18:12 | ||
| 804 | + */ | ||
| 805 | + public function saveDetailCommonHtml($is_custom,$type,$template_id,$html){ | ||
| 612 | $publicData = [ | 806 | $publicData = [ |
| 613 | - 'head_html' => characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'), | ||
| 614 | - 'head_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'), | ||
| 615 | - 'footer_html' => characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'), | ||
| 616 | - 'footer_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | ||
| 617 | - 'other'=>str_replace('<header','',characterTruncation($this->param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")), | 807 | + 'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), |
| 808 | + 'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | ||
| 809 | + 'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | ||
| 810 | + 'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | ||
| 811 | + 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")), | ||
| 618 | ]; | 812 | ]; |
| 619 | //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部 | 813 | //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部 |
| 814 | + if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块 | ||
| 815 | + $this->user['configuration']['is_head'] = BTemplate::SOURCE_NO_CUSTOM; | ||
| 816 | + } | ||
| 620 | $templateCommonModel = new BTemplateCommon(); | 817 | $templateCommonModel = new BTemplateCommon(); |
| 621 | if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | 818 | if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { |
| 622 | - $templateCommonInfo = $templateCommonModel->read(['type'=>$this->param['type'],'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]); | 819 | + $templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]); |
| 623 | if($templateCommonInfo === false){ | 820 | if($templateCommonInfo === false){ |
| 624 | - $publicData['type'] = $this->param['type']; | 821 | + $publicData['type'] = $type; |
| 625 | $publicData['project_id'] = $this->user['project_id']; | 822 | $publicData['project_id'] = $this->user['project_id']; |
| 626 | - $publicData['template_id'] = $bSettingInfo['template_id']; | 823 | + $publicData['template_id'] = $template_id; |
| 627 | $templateCommonModel->add($publicData); | 824 | $templateCommonModel->add($publicData); |
| 628 | }else{ | 825 | }else{ |
| 629 | $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]); | 826 | $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]); |
| 630 | } | 827 | } |
| 631 | }else{ | 828 | }else{ |
| 632 | //更新首页头部底部 | 829 | //更新首页头部底部 |
| 633 | - $templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]); | 830 | + $templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]); |
| 634 | } | 831 | } |
| 635 | - return $this->success(); | 832 | + return true; |
| 636 | } | 833 | } |
| 637 | } | 834 | } |
| @@ -42,51 +42,17 @@ class VisualizationLogic extends BaseLogic | @@ -42,51 +42,17 @@ class VisualizationLogic extends BaseLogic | ||
| 42 | * @time :2023/11/17 14:44 | 42 | * @time :2023/11/17 14:44 |
| 43 | */ | 43 | */ |
| 44 | public function getVisualizationInfo(){ | 44 | public function getVisualizationInfo(){ |
| 45 | - $data = $this->getSource($this->param['type']); | ||
| 46 | - $source = $data['source']; | ||
| 47 | - $source_id = $data['source_id']; | ||
| 48 | - $type = $this->getType($source,$source_id); | ||
| 49 | - $typeArray = [BTemplate::TYPE_ONE,BTemplate::TYPE_THREE,BTemplate::TYPE_FIVE,BTemplate::TYPE_SEVEN];//单页数据 | ||
| 50 | - if(in_array($type,$typeArray)){ | ||
| 51 | - $bTemplateModel = new BTemplate(); | ||
| 52 | - $info = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]); | ||
| 53 | - if($info === false){ | ||
| 54 | - $html = ''; | ||
| 55 | - }else{ | ||
| 56 | - $html = $info['html']; | ||
| 57 | - } | ||
| 58 | - }else{//模块数据 | ||
| 59 | - $bTemplateMainModel = new BTemplateMain(); | ||
| 60 | - $info = $bTemplateMainModel->read(['type'=>$type]); | ||
| 61 | - if($info === false){ | ||
| 62 | - $html = ''; | ||
| 63 | - }else{ | ||
| 64 | - $html = $info['main_html']; | ||
| 65 | - } | 45 | + $bTemplateMainModel = new BTemplateMain(); |
| 46 | + $info = $bTemplateMainModel->read(['type'=>$this->param['type']]); | ||
| 47 | + if($info === false){ | ||
| 48 | + $html = ''; | ||
| 49 | + }else{ | ||
| 50 | + $html = $info['main_html']; | ||
| 66 | } | 51 | } |
| 67 | return $this->success(['html'=>$html]); | 52 | return $this->success(['html'=>$html]); |
| 68 | } | 53 | } |
| 69 | 54 | ||
| 70 | /** | 55 | /** |
| 71 | - * @remark :根据type获取source类型 | ||
| 72 | - * @name :getSource | ||
| 73 | - * @author :lyh | ||
| 74 | - * @method :post | ||
| 75 | - * @time :2023/12/6 11:25 | ||
| 76 | - */ | ||
| 77 | - public function getSource($type){ | ||
| 78 | - $source_id = 0; | ||
| 79 | - if ($type == 2){$source = 2;$source_id = 1; | ||
| 80 | - }elseif ($type == 3){$source = 2; | ||
| 81 | - }elseif ($type == 4){$source = 3;$source_id = 1; | ||
| 82 | - }elseif ($type == 5){$source = 3; | ||
| 83 | - }elseif ($type == 6){$source = 4;$source_id = 1; | ||
| 84 | - }elseif ($type == 7){$source = 4; | ||
| 85 | - }else{$source = 1;} | ||
| 86 | - return ['source'=>$source,'source_id'=>$source_id]; | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - /** | ||
| 90 | * @remark :保存定制html | 56 | * @remark :保存定制html |
| 91 | * @name :saveHtml | 57 | * @name :saveHtml |
| 92 | * @author :lyh | 58 | * @author :lyh |
| @@ -95,36 +61,18 @@ class VisualizationLogic extends BaseLogic | @@ -95,36 +61,18 @@ class VisualizationLogic extends BaseLogic | ||
| 95 | */ | 61 | */ |
| 96 | public function saveVisualization(){ | 62 | public function saveVisualization(){ |
| 97 | try { | 63 | try { |
| 98 | - $sourceData = $this->getSource($this->param['type']); | ||
| 99 | - $source = $sourceData['source']; | ||
| 100 | - $source_id = $sourceData['source_id']; | ||
| 101 | $type = $this->param['type']; | 64 | $type = $this->param['type']; |
| 102 | - $typeArray = [1,3,5,7];//单页数据 | ||
| 103 | - if(in_array($type,$typeArray)){ | ||
| 104 | - $bTemplateModel = new BTemplate(); | ||
| 105 | - $templateInfo = $bTemplateModel->read(['source'=>$source,'source_id'=>$source_id,'template_id'=>0]); | ||
| 106 | - if($templateInfo === false){ | ||
| 107 | - $data = [ | ||
| 108 | - 'html'=>$this->param['html'], 'project_id'=>$this->user['project_id'], | ||
| 109 | - 'source'=>$source, 'source_id'=>$source_id, | ||
| 110 | - ]; | ||
| 111 | - $bTemplateModel->add($data); | ||
| 112 | - }else{ | ||
| 113 | - $bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]); | ||
| 114 | - } | ||
| 115 | - }else{//模块数据 | ||
| 116 | - $bTemplateMainModel = new BTemplateMain(); | ||
| 117 | - $mainInfo = $bTemplateMainModel->read(['type'=>$type]); | ||
| 118 | - if($mainInfo === false){ | ||
| 119 | - $mainData = [ | ||
| 120 | - 'project_id'=>$this->user['project_id'], | ||
| 121 | - 'type'=>$type, | ||
| 122 | - 'main_html'=>$this->param['html'] | ||
| 123 | - ]; | ||
| 124 | - $bTemplateMainModel->add($mainData); | ||
| 125 | - }else{ | ||
| 126 | - $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); | ||
| 127 | - } | 65 | + $bTemplateMainModel = new BTemplateMain(); |
| 66 | + $mainInfo = $bTemplateMainModel->read(['type'=>$type]); | ||
| 67 | + if($mainInfo === false){ | ||
| 68 | + $mainData = [ | ||
| 69 | + 'project_id'=>$this->user['project_id'], | ||
| 70 | + 'type'=>$type, | ||
| 71 | + 'main_html'=>$this->param['html'] | ||
| 72 | + ]; | ||
| 73 | + $bTemplateMainModel->add($mainData); | ||
| 74 | + }else{ | ||
| 75 | + $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); | ||
| 128 | } | 76 | } |
| 129 | }catch (\Exception $e){ | 77 | }catch (\Exception $e){ |
| 130 | $this->fail('系统错误,请联系管理员'); | 78 | $this->fail('系统错误,请联系管理员'); |
| @@ -158,6 +106,7 @@ class VisualizationLogic extends BaseLogic | @@ -158,6 +106,7 @@ class VisualizationLogic extends BaseLogic | ||
| 158 | * @time :2023/12/6 11:47 | 106 | * @time :2023/12/6 11:47 |
| 159 | */ | 107 | */ |
| 160 | public function getVisualizationHtml($type){ | 108 | public function getVisualizationHtml($type){ |
| 109 | + | ||
| 161 | if(in_array($type,[1,3,5,7])){//单页 | 110 | if(in_array($type,[1,3,5,7])){//单页 |
| 162 | $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块 | 111 | $templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块 |
| 163 | if($templateInfo === false){ | 112 | if($templateInfo === false){ |
| @@ -270,15 +219,15 @@ class VisualizationLogic extends BaseLogic | @@ -270,15 +219,15 @@ class VisualizationLogic extends BaseLogic | ||
| 270 | * @time :2023/11/16 11:20 | 219 | * @time :2023/11/16 11:20 |
| 271 | */ | 220 | */ |
| 272 | public function getType($source,$source_id){ | 221 | public function getType($source,$source_id){ |
| 273 | - $type = 1; | ||
| 274 | - if($source == 2){ | ||
| 275 | - if($source_id == 0){$type = 3;}else{$type = 2;} | 222 | + $type = BTemplate::TYPE_ONE; |
| 223 | + if($source == BTemplate::SOURCE_PRODUCT){ | ||
| 224 | + if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;} | ||
| 276 | } | 225 | } |
| 277 | - if($source == 3){ | ||
| 278 | - if($source_id == 0){$type = 5;}else{$type = 4;} | 226 | + if($source == BTemplate::SOURCE_BLOG){ |
| 227 | + if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;} | ||
| 279 | } | 228 | } |
| 280 | - if($source == 4){ | ||
| 281 | - if($source_id == 0){$type = 7;}else{$type = 6;} | 229 | + if($source == BTemplate::SOURCE_NEWS){ |
| 230 | + if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;} | ||
| 282 | } | 231 | } |
| 283 | return $type; | 232 | return $type; |
| 284 | } | 233 | } |
| @@ -323,7 +272,10 @@ class VisualizationLogic extends BaseLogic | @@ -323,7 +272,10 @@ class VisualizationLogic extends BaseLogic | ||
| 323 | if(in_array($type,$page_array)){//定制页面 | 272 | if(in_array($type,$page_array)){//定制页面 |
| 324 | $this->saveVisualizationHtml($type); | 273 | $this->saveVisualizationHtml($type); |
| 325 | }else{ | 274 | }else{ |
| 326 | - $this->saveTemplateHtml(); | 275 | + if(!isset($this->param['is_custom'])){ |
| 276 | + $this->param['is_custom'] = 0; | ||
| 277 | + } | ||
| 278 | + $this->saveTemplateHtml($this->param); | ||
| 327 | } | 279 | } |
| 328 | }catch (\Exception $e){ | 280 | }catch (\Exception $e){ |
| 329 | $this->fail('系统错误,请联系管理员'); | 281 | $this->fail('系统错误,请联系管理员'); |
| @@ -396,26 +348,29 @@ class VisualizationLogic extends BaseLogic | @@ -396,26 +348,29 @@ class VisualizationLogic extends BaseLogic | ||
| 396 | * @method :post | 348 | * @method :post |
| 397 | * @time :2023/12/5 15:44 | 349 | * @time :2023/12/5 15:44 |
| 398 | */ | 350 | */ |
| 399 | - public function saveTemplateHtml(){ | 351 | + public function saveTemplateHtml($param){ |
| 400 | $bTemplateModel = new BTemplate(); | 352 | $bTemplateModel = new BTemplate(); |
| 401 | $templateInfo = $bTemplateModel->read([ | 353 | $templateInfo = $bTemplateModel->read([ |
| 402 | - 'source'=>$this->param['source'], | 354 | + 'source'=>$param['source'], |
| 403 | 'project_id'=>$this->user['project_id'], | 355 | 'project_id'=>$this->user['project_id'], |
| 404 | - 'source_id'=>$this->param['source_id'], | ||
| 405 | - 'template_id'=>$this->param['template_id'], | 356 | + 'source_id'=>$param['source_id'], |
| 357 | + 'template_id'=>$param['template_id'], | ||
| 358 | + 'is_custom'=>$param['is_custom'] | ||
| 406 | ]); | 359 | ]); |
| 407 | - $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); | ||
| 408 | - $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | 360 | + $this->param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); |
| 361 | + $this->param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | ||
| 409 | //保存头部 | 362 | //保存头部 |
| 410 | - $this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']); | 363 | + if($param['is_custom'] == BTemplate::SOURCE_NO_CUSTOM){//非扩展模块才可以保存头底 |
| 364 | + $this->saveCommonTemplate($param['html'],$param['source'],$param['source_id'],$param['template_id']); | ||
| 365 | + } | ||
| 411 | if($templateInfo === false){ | 366 | if($templateInfo === false){ |
| 412 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 413 | - $bTemplateModel->add($this->param); | 367 | + $param['project_id'] = $this->user['project_id']; |
| 368 | + $bTemplateModel->add($param); | ||
| 414 | }else{ | 369 | }else{ |
| 415 | - $bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]); | 370 | + $bTemplateModel->edit($param,['source'=>$param['source'],'source_id'=>$param['source_id'],'is_custom'=>$param['is_custom']]); |
| 416 | } | 371 | } |
| 417 | - $this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']); | ||
| 418 | - $this->homeOrProduct($this->param['source'],$this->param['source_id']); | 372 | + $this->setTemplateLog($param['template_id'],$param['html'],$param['source'],$param['source_id'],$param['is_custom']); |
| 373 | + $this->homeOrProduct($param['source'],$param['source_id'],$param['is_custom']); | ||
| 419 | } | 374 | } |
| 420 | 375 | ||
| 421 | /** | 376 | /** |
| @@ -425,33 +380,24 @@ class VisualizationLogic extends BaseLogic | @@ -425,33 +380,24 @@ class VisualizationLogic extends BaseLogic | ||
| 425 | * @method :post | 380 | * @method :post |
| 426 | * @time :2023/7/31 16:05 | 381 | * @time :2023/7/31 16:05 |
| 427 | */ | 382 | */ |
| 428 | - public function homeOrProduct($source,$source_id = ''){ | ||
| 429 | - if($source == BTemplate::SOURCE_HOME){ | ||
| 430 | - $type = 'index'; | ||
| 431 | - $route = ''; | ||
| 432 | - //路由映射 | ||
| 433 | - RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); | ||
| 434 | - }else{ | ||
| 435 | - //其他界面通知更新 | ||
| 436 | - if($source == 2 && $source_id != 0){ | 383 | + public function homeOrProduct($source,$source_id = '',$is_custom = 0){ |
| 384 | + if($is_custom == 0){ | ||
| 385 | + if($source == BTemplate::SOURCE_HOME){ | ||
| 386 | + RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); | ||
| 387 | + $type = RouteMap::SOURCE_INDEX; | ||
| 388 | + }elseif($source == BTemplate::SOURCE_PRODUCT){ | ||
| 437 | $type = RouteMap::SOURCE_PRODUCT; | 389 | $type = RouteMap::SOURCE_PRODUCT; |
| 438 | - $productModel = new Product(); | ||
| 439 | - $productInfo = $productModel->read(['id'=>$source_id],['route']); | ||
| 440 | - $route = $productInfo['route']; | ||
| 441 | - }elseif($source == 3 && $source_id != 0){ | 390 | + }elseif($source == BTemplate::SOURCE_BLOG){ |
| 442 | $type = RouteMap::SOURCE_BLOG; | 391 | $type = RouteMap::SOURCE_BLOG; |
| 443 | - $blogModel = new Blog(); | ||
| 444 | - $blogInfo = $blogModel->read(['id'=>$source_id],['url']); | ||
| 445 | - $route = $blogInfo['url']; | ||
| 446 | - }elseif($source == 4 && $source_id != 0){ | 392 | + }elseif($source == BTemplate::SOURCE_NEWS){ |
| 447 | $type = RouteMap::SOURCE_NEWS; | 393 | $type = RouteMap::SOURCE_NEWS; |
| 448 | - $newsModel = new News(); | ||
| 449 | - $newsInfo = $newsModel->read(['id'=>$source_id],['url']); | ||
| 450 | - $route = $newsInfo['url']; | ||
| 451 | }else{ | 394 | }else{ |
| 452 | $type = 'all'; | 395 | $type = 'all'; |
| 453 | - $route = 'all'; | ||
| 454 | } | 396 | } |
| 397 | + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); | ||
| 398 | + }else{ | ||
| 399 | + $type = RouteMap::SOURCE_MODULE; | ||
| 400 | + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); | ||
| 455 | } | 401 | } |
| 456 | $this->addUpdateNotify($type,$route); | 402 | $this->addUpdateNotify($type,$route); |
| 457 | return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); | 403 | return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); |
| @@ -464,7 +410,7 @@ class VisualizationLogic extends BaseLogic | @@ -464,7 +410,7 @@ class VisualizationLogic extends BaseLogic | ||
| 464 | * @method :post | 410 | * @method :post |
| 465 | * @time :2023/8/23 11:16 | 411 | * @time :2023/8/23 11:16 |
| 466 | */ | 412 | */ |
| 467 | - public function setTemplateLog($template_id,$html,$source,$source_id){ | 413 | + public function setTemplateLog($template_id,$html,$source,$source_id,$is_custom){ |
| 468 | $data = [ | 414 | $data = [ |
| 469 | 'template_id'=>$template_id, | 415 | 'template_id'=>$template_id, |
| 470 | 'project_id'=>$this->user['project_id'], | 416 | 'project_id'=>$this->user['project_id'], |
| @@ -478,6 +424,7 @@ class VisualizationLogic extends BaseLogic | @@ -478,6 +424,7 @@ class VisualizationLogic extends BaseLogic | ||
| 478 | 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | 424 | 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), |
| 479 | 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | 425 | 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), |
| 480 | 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | 426 | 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), |
| 427 | + 'is_custom'=>$is_custom | ||
| 481 | ]; | 428 | ]; |
| 482 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); | 429 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); |
| 483 | $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | 430 | $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); |
| @@ -325,4 +325,16 @@ class CustomModuleContentLogic extends BaseLogic | @@ -325,4 +325,16 @@ class CustomModuleContentLogic extends BaseLogic | ||
| 325 | $this->curlDelRoute(['route'=>$info['route']]); | 325 | $this->curlDelRoute(['route'=>$info['route']]); |
| 326 | return $this->success(); | 326 | return $this->success(); |
| 327 | } | 327 | } |
| 328 | + | ||
| 329 | + /** | ||
| 330 | + * @remark :排序 | ||
| 331 | + * @name :contentSort | ||
| 332 | + * @author :lyh | ||
| 333 | + * @method :post | ||
| 334 | + * @time :2023/12/15 17:47 | ||
| 335 | + */ | ||
| 336 | + public function contentSort(){ | ||
| 337 | + $this->model->edit(['sort' => $this->param['sort']], ['id'=>$this->param['id']]); | ||
| 338 | + return $this->success(); | ||
| 339 | + } | ||
| 328 | } | 340 | } |
| @@ -82,23 +82,23 @@ class NavLogic extends BaseLogic | @@ -82,23 +82,23 @@ class NavLogic extends BaseLogic | ||
| 82 | */ | 82 | */ |
| 83 | public function navSave() | 83 | public function navSave() |
| 84 | { | 84 | { |
| 85 | + $data = $this->handleParam($this->param);//处理保存字符串 | ||
| 85 | if(!empty($this->param['location'])){ | 86 | if(!empty($this->param['location'])){ |
| 86 | if($this->param['location'] == 'header'){ | 87 | if($this->param['location'] == 'header'){ |
| 87 | - $this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID; | 88 | + $data['group_id'] = BNavGroup::DEFAULT_HEADER_ID; |
| 88 | } | 89 | } |
| 89 | if($this->param['location'] == 'footer'){ | 90 | if($this->param['location'] == 'footer'){ |
| 90 | - $this->param['group_id'] = BNavGroup::DEFAULT_FOOTER_ID; | 91 | + $data['group_id'] = BNavGroup::DEFAULT_FOOTER_ID; |
| 91 | } | 92 | } |
| 92 | } | 93 | } |
| 93 | - unset($this->param['able_import']); | ||
| 94 | - $this->param['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : ''); | ||
| 95 | - $this->param['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : ''); | 94 | + $data['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : ''); |
| 95 | + $data['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : ''); | ||
| 96 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 96 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 97 | $this->handleEditParam();//验证是否可编辑分类 | 97 | $this->handleEditParam();//验证是否可编辑分类 |
| 98 | - $this->model->edit($this->param,['id'=>$this->param['id']]); | 98 | + $this->model->edit($data,['id'=>$this->param['id']]); |
| 99 | }else{ | 99 | }else{ |
| 100 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 101 | - $this->model->add($this->param); | 100 | + $data['project_id'] = $this->user['project_id']; |
| 101 | + $this->model->add($data); | ||
| 102 | } | 102 | } |
| 103 | //编辑菜单后,通知更新 | 103 | //编辑菜单后,通知更新 |
| 104 | $this->addUpdateNotify(RouteMap::SOURCE_NAV, 'all'); | 104 | $this->addUpdateNotify(RouteMap::SOURCE_NAV, 'all'); |
| @@ -106,6 +106,26 @@ class NavLogic extends BaseLogic | @@ -106,6 +106,26 @@ class NavLogic extends BaseLogic | ||
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | /** | 108 | /** |
| 109 | + * @remark :保存时处理数据 | ||
| 110 | + * @name :saveHandleParam | ||
| 111 | + * @author :lyh | ||
| 112 | + * @method :post | ||
| 113 | + * @time :2023/12/15 14:26 | ||
| 114 | + */ | ||
| 115 | + public function handleParam($param){ | ||
| 116 | + $data = [ | ||
| 117 | + 'pid'=>$param['pid'] ?? 0, | ||
| 118 | + 'name'=>$param['name'] ?? '', | ||
| 119 | + 'location'=>$param['location'] ?? '', | ||
| 120 | + 'url'=>$param['url'], | ||
| 121 | + 'status'=>$param['status'] ?? 1, | ||
| 122 | + 'target'=>$param['target'] ?? 1, | ||
| 123 | + 'remark'=>$param['remark'] ?? '', | ||
| 124 | + ]; | ||
| 125 | + return $this->success($data); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /** | ||
| 109 | * @remark :验证是否可编辑 | 129 | * @remark :验证是否可编辑 |
| 110 | * @name :handleEditParam | 130 | * @name :handleEditParam |
| 111 | * @author :lyh | 131 | * @author :lyh |
| @@ -117,10 +137,6 @@ class NavLogic extends BaseLogic | @@ -117,10 +137,6 @@ class NavLogic extends BaseLogic | ||
| 117 | if($this->param['pid'] == $info['id']){ | 137 | if($this->param['pid'] == $info['id']){ |
| 118 | $this->fail('不允许成为自己的上级'); | 138 | $this->fail('不允许成为自己的上级'); |
| 119 | } | 139 | } |
| 120 | -// $pid_info = $this->model->read(['pid'=>$this->param['id']]); | ||
| 121 | -// if(($pid_info !== false) && $this->param['pid'] != $info['pid']){ | ||
| 122 | -// $this->fail('当前菜单拥有子集不允许修改上级'); | ||
| 123 | -// } | ||
| 124 | return $this->success(); | 140 | return $this->success(); |
| 125 | } | 141 | } |
| 126 | 142 |
| @@ -71,7 +71,7 @@ class KeywordLogic extends BaseLogic | @@ -71,7 +71,7 @@ class KeywordLogic extends BaseLogic | ||
| 71 | DB::commit(); | 71 | DB::commit(); |
| 72 | }catch (\Exception $e){ | 72 | }catch (\Exception $e){ |
| 73 | DB::rollBack(); | 73 | DB::rollBack(); |
| 74 | - $this->fail('保存失败,请连续管理员'); | 74 | + $this->fail('保存失败'); |
| 75 | } | 75 | } |
| 76 | $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route); | 76 | $this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route); |
| 77 | $this->curlDelRoute(['new_route'=>$route]); | 77 | $this->curlDelRoute(['new_route'=>$route]); |
| @@ -137,12 +137,12 @@ class KeywordLogic extends BaseLogic | @@ -137,12 +137,12 @@ class KeywordLogic extends BaseLogic | ||
| 137 | $param['title'] = $v; | 137 | $param['title'] = $v; |
| 138 | $id = $this->model->insertGetId($param); | 138 | $id = $this->model->insertGetId($param); |
| 139 | $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 139 | $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 140 | - $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 141 | // $this->curlDelRoute(['new_route'=>$route]); | 140 | // $this->curlDelRoute(['new_route'=>$route]); |
| 141 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 142 | } | 142 | } |
| 143 | } | 143 | } |
| 144 | }catch (\Exception $e){ | 144 | }catch (\Exception $e){ |
| 145 | - $this->fail('保存失败,请联系管理员'); | 145 | + $this->fail('error'); |
| 146 | } | 146 | } |
| 147 | return $this->success(); | 147 | return $this->success(); |
| 148 | } | 148 | } |
| @@ -181,8 +181,8 @@ class KeywordLogic extends BaseLogic | @@ -181,8 +181,8 @@ class KeywordLogic extends BaseLogic | ||
| 181 | //删除路由映射 | 181 | //删除路由映射 |
| 182 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 182 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 183 | //生成一条删除路由记录 | 183 | //生成一条删除路由记录 |
| 184 | -// $info = $this->model->read(['id'=>$id],['id','route']); | ||
| 185 | -// $this->curlDelRoute(['route'=>$info['route']]); | 184 | + $info = $this->model->read(['id'=>$id],['id','route']); |
| 185 | + $this->curlDelRoute(['route'=>$info['route']]); | ||
| 186 | return $this->success(); | 186 | return $this->success(); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| @@ -197,7 +197,7 @@ class KeywordLogic extends BaseLogic | @@ -197,7 +197,7 @@ class KeywordLogic extends BaseLogic | ||
| 197 | */ | 197 | */ |
| 198 | public function importProductKeyword($project_id,$keyword){ | 198 | public function importProductKeyword($project_id,$keyword){ |
| 199 | $return = []; | 199 | $return = []; |
| 200 | - $keyword_arr = explode('^v6sp$',$keyword); | 200 | + $keyword_arr = explode(',',$keyword); |
| 201 | foreach ($keyword_arr as $v){ | 201 | foreach ($keyword_arr as $v){ |
| 202 | if($v){ | 202 | if($v){ |
| 203 | $keyword_info = $this->model->read(['title'=>$v]); | 203 | $keyword_info = $this->model->read(['title'=>$v]); |
| @@ -19,6 +19,6 @@ class CustomModuleContent extends Base | @@ -19,6 +19,6 @@ class CustomModuleContent extends Base | ||
| 19 | protected $connection = 'custom_mysql'; | 19 | protected $connection = 'custom_mysql'; |
| 20 | 20 | ||
| 21 | public function getCategoryIdAttribute($value){ | 21 | public function getCategoryIdAttribute($value){ |
| 22 | - return Arr::setToArr(trim($value,',')); | 22 | + return explode(',',trim($value,',')); |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| @@ -16,6 +16,7 @@ class Project extends Base | @@ -16,6 +16,7 @@ class Project extends Base | ||
| 16 | 16 | ||
| 17 | const DATABASE_NAME_FIX = 'gl_data_'; | 17 | const DATABASE_NAME_FIX = 'gl_data_'; |
| 18 | 18 | ||
| 19 | + const CUSTOMIZED_ONE = 1;//定制项目 | ||
| 19 | const DEMO_PROJECT_ID = 1; | 20 | const DEMO_PROJECT_ID = 1; |
| 20 | 21 | ||
| 21 | const STATUS_ONE = 1;//审核通过 | 22 | const STATUS_ONE = 1;//审核通过 |
| @@ -54,7 +54,6 @@ class RouteMap extends Base | @@ -54,7 +54,6 @@ class RouteMap extends Base | ||
| 54 | * @date 2023/4/17 | 54 | * @date 2023/4/17 |
| 55 | */ | 55 | */ |
| 56 | public static function generateRoute($title, $source, $source_id, $project_id){ | 56 | public static function generateRoute($title, $source, $source_id, $project_id){ |
| 57 | - // 所有的都需要翻译成为英文 | ||
| 58 | $title = Translate::tran($title, 'en'); | 57 | $title = Translate::tran($title, 'en'); |
| 59 | $i=1; | 58 | $i=1; |
| 60 | $sign = generateRoute($title); | 59 | $sign = generateRoute($title); |
| @@ -12,21 +12,29 @@ use App\Models\Base; | @@ -12,21 +12,29 @@ use App\Models\Base; | ||
| 12 | */ | 12 | */ |
| 13 | class BTemplate extends Base | 13 | class BTemplate extends Base |
| 14 | { | 14 | { |
| 15 | + const SOURCE_CUSTOM = 1;//自定义模块 | ||
| 15 | const SOURCE_HOME = 1;//首页 | 16 | const SOURCE_HOME = 1;//首页 |
| 16 | const SOURCE_PRODUCT = 2;//产品 | 17 | const SOURCE_PRODUCT = 2;//产品 |
| 17 | const SOURCE_BLOG = 3;//博客 | 18 | const SOURCE_BLOG = 3;//博客 |
| 18 | const SOURCE_NEWS = 4;//新闻详情页 | 19 | const SOURCE_NEWS = 4;//新闻详情页 |
| 19 | const SOURCE_KEYWORD = 5;//聚合页 | 20 | const SOURCE_KEYWORD = 5;//聚合页 |
| 21 | + | ||
| 22 | + const ALL_HTML = 1;//无需拼接数据,获取整个html | ||
| 23 | + | ||
| 24 | + const PAGE_HTML = 0;//默认保存方式为0, | ||
| 25 | + const SOURCE_VISUALIZATION = 1;//定制项目 | ||
| 26 | + | ||
| 27 | + const SOURCE_NO_CUSTOM = 0;//默认模块 | ||
| 20 | const STATUS = 0; | 28 | const STATUS = 0; |
| 21 | 29 | ||
| 22 | - const TYPE_ONE = 1; | ||
| 23 | - const TYPE_TWO = 2; | ||
| 24 | - const TYPE_THREE = 3; | ||
| 25 | - const TYPE_FOUR = 4; | ||
| 26 | - const TYPE_FIVE = 5; | ||
| 27 | - const TYPE_SIX = 6; | ||
| 28 | - const TYPE_SEVEN = 7; | ||
| 29 | - const TYPE_EIGHT = 8; | 30 | + const TYPE_ONE = 1;//首页类型 |
| 31 | + const TYPE_TWO = 2;//产品详情 | ||
| 32 | + const TYPE_THREE = 3;//产品列表 | ||
| 33 | + const TYPE_FOUR = 4;//博客详情 | ||
| 34 | + const TYPE_FIVE = 5;//博客列表 | ||
| 35 | + const TYPE_SIX = 6;//新闻详情 | ||
| 36 | + const TYPE_SEVEN = 7;//新闻列表 | ||
| 37 | + const TYPE_EIGHT = 8;//自定义页面 | ||
| 30 | 38 | ||
| 31 | protected $table = 'gl_web_template'; | 39 | protected $table = 'gl_web_template'; |
| 32 | //连接数据库 | 40 | //连接数据库 |
| @@ -96,5 +104,12 @@ class BTemplate extends Base | @@ -96,5 +104,12 @@ class BTemplate extends Base | ||
| 96 | ], | 104 | ], |
| 97 | ] | 105 | ] |
| 98 | ]; | 106 | ]; |
| 107 | + | ||
| 108 | + public function typeMap() | ||
| 109 | + { | ||
| 110 | + return [ | ||
| 111 | + self::SOURCE_HOME => 'xxxx', | ||
| 112 | + ]; | ||
| 113 | + } | ||
| 99 | } | 114 | } |
| 100 | 115 |
| @@ -301,6 +301,13 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -301,6 +301,13 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 301 | Route::any('/getTimeZone', [Aside\Optimize\InquiryInfoController::class, 'getTimeZone'])->name('admin.inquiry_getTimeZone'); | 301 | Route::any('/getTimeZone', [Aside\Optimize\InquiryInfoController::class, 'getTimeZone'])->name('admin.inquiry_getTimeZone'); |
| 302 | Route::any('/getInternalCount', [Aside\Optimize\InquiryInfoController::class, 'getInternalCount'])->name('admin.inquiry_getInternalCount'); | 302 | Route::any('/getInternalCount', [Aside\Optimize\InquiryInfoController::class, 'getInternalCount'])->name('admin.inquiry_getInternalCount'); |
| 303 | }); | 303 | }); |
| 304 | + | ||
| 305 | + Route::prefix('custom_module')->group(function () { | ||
| 306 | + Route::any('/', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); | ||
| 307 | + Route::any('/save', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save'); | ||
| 308 | + Route::any('/del', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); | ||
| 309 | + }); | ||
| 310 | + | ||
| 304 | // 公共主题模版 | 311 | // 公共主题模版 |
| 305 | Route::prefix('template')->group(function () { | 312 | Route::prefix('template')->group(function () { |
| 306 | Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists'); | 313 | Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists'); |
| @@ -13,6 +13,8 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -13,6 +13,8 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 13 | Route::any('/unbindWechat', [\App\Http\Controllers\Bside\BCom\ComController::class, 'unbindWechat'])->name('unbindWechat'); | 13 | Route::any('/unbindWechat', [\App\Http\Controllers\Bside\BCom\ComController::class, 'unbindWechat'])->name('unbindWechat'); |
| 14 | //获取当前登录用户菜单 | 14 | //获取当前登录用户菜单 |
| 15 | Route::any('/get_menu', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_menu'])->name('get_menu'); | 15 | Route::any('/get_menu', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_menu'])->name('get_menu'); |
| 16 | + //自定义菜单 | ||
| 17 | + Route::any('/getCustomMenu', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getCustomMenu'])->name('get_getCustomMenu'); | ||
| 16 | //获取当前登录用户项目详情 | 18 | //获取当前登录用户项目详情 |
| 17 | Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project'); | 19 | Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project'); |
| 18 | Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken'); | 20 | Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken'); |
| @@ -443,6 +445,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -443,6 +445,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 443 | Route::any('/getCategoryList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'getCategoryList'])->name('custom_content_getCategoryList'); | 445 | Route::any('/getCategoryList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'getCategoryList'])->name('custom_content_getCategoryList'); |
| 444 | Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info'); | 446 | Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info'); |
| 445 | Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save'); | 447 | Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save'); |
| 448 | + Route::any('/sort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'sort'])->name('custom_content_sort'); | ||
| 446 | Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del'); | 449 | Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del'); |
| 447 | }); | 450 | }); |
| 448 | 451 |
-
请 注册 或 登录 后发表评论