作者 刘锟

Merge remote-tracking branch 'origin/develop' into akun

... ... @@ -77,6 +77,7 @@ class SyncProject extends Command
if(!$data || empty($data['data'])){
LogUtils::error('OaGlobalsoApi order_info error', $data);
$this->retry($item, '未获取到订单信息');
continue;
}
if($data['data']['order_type'] == '首次'){
$this->sync($data['data'],$is_update);
... ... @@ -275,6 +276,7 @@ class SyncProject extends Command
$projectModel = new Project();
$info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
if($info !== false){
unset($param['type']); //更新的 不更新状态了
$projectModel->edit($param, ['id' => $info['id']]);
return $info['id'];
}else{
... ...
... ... @@ -110,7 +110,7 @@ class GoogleSpeedApi
try {
if($url){
$params = [
'url' => $url
'url' => base64_encode($url)
];
$res = HttpUtils::get('http://pagespeed.quanqiusou.cn/api.php', $params);
if ($res) {
... ...
... ... @@ -207,7 +207,7 @@ class LoginController extends BaseController
* @time :2023/9/1 10:12
*/
public function getWechatLoginInfo(){
$this->request->validate([
$this->param = $this->request->validate([
'ticket' => 'required',
],[
'ticket.required' => 'ticket不能为空',
... ...
<?php
namespace App\Http\Controllers\Bside\Nav;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Nav\BNavGroup;
use Illuminate\Http\Request;
/**
* 导航组
* Class NavGroupController
* @package App\Http\Controllers\Bside\Nav
* @author zbj
* @date 2023/10/9
*/
class NavGroupController extends BaseController
{
public function index(BNavGroup $nav_group){
$this->map['project_id'] = $this->user['project_id'];
$lists = $nav_group->list($this->map, 'id', ['id', 'name'], 'asc');
$this->response('success',Code::SUCCESS,$lists);
}
public function save(Request $request){
$request->validate([
'name'=> ['required','max:100'],
],[
'name.required' => '菜单组名称不能为空',
'name.max' => '菜单组名称不能超过100个字符'
]);
if(empty($this->param['id'])){
$nav_group = new BNavGroup();
}else{
if(in_array($this->param['id'], [BNavGroup::DEFAULT_HEADER_ID,BNavGroup::DEFAULT_FOOTER_ID])){
$this->fail('系统内置菜单组不能修改');
}
$nav_group = BNavGroup::find($this->param['id']);
if(!$nav_group){
$this->fail('数据不存在或者已经删除');
}
}
$nav_group->project_id = $this->user['project_id'];
$nav_group->name = $this->param['name'];
$nav_group->save();
$this->response('success');
}
public function delete(Request $request){
$request->validate([
'id'=>'required',
],[
'id.required' => 'ID不能为空',
]);
if(in_array($this->param['id'], [BNavGroup::DEFAULT_HEADER_ID,BNavGroup::DEFAULT_FOOTER_ID])){
$this->fail('系统内置菜单组不能删除');
}
$nav_group = BNavGroup::find($this->param['id']);
if(!$nav_group){
$this->response('数据不存在或者已经删除');
}
$nav_group->delete();
$this->response('success');
}
}
... ...
... ... @@ -38,7 +38,7 @@ class CategoryController extends BaseController
if(!empty($list)){
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'];
$v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();
$v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->where(['status'=>1])->count();
$v['image_link'] = getImageUrl($v['image']);
$list[$k] = $v;
}
... ...
... ... @@ -110,11 +110,12 @@ class FileController
*/
public function single(&$files){
$hash = hash_file('md5', $files->getPathname());
$name = $files->getClientOriginalName();
//查看文件是否存在
$fileModel = new File();
$file_hash = $fileModel->read(['hash'=>$hash]);
if($file_hash !== false){
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path']));
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
}
$url = $this->config['root'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
... ... @@ -128,8 +129,8 @@ class FileController
return $this->response($files->getError(), Code::USER_ERROR);
}
}
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType());
return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
/**
... ... @@ -139,7 +140,7 @@ class FileController
* @method :post
* @time :2023/7/19 16:38
*/
public function saveMysql(&$fileModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = ''){
public function saveMysql(&$fileModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = '',$name=''){
$data = [
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
... ... @@ -149,6 +150,7 @@ class FileController
'refer'=>$this->param['refer'] ?? 1,
'is_cos'=>$is_cos,
'mime'=>$mime,
'name'=>$name,
];
$rs = $fileModel->add($data);
if ($rs === false) {
... ... @@ -168,10 +170,11 @@ class FileController
$data = [];
foreach ($files as $file) {
$fileModel = new File();
$name = $file->getClientOriginalName();
$hash = hash_file('md5', $file->getPathname());
$file_hash = $fileModel->read(['hash'=>$hash]);
if($file_hash !== false){
$data[] = $this->responseData($file_hash['path']);
$data[] = $this->responseData($file_hash['path'], $name);
continue;
}
$url = $this->config['root'].'/'.$this->path;
... ... @@ -189,8 +192,8 @@ class FileController
}
$size = $file->getSize();
$mime = $file->getMimeType();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
$data[] = $this->responseData($this->path.'/'.$fileName);
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
$data[] = $this->responseData($this->path.'/'.$fileName, $name);
}
$this->response('资源',Code::SUCCESS,$data);
}
... ... @@ -230,11 +233,11 @@ class FileController
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$fileUrl = getFileUrl($info['path'],$info['is_cos']);
$fileName = basename($fileUrl); // 要保存的文件名
// $fileName = basename($fileUrl); // 要保存的文件名
// 设置响应头
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Disposition: attachment; filename="' . $info['name'] . '"');
// 下载文件
readfile($fileUrl);
}
... ... @@ -277,7 +280,7 @@ class FileController
}
$this->map['refer'] = 1;
$fileModel = new File();
$lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at']);
$lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']);
foreach ($lists as $k => $v){
$v['file_link'] = getFileUrl($v['path']);
$lists[$k] = $v;
... ... @@ -292,10 +295,11 @@ class FileController
* @method :post
* @time :2023/7/26 13:41
*/
public function responseData($path){
public function responseData($path, $name){
$data = [
'file'=>$path,
'file_link'=>getFileUrl($path,$this->upload_location),
'name'=>$name,
];
return $data;
}
... ... @@ -313,7 +317,7 @@ class FileController
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$data = ['file_download'=>url('a/download_files?path='.$info['path'])];
$data = ['file_download'=>url('a/download_files?path='.$info['path']), 'name' => $info['name']];
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -180,6 +180,7 @@ class ImageController extends Controller
*/
public function single(&$files){
$hash = hash_file('md5', $files->getPathname());
$name = $files->getClientOriginalName();
//查看文件是否存在
$imageModel = new ImageModel();
//查看图片是否已上传
... ... @@ -189,7 +190,7 @@ class ImageController extends Controller
}
$image_hash = $imageModel->read($param);
if($image_hash !== false){
return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path']));
return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name));
}
//保存路径
$url = $this->config['root'].$this->path;
... ... @@ -202,8 +203,8 @@ class ImageController extends Controller
}else{
$files->move($url,$fileName);
}
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType());
return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
/**
... ... @@ -213,7 +214,7 @@ class ImageController extends Controller
* @method :post
* @time :2023/7/19 16:38
*/
public function saveMysql(&$imageModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = ''){
public function saveMysql(&$imageModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = '', $name=''){
$data = [
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
... ... @@ -224,6 +225,7 @@ class ImageController extends Controller
'is_cos'=>$is_cos,
'mime'=>$mime,
'project_id'=>$this->cache['project_id'] ?? 0,
'name'=>$name,
];
$rs = $imageModel->add($data);
if ($rs === false) {
... ... @@ -258,6 +260,7 @@ class ImageController extends Controller
foreach ($files as $file) {
$imageModel = new ImageModel();
$hash = hash_file('md5', $file->getPathname());
$name = $files->getClientOriginalName();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
... ... @@ -279,8 +282,8 @@ class ImageController extends Controller
$file->move($url,$fileName);
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType());
$data[] = $this->responseData($this->path.'/'.$fileName);
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
}
$this->response('图片资源',Code::SUCCESS,$data);
}
... ... @@ -309,11 +312,11 @@ class ImageController extends Controller
$this->response('指定图片已被系统删除!', Code::USER_ERROR);
}
}
$fileName = basename($info['path']); // 要保存的文件名
// $fileName = basename($info['path']); // 要保存的文件名
// 设置响应头
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Disposition: attachment; filename="' . $info['name'] . '"');
// 下载文件
readfile($fileUrl);
}
... ... @@ -392,10 +395,11 @@ class ImageController extends Controller
* @method :post
* @time :2023/7/26 13:41
*/
public function responseData($path = ''){
public function responseData($path = '', $name = ''){
$data = [
'image'=>$path,
'image_link'=>getImageUrl($path),
'name'=>$name,
];
return $data;
}
... ... @@ -413,7 +417,7 @@ class ImageController extends Controller
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$data = ['image_download'=>url('a/download_images?path='.$info['path'])];
$data = ['image_download'=>url('a/download_images?path='.$info['path']), 'name' => $info['name']];
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -113,7 +113,7 @@ class ProjectLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('请填写完整后再提交');
}
return $this->success();
}
... ... @@ -158,8 +158,6 @@ class ProjectLogic extends BaseLogic
'upload_max_size' => $param['upload_config']['upload_max_size'] ?? 5,
];
}
$this->model->edit($param,['id'=>$param['id']]);
Common::del_user_cache($this->model->getTable(),$param['id']);
return $this->success();
... ... @@ -196,9 +194,6 @@ class ProjectLogic extends BaseLogic
*/
protected function saveProjectDeployBuild($deploy_build){
$deployBuildModel = new DeployBuild();
if(isset($deploy_build['configuration']['build_status']) && ($deploy_build['configuration']['build_status'] == 0)){
}
$deploy_build['configuration'] = Arr::a2s(!empty($deploy_build['configuration']) ? $deploy_build['configuration'] : []);
$deployBuildModel->edit($deploy_build,['id'=>$deploy_build['id']]);
return $this->success();
... ...
... ... @@ -7,7 +7,6 @@ use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\Template;
use App\Models\Template\Setting;
use Illuminate\Support\Facades\DB;
use mysql_xdevapi\Exception;
class ATemplateLogic extends BaseLogic
{
... ... @@ -141,7 +140,7 @@ class ATemplateLogic extends BaseLogic
];
$serviceSettingModel->insert($data);
DB::commit();
}catch (Exception $e){
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
... ...
... ... @@ -9,6 +9,7 @@ use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateLog;
... ... @@ -103,6 +104,13 @@ class BTemplateLogic extends BaseLogic
$ATemplateModel = new Template();
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
}else{
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
}
//渲染首页数据
$ATemplateModel = new Template();
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
... ... @@ -121,23 +129,34 @@ class BTemplateLogic extends BaseLogic
* @time :2023/7/25 16:40
*/
public function productHtml($info,$source,$source_id){
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
$this->fail('请先装修首页');
}
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
if($TemplateInfo === false){
//获取首页数据
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
$this->fail('请先装修首页');
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$this->getProductModule().$commonInfo['footer_html'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
}
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
}else{
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
$this->fail('请先装修首页');
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
}
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
}
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
return $this->success($TemplateInfo);
... ... @@ -186,7 +205,8 @@ class BTemplateLogic extends BaseLogic
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
//字符串截取
$this->param = $this->stringProcessing($this->param);
$this->param = $this->templateSaveParam($this->param);
$this->saveCommonTemplate($this->param);
$this->param = $this->templateSaveParam($this->param);//组装数据
if($info === false){
$this->model->add($this->param);
}else{
... ... @@ -196,7 +216,7 @@ class BTemplateLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('系统错误,请联系管理员');
}
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
... ... @@ -204,6 +224,34 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($param){
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id']]);
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
$data = [
'head_html'=>$param['head_html'],
'head_css'=>$param['head_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
if($info === false){
$data['template_id'] = $param['template_id'];
$data['project_id'] = $this->user['project_id'];
$templateCommonModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
}
return $this->success();
}
/**
* @remark :生成记录
* @name :setTemplateLog
* @author :lyh
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Nav;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Nav\BNav;
use App\Models\Nav\BNavGroup;
use App\Models\RouteMap\RouteMap;
use Illuminate\Support\Facades\DB;
... ... @@ -36,6 +37,14 @@ class NavLogic extends BaseLogic
{
DB::beginTransaction();
try {
if(!empty($this->param['location'])){
if($this->param['location'] == 'header'){
$this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID;
}
if($this->param['location'] == 'footer'){
$this->param['group_id'] = BNavGroup::DEFAULT_FOOTER_ID;
}
}
$this->param['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : '');
$this->param['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : '');
if(isset($this->param['id']) && !empty($this->param['id'])){
... ...
... ... @@ -336,12 +336,9 @@ class ProductLogic extends BaseLogic
public function batchSetCategory(){
DB::beginTransaction();
try {
//删除分类关联表记录
$categoryRelatedModel = new CategoryRelated();
$categoryRelatedModel->del(['product_id'=>['in',$this->param['id']]]);
//批量
$param = [
'category_id'=>Arr::arrToSet($this->param['category_id']),
'category_id'=>','.Arr::arrToSet($this->param['category_id']).',',
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
... ... @@ -349,7 +346,7 @@ class ProductLogic extends BaseLogic
//对应添加关联表
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
... ...
... ... @@ -33,7 +33,7 @@ class WebSettingReceivingLogic extends BaseLogic
* @time :2023/5/8 16:26
*/
public function setting_receiving_save(){
// try {
try {
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['project_id'] = $this->user['project_id'];
... ... @@ -42,9 +42,9 @@ class WebSettingReceivingLogic extends BaseLogic
$this->param['data'][$k] = $v;
}
$this->model->insert($this->param['data']);
// }catch (\Exception $e){
// $this->fail('error');
// }
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -41,6 +41,9 @@ class WebSettingServiceLogic extends BaseLogic
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
if(!isset($v['values']) || empty($v['values'])){
$v['values'] = '';
}
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
... ... @@ -50,7 +53,7 @@ class WebSettingServiceLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
... ...
... ... @@ -32,6 +32,7 @@ class NavRequest extends FormRequest
public function rules()
{
$rule = [
// 'group_id' => ['required','integer'],
'pid' => ['required','integer'],
'name' => ['required','max:100'],
];
... ... @@ -41,6 +42,8 @@ class NavRequest extends FormRequest
public function messages()
{
return [
'group_id.required' => '未定义菜单组',
'group_id.integer' => '菜单组错误',
'pid.required' => '上级选择错误',
'pid.gte' => '上级选择错误',
'pid.integer' => '上级选择错误',
... ...
<?php
namespace App\Models\Nav;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class BNavGroup
* @package App\Models\Nav
* @author zbj
* @date 2023/10/9
*/
class BNavGroup extends Base
{
protected $table = 'gl_web_nav_group';
//连接数据库
protected $connection = 'custom_mysql';
use SoftDeletes;
public $hidden = ['deleted_at'];
const DEFAULT_HEADER_ID = 1;
const DEFAULT_FOOTER_ID = 2;
}
... ...
<?php
/**
* @remark :
* @name :BTemplateCommon.php
* @author :lyh
* @method :post
* @time :2023/10/13 11:45
*/
namespace App\Models\Template;
use App\Models\Base;
class BTemplateCommon extends Base
{
protected $table = 'gl_web_template_common';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -103,14 +103,20 @@ class ProjectServer extends BaseService
if(empty($info)){
$created_at = date('Y-m-d H:i:s');
$data = [
['project_id'=>$project_id,'name'=>'Home','url'=>'nav-home-'.$project_id,'location'=>'header','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'Products','url'=>'nav-product'.$project_id,'location'=>'header','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'News','url'=>'nav-news'.$project_id,'location'=>'header','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'ABOUT US','url'=>'nav-about-us'.$project_id,'location'=>'footer','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'Contact Us','url'=>'nav-contact-us'.$project_id,'location'=>'footer','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'FAQ','url'=>'nav-faq'.$project_id,'location'=>'footer','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'Home','url'=>'nav-home-'.$project_id,'location'=>'header','group_id'=>1,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'Products','url'=>'nav-product'.$project_id,'location'=>'header','group_id'=>1,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'News','url'=>'nav-news'.$project_id,'location'=>'header','group_id'=>1,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'ABOUT US','url'=>'nav-about-us'.$project_id,'location'=>'footer','group_id'=>2,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'Contact Us','url'=>'nav-contact-us'.$project_id,'location'=>'footer','group_id'=>2,'created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'FAQ','url'=>'nav-faq'.$project_id,'location'=>'footer','group_id'=>2,'created_at'=>$created_at,'updated_at'=>$created_at],
];
DB::connection('custom_mysql')->table('gl_web_nav')->insert($data);
$data = [
['project_id'=>$project_id,'name'=>'全局顶部菜单','created_at'=>$created_at,'updated_at'=>$created_at],
['project_id'=>$project_id,'name'=>'底部菜单','created_at'=>$created_at,'updated_at'=>$created_at],
];
DB::connection('custom_mysql')->table('gl_web_nav_group')->insert($data);
}
DB::disconnect('custom_mysql');
return true;
... ...