作者 lyh

gx

@@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
7 */ 7 */
8 namespace App\Console\Commands\Test; 8 namespace App\Console\Commands\Test;
9 9
  10 +use App\Models\Devops\ServerConfig;
  11 +use App\Services\ProjectServer;
10 use GuzzleHttp\Client; 12 use GuzzleHttp\Client;
11 use Illuminate\Console\Command; 13 use Illuminate\Console\Command;
12 use Illuminate\Support\Facades\DB; 14 use Illuminate\Support\Facades\DB;
@@ -42,6 +44,15 @@ class Demo extends Command @@ -42,6 +44,15 @@ class Demo extends Command
42 */ 44 */
43 public function handle() 45 public function handle()
44 { 46 {
  47 + //切换数据库配置
  48 + $project = ProjectServer::useProject(1);
  49 + //创建数据库
  50 + ProjectServer::createDatabase($project);
  51 + //创建表
  52 + ProjectServer::initTable($project);
  53 +
  54 + dd(1);
  55 +
45 $sql = 'CREATE DATABASE database_name;'; 56 $sql = 'CREATE DATABASE database_name;';
46 $results = DB::select($sql); 57 $results = DB::select($sql);
47 dd($results); 58 dd($results);
@@ -124,15 +124,6 @@ class Handler extends ExceptionHandler @@ -124,15 +124,6 @@ class Handler extends ExceptionHandler
124 } else { 124 } else {
125 $code = Code::SYSTEM_ERROR(); 125 $code = Code::SYSTEM_ERROR();
126 } 126 }
127 - //钉钉通知错误信息  
128 - if (in_array(config('app.env'), ['test', 'production']) && (in_array(substr($code, 0, 1), ['B', 'C']))) {  
129 - $exceptionMessage = "路由:" . Route::current()->uri .  
130 - "-----错误CODE:" . $exception->getCode() .  
131 - "-----错误message:" . $exception->getMessage() .  
132 - '------错误文件:' . $exception->getFile() . '-------错误行数:' .  
133 - $exception->getLine();  
134 - (new DingService())->handle(['keyword' => "ERROR", 'msg' => config('app.env') . '环境报错:' . $exceptionMessage, 'isAtAll' => false]);  
135 - }  
136 //开启debug 错误原样输出 127 //开启debug 错误原样输出
137 $debub = config('app.debug'); 128 $debub = config('app.debug');
138 $message = $debub ? $message : ($code->description ?? $message); 129 $message = $debub ? $message : ($code->description ?? $message);
@@ -41,16 +41,6 @@ class BaseController extends Controller @@ -41,16 +41,6 @@ class BaseController extends Controller
41 $this->set_user_log(); 41 $this->set_user_log();
42 } 42 }
43 } 43 }
44 -  
45 - /**  
46 - * @name :ceshi  
47 - * @author :lyh  
48 - * @method :post  
49 - * @time :2023/5/9 11:43  
50 - */  
51 - public function ceshi(){  
52 -  
53 - }  
54 /** 44 /**
55 * @name 参数过滤 45 * @name 参数过滤
56 * @return void 46 * @return void
@@ -205,4 +195,16 @@ class BaseController extends Controller @@ -205,4 +195,16 @@ class BaseController extends Controller
205 } 195 }
206 return true; 196 return true;
207 } 197 }
  198 +
  199 +
  200 + /**
  201 + * 是否post请求
  202 + * @return bool
  203 + */
  204 + protected final function isPost()
  205 + {
  206 + return \Illuminate\Support\Facades\Request::isMethod('post');
  207 + }
  208 +
  209 +
208 } 210 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside;
  4 +
  5 +
  6 +use App\Enums\Common\Code;
  7 +use App\Models\BCustom;
  8 +
  9 +/**
  10 + * 自定义 页面
  11 + * @author:dc
  12 + * @time 2023/5/9 10:08
  13 + * Class CustomController
  14 + * @package App\Http\Controllers\Bside
  15 + */
  16 +class CustomController extends BaseController
  17 +{
  18 +
  19 + /**
  20 + * 验证规则
  21 + * @var array[]
  22 + */
  23 + private $verify = [
  24 + 'role' => [
  25 + 'name' => ['required','max:100'],
  26 + 'title' => ['required','max:200'],
  27 + 'keywords' => ['required','max:200'],
  28 + 'description' => ['required','max:250'],
  29 + 'html' => ['required'],
  30 + 'url' => ['required','max:200'],
  31 + 'status' => ['required','in:0,1'],
  32 + ],
  33 + 'message' => [
  34 + 'name.required' => '名称必须',
  35 + 'name.max' => '名称不能超过100个字符',
  36 + 'title.required' => '网页标题必须',
  37 + 'title.max' => '网页标题不能超过200个字符',
  38 + 'keywords.required' => '网页关键字必须',
  39 + 'keywords.max' => '网页关键字不能超过200个字符',
  40 + 'description.required' => '网页描述必须',
  41 + 'description.max' => '网页描述不能超过250个字符',
  42 +
  43 + 'url.required' => '链接必须',
  44 + 'url.max' => '链接不能超过200个字符',
  45 +
  46 + 'status.required' => '状态选择错误',
  47 + 'status.in' => '状态必须是显示/隐藏'
  48 + ],
  49 + 'attr' => [
  50 +
  51 + ]
  52 + ];
  53 +
  54 + /**
  55 + * 列表数据
  56 + * @throws \Psr\Container\ContainerExceptionInterface
  57 + * @throws \Psr\Container\NotFoundExceptionInterface
  58 + * @author:dc
  59 + * @time 2023/5/8 16:37
  60 + */
  61 + public function index(){
  62 +
  63 + // 每页数量
  64 + $limit = intval($this->param['limit']??20);
  65 +
  66 +
  67 + $lists = BCustom::_all($this->user['project_id'],$limit)->toArray();
  68 +
  69 +
  70 + return $this->success($lists);
  71 +
  72 + }
  73 +
  74 +
  75 +
  76 + /**
  77 + * 创建数据
  78 + * @author:dc
  79 + * @time 2023/5/8 16:39
  80 + */
  81 + public function create(){
  82 + return $this->save();
  83 + }
  84 +
  85 +
  86 + /**
  87 + * 修改
  88 + * @return \Illuminate\Http\JsonResponse
  89 + * @throws \Illuminate\Validation\ValidationException
  90 + * @throws \Psr\Container\ContainerExceptionInterface
  91 + * @throws \Psr\Container\NotFoundExceptionInterface
  92 + * @author:dc
  93 + * @time 2023/5/8 17:06
  94 + */
  95 + public function update(){
  96 + $this->verify['role']['id'] = ['required','integer','gt:0'];
  97 + $this->verify['message']['id.gt'] = $this->verify['message']['id.integer'] = $this->verify['message']['id.required'] = '编辑导航数据不存在';
  98 + return $this->save();
  99 + }
  100 +
  101 + /**
  102 + * 新增修改
  103 + * @return \Illuminate\Http\JsonResponse
  104 + * @throws \Illuminate\Validation\ValidationException
  105 + * @throws \Psr\Container\ContainerExceptionInterface
  106 + * @throws \Psr\Container\NotFoundExceptionInterface
  107 + * @author:dc
  108 + * @time 2023/5/8 17:06
  109 + */
  110 + private function save(){
  111 + $data = $this->validate(request() ,$this->verify['role'],$this->verify['message']);
  112 +
  113 + // 保存
  114 + $id = BCustom::_save($this->user['project_id'],$data,$data['id']??0);
  115 +
  116 + if($id===-1){
  117 + return $this->response('数据不存在','B_CUSTOM_NOTFOUND');
  118 + }
  119 +
  120 + return $this->success(BCustom::_find($this->user['project_id'],$id,true));
  121 + }
  122 +
  123 +
  124 + /**
  125 + * 删除数据
  126 + * @return \Illuminate\Http\JsonResponse
  127 + * @author:dc
  128 + * @time 2023/5/9 9:20
  129 + */
  130 + public function delete(){
  131 + $id = $this->param['id']??0;
  132 + $data = BCustom::_find($this->user['project_id'],$id);
  133 +
  134 + if(empty($data)){
  135 + return $this->response('数据不存在','B_CUSTOM_NOTFOUND');
  136 + }
  137 +
  138 +
  139 + if($data->delete()){
  140 + return $this->response('删除成功',Code::SUCCESS);
  141 + }
  142 +
  143 + }
  144 +
  145 +
  146 +
  147 +
  148 +}
@@ -169,6 +169,33 @@ class NavController extends BaseController @@ -169,6 +169,33 @@ class NavController extends BaseController
169 } 169 }
170 170
171 171
  172 + /**
  173 + * @author:dc
  174 + * @time 2023/5/9 16:14
  175 + */
  176 + public function urls(){
  177 + // todo::需要配合 c端来
  178 + return $this->success([
  179 + [
  180 + 'url' => '/',
  181 + 'name' => '首页'
  182 + ],
  183 + [
  184 + 'url' => '/list',
  185 + 'name' => '列表'
  186 + ],
  187 + [
  188 + 'url' => '/page',
  189 + 'name' => '单页'
  190 + ],
  191 + [
  192 + 'url' => 'goods',
  193 + 'name' => '商品'
  194 + ],
  195 + ]);
  196 + }
  197 +
  198 +
172 199
173 200
174 201
@@ -2,18 +2,15 @@ @@ -2,18 +2,15 @@
2 2
3 namespace App\Http\Controllers\Bside; 3 namespace App\Http\Controllers\Bside;
4 4
5 -use App\Enums\Common\Code;  
6 -use App\Exceptions\BsideGlobalException;  
7 -use App\Models\Template\AHeadFoot;  
8 -use App\Models\Template\BCustom;  
9 -use App\Models\Template\BHeadFoot;  
10 -use App\Models\Template\BTemplate;  
11 -use Illuminate\Support\Facades\DB; 5 +
  6 +use App\Models\Template\ATemplate;
  7 +use App\Models\Template\BSetting;
  8 +
12 9
13 /** 10 /**
14 - * 自定义 页面 11 + * 模板
15 * @author:dc 12 * @author:dc
16 - * @time 2023/5/4 15:59 13 + * @time 2023/5/9 14:00
17 * Class TemplateController 14 * Class TemplateController
18 * @package App\Http\Controllers\Bside 15 * @package App\Http\Controllers\Bside
19 */ 16 */
@@ -22,141 +19,57 @@ class TemplateController extends BaseController @@ -22,141 +19,57 @@ class TemplateController extends BaseController
22 19
23 20
24 /** 21 /**
25 - * 头部底部的 html 22 + * 模板列表
26 * @return \Illuminate\Http\JsonResponse 23 * @return \Illuminate\Http\JsonResponse
27 - * @throws \Psr\Container\ContainerExceptionInterface  
28 - * @throws \Psr\Container\NotFoundExceptionInterface  
29 * @author:dc 24 * @author:dc
30 - * @time 2023/5/4 16:15 25 + * @time 2023/5/9 14:20
31 */ 26 */
32 public function index(){ 27 public function index(){
33 28
34 - $data = BTemplate::_get($this->user['project_id']);  
35 -  
36 - // todo::这里要进行html的替换  
37 -  
38 -  
39 -  
40 - return $this->success($data);  
41 - }  
42 -  
43 -  
44 - /**  
45 - * 读取编辑的html  
46 - * @author:dc  
47 - * @time 2023/5/4 16:19  
48 - */  
49 - public function edit_html(){  
50 - $data = BHeadFoot::_get($this->user['project_id']);  
51 -  
52 - if(!$data){  
53 - $data = AHeadFoot::_bDefault();  
54 - }  
55 -  
56 - return $this->success([  
57 - 'header' => $data[BHeadFoot::TYPE_HEADER]??'',  
58 - 'footer' => $data[BHeadFoot::TYPE_FOOTER]??'',  
59 - ]);  
60 - }  
61 -  
62 - /**  
63 - * 保存  
64 - * @author:dc  
65 - * @time 2023/5/4 17:42  
66 - */  
67 - public function edit_save(){ 29 + $limit = intval($this->param['limit']??20);
68 30
69 - $header = $this->param['header']??'';  
70 31
71 - $footer = $this->param['footer']??''; 32 + // 读取列表
  33 + $data = ATemplate::_bAll($limit)->toArray();
72 34
73 - if(!$header && !$footer){  
74 - throw new BsideGlobalException('B01024','不能为空');  
75 - }  
76 35
77 - DB::beginTransaction();  
78 36
79 - try {  
80 - if($header){  
81 - BHeadFoot::_save($this->user['project_id'],BHeadFoot::TYPE_HEADER,$header);  
82 - }  
83 -  
84 - if($footer){  
85 - BHeadFoot::_save($this->user['project_id'],BHeadFoot::TYPE_FOOTER,$footer);  
86 - }  
87 - }catch (\Throwable $e){  
88 - DB::rollBack();  
89 -  
90 - throw new BsideGlobalException('B01024','保存失败');  
91 - }  
92 -  
93 - DB::commit();  
94 -  
95 -  
96 - $this->success([]);  
97 37
  38 + return $this->success($data);
98 } 39 }
99 40
100 41
101 /** 42 /**
102 - * 获取系统的模板 43 + * 当前使用的模板
103 * @author:dc 44 * @author:dc
104 - * @time 2023/5/4 16:21 45 + * @time 2023/5/9 15:19
105 */ 46 */
106 - public function system_all_html(){  
107 -  
108 - $data = AHeadFoot::_ball();  
109 -  
110 - $lists = [];  
111 - // 以名字为单位区分  
112 - foreach ($data as $datum){  
113 - if(empty($lists[$datum['name']])) $lists[$datum['name']] = [];  
114 - $lists[$datum['name']]['name'] = $datum['name'];  
115 - $lists[$datum['name']]['default'] = $datum['is_default'];  
116 - $lists[$datum['name']][$datum['type']==AHeadFoot::TYPE_HEADER?'header':'footer'] = $datum['html']; 47 + public function info(){
  48 +
  49 + // 保存更新
  50 + if($this->isPost()){
  51 + $template_id = intval($this->param['template_id']??0);
  52 + // 是否存在模板
  53 + if($template_id && ATemplate::_bFind($template_id)){
  54 + BSetting::_save($this->user['project_id'],$template_id);
  55 + }else{
  56 + return $this->response('无法使用不存在的模板','B_TEMPLATE_NOTFOUND');
  57 + }
117 } 58 }
118 59
  60 + // 读取我的模板
  61 + $conf = BSetting::_get($this->user['project_id']);
  62 + // 读取模板信息
  63 + $data = ATemplate::_bFind($conf['template_id']);
119 64
120 - return $this->success(array_values($lists));  
121 -  
122 - }  
123 -  
124 -  
125 -  
126 -  
127 -  
128 -  
129 -  
130 -  
131 - /**  
132 - * 自定义 列表  
133 - * @author:dc  
134 - * @time 2023/5/4 17:13  
135 - */  
136 - public function custom(){  
137 -  
138 - $data = BCustom::_all($this->user['project_id']);  
139 -  
140 -  
141 - return $this->success($data->toArray());  
142 - }  
143 -  
144 -  
145 - public function custom_create(){  
146 -  
147 - }  
148 -  
149 - public function custom_edit($id){  
150 -  
151 - }  
152 -  
153 - public function custom_delete($id){  
154 - 65 + return $this->success([
  66 + 'template_id' => $data['id']??0,
  67 + 'name' => $data['name']??'',
  68 + 'thumb' => $data['thumb']??'',
  69 + 'time' => $conf['time']
  70 + ]);
155 } 71 }
156 72
157 73
158 74
159 -  
160 -  
161 -  
162 } 75 }
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\SoftDeletes;
  6 +
  7 +/**
  8 + * b端控制, c端显示的自定义页面
  9 + * @author:dc
  10 + * @time 2023/5/8 16:14
  11 + * Class BCustom
  12 + * @package App\Models
  13 + */
  14 +class BCustom extends Base
  15 +{
  16 +
  17 + protected $table = 'gl_web_custom';
  18 +
  19 + use SoftDeletes;
  20 +
  21 + public $hidden = ['deleted_at','project_id'];
  22 +
  23 +
  24 + /**
  25 + * 显示
  26 + */
  27 + const STATUS_ACTIVE = 1;
  28 +
  29 + /**
  30 + * 隐藏
  31 + */
  32 + const STATUS_DISABLED = 0;
  33 +
  34 +
  35 + /**
  36 + * 创建或者新增导航栏
  37 + * @param int $project_id
  38 + * @param array $data
  39 + * @param int $id
  40 + * @return int
  41 + * @author:dc
  42 + * @time 2023/5/8 16:24
  43 + */
  44 + public static function _save(int $project_id, array $data, int $id = 0):int {
  45 + if($id){
  46 + $model = static::where('id',$id)->where('project_id', $project_id)->first();
  47 + if(!$model){
  48 + return -1;
  49 + }
  50 + }else{
  51 + $model = new static();
  52 + $model->project_id = $project_id;
  53 +
  54 + }
  55 +
  56 + $model->name = $data['name'];
  57 + $model->title = $data['title'];
  58 + $model->keywords = $data['keywords'];
  59 + $model->description = $data['description'];
  60 + $model->url = $data['url'];
  61 + $model->status = $data['status'];
  62 + $model->html = $data['html'];
  63 +
  64 + $model->save();
  65 +
  66 + // 创建路由标识
  67 + try {
  68 + RouteMap::setRoute($model->url,RouteMap::SOURCE_CUSTOM,$model->id,$project_id);
  69 + }catch (\Throwable $e){
  70 +
  71 + }
  72 +
  73 +
  74 + return $model->id;
  75 + }
  76 +
  77 +
  78 + /**
  79 + * 删除
  80 + * @param int $project_id
  81 + * @param int $id
  82 + * @return mixed
  83 + * @author:dc
  84 + * @time 2023/5/8 16:27
  85 + */
  86 + public static function _del(int $project_id, int $id){
  87 + return static::where(['project_id'=>$project_id,'id'=>$id])->delete();
  88 + }
  89 +
  90 +
  91 + /**
  92 + * 查询当前项目下的所有信息
  93 + * @param int $project_id
  94 + * @return mixed
  95 + * @author:dc
  96 + * @time 2023/5/8 16:29
  97 + */
  98 + public static function _all(int $project_id, int $limit = 20)
  99 + {
  100 + return static::where(function ($query) use ($project_id){
  101 + // 那个公司
  102 + $query->where('project_id',$project_id);
  103 + })
  104 + ->select(['id','name','title','status','url','keywords','description','created_at','updated_at'])
  105 + ->paginate($limit);
  106 + }
  107 +
  108 + /**
  109 + * 查询一条数据
  110 + * @param int $project_id
  111 + * @param int $id
  112 + * @return mixed
  113 + * @author:dc
  114 + * @time 2023/5/8 17:04
  115 + */
  116 + public static function _find(int $project_id, int $id, $array = false)
  117 + {
  118 + $data = static::where(['id'=>$id,'project_id'=>$project_id])->first();
  119 + if($data){
  120 + return $array ? $data->toArray() : $data;
  121 + }
  122 + return [];
  123 + }
  124 +
  125 +
  126 +}
@@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; @@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
14 class BNav extends Base 14 class BNav extends Base
15 { 15 {
16 16
17 - protected $table = 'gl_bside_nav'; 17 + protected $table = 'gl_web_nav';
18 18
19 use SoftDeletes; 19 use SoftDeletes;
20 20
@@ -24,7 +24,7 @@ class ManageLog extends Base @@ -24,7 +24,7 @@ class ManageLog extends Base
24 24
25 $log = new self(); 25 $log = new self();
26 $log->title = $menu ? $menu['title'] : ''; 26 $log->title = $menu ? $menu['title'] : '';
27 - $log->manage_id = LoginLogic::manage('id'); 27 + $log->manage_id = LoginLogic::manage('id') ? : 0;
28 $log->route_name = request()->route()->getName(); 28 $log->route_name = request()->route()->getName();
29 $log->action = request()->path(); 29 $log->action = request()->path();
30 $log->method = request()->method(); 30 $log->method = request()->method();
@@ -12,7 +12,7 @@ class Project extends Base @@ -12,7 +12,7 @@ class Project extends Base
12 //设置关联表名 12 //设置关联表名
13 protected $table = 'gl_project'; 13 protected $table = 'gl_project';
14 14
15 - const DATABASE_NAME_FIX = 'globalso_project_'; 15 + const DATABASE_NAME_FIX = 'gl_data_';
16 16
17 /** 17 /**
18 * 星级客户 18 * 星级客户
@@ -26,6 +26,8 @@ class RouteMap extends Model @@ -26,6 +26,8 @@ class RouteMap extends Model
26 //路由类型 26 //路由类型
27 const SOURCE_BLOG = 'blog'; 27 const SOURCE_BLOG = 'blog';
28 const SOURCE_NEWS = 'news'; 28 const SOURCE_NEWS = 'news';
  29 + // 自定义界面
  30 + const SOURCE_CUSTOM = 'custom';
29 /** 31 /**
30 * 生成路由标识 32 * 生成路由标识
31 * @param $title 33 * @param $title
1 -<?php  
2 -  
3 -namespace App\Models\Template;  
4 -  
5 -/**  
6 - * 头部底部  
7 - * @author:dc  
8 - * @time 2023/5/4 15:52  
9 - * Class AHeadFoot  
10 - * @package App\Models\Template  
11 - */  
12 -class AHeadFoot extends \App\Models\Base{  
13 -  
14 - protected $table = 'gl_aside_template_header_footer';  
15 -  
16 -// 分开存 头底 为了方便后期可能会 改版为 随意搭配 头底部  
17 - const TYPE_HEADER = 'H';  
18 - const TYPE_FOOTER = 'F';  
19 -  
20 - const STATUS_ACTIVE = 1;  
21 - const STATUS_DISABLED = 0;  
22 -  
23 - const IS_DEFAULT = 1;  
24 -  
25 -  
26 - /**  
27 - * b 端 查询  
28 - * @return mixed  
29 - * @author:dc  
30 - * @time 2023/5/4 16:24  
31 - */  
32 - public static function _ball(){  
33 - return static::where('status',static::STATUS_ACTIVE)->orderBy('sort')->get(['id','name','type','html','is_default']);  
34 - }  
35 -  
36 - /**  
37 - * b 端 读取默认的一个头部底部  
38 - * @return mixed  
39 - * @author:dc  
40 - * @time 2023/5/4 16:51  
41 - */  
42 - public static function _bDefault(){  
43 - return static::where(['status'=>static::STATUS_ACTIVE,'is_default'=>static::IS_DEFAULT])  
44 - ->get(['type','html'])  
45 - ->pluck('html','type')  
46 - ->toArray();  
47 - }  
48 -  
49 -  
50 -  
51 -  
52 -}  
  1 +<?php
  2 +
  3 +namespace App\Models\Template;
  4 +
  5 +use Illuminate\Database\Eloquent\SoftDeletes;
  6 +
  7 +/**
  8 + * 由 A端增删改
  9 + * 模板
  10 + * @author:dc
  11 + * @time 2023/5/9 13:56
  12 + * Class ATemplate
  13 + * @package App\Models\Template
  14 + */
  15 +class ATemplate extends \App\Models\Base{
  16 +
  17 +
  18 + protected $table = 'gl_aside_template';
  19 +
  20 +
  21 + protected $hidden = ['deleted_at'];
  22 +
  23 +
  24 + use SoftDeletes;
  25 +
  26 + /**
  27 + * 显示
  28 + */
  29 + const STATUS_ACTIVE = 1;
  30 +
  31 + /**
  32 + * 隐藏
  33 + */
  34 + const STATUS_DISABLED = 0;
  35 +
  36 +
  37 + /**
  38 + * b 端调用
  39 + * @param int $limit
  40 + * @return mixed
  41 + * @author:dc
  42 + * @time 2023/5/9 14:14
  43 + */
  44 + public static function _bAll(int $limit = 20)
  45 + {
  46 + return static::where(function ($query){
  47 +
  48 + $query->where('status',static::STATUS_ACTIVE);
  49 +
  50 + })
  51 + ->select(['id','name','url','thumb','created_at','updated_at'])
  52 + ->orderBy('sort')
  53 + ->paginate($limit);
  54 + }
  55 +
  56 + /**
  57 + * @param $id
  58 + * @return array
  59 + * @author:dc
  60 + * @time 2023/5/9 15:16
  61 + */
  62 + public static function _bFind($id)
  63 + {
  64 + $data = static::where('id',$id)->first();
  65 + if(!$data || $data->status === static::STATUS_DISABLED){
  66 + return [];
  67 + }
  68 + return $data;
  69 + }
  70 +
  71 +
  72 + /**
  73 + * 获取默认模板
  74 + * @return mixed
  75 + * @author:dc
  76 + * @time 2023/5/9 15:09
  77 + */
  78 + public static function _default()
  79 + {
  80 + return static::where(['status'=>static::STATUS_ACTIVE,'is_default'=>1])->first();
  81 + }
  82 +
  83 +
  84 +
  85 +}
  1 +<?php
  2 +
  3 +namespace App\Models\Template;
  4 +
  5 +use Illuminate\Database\Eloquent\SoftDeletes;
  6 +
  7 +/**
  8 + * 由 A端增删改
  9 + * 模板
  10 + * @author:dc
  11 + * @time 2023/5/9 13:56
  12 + * Class ATemplate
  13 + * @package App\Models\Template
  14 + */
  15 +class ATemplateHtml extends \App\Models\Base{
  16 +
  17 +
  18 + protected $table = 'gl_aside_template_html';
  19 +
  20 +
  21 + protected $hidden = ['deleted_at'];
  22 +
  23 +
  24 + use SoftDeletes;
  25 +
  26 +
  27 +
  28 +
  29 +}
1 -<?php  
2 -  
3 -namespace App\Models\Template;  
4 -  
5 -use Illuminate\Database\Eloquent\SoftDeletes;  
6 -  
7 -/**  
8 - * 自定义 页面  
9 - * @author:dc  
10 - * @time 2023/5/4 17:18  
11 - * Class BCustom  
12 - * @package App\Models\Template  
13 - */  
14 -class BCustom extends \App\Models\Base{  
15 -  
16 - protected $table = 'gl_bside_template_custom';  
17 -  
18 - use SoftDeletes;  
19 -  
20 -  
21 - const STATUS_ACTIVE = 1;  
22 -  
23 - const STATUS_DISABLED = 0;  
24 -  
25 -  
26 - /**  
27 - * 读取列表  
28 - * @param $project_id  
29 - * @return mixed  
30 - * @author:dc  
31 - * @time 2023/5/4 17:22  
32 - */  
33 - public static function _all($project_id){  
34 - return static::where([  
35 - 'project_id' => $project_id  
36 - ])->paginate(20);  
37 - }  
38 -  
39 -  
40 -  
41 -  
42 -  
43 -  
44 -}  
  1 +<?php
  2 +
  3 +namespace App\Models\Template;
  4 +
  5 +use Illuminate\Database\Eloquent\SoftDeletes;
  6 +
  7 +/**
  8 + * 当前用户的模板
  9 + * @author:dc
  10 + * @time 2023/5/9 15:03
  11 + * Class BSetting
  12 + * @package App\Models\Template
  13 + */
  14 +class BSetting extends \App\Models\Base{
  15 +
  16 +
  17 +
  18 + protected $table = 'gl_web_setting_template';
  19 +
  20 +
  21 +
  22 + /**
  23 + * b 端调用
  24 + * @param int $limit
  25 + * @return mixed
  26 + * @author:dc
  27 + * @time 2023/5/9 14:14
  28 + */
  29 + public static function _get(int $project_id)
  30 + {
  31 + $data = static::where('project_id',$project_id)->first();
  32 +
  33 + if($data){
  34 + return [
  35 + 'template_id' => $data['template_id'],
  36 + 'time' => $data['updated_at']
  37 + ];
  38 + }
  39 +
  40 + // 米有数据
  41 + // 读取默认的模板
  42 + $temp = ATemplate::_default();
  43 + // 保存
  44 + self::_save($project_id,$temp['id']);
  45 +
  46 + return [
  47 + 'template_id' => $temp['id'],
  48 + 'time' => date('Y-m-d H:i:s')
  49 + ];
  50 + }
  51 +
  52 +
  53 + /**
  54 + * 模板保存
  55 + * @param int $project_id
  56 + * @param int $template_id
  57 + * @return mixed
  58 + * @author:dc
  59 + * @time 2023/5/9 15:13
  60 + */
  61 + public static function _save(int $project_id, int $template_id)
  62 + {
  63 +
  64 + $data = static::where('project_id',$project_id)->first();
  65 + if(!$data){
  66 + $data = new static();
  67 + $data->project_id = $project_id;
  68 + }
  69 +
  70 + $data->template_id = $template_id;
  71 +
  72 + $data->save();
  73 +
  74 + return $data->id;
  75 +
  76 + }
  77 +
  78 +
  79 +
  80 +
  81 +}
@@ -11,7 +11,7 @@ namespace App\Models\Template; @@ -11,7 +11,7 @@ namespace App\Models\Template;
11 */ 11 */
12 class BTemplate extends \App\Models\Base{ 12 class BTemplate extends \App\Models\Base{
13 13
14 - protected $table = 'gl_bside_template_html'; 14 + protected $table = 'gl_web_template_html';
15 15
16 16
17 17
@@ -24,7 +24,7 @@ class ProjectServer extends BaseService @@ -24,7 +24,7 @@ class ProjectServer extends BaseService
24 */ 24 */
25 public static function useProject($project_id) 25 public static function useProject($project_id)
26 { 26 {
27 - $project = Project::getProjectById($project_id); 27 + $project = Project::where(['id' => $project_id])->first();
28 if (empty($project)) 28 if (empty($project))
29 return false; 29 return false;
30 30
@@ -68,7 +68,7 @@ return [ @@ -68,7 +68,7 @@ return [
68 'url' => env('DATABASE_URL'), 68 'url' => env('DATABASE_URL'),
69 'host' => env('DB_HOST', '127.0.0.1'), 69 'host' => env('DB_HOST', '127.0.0.1'),
70 'port' => env('DB_PORT', '3306'), 70 'port' => env('DB_PORT', '3306'),
71 - 'database' => env('DB_DATABASE_TMP', 'globalso_project_tmp'), 71 + 'database' => env('DB_DATABASE_TMP', 'gl_data_0_tmp'),
72 'username' => env('DB_USERNAME', 'forge'), 72 'username' => env('DB_USERNAME', 'forge'),
73 'password' => env('DB_PASSWORD', ''), 73 'password' => env('DB_PASSWORD', ''),
74 'unix_socket' => env('DB_SOCKET', ''), 74 'unix_socket' => env('DB_SOCKET', ''),