作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

@@ -13,3 +13,4 @@ npm-debug.log @@ -13,3 +13,4 @@ npm-debug.log
13 yarn-error.log 13 yarn-error.log
14 /.idea 14 /.idea
15 /.vscode 15 /.vscode
  16 +composer.lock
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2023/4/12
  6 + * Time: 15:33
  7 + */
  8 +namespace App\Console\Commands;
  9 +
  10 +use App\Models\Project;
  11 +use Illuminate\Console\Command;
  12 +use Illuminate\Support\Facades\DB;
  13 +use Illuminate\Support\Facades\Schema;
  14 +
  15 +/**
  16 + * Class ProjectInitDatabase
  17 + * @package App\Console\Commands
  18 + */
  19 +class ProjectInit extends Command
  20 +{
  21 + /**
  22 + * The name and signature of the console command.
  23 + *
  24 + * @var string
  25 + */
  26 + protected $signature = 'project:init';
  27 +
  28 + /**
  29 + * The console command description.
  30 + *
  31 + * @var string
  32 + */
  33 + protected $description = '项目数据库初始化';
  34 +
  35 + protected $connect = null;
  36 +
  37 + /**
  38 + * Create a new command instance.
  39 + *
  40 + * @return void
  41 + */
  42 + public function __construct()
  43 + {
  44 + parent::__construct();
  45 + }
  46 +
  47 + /**
  48 + * @return bool
  49 + */
  50 + public function handle()
  51 + {
  52 + #TODO 通过项目ID获取项目部署数据库配置, 创建数据库, 同步数据表
  53 + $project_id = 102;
  54 + $project = Project::getProjectById($project_id);
  55 + if (empty($project) || empty($project->mysqlConfig()))
  56 + return true;
  57 + $this->initDatabase($project);
  58 +
  59 + return true;
  60 + }
  61 +
  62 + /**
  63 + * @param Project $project
  64 + * @return bool
  65 + */
  66 + public function initDatabase($project)
  67 + {
  68 + $create_flag = $this->createDatabase($project);
  69 +
  70 + if (!$create_flag) {
  71 + // 创建数据库失败 添加通知以及再次处理
  72 + }
  73 + // 设置 database.connections.custom_mysql 数据
  74 + config(['database.connections.custom_mysql.host' => $project->mysqlConfig()->host]);
  75 + config(['database.connections.custom_mysql.port' => $project->mysqlConfig()->port]);
  76 + config(['database.connections.custom_mysql.database' => $project->databaseName()]);
  77 + config(['database.connections.custom_mysql.username' => $project->mysqlConfig()->user]);
  78 + config(['database.connections.custom_mysql.password' => $project->mysqlConfig()->password]);
  79 +
  80 + // TODO 创建对应库 初始化数据表
  81 + $this->initTable();
  82 + return true;
  83 + }
  84 +
  85 + /**
  86 + * @return bool
  87 + */
  88 + public function initTable()
  89 + {
  90 +// $table = DB::select('show tables');
  91 +// $table = array_column($table, 'Tables_in_globalso_dev');
  92 +// $table = DB::connection('custom_tmp_mysql')->select('show tables');
  93 +// $table_in = DB::connection('custom_tmp_mysql')->getDatabaseName();
  94 +// dd($table, $table_in);
  95 +
  96 + $database_name = DB::connection('custom_tmp_mysql')->getDatabaseName();
  97 +
  98 + $table = Schema::connection('custom_tmp_mysql')->getAllTables();
  99 + $table = array_column($table, 'Tables_in_' . $database_name);
  100 + foreach ($table as $v) {
  101 + $has_table = Schema::connection('custom_mysql')->hasTable($v);
  102 + if ($has_table)
  103 + continue;
  104 +
  105 + $connection = DB::connection('custom_tmp_mysql');
  106 + $sql = $connection->getDoctrineSchemaManager()
  107 + ->getDatabasePlatform()
  108 + ->getCreateTableSQL($connection->getDoctrineSchemaManager()->listTableDetails($v));
  109 +
  110 + DB::connection('custom_mysql')->select($sql[0]);
  111 + }
  112 + return true;
  113 + }
  114 +
  115 + /**
  116 + * 创建数据库
  117 + * 链接mysql 查询数据库是否存在 创建数据库
  118 + * @param Project $project
  119 + * @return bool|\mysqli_result|null
  120 + */
  121 + public function createDatabase($project)
  122 + {
  123 + # 该方法需要:composer require parity-bit/laravel-db-commands
  124 +// $result = Artisan::call('db:create', [
  125 +// '--database' => $database_name,
  126 +// ]);
  127 +//
  128 +// return $result;
  129 +
  130 + if ($this->connect)
  131 + return $this->connect;
  132 +
  133 + //连接到 MySQL 服务器
  134 + $servername = $project->mysqlConfig()->host;
  135 + $username = $project->mysqlConfig()->user;
  136 + $password = $project->mysqlConfig()->password;
  137 + $conn = new \mysqli($servername, $username, $password);
  138 + //检查连接是否成功
  139 + if ($conn->connect_error) {
  140 + die("连接失败: " . $conn->connect_error);
  141 + }
  142 + $this->connect = $conn;
  143 +// $result = $conn->query('SHOW DATABASES LIKE \'' . $database_name . '\';');
  144 +// if ($result)
  145 +// return true;
  146 + $result = $conn->query('CREATE DATABASE ' . $project->databaseName() . ';');
  147 + return $result;
  148 + }
  149 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2023/2/7
  6 + * Time: 17:58
  7 + */
  8 +namespace App\Console\Commands\Test;
  9 +
  10 +use GuzzleHttp\Client;
  11 +use Illuminate\Console\Command;
  12 +use Illuminate\Support\Facades\DB;
  13 +
  14 +class Demo extends Command
  15 +{
  16 + /**
  17 + * The name and signature of the console command.
  18 + *
  19 + * @var string
  20 + */
  21 + protected $signature = 'demo';
  22 +
  23 + /**
  24 + * The console command description.
  25 + *
  26 + * @var string
  27 + */
  28 + protected $description = 'demo';
  29 +
  30 + /**
  31 + * Create a new command instance.
  32 + *
  33 + * @return void
  34 + */
  35 + public function __construct()
  36 + {
  37 + parent::__construct();
  38 + }
  39 +
  40 + /**
  41 + * @return bool
  42 + */
  43 + public function handle()
  44 + {
  45 + $sql = 'CREATE DATABASE database_name;';
  46 + $results = DB::select($sql);
  47 + dd($results);
  48 + return true;
  49 + }
  50 +
  51 + public function printMessage()
  52 + {
  53 + $client = new Client();
  54 + $headers = [
  55 + 'Accept-Language' => 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
  56 + 'Cache-Control' => 'no-cache',
  57 + 'Content-Type' => 'application/json',
  58 + 'DNT' => '1',
  59 + 'Origin' => 'http://openai.waimaoq.com',
  60 + 'Pragma' => 'no-cache',
  61 + 'Proxy-Connection' => 'keep-alive',
  62 + 'Referer' => 'http://openai.waimaoq.com/docs',
  63 + 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
  64 + 'accept' => 'application/json',
  65 + 'Access-Control-Allow-Origin' => '*'
  66 + ];
  67 + $body = '{
  68 + "prompt": "Human: 我需要一篇100字的英文原创博客并包含标题,内容结合:“cnc machine”。AI:"
  69 + }';
  70 + $response = $client->post('http://openai.waimaoq.com/v1/openai_chat_stream', [
  71 + 'stream' => true,
  72 + 'headers' => $headers,
  73 + 'body' => $body
  74 + ]);
  75 + // 获取响应流对象
  76 + $stream = $response->getBody();
  77 +
  78 + // 设置输出缓冲区
  79 + ob_start();
  80 +
  81 + // 读取流中的数据并输出到页面
  82 + while (!$stream->eof()) {
  83 + echo $stream->read(4);
  84 + ob_flush();
  85 + flush();
  86 + }
  87 + dd(1);
  88 + }
  89 +}
@@ -3,6 +3,18 @@ use Illuminate\Support\Facades\Log; @@ -3,6 +3,18 @@ use Illuminate\Support\Facades\Log;
3 3
4 define('HTTP_OPENAI_URL','http://openai.waimaoq.com'); 4 define('HTTP_OPENAI_URL','http://openai.waimaoq.com');
5 5
  6 +//ai自动生成文本
  7 +function send_openai_msg($url , $command , $param){
  8 + $url = HTTP_OPENAI_URL.$url;
  9 + $data = [
  10 + 'messages'=>[
  11 + ['role'=>$command['key'],'content'=>$command['scene']],
  12 + ['role'=>$param['key'],'content'=>$param['scene']],
  13 + ]
  14 + ];
  15 + return http_post($url,json_encode($data));
  16 +}
  17 +
6 if(!function_exists('http_post')){ 18 if(!function_exists('http_post')){
7 /** 19 /**
8 * 发送http post请求 20 * 发送http post请求
@@ -56,6 +68,7 @@ if(!function_exists('http_get')){ @@ -56,6 +68,7 @@ if(!function_exists('http_get')){
56 } 68 }
57 } 69 }
58 70
  71 +
59 if(!function_exists('_get_child')){ 72 if(!function_exists('_get_child')){
60 /** 73 /**
61 * 菜单权限->得到子级数组 74 * 菜单权限->得到子级数组
@@ -4,25 +4,25 @@ namespace App\Http\Controllers\Aside; @@ -4,25 +4,25 @@ namespace App\Http\Controllers\Aside;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Controller; 6 use App\Http\Controllers\Controller;
7 -use App\Utils\EncryptUtils;  
8 -use Illuminate\Http\Exceptions\HttpResponseException;  
9 use Illuminate\Http\JsonResponse; 7 use Illuminate\Http\JsonResponse;
10 use Illuminate\Http\Request; 8 use Illuminate\Http\Request;
11 -use Illuminate\Http\Response;  
12 -use Illuminate\Support\Facades\Cache; 9 +use Illuminate\Http\Exceptions\HttpResponseException;
  10 +use Illuminate\Support\Facades\Session;
13 11
14 class BaseController extends Controller 12 class BaseController extends Controller
15 { 13 {
16 protected $param = [];//所有请求参数 14 protected $param = [];//所有请求参数
17 protected $token = ''; //token 15 protected $token = ''; //token
18 protected $request = [];//助手函数 16 protected $request = [];//助手函数
19 - protected $p = 1;//当前页 17 + protected $allCount = 0;//总条数
  18 + protected $page = 1;//当前页
20 protected $row = 20;//每页条数 19 protected $row = 20;//每页条数
21 protected $header = [];//设置请求头参数 20 protected $header = [];//设置请求头参数
22 protected $order = 'id'; 21 protected $order = 'id';
23 protected $map = [];//处理后的参数 22 protected $map = [];//处理后的参数
24 protected $uid = 0; 23 protected $uid = 0;
25 protected $user = [];//当前登录用户详情 24 protected $user = [];//当前登录用户详情
  25 +
26 /** 26 /**
27 * 获取所有参数 27 * 获取所有参数
28 */ 28 */
@@ -30,32 +30,24 @@ class BaseController extends Controller @@ -30,32 +30,24 @@ class BaseController extends Controller
30 { 30 {
31 $this->request = $request; 31 $this->request = $request;
32 $this->param = $this->request->all(); 32 $this->param = $this->request->all();
33 - $this->token = $this->request->header('token');  
34 $this->get_param(); 33 $this->get_param();
35 - $this->auth_token();  
36 } 34 }
37 35
38 /** 36 /**
39 - * @name  
40 - * @return void  
41 - * @author :liyuhang  
42 - * @method 37 + * @return mixed
  38 + * @author zbj
  39 + * @date 2023/4/19
43 */ 40 */
44 - public function auth_token(){  
45 - $info = Cache::get($this->token);  
46 - if(isset($info) && !empty($info)){  
47 - $this->user = $info;  
48 - $this->uid = $info['id'];  
49 - } 41 + public function manage(){
  42 + return Session::get('manage');
50 } 43 }
  44 +
51 /** 45 /**
52 * 成功返回 46 * 成功返回
53 * @param array $data 47 * @param array $data
54 * @param string $code 48 * @param string $code
55 * @param bool $objectData 49 * @param bool $objectData
56 * @return JsonResponse 50 * @return JsonResponse
57 - * @throws \Psr\Container\ContainerExceptionInterface  
58 - * @throws \Psr\Container\NotFoundExceptionInterface  
59 */ 51 */
60 function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse 52 function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
61 { 53 {
@@ -68,16 +60,8 @@ class BaseController extends Controller @@ -68,16 +60,8 @@ class BaseController extends Controller
68 'data' => $data, 60 'data' => $data,
69 'msg' => $code->description, 61 'msg' => $code->description,
70 ]; 62 ];
71 - //加密-返回数据  
72 - if (config('app.params_encrypt')) {  
73 - $k = config('app.params_encrypt_key');  
74 - $i = config('app.params_encrypt_iv');  
75 - $response = [  
76 - 'p' => (new EncryptUtils())->openssl_en($response, $k, $i)];  
77 - }  
78 return response()->json($response,200,$this->header); 63 return response()->json($response,200,$this->header);
79 } 64 }
80 -  
81 /** 65 /**
82 * @name 参数过滤 66 * @name 参数过滤
83 * @return void 67 * @return void
@@ -94,20 +78,23 @@ class BaseController extends Controller @@ -94,20 +78,23 @@ class BaseController extends Controller
94 case "order": 78 case "order":
95 $this->order = $v; 79 $this->order = $v;
96 break; 80 break;
97 - case 'p':  
98 - $this->p = $v; 81 + case 'page':
  82 + $this->page = $v;
99 break; 83 break;
100 case 'row': 84 case 'row':
101 $this->row = $v; 85 $this->row = $v;
102 break; 86 break;
103 - case "created_at": 87 + case "name":
  88 + $this->map['name'] = ['like','%'.$v.'%'];
  89 + break;
  90 + case "start_at":
104 $this->_btw[0] = $v; 91 $this->_btw[0] = $v;
105 $this->_btw[1] = date('Y-m-d H:i:s',time()); 92 $this->_btw[1] = date('Y-m-d H:i:s',time());
106 - $this->map['create_at'] = ['between', $this->_btw]; 93 + $this->map['created_at'] = ['between', $this->_btw];
107 break; 94 break;
108 - case "updated_at": 95 + case "end_at":
109 $this->_btw[1] = $v; 96 $this->_btw[1] = $v;
110 - $this->map['update_at'] = ['between', $this->_btw]; 97 + $this->map['updated_at'] = ['between', $this->_btw];
111 break; 98 break;
112 default: 99 default:
113 if (!empty($v)) { 100 if (!empty($v)) {
@@ -116,46 +103,24 @@ class BaseController extends Controller @@ -116,46 +103,24 @@ class BaseController extends Controller
116 break; 103 break;
117 } 104 }
118 } 105 }
119 -  
120 } 106 }
121 /** 107 /**
122 * @name 统一返回参数 108 * @name 统一返回参数
123 - * @return void 109 + * @return JsonResponse
124 * @author :liyuhang 110 * @author :liyuhang
125 * @method 111 * @method
126 */ 112 */
127 - public function response($msg,$code = 200,$data = [],$result_code = null,$type = 'application/json'){  
128 - $result_code === null && $result_code = $code; 113 + public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
  114 + {
  115 + $code = Code::fromValue($code);
129 $result = [ 116 $result = [
130 - 'msg' =>$msg,  
131 - 'code'=>$result_code,  
132 - 'data'=>$data 117 + 'msg' => $msg == ' ' ? $code->description : $msg,
  118 + 'code' => $code->value,
  119 + 'data' => $data,
133 ]; 120 ];
134 $this->header['Content-Type'] = $type; 121 $this->header['Content-Type'] = $type;
135 $this->header['token'] = $this->token; 122 $this->header['token'] = $this->token;
136 $response = response($result,$result_code,$this->header);; 123 $response = response($result,$result_code,$this->header);;
137 throw new HttpResponseException($response); 124 throw new HttpResponseException($response);
138 } 125 }
139 -  
140 - /**  
141 - * @name :上传图片  
142 - * @return void  
143 - * @author :liyuhang  
144 - * @method  
145 - */  
146 - public function uploads(){  
147 - $files = $this->request->file('file');  
148 - if(empty($files)){  
149 - return $this->response('没有上传文件',Code::USER_ERROR);  
150 - }  
151 - $url = './uploads/images/';  
152 - $param = $this->request->post();  
153 - if($this->request->hasFile('image') && $files->isValid()){  
154 - $filename = date('ymdHis').rand(10000,99999).$this->request->file('image');  
155 - $this->request->file('image')->move('./uploads/images/',$filename);  
156 - }else{  
157 - return false;  
158 - }  
159 - return $url.$filename;  
160 - }  
161 } 126 }
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Aside;  
4 -  
5 -use App\Http\Logic\Aside\DemoLogic;  
6 -use App\Http\Requests\Aside\DemoRequest;  
7 -  
8 -class DemoController extends BaseController  
9 -{  
10 - /**  
11 - * Deom控制器  
12 - * @param DemoRequest $request  
13 - * @param DemoLogic $logic  
14 - * @return \Illuminate\Http\JsonResponse  
15 - * @throws \Psr\Container\ContainerExceptionInterface  
16 - * @throws \Psr\Container\NotFoundExceptionInterface  
17 - */  
18 - public function test(DemoRequest $request,DemoLogic $logic)  
19 - {  
20 - $request->validated();  
21 - $data=$logic->testLogic();  
22 - return $this->success($data);  
23 - }  
24 -}  
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use Illuminate\Http\Request;
  7 +
  8 +/**
  9 + * Class IndexController
  10 + * @package App\Http\Controllers\Aside
  11 + * @author zbj
  12 + * @date 2023/4/19
  13 + */
  14 +class IndexController extends Controller
  15 +{
  16 + /**
  17 + * 首页
  18 + * @param Request $request
  19 + * @return \Illuminate\Http\JsonResponse
  20 + */
  21 + public function index(Request $request)
  22 + {
  23 +
  24 + }
  25 +
  26 +}
  1 +<?php
  2 +
  3 +
  4 +namespace App\Http\Controllers\Aside;
  5 +
  6 +use App\Http\Logic\Aside\LoginLogic;
  7 +use App\Rules\Mobile;
  8 +use Illuminate\Http\Request;
  9 +
  10 +/**
  11 + * Class LoginController
  12 + * @package App\Http\Controllers\Aside
  13 + * @author zbj
  14 + * @date 2023/4/19
  15 + */
  16 +class LoginController extends BaseController
  17 +{
  18 +
  19 + function login(Request $request, LoginLogic $logic)
  20 + {
  21 + if ($request->isMethod('POST')) {
  22 + $request->validate([
  23 + 'mobile' => ['required', new Mobile()],
  24 + 'password' => 'required',
  25 + ], [
  26 + 'mobile.required' => '请输入手机号',
  27 + 'password.required' => '请输入密码',
  28 + ]);
  29 +
  30 + $logic->login();
  31 +
  32 + return $this->success();
  33 + }
  34 + return view('admin.login');
  35 + }
  36 +
  37 + public function logout(LoginLogic $logic)
  38 + {
  39 + return $logic->logout();
  40 + }
  41 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside;
  4 +
  5 +use App\Http\Controllers\Controller;
  6 +use Illuminate\Http\Request;
  7 +
  8 +/**
  9 + * Class Menu
  10 + * @package App\Http\Controllers\Aside
  11 + * @author zbj
  12 + * @date 2023/4/19
  13 + */
  14 +class MenuController extends Controller
  15 +{
  16 + /**
  17 + * 菜单列表
  18 + * @param Request $request
  19 + * @return \Illuminate\Http\JsonResponse
  20 + */
  21 + public function index(Request $request)
  22 + {
  23 + echo 111;
  24 + }
  25 +
  26 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\Blog;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +
  8 +class AiCommandController extends BaseController
  9 +{
  10 + /**
  11 + * @name :指令列表
  12 + * @return void
  13 + * @author :liyuhang
  14 + * @method
  15 + */
  16 + public function lists(){
  17 + $url = 'v2/openai_chat';
  18 + $command = ['key'=>'user','scene'=>'system'];
  19 + $param = ['key'=>'user','scene'=>'请问你是谁?'];
  20 + $data = send_openai_msg($url,$command,$param);
  21 + var_dump($data);
  22 + die();
  23 + $this->response('success',Code::SUCCESS,$data);
  24 + }
  25 +
  26 + /**
  27 + * @name
  28 + * @return void
  29 + * @author :liyuhang
  30 + * @method
  31 + */
  32 + public function add(){
  33 +
  34 + }
  35 +
  36 + /**
  37 + * @name
  38 + * @return void
  39 + * @author :liyuhang
  40 + * @method
  41 + */
  42 + public function edit(){
  43 +
  44 + }
  45 +
  46 + /**
  47 + * @name
  48 + * @return void
  49 + * @author :liyuhang
  50 + * @method
  51 + */
  52 + public function del(){
  53 +
  54 + }
  55 +}
@@ -23,8 +23,8 @@ class ComController extends BaseController @@ -23,8 +23,8 @@ class ComController extends BaseController
23 */ 23 */
24 public function login(Request $request){ 24 public function login(Request $request){
25 $request->validate([ 25 $request->validate([
26 - 'mobile'=>'required|string|max:12',  
27 - 'password'=>'required|string', 26 + 'mobile'=>['required|string|max:12'],
  27 + 'password'=>['required|string'],
28 ],[ 28 ],[
29 'mobile.required'=>'标题必须填写', 29 'mobile.required'=>'标题必须填写',
30 'mobile.string'=>'标题中含有非法文字', 30 'mobile.string'=>'标题中含有非法文字',
@@ -87,8 +87,8 @@ class ComController extends BaseController @@ -87,8 +87,8 @@ class ComController extends BaseController
87 */ 87 */
88 public function edit_info(Request $request){ 88 public function edit_info(Request $request){
89 $request->validate([ 89 $request->validate([
90 - 'password'=>'required,string,min:5',  
91 - 'name'=>'required,max:20', 90 + 'password'=>['required,string,min:5'],
  91 + 'name'=>['required,max:20'],
92 ],[ 92 ],[
93 'password.required'=>'密码必须填写', 93 'password.required'=>'密码必须填写',
94 'password.string'=>'密码中含有非法文字', 94 'password.string'=>'密码中含有非法文字',
@@ -2,35 +2,21 @@ @@ -2,35 +2,21 @@
2 2
3 namespace App\Http\Logic\Aside; 3 namespace App\Http\Logic\Aside;
4 4
5 -use App\Enums\Common\Code;  
6 -use App\Exceptions\AsideGlobalException; 5 +
  6 +use App\Http\Logic\Logic;
7 7
8 /** 8 /**
9 * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 9 * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常
10 * Class BaseLogic 10 * Class BaseLogic
11 * @package App\Http\Logic\Aside 11 * @package App\Http\Logic\Aside
12 */ 12 */
13 -class BaseLogic 13 +class BaseLogic extends Logic
14 { 14 {
15 protected $requestAll; 15 protected $requestAll;
16 - public function __construct()  
17 - {  
18 - $this->requestAll=request()->all();  
19 - }  
20 16
21 - /**  
22 - * @notes: 统一格式化分页返回  
23 - * @return array  
24 - */  
25 - function getPageData($pagninate): array 17 + public function __construct()
26 { 18 {
27 - $p = $pagninate->toArray();  
28 - $result['list'] = $p ['data'];  
29 - $result['pager']['total'] = $p ['total'];  
30 - $result['pager']['page'] = $p ['current_page'];  
31 - $result['pager']['pagesize'] = $p ['per_page'];  
32 -  
33 - return $result; 19 + $this->requestAll = request()->all();
34 } 20 }
35 21
36 } 22 }
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Aside;
  4 +
  5 +use App\Models\Manage;
  6 +use Illuminate\Support\Facades\Hash;
  7 +use Illuminate\Support\Facades\Session;
  8 +
  9 +
  10 +/**
  11 + * Class LoginLogic
  12 + * @package App\Http\Logic\Aside
  13 + * @author zbj
  14 + * @date 2023/4/19
  15 + */
  16 +class LoginLogic extends BaseLogic
  17 +{
  18 + public function __construct()
  19 + {
  20 + parent::__construct();
  21 +
  22 + $this->model = new Manage();
  23 + }
  24 +
  25 +
  26 + public function login()
  27 + {
  28 + $info = $this->model->where('mobile', $this->requestAll['mobile'])->first();
  29 +
  30 + if (!$info){
  31 + $this->fail('登录用户名不存在');
  32 + }
  33 + if (Manage::STATUS_DISABLE == $info->status) {
  34 + $this->fail('帐号已被禁用');
  35 + }
  36 + if (!Hash::check($this->requestAll['password'], $info->password)) {
  37 + $this->fail('登录密码不正确');
  38 + }
  39 + Session::put('manage', $info->toArray());
  40 + return $this->success();
  41 + }
  42 +
  43 + public function logout(){
  44 + Session::forget('manage');
  45 + return redirect(route('admin.login'));
  46 + }
  47 +}
1 <?php 1 <?php
2 2
3 -namespace App\Http\Logic\Aside; 3 +namespace App\Http\Logic\Bside;
4 4
5 -class DemoLogic extends BaseLogic 5 +class AiCommandLogic extends BaseLogic
6 { 6 {
7 - protected $requestAll;  
8 public function __construct() 7 public function __construct()
9 { 8 {
10 - $this->requestAll=request()->all();  
11 - }  
12 - public function testLogic():array  
13 - {  
14 - return $this->success($this->requestAll); 9 + parent::__construct();
  10 +
  11 + $this->model = new Department();
15 } 12 }
16 } 13 }
@@ -2,18 +2,16 @@ @@ -2,18 +2,16 @@
2 2
3 namespace App\Http\Logic\Bside; 3 namespace App\Http\Logic\Bside;
4 4
5 -use App\Enums\Common\Code;  
6 use App\Exceptions\BsideGlobalException; 5 use App\Exceptions\BsideGlobalException;
7 -use App\Helper\Arr; 6 +use App\Http\Logic\Logic;
8 use Illuminate\Http\Request; 7 use Illuminate\Http\Request;
9 use Illuminate\Support\Facades\Cache; 8 use Illuminate\Support\Facades\Cache;
10 9
11 /** 10 /**
12 * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 11 * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常
13 */ 12 */
14 -class BaseLogic 13 +class BaseLogic extends Logic
15 { 14 {
16 - protected $model;  
17 15
18 protected $requestAll; 16 protected $requestAll;
19 17
@@ -21,8 +19,6 @@ class BaseLogic @@ -21,8 +19,6 @@ class BaseLogic
21 19
22 protected $user; 20 protected $user;
23 21
24 - protected $is_cache = true; //是否缓存数据  
25 -  
26 public function __construct() 22 public function __construct()
27 { 23 {
28 $this->requestAll = request()->all(); 24 $this->requestAll = request()->all();
@@ -30,27 +26,6 @@ class BaseLogic @@ -30,27 +26,6 @@ class BaseLogic
30 $this->user = Cache::get(request()->header('token')); 26 $this->user = Cache::get(request()->header('token'));
31 } 27 }
32 28
33 - /**  
34 - * @notes: 请简要描述方法功能  
35 - * @param array $data  
36 - * @return array  
37 - */  
38 - public function success(array $data = [])  
39 - {  
40 - return $data;  
41 - }  
42 -  
43 - /**  
44 - * @notes: 错误抛出  
45 - * @param string $code  
46 - * @param string $message  
47 - * @throws BsideGlobalException  
48 - */  
49 - public function fail(string $message = "", string $code = Code::SYSTEM_ERROR)  
50 - {  
51 - throw new BsideGlobalException($code, $message);  
52 - }  
53 -  
54 29
55 /** 30 /**
56 * 列表 31 * 列表
@@ -65,41 +40,7 @@ class BaseLogic @@ -65,41 +40,7 @@ class BaseLogic
65 public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) 40 public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
66 { 41 {
67 $map[] = ['project_id' => $this->user['project_id']]; 42 $map[] = ['project_id' => $this->user['project_id']];
68 - // 闭包查询条件格式化  
69 - $query = $this->formatQuery($map);  
70 -  
71 - // 排序(支持多重排序)  
72 - $query = $query->when($sort, function ($query, $sort) {  
73 - foreach ($sort as $k=>$v) {  
74 - $query->orderBy($k, $v);  
75 - }  
76 - });  
77 -  
78 - // 数据分页设置  
79 - if ($limit) {  
80 - $result = $query->select($columns)->paginate($limit);  
81 - }else{  
82 - $result = $query->select($columns)->get();  
83 - }  
84 -  
85 - return $this->success($result ? $result->toArray() : []);  
86 - }  
87 -  
88 -  
89 - /**  
90 - * 详情  
91 - * @param $id  
92 - * @return array  
93 - * @author zbj  
94 - * @date 2023/4/13  
95 - */  
96 - public function getInfo($id)  
97 - {  
98 - $info = $this->getCacheInfo($id);  
99 - if(!$info){  
100 - $this->fail('数据不存在或者已经删除');  
101 - }  
102 - return $this->success($info->toArray()); 43 + return parent::getList($map, $sort, $columns, $limit);
103 } 44 }
104 45
105 /** 46 /**
@@ -108,19 +49,10 @@ class BaseLogic @@ -108,19 +49,10 @@ class BaseLogic
108 * @author zbj 49 * @author zbj
109 * @date 2023/4/15 50 * @date 2023/4/15
110 */ 51 */
111 - public function getCacheInfo($id){  
112 - if($this->is_cache){  
113 - $info = Cache::get($this->getInfoCacheKey($id));  
114 - if (!$info) {  
115 - $info = $this->model->find($id);  
116 - if($info){  
117 - Cache::put($this->getInfoCacheKey($id), $info);  
118 - }  
119 - }  
120 - }else{  
121 - $info = $this->model->find($id);  
122 - }  
123 - if($info && $info['project_id'] != $this->user['project_id']) { 52 + public function getCacheInfo($id)
  53 + {
  54 + $info = parent::getCacheInfo($id);
  55 + if ($info && $info['project_id'] != $this->user['project_id']) {
124 $info = null; 56 $info = null;
125 } 57 }
126 return $info; 58 return $info;
@@ -134,178 +66,24 @@ class BaseLogic @@ -134,178 +66,24 @@ class BaseLogic
134 * @author zbj 66 * @author zbj
135 * @date 2023/4/13 67 * @date 2023/4/13
136 */ 68 */
137 - public function save($param){  
138 - if(!empty($param['id'])){  
139 - $this->model = $this->getCacheInfo($param['id']);  
140 - if(!$this->model){  
141 - $this->fail('数据不存在或者已经删除');  
142 - }  
143 - } 69 + public function save($param)
  70 + {
144 $param['project_id'] = $this->user['project_id']; 71 $param['project_id'] = $this->user['project_id'];
145 - foreach ($param as $name => $value){  
146 - $this->model[$name] = $value;  
147 - }  
148 -  
149 - $res = $this->model->save();  
150 -  
151 - if($res){  
152 - //清缓存  
153 - if($this->is_cache && !empty($param['id'])){  
154 - Cache::forget($this->getInfoCacheKey($param['id']));  
155 - }  
156 - return $this->success(['id' => $this->model->id]); //返回保存的数据id  
157 - }else{  
158 - $this->fail('保存失败');  
159 - } 72 + return parent::save($param);
160 } 73 }
161 74
162 /** 75 /**
163 * 批量删除 76 * 批量删除
164 * @param $ids 77 * @param $ids
  78 + * @param array $map
165 * @return array 79 * @return array
166 - * @throws BsideGlobalException  
167 - * @author zbj  
168 - * @date 2023/4/13  
169 - */  
170 - public function delete($ids){  
171 - $ids = array_filter(Arr::splitFilterToArray($ids), 'intval');  
172 - if(!$ids){  
173 - $this->fail('ID不能为空');  
174 - }  
175 - $map[] = ['id', 'in', $ids];  
176 - $map[] = ['project_id' => $this->user['project_id']];  
177 -  
178 - $res = $this->formatQuery($map)->delete();  
179 - if($res){  
180 -  
181 - if($this->is_cache){  
182 - foreach ($ids as $id){  
183 - Cache::forget($this->getInfoCacheKey($id));  
184 - }  
185 - }  
186 - return $this->success();  
187 - }else{  
188 - $this->fail('删除失败');  
189 - }  
190 - }  
191 -  
192 - /**  
193 - * @param $id  
194 - * @return string  
195 - * @author zbj  
196 - * @date 2023/4/13  
197 - */  
198 - public function getInfoCacheKey($id){  
199 - return $this->model->getTable() . '_info_' . $id;  
200 - }  
201 -  
202 - /**  
203 - * 格式化查询条件  
204 - * @param $map  
205 - * @param $query  
206 - * @return mixed  
207 * @author zbj 80 * @author zbj
208 * @date 2023/4/13 81 * @date 2023/4/13
209 */ 82 */
210 - public function formatQuery($map, $query = '') 83 + public function delete($ids, $map = [])
211 { 84 {
212 - $model = $query ?: $this->model;  
213 - $query = $model->where(function ($query) use ($map) {  
214 - foreach ($map as $v) {  
215 - if ($v instanceof \Closure) {  
216 - $query = $query->where($v);  
217 - continue;  
218 - }  
219 - // 判断是否是键值对类型  
220 - if (key($v) !== 0) {  
221 - $key = key($v);  
222 - $val = $v[$key];  
223 - $v = [$key, is_array($val) ? 'in' : '=', $val];  
224 - }  
225 - switch ($v[1]) {  
226 - case 'like':  
227 - // like查询 ['name|title', 'like', '%a%']  
228 - if (strpos($v[0], '|') !== false) {  
229 - $query->where(function ($query) use ($v) {  
230 - $item = explode('|', $v[0]);  
231 - foreach ($item as $vo) {  
232 - $query->orWhere($vo, $v[1], $v[2]);  
233 - }  
234 - });  
235 - } else {  
236 - $query->where($v[0], $v[1], $v[2]);  
237 - }  
238 - break;  
239 - case 'in':  
240 - // in查询 ['id', 'in', [1,2,3]]  
241 - if (!is_array($v[2])) {  
242 - $v[2] = explode(',', $v[2]);  
243 - }  
244 - $query->whereIn($v[0], $v[2]);  
245 - break;  
246 - case 'not in':  
247 - // not in查询 ['id', 'not in', [1,2,3]]  
248 - if (!is_array($v[2])) {  
249 - $v[2] = explode(',', $v[2]);  
250 - }  
251 - $query->whereNotIn($v[0], $v[2]);  
252 - break;  
253 - case 'between':  
254 - // between查询 ['created_at', 'between', ['xxx', 'xxx]]  
255 - if (!is_array($v[2])) {  
256 - $v[2] = explode(',', $v[2]);  
257 - }  
258 - $query->whereBetween($v[0], $v[2]);  
259 - break;  
260 - case 'not between':  
261 - // not between查询 ['created_at', 'not between', ['xxx', 'xxx]]  
262 - if (!is_array($v[2])) {  
263 - $v[2] = explode(',', $v[2]);  
264 - }  
265 - $query->whereNotBetween($v[0], $v[2]);  
266 - break;  
267 - case 'null':  
268 - // null查询 ['deleted_at', 'null']  
269 - $query->whereNull($v[0]);  
270 - break;  
271 - case "not null":  
272 - // not null查询 ['deleted_at', 'not null']  
273 - $query->whereNotNull($v[0]);  
274 - break;  
275 - case "or":  
276 - // or查询 [[['status'=>1],['status'=>2]], 'or'];  
277 - //格式:or (status=1 and status=2)  
278 - $where = $v[0];  
279 - $query->orWhere(function ($query) use ($where) {  
280 - // 递归解析查询条件  
281 - $this->formatQuery($where, $query);  
282 - });  
283 - break;  
284 - case 'xor':  
285 - // xor查询 [[['status'=>1],['status'=>2]], 'xor'];  
286 - // 格式:and (status=1 or status=2)  
287 - $where = $v[0];  
288 - $query->where(function ($query) use ($where) {  
289 - foreach ($where as $w) {  
290 - $query->orWhere(function ($query) use ($w) {  
291 - // 递归解析查询条件  
292 - $this->formatQuery([$w], $query);  
293 - });  
294 - }  
295 - });  
296 - break;  
297 - default:  
298 - // 常规查询  
299 - if (count($v) == 2) {  
300 - $query->where($v[0], '=', $v[1]);  
301 - } else {  
302 - $query->where($v[0], $v[1], $v[2]);  
303 - }  
304 - break;  
305 - }  
306 - }  
307 - });  
308 - return $query; 85 + $map[] = ['project_id' => $this->user['project_id']];
  86 + return parent::delete($ids, $map);
309 } 87 }
310 /** 88 /**
311 * @name :上传图片 89 * @name :上传图片
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 namespace App\Http\Logic\Bside\Product; 3 namespace App\Http\Logic\Bside\Product;
4 4
5 -use App\Helper\Arr;  
6 use App\Http\Logic\Bside\BaseLogic; 5 use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\Product\Attr; 6 use App\Models\Product\Attr;
8 use App\Models\Product\AttrValue; 7 use App\Models\Product\AttrValue;
  1 +<?php
  2 +
  3 +namespace App\Http\Logic;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Enums\Common\Common;
  7 +use App\Exceptions\AsideGlobalException;
  8 +use App\Exceptions\BsideGlobalException;
  9 +use App\Helper\Arr;
  10 +use Illuminate\Support\Facades\Cache;
  11 +
  12 +/**
  13 + * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常
  14 + */
  15 +class Logic
  16 +{
  17 + protected $model;
  18 +
  19 + protected $is_cache = true; //是否缓存数据
  20 +
  21 + /**
  22 + * @notes: 请简要描述方法功能
  23 + * @param array $data
  24 + * @return array
  25 + */
  26 + public function success(array $data = [])
  27 + {
  28 + return $data;
  29 + }
  30 +
  31 + /**
  32 + * @notes: 错误抛出
  33 + * @param string $code
  34 + * @param string $message
  35 + * @throws AsideGlobalException|BsideGlobalException
  36 + */
  37 + public function fail(string $message = "", string $code = Code::SYSTEM_ERROR)
  38 + {
  39 + if((request()->path()[0]) == Common::B){
  40 + throw new BsideGlobalException($code, $message);
  41 + }
  42 + throw new AsideGlobalException($code, $message);
  43 + }
  44 +
  45 + /**
  46 + * 列表
  47 + * @param array $map
  48 + * @param array $sort
  49 + * @param array $columns
  50 + * @param int $limit
  51 + * @return array
  52 + * @author zbj
  53 + * @date 2023/4/13
  54 + */
  55 + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
  56 + {
  57 + // 闭包查询条件格式化
  58 + $query = $this->formatQuery($map);
  59 +
  60 + // 排序(支持多重排序)
  61 + $query = $query->when($sort, function ($query, $sort) {
  62 + foreach ($sort as $k=>$v) {
  63 + $query->orderBy($k, $v);
  64 + }
  65 + });
  66 +
  67 + // 数据分页设置
  68 + if ($limit) {
  69 + $result = $query->select($columns)->paginate($limit);
  70 + }else{
  71 + $result = $query->select($columns)->get();
  72 + }
  73 +
  74 + return $this->success($result ? $result->toArray() : []);
  75 + }
  76 +
  77 +
  78 + /**
  79 + * 详情
  80 + * @param $id
  81 + * @return array
  82 + * @throws AsideGlobalException|BsideGlobalException
  83 + * @author zbj
  84 + * @date 2023/4/13
  85 + */
  86 + public function getInfo($id)
  87 + {
  88 + $info = $this->getCacheInfo($id);
  89 + if(!$info){
  90 + $this->fail('数据不存在或者已经删除');
  91 + }
  92 + return $this->success($info->toArray());
  93 + }
  94 +
  95 + /**
  96 + * @param $id
  97 + * @return mixed
  98 + * @author zbj
  99 + * @date 2023/4/15
  100 + */
  101 + public function getCacheInfo($id){
  102 + if($this->is_cache){
  103 + $info = Cache::get($this->getInfoCacheKey($id));
  104 + if (!$info) {
  105 + $info = $this->model->find($id);
  106 + if($info){
  107 + Cache::put($this->getInfoCacheKey($id), $info);
  108 + }
  109 + }
  110 + }else{
  111 + $info = $this->model->find($id);
  112 + }
  113 + return $info;
  114 + }
  115 +
  116 + /**
  117 + * 保存
  118 + * @param $param
  119 + * @return array
  120 + * @throws BsideGlobalException|AsideGlobalException
  121 + * @author zbj
  122 + * @date 2023/4/13
  123 + */
  124 + public function save($param){
  125 + if(!empty($param['id'])){
  126 + $this->model = $this->getCacheInfo($param['id']);
  127 + if(!$this->model){
  128 + $this->fail('数据不存在或者已经删除');
  129 + }
  130 + }
  131 + foreach ($param as $name => $value){
  132 + $this->model[$name] = $value;
  133 + }
  134 +
  135 + $res = $this->model->save();
  136 +
  137 + if($res){
  138 + //清缓存
  139 + if($this->is_cache && !empty($param['id'])){
  140 + Cache::forget($this->getInfoCacheKey($param['id']));
  141 + }
  142 + return $this->success(['id' => $this->model->id]); //返回保存的数据id
  143 + }else{
  144 + $this->fail('保存失败');
  145 + }
  146 + }
  147 +
  148 + /**
  149 + * 批量删除
  150 + * @param $ids
  151 + * @param array $map
  152 + * @return array
  153 + * @throws AsideGlobalException|BsideGlobalException
  154 + * @author zbj
  155 + * @date 2023/4/13
  156 + */
  157 + public function delete($ids, $map = []){
  158 + $ids = array_filter(Arr::splitFilterToArray($ids), 'intval');
  159 + if(!$ids){
  160 + $this->fail('ID不能为空');
  161 + }
  162 + $map[] = ['id', 'in', $ids];
  163 +
  164 + $res = $this->formatQuery($map)->delete();
  165 + if($res){
  166 +
  167 + if($this->is_cache){
  168 + foreach ($ids as $id){
  169 + Cache::forget($this->getInfoCacheKey($id));
  170 + }
  171 + }
  172 + return $this->success();
  173 + }else{
  174 + $this->fail('删除失败');
  175 + }
  176 + }
  177 +
  178 + /**
  179 + * @param $id
  180 + * @return string
  181 + * @author zbj
  182 + * @date 2023/4/13
  183 + */
  184 + public function getInfoCacheKey($id){
  185 + return $this->model->getTable() . '_info_' . $id;
  186 + }
  187 +
  188 + /**
  189 + * 格式化查询条件
  190 + * @param $map
  191 + * @param $query
  192 + * @return mixed
  193 + * @author zbj
  194 + * @date 2023/4/13
  195 + */
  196 + public function formatQuery($map, $query = '')
  197 + {
  198 + $model = $query ?: $this->model;
  199 + $query = $model->where(function ($query) use ($map) {
  200 + foreach ($map as $v) {
  201 + if ($v instanceof \Closure) {
  202 + $query = $query->where($v);
  203 + continue;
  204 + }
  205 + // 判断是否是键值对类型
  206 + if (key($v) !== 0) {
  207 + $key = key($v);
  208 + $val = $v[$key];
  209 + $v = [$key, is_array($val) ? 'in' : '=', $val];
  210 + }
  211 + switch ($v[1]) {
  212 + case 'like':
  213 + // like查询 ['name|title', 'like', '%a%']
  214 + if (strpos($v[0], '|') !== false) {
  215 + $query->where(function ($query) use ($v) {
  216 + $item = explode('|', $v[0]);
  217 + foreach ($item as $vo) {
  218 + $query->orWhere($vo, $v[1], $v[2]);
  219 + }
  220 + });
  221 + } else {
  222 + $query->where($v[0], $v[1], $v[2]);
  223 + }
  224 + break;
  225 + case 'in':
  226 + // in查询 ['id', 'in', [1,2,3]]
  227 + if (!is_array($v[2])) {
  228 + $v[2] = explode(',', $v[2]);
  229 + }
  230 + $query->whereIn($v[0], $v[2]);
  231 + break;
  232 + case 'not in':
  233 + // not in查询 ['id', 'not in', [1,2,3]]
  234 + if (!is_array($v[2])) {
  235 + $v[2] = explode(',', $v[2]);
  236 + }
  237 + $query->whereNotIn($v[0], $v[2]);
  238 + break;
  239 + case 'between':
  240 + // between查询 ['created_at', 'between', ['xxx', 'xxx]]
  241 + if (!is_array($v[2])) {
  242 + $v[2] = explode(',', $v[2]);
  243 + }
  244 + $query->whereBetween($v[0], $v[2]);
  245 + break;
  246 + case 'not between':
  247 + // not between查询 ['created_at', 'not between', ['xxx', 'xxx]]
  248 + if (!is_array($v[2])) {
  249 + $v[2] = explode(',', $v[2]);
  250 + }
  251 + $query->whereNotBetween($v[0], $v[2]);
  252 + break;
  253 + case 'null':
  254 + // null查询 ['deleted_at', 'null']
  255 + $query->whereNull($v[0]);
  256 + break;
  257 + case "not null":
  258 + // not null查询 ['deleted_at', 'not null']
  259 + $query->whereNotNull($v[0]);
  260 + break;
  261 + case "or":
  262 + // or查询 [[['status'=>1],['status'=>2]], 'or'];
  263 + //格式:or (status=1 and status=2)
  264 + $where = $v[0];
  265 + $query->orWhere(function ($query) use ($where) {
  266 + // 递归解析查询条件
  267 + $this->formatQuery($where, $query);
  268 + });
  269 + break;
  270 + case 'xor':
  271 + // xor查询 [[['status'=>1],['status'=>2]], 'xor'];
  272 + // 格式:and (status=1 or status=2)
  273 + $where = $v[0];
  274 + $query->where(function ($query) use ($where) {
  275 + foreach ($where as $w) {
  276 + $query->orWhere(function ($query) use ($w) {
  277 + // 递归解析查询条件
  278 + $this->formatQuery([$w], $query);
  279 + });
  280 + }
  281 + });
  282 + break;
  283 + default:
  284 + // 常规查询
  285 + if (count($v) == 2) {
  286 + $query->where($v[0], '=', $v[1]);
  287 + } else {
  288 + $query->where($v[0], $v[1], $v[2]);
  289 + }
  290 + break;
  291 + }
  292 + }
  293 + });
  294 + return $query;
  295 + }
  296 +}
@@ -2,8 +2,10 @@ @@ -2,8 +2,10 @@
2 2
3 namespace App\Http\Middleware\Aside; 3 namespace App\Http\Middleware\Aside;
4 4
  5 +use App\Enums\Common\Code;
5 use Closure; 6 use Closure;
6 use Illuminate\Http\Request; 7 use Illuminate\Http\Request;
  8 +use Illuminate\Support\Facades\Session;
7 9
8 class LoginAuthMiddleware 10 class LoginAuthMiddleware
9 { 11 {
@@ -16,6 +18,16 @@ class LoginAuthMiddleware @@ -16,6 +18,16 @@ class LoginAuthMiddleware
16 */ 18 */
17 public function handle(Request $request, Closure $next) 19 public function handle(Request $request, Closure $next)
18 { 20 {
  21 + $manage = Session::get('manage');
  22 +
  23 + if (!$manage) {
  24 + if($request->ajax()){
  25 + return response(['status'=> Code::USER_ERROR,'msg'=>'当前用户未登录']);
  26 + }else{
  27 + return redirect(route('admin.login'));
  28 + }
  29 + }
  30 +
19 return $next($request); 31 return $next($request);
20 } 32 }
21 } 33 }
@@ -5,6 +5,7 @@ namespace App\Http\Middleware\Bside; @@ -5,6 +5,7 @@ namespace App\Http\Middleware\Bside;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Models\ProjectMenu; 6 use App\Models\ProjectMenu;
7 use App\Models\ProjectRole as ProjectRoleModel; 7 use App\Models\ProjectRole as ProjectRoleModel;
  8 +use App\Services\ProjectServer;
8 use Closure; 9 use Closure;
9 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
10 use Illuminate\Http\Response; 11 use Illuminate\Http\Response;
@@ -29,6 +30,9 @@ class LoginAuthMiddleware @@ -29,6 +30,9 @@ class LoginAuthMiddleware
29 if(empty($info)){ 30 if(empty($info)){
30 return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']); 31 return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']);
31 } 32 }
  33 + // 设置数据信息
  34 + ProjectServer::useProject($info['project_id']);
  35 +
32 //操作权限设置 36 //操作权限设置
33 $projectRoleModel = new ProjectRoleModel(); 37 $projectRoleModel = new ProjectRoleModel();
34 $role_info = $projectRoleModel->read(['id'=>$info['role_id']]); 38 $role_info = $projectRoleModel->read(['id'=>$info['role_id']]);
1 -<?php  
2 -  
3 -namespace App\Http\Requests\Aside;  
4 -  
5 -use App\Enums\Common\Demo;  
6 -use BenSampo\Enum\Rules\EnumValue;  
7 -use Illuminate\Foundation\Http\FormRequest;  
8 -  
9 -class DemoRequest extends FormRequest  
10 -{  
11 - /**  
12 - * Determine if the user is authorized to make this request.  
13 - *  
14 - * @return bool  
15 - */  
16 - public function authorize()  
17 - {  
18 - return true;  
19 - }  
20 -  
21 - /**  
22 - * Get the validation rules that apply to the request.  
23 - *  
24 - * @return array  
25 - */  
26 - public function rules()  
27 - {  
28 - return [  
29 - 'name'=>['required'],  
30 - 'status'=>['required','integer',new EnumValue(Demo::class)]  
31 - ];  
32 - }  
33 -}  
@@ -2,11 +2,10 @@ @@ -2,11 +2,10 @@
2 2
3 namespace App\Models; 3 namespace App\Models;
4 4
5 -class Manager extends Base 5 +class AiCommand extends Base
6 { 6 {
7 //设置关联表名 7 //设置关联表名
8 - protected $table = 'gl_manager'; 8 + protected $table = 'gl_ai_command';
9 //自动维护create_at创建时间 updated_at修改时间 9 //自动维护create_at创建时间 updated_at修改时间
10 public $timestamps = true; 10 public $timestamps = true;
11 -  
12 } 11 }
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +class Manage extends Base
  6 +{
  7 + //设置关联表名
  8 + protected $table = 'gl_manage';
  9 +
  10 + protected $hidden = ['password'];
  11 +
  12 + const STATUS_ACTIVE = 0;
  13 + const STATUS_DISABLE = 1;
  14 +}
@@ -12,6 +12,8 @@ class Project extends Base @@ -12,6 +12,8 @@ class Project extends Base
12 public $timestamps = true; 12 public $timestamps = true;
13 protected $dateFormat = 'Y-m-d'; 13 protected $dateFormat = 'Y-m-d';
14 14
  15 + const DATABASE_NAME_FIX = 'globalso_project_';
  16 +
15 /** 17 /**
16 * @name:获取当前对象不分页列表 18 * @name:获取当前对象不分页列表
17 */ 19 */
@@ -19,4 +21,52 @@ class Project extends Base @@ -19,4 +21,52 @@ class Project extends Base
19 $lists = DB::table($this->table)->select(['*'])->where($this->map)->orderBy($this->order)->get(); 21 $lists = DB::table($this->table)->select(['*'])->where($this->map)->orderBy($this->order)->get();
20 return $lists; 22 return $lists;
21 } 23 }
  24 +
  25 + /**
  26 + * 通过ID获取项目信息
  27 + * @param $id
  28 + * @return self
  29 + */
  30 + public static function getProjectById($id)
  31 + {
  32 + return self::where(['id' => $id])->first();
  33 + }
  34 +
  35 + /**
  36 + * 项目部署服务器信息
  37 + * @return \Illuminate\Database\Eloquent\Relations\HasOne
  38 + */
  39 + public function serverConfig()
  40 + {
  41 + return self::hasOne(ServeConfig::class, 'id', 'serve_id');
  42 + }
  43 +
  44 + /**
  45 + * 项目部署mysql数据库信息
  46 + * @return \Illuminate\Database\Eloquent\Relations\HasOne
  47 + */
  48 + public function mysqlConfig()
  49 + {
  50 + return self::hasOne(ServeConfig::class, 'id', 'mysql_id');
  51 + }
  52 +
  53 + /**
  54 + * 项目使用Redis服务器信息, 如果没有即使用默认配置
  55 + * @return \Illuminate\Database\Eloquent\Relations\HasOne
  56 + */
  57 + public function redisConfig()
  58 + {
  59 + return self::hasOne(ServeConfig::class, 'id', 'redis_id');
  60 + }
  61 +
  62 + /**
  63 + * 获取项目对应数据库名称
  64 + * 初始化数据库、数据表迭代等功能使用
  65 + * TODO 如果前缀变更,请使用该方法进行处理
  66 + * @return string
  67 + */
  68 + public function databaseName()
  69 + {
  70 + return self::DATABASE_NAME_FIX . $this->id;
  71 + }
22 } 72 }
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2023/4/17
  6 + * Time: 10:04
  7 + */
  8 +
  9 +namespace App\Models;
  10 +
  11 +/**
  12 + * 服务账户信息
  13 + * Class ServeConfig
  14 + * @package App\Models
  15 + */
  16 +class ServeConfig extends Base
  17 +{
  18 + /**
  19 + * @var string
  20 + */
  21 + protected $table = 'gl_server_config';
  22 +
  23 + /**
  24 + * @var array
  25 + */
  26 + protected $guarded = ['updated_at'];
  27 +
  28 + /**
  29 + * 1:服务器, 2:MySQL, 3:Redis
  30 + */
  31 + const TYPE_SERVER = 1;
  32 + const TYPE_MYSQL = 2;
  33 + const TYPE_REDIS = 3;
  34 +
  35 + /**
  36 + * 用户名加密
  37 + * @param $value
  38 + */
  39 + public function setUserAttribute($value)
  40 + {
  41 + $this->attributes['user'] = encrypt($value);
  42 + }
  43 +
  44 + /**
  45 + * 密码加密
  46 + * @param $value
  47 + */
  48 + public function setPasswordAttribute($value)
  49 + {
  50 + $this->attributes['password'] = encrypt($value);
  51 + }
  52 +
  53 + /**
  54 + * 端口加密
  55 + * @param $value
  56 + */
  57 + public function setPortAttribute($value)
  58 + {
  59 + $this->attributes['Port'] = encrypt($value);
  60 + }
  61 +
  62 + /**
  63 + * @return mixed
  64 + */
  65 + public function getUserAttribute()
  66 + {
  67 + return decrypt($this->user);
  68 + }
  69 +
  70 + /**
  71 + * @return mixed
  72 + */
  73 + public function getPasswordAttribute()
  74 + {
  75 + return decrypt($this->password);
  76 + }
  77 +
  78 + /**
  79 + * @return mixed
  80 + */
  81 + public function getPortAttribute()
  82 + {
  83 + return decrypt($this->port);
  84 + }
  85 +
  86 +}
@@ -42,16 +42,16 @@ class RouteServiceProvider extends ServiceProvider @@ -42,16 +42,16 @@ class RouteServiceProvider extends ServiceProvider
42 $this->mapBsideRoute(); 42 $this->mapBsideRoute();
43 43
44 // 暂时无用 44 // 暂时无用
45 -// $this->routes(function () {  
46 -// Route::prefix('api')  
47 -// ->middleware('api')  
48 -// ->namespace($this->namespace)  
49 -// ->group(base_path('routes/api.php'));  
50 -//  
51 -// Route::middleware('web')  
52 -// ->namespace($this->namespace)  
53 -// ->group(base_path('routes/web.php'));  
54 -// }); 45 + $this->routes(function () {
  46 + Route::prefix('api')
  47 + ->middleware('api')
  48 + ->namespace($this->namespace)
  49 + ->group(base_path('routes/api.php'));
  50 +
  51 + Route::middleware('web')
  52 + ->namespace($this->namespace)
  53 + ->group(base_path('routes/web.php'));
  54 + });
55 } 55 }
56 56
57 /** 57 /**
  1 +<?php
  2 +
  3 +namespace App\Rules;
  4 +
  5 +use Illuminate\Contracts\Validation\Rule;
  6 +
  7 +/**
  8 + * 验证手机号
  9 + * Class Mobile
  10 + * @package App\Rules
  11 + * @author zbj
  12 + * @date 2023/4/19
  13 + */
  14 +class Mobile implements Rule
  15 +{
  16 +
  17 + /**
  18 + * Determine if the validation rule passes.
  19 + *
  20 + * @param string $attribute
  21 + * @param mixed $value
  22 + * @return bool
  23 + */
  24 + public function passes($attribute, $value)
  25 + {
  26 + $cardReg = '/^1(3|4|5|7|8)\d{9}$/';
  27 + return preg_match($cardReg, $value);
  28 + }
  29 +
  30 + /**
  31 + * Get the validation error message.
  32 + *
  33 + * @return string
  34 + */
  35 + public function message()
  36 + {
  37 + return '手机号码格式不正确';
  38 + }
  39 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2023/4/17
  6 + * Time: 15:16
  7 + */
  8 +
  9 +namespace App\Services;
  10 +
  11 +use App\Models\Project;
  12 +
  13 +/**
  14 + * Class ProjectServer
  15 + * @package App\Services
  16 + */
  17 +class ProjectServer extends BaseService
  18 +{
  19 + /**
  20 + * @param $project_id
  21 + * @return bool
  22 + */
  23 + public static function useProject($project_id)
  24 + {
  25 + $project = Project::getProjectById($project_id);
  26 + if (empty($project))
  27 + return false;
  28 + // 设置 database.connections.custom_mysql 配置
  29 + config(['database.connections.custom_mysql.host' => $project->mysqlConfig()->host]);
  30 + config(['database.connections.custom_mysql.port' => $project->mysqlConfig()->port]);
  31 + config(['database.connections.custom_mysql.database' => $project->databaseName()]);
  32 + config(['database.connections.custom_mysql.username' => $project->mysqlConfig()->user]);
  33 + config(['database.connections.custom_mysql.password' => $project->mysqlConfig()->password]);
  34 + // 设置 redis 配置
  35 + return true;
  36 + }
  37 +}
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 "require": { 7 "require": {
8 "php": "^7.3|^8.0", 8 "php": "^7.3|^8.0",
9 "bensampo/laravel-enum": "^4.2", 9 "bensampo/laravel-enum": "^4.2",
  10 + "doctrine/dbal": "^3.6",
10 "fruitcake/laravel-cors": "^2.0", 11 "fruitcake/laravel-cors": "^2.0",
11 "guzzlehttp/guzzle": "^7.0.1", 12 "guzzlehttp/guzzle": "^7.0.1",
12 "laravel/framework": "^8.75", 13 "laravel/framework": "^8.75",
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 "This file is @generated automatically" 5 "This file is @generated automatically"
6 ], 6 ],
7 - "content-hash": "ec0188ad5b235cba39d53baaa3d96767", 7 + "content-hash": "6c3880102ef840b5bed38e672d350800",
8 "packages": [ 8 "packages": [
9 { 9 {
10 "name": "asm89/stack-cors", 10 "name": "asm89/stack-cors",
@@ -305,6 +305,346 @@ @@ -305,6 +305,346 @@
305 "time": "2021-08-13T13:06:58+00:00" 305 "time": "2021-08-13T13:06:58+00:00"
306 }, 306 },
307 { 307 {
  308 + "name": "doctrine/cache",
  309 + "version": "2.2.0",
  310 + "source": {
  311 + "type": "git",
  312 + "url": "https://github.com/doctrine/cache.git",
  313 + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb"
  314 + },
  315 + "dist": {
  316 + "type": "zip",
  317 + "url": "https://api.github.com/repos/doctrine/cache/zipball/1ca8f21980e770095a31456042471a57bc4c68fb",
  318 + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb",
  319 + "shasum": ""
  320 + },
  321 + "require": {
  322 + "php": "~7.1 || ^8.0"
  323 + },
  324 + "conflict": {
  325 + "doctrine/common": ">2.2,<2.4"
  326 + },
  327 + "require-dev": {
  328 + "cache/integration-tests": "dev-master",
  329 + "doctrine/coding-standard": "^9",
  330 + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
  331 + "psr/cache": "^1.0 || ^2.0 || ^3.0",
  332 + "symfony/cache": "^4.4 || ^5.4 || ^6",
  333 + "symfony/var-exporter": "^4.4 || ^5.4 || ^6"
  334 + },
  335 + "type": "library",
  336 + "autoload": {
  337 + "psr-4": {
  338 + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
  339 + }
  340 + },
  341 + "notification-url": "https://packagist.org/downloads/",
  342 + "license": [
  343 + "MIT"
  344 + ],
  345 + "authors": [
  346 + {
  347 + "name": "Guilherme Blanco",
  348 + "email": "guilhermeblanco@gmail.com"
  349 + },
  350 + {
  351 + "name": "Roman Borschel",
  352 + "email": "roman@code-factory.org"
  353 + },
  354 + {
  355 + "name": "Benjamin Eberlei",
  356 + "email": "kontakt@beberlei.de"
  357 + },
  358 + {
  359 + "name": "Jonathan Wage",
  360 + "email": "jonwage@gmail.com"
  361 + },
  362 + {
  363 + "name": "Johannes Schmitt",
  364 + "email": "schmittjoh@gmail.com"
  365 + }
  366 + ],
  367 + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.",
  368 + "homepage": "https://www.doctrine-project.org/projects/cache.html",
  369 + "keywords": [
  370 + "abstraction",
  371 + "apcu",
  372 + "cache",
  373 + "caching",
  374 + "couchdb",
  375 + "memcached",
  376 + "php",
  377 + "redis",
  378 + "xcache"
  379 + ],
  380 + "support": {
  381 + "issues": "https://github.com/doctrine/cache/issues",
  382 + "source": "https://github.com/doctrine/cache/tree/2.2.0"
  383 + },
  384 + "funding": [
  385 + {
  386 + "url": "https://www.doctrine-project.org/sponsorship.html",
  387 + "type": "custom"
  388 + },
  389 + {
  390 + "url": "https://www.patreon.com/phpdoctrine",
  391 + "type": "patreon"
  392 + },
  393 + {
  394 + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache",
  395 + "type": "tidelift"
  396 + }
  397 + ],
  398 + "time": "2022-05-20T20:07:39+00:00"
  399 + },
  400 + {
  401 + "name": "doctrine/dbal",
  402 + "version": "3.6.1",
  403 + "source": {
  404 + "type": "git",
  405 + "url": "https://github.com/doctrine/dbal.git",
  406 + "reference": "57815c7bbcda3cd18871d253c1dd8cbe56f8526e"
  407 + },
  408 + "dist": {
  409 + "type": "zip",
  410 + "url": "https://api.github.com/repos/doctrine/dbal/zipball/57815c7bbcda3cd18871d253c1dd8cbe56f8526e",
  411 + "reference": "57815c7bbcda3cd18871d253c1dd8cbe56f8526e",
  412 + "shasum": ""
  413 + },
  414 + "require": {
  415 + "composer-runtime-api": "^2",
  416 + "doctrine/cache": "^1.11|^2.0",
  417 + "doctrine/deprecations": "^0.5.3|^1",
  418 + "doctrine/event-manager": "^1|^2",
  419 + "php": "^7.4 || ^8.0",
  420 + "psr/cache": "^1|^2|^3",
  421 + "psr/log": "^1|^2|^3"
  422 + },
  423 + "require-dev": {
  424 + "doctrine/coding-standard": "11.1.0",
  425 + "fig/log-test": "^1",
  426 + "jetbrains/phpstorm-stubs": "2022.3",
  427 + "phpstan/phpstan": "1.10.3",
  428 + "phpstan/phpstan-strict-rules": "^1.5",
  429 + "phpunit/phpunit": "9.6.4",
  430 + "psalm/plugin-phpunit": "0.18.4",
  431 + "squizlabs/php_codesniffer": "3.7.2",
  432 + "symfony/cache": "^5.4|^6.0",
  433 + "symfony/console": "^4.4|^5.4|^6.0",
  434 + "vimeo/psalm": "4.30.0"
  435 + },
  436 + "suggest": {
  437 + "symfony/console": "For helpful console commands such as SQL execution and import of files."
  438 + },
  439 + "bin": [
  440 + "bin/doctrine-dbal"
  441 + ],
  442 + "type": "library",
  443 + "autoload": {
  444 + "psr-4": {
  445 + "Doctrine\\DBAL\\": "src"
  446 + }
  447 + },
  448 + "notification-url": "https://packagist.org/downloads/",
  449 + "license": [
  450 + "MIT"
  451 + ],
  452 + "authors": [
  453 + {
  454 + "name": "Guilherme Blanco",
  455 + "email": "guilhermeblanco@gmail.com"
  456 + },
  457 + {
  458 + "name": "Roman Borschel",
  459 + "email": "roman@code-factory.org"
  460 + },
  461 + {
  462 + "name": "Benjamin Eberlei",
  463 + "email": "kontakt@beberlei.de"
  464 + },
  465 + {
  466 + "name": "Jonathan Wage",
  467 + "email": "jonwage@gmail.com"
  468 + }
  469 + ],
  470 + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.",
  471 + "homepage": "https://www.doctrine-project.org/projects/dbal.html",
  472 + "keywords": [
  473 + "abstraction",
  474 + "database",
  475 + "db2",
  476 + "dbal",
  477 + "mariadb",
  478 + "mssql",
  479 + "mysql",
  480 + "oci8",
  481 + "oracle",
  482 + "pdo",
  483 + "pgsql",
  484 + "postgresql",
  485 + "queryobject",
  486 + "sasql",
  487 + "sql",
  488 + "sqlite",
  489 + "sqlserver",
  490 + "sqlsrv"
  491 + ],
  492 + "support": {
  493 + "issues": "https://github.com/doctrine/dbal/issues",
  494 + "source": "https://github.com/doctrine/dbal/tree/3.6.1"
  495 + },
  496 + "funding": [
  497 + {
  498 + "url": "https://www.doctrine-project.org/sponsorship.html",
  499 + "type": "custom"
  500 + },
  501 + {
  502 + "url": "https://www.patreon.com/phpdoctrine",
  503 + "type": "patreon"
  504 + },
  505 + {
  506 + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal",
  507 + "type": "tidelift"
  508 + }
  509 + ],
  510 + "time": "2023-03-02T19:26:24+00:00"
  511 + },
  512 + {
  513 + "name": "doctrine/deprecations",
  514 + "version": "v1.0.0",
  515 + "source": {
  516 + "type": "git",
  517 + "url": "https://github.com/doctrine/deprecations.git",
  518 + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
  519 + },
  520 + "dist": {
  521 + "type": "zip",
  522 + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
  523 + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
  524 + "shasum": ""
  525 + },
  526 + "require": {
  527 + "php": "^7.1|^8.0"
  528 + },
  529 + "require-dev": {
  530 + "doctrine/coding-standard": "^9",
  531 + "phpunit/phpunit": "^7.5|^8.5|^9.5",
  532 + "psr/log": "^1|^2|^3"
  533 + },
  534 + "suggest": {
  535 + "psr/log": "Allows logging deprecations via PSR-3 logger implementation"
  536 + },
  537 + "type": "library",
  538 + "autoload": {
  539 + "psr-4": {
  540 + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
  541 + }
  542 + },
  543 + "notification-url": "https://packagist.org/downloads/",
  544 + "license": [
  545 + "MIT"
  546 + ],
  547 + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
  548 + "homepage": "https://www.doctrine-project.org/",
  549 + "support": {
  550 + "issues": "https://github.com/doctrine/deprecations/issues",
  551 + "source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
  552 + },
  553 + "time": "2022-05-02T15:47:09+00:00"
  554 + },
  555 + {
  556 + "name": "doctrine/event-manager",
  557 + "version": "1.2.0",
  558 + "source": {
  559 + "type": "git",
  560 + "url": "https://github.com/doctrine/event-manager.git",
  561 + "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520"
  562 + },
  563 + "dist": {
  564 + "type": "zip",
  565 + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520",
  566 + "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520",
  567 + "shasum": ""
  568 + },
  569 + "require": {
  570 + "doctrine/deprecations": "^0.5.3 || ^1",
  571 + "php": "^7.1 || ^8.0"
  572 + },
  573 + "conflict": {
  574 + "doctrine/common": "<2.9"
  575 + },
  576 + "require-dev": {
  577 + "doctrine/coding-standard": "^9 || ^10",
  578 + "phpstan/phpstan": "~1.4.10 || ^1.8.8",
  579 + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
  580 + "vimeo/psalm": "^4.24"
  581 + },
  582 + "type": "library",
  583 + "autoload": {
  584 + "psr-4": {
  585 + "Doctrine\\Common\\": "src"
  586 + }
  587 + },
  588 + "notification-url": "https://packagist.org/downloads/",
  589 + "license": [
  590 + "MIT"
  591 + ],
  592 + "authors": [
  593 + {
  594 + "name": "Guilherme Blanco",
  595 + "email": "guilhermeblanco@gmail.com"
  596 + },
  597 + {
  598 + "name": "Roman Borschel",
  599 + "email": "roman@code-factory.org"
  600 + },
  601 + {
  602 + "name": "Benjamin Eberlei",
  603 + "email": "kontakt@beberlei.de"
  604 + },
  605 + {
  606 + "name": "Jonathan Wage",
  607 + "email": "jonwage@gmail.com"
  608 + },
  609 + {
  610 + "name": "Johannes Schmitt",
  611 + "email": "schmittjoh@gmail.com"
  612 + },
  613 + {
  614 + "name": "Marco Pivetta",
  615 + "email": "ocramius@gmail.com"
  616 + }
  617 + ],
  618 + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.",
  619 + "homepage": "https://www.doctrine-project.org/projects/event-manager.html",
  620 + "keywords": [
  621 + "event",
  622 + "event dispatcher",
  623 + "event manager",
  624 + "event system",
  625 + "events"
  626 + ],
  627 + "support": {
  628 + "issues": "https://github.com/doctrine/event-manager/issues",
  629 + "source": "https://github.com/doctrine/event-manager/tree/1.2.0"
  630 + },
  631 + "funding": [
  632 + {
  633 + "url": "https://www.doctrine-project.org/sponsorship.html",
  634 + "type": "custom"
  635 + },
  636 + {
  637 + "url": "https://www.patreon.com/phpdoctrine",
  638 + "type": "patreon"
  639 + },
  640 + {
  641 + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager",
  642 + "type": "tidelift"
  643 + }
  644 + ],
  645 + "time": "2022-10-12T20:51:15+00:00"
  646 + },
  647 + {
308 "name": "doctrine/inflector", 648 "name": "doctrine/inflector",
309 "version": "2.0.4", 649 "version": "2.0.4",
310 "source": { 650 "source": {
@@ -2597,6 +2937,55 @@ @@ -2597,6 +2937,55 @@
2597 "time": "2023-02-25T19:38:58+00:00" 2937 "time": "2023-02-25T19:38:58+00:00"
2598 }, 2938 },
2599 { 2939 {
  2940 + "name": "psr/cache",
  2941 + "version": "1.0.1",
  2942 + "source": {
  2943 + "type": "git",
  2944 + "url": "https://github.com/php-fig/cache.git",
  2945 + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
  2946 + },
  2947 + "dist": {
  2948 + "type": "zip",
  2949 + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
  2950 + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
  2951 + "shasum": ""
  2952 + },
  2953 + "require": {
  2954 + "php": ">=5.3.0"
  2955 + },
  2956 + "type": "library",
  2957 + "extra": {
  2958 + "branch-alias": {
  2959 + "dev-master": "1.0.x-dev"
  2960 + }
  2961 + },
  2962 + "autoload": {
  2963 + "psr-4": {
  2964 + "Psr\\Cache\\": "src/"
  2965 + }
  2966 + },
  2967 + "notification-url": "https://packagist.org/downloads/",
  2968 + "license": [
  2969 + "MIT"
  2970 + ],
  2971 + "authors": [
  2972 + {
  2973 + "name": "PHP-FIG",
  2974 + "homepage": "http://www.php-fig.org/"
  2975 + }
  2976 + ],
  2977 + "description": "Common interface for caching libraries",
  2978 + "keywords": [
  2979 + "cache",
  2980 + "psr",
  2981 + "psr-6"
  2982 + ],
  2983 + "support": {
  2984 + "source": "https://github.com/php-fig/cache/tree/master"
  2985 + },
  2986 + "time": "2016-08-06T20:24:11+00:00"
  2987 + },
  2988 + {
2600 "name": "psr/container", 2989 "name": "psr/container",
2601 "version": "1.1.2", 2990 "version": "1.1.2",
2602 "source": { 2991 "source": {
@@ -8574,5 +8963,5 @@ @@ -8574,5 +8963,5 @@
8574 "php": "^7.3|^8.0" 8963 "php": "^7.3|^8.0"
8575 }, 8964 },
8576 "platform-dev": [], 8965 "platform-dev": [],
8577 - "plugin-api-version": "2.3.0" 8966 + "plugin-api-version": "2.1.0"
8578 } 8967 }
@@ -63,6 +63,46 @@ return [ @@ -63,6 +63,46 @@ return [
63 ]) : [], 63 ]) : [],
64 ], 64 ],
65 65
  66 + 'custom_tmp_mysql' => [
  67 + 'driver' => 'mysql',
  68 + 'url' => env('DATABASE_URL'),
  69 + 'host' => env('DB_HOST', '127.0.0.1'),
  70 + 'port' => env('DB_PORT', '3306'),
  71 + 'database' => env('DB_DATABASE_TMP', 'globalso_project_tmp'),
  72 + 'username' => env('DB_USERNAME', 'forge'),
  73 + 'password' => env('DB_PASSWORD', ''),
  74 + 'unix_socket' => env('DB_SOCKET', ''),
  75 + 'charset' => 'utf8mb4',
  76 + 'collation' => 'utf8mb4_unicode_ci',
  77 + 'prefix' => '',
  78 + 'prefix_indexes' => true,
  79 + 'strict' => true,
  80 + 'engine' => null,
  81 + 'options' => extension_loaded('pdo_mysql') ? array_filter([
  82 + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
  83 + ]) : [],
  84 + ],
  85 +
  86 + 'custom_mysql' => [
  87 + 'driver' => 'mysql',
  88 + 'url' => '', // DB_DATABASE_URL
  89 + 'host' => '', // DB_DATABASE_HOST
  90 + 'port' => '', // DB_DATABASE_PORT
  91 + 'database' => '', // DB_DATABASE_CUSTOM
  92 + 'username' => '', // DB_DATABASE_USER
  93 + 'password' => '', // DB_DATABASE_PASSWORD
  94 + 'unix_socket' => env('DB_SOCKET', ''),
  95 + 'charset' => 'utf8mb4',
  96 + 'collation' => 'utf8mb4_unicode_ci',
  97 + 'prefix' => '',
  98 + 'prefix_indexes' => true,
  99 + 'strict' => true,
  100 + 'engine' => null,
  101 + 'options' => extension_loaded('pdo_mysql') ? array_filter([
  102 + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
  103 + ]) : [],
  104 + ],
  105 +
66 'pgsql' => [ 106 'pgsql' => [
67 'driver' => 'pgsql', 107 'driver' => 'pgsql',
68 'url' => env('DATABASE_URL'), 108 'url' => env('DATABASE_URL'),
  1 +<form method="post" action="">
  2 + @csrf
  3 + <input type="text" name="mobile" value="15680871314">
  4 + <input type="text" name="password" value="123456">
  5 + <input type="submit">
  6 +</form>
@@ -5,12 +5,23 @@ @@ -5,12 +5,23 @@
5 use \Illuminate\Support\Facades\Route; 5 use \Illuminate\Support\Facades\Route;
6 use \App\Http\Controllers\Aside; 6 use \App\Http\Controllers\Aside;
7 //必须登录验证的路由组 7 //必须登录验证的路由组
8 -Route::middleware(['aloginauth'])->group(function ($route) { 8 +Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上web的中间件
  9 + Route::middleware(['aloginauth'])->group(function () {
  10 + Route::get('/', [Aside\IndexController::class, 'index'])->name('admin.home');
  11 + Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout');
9 12
10 -}); 13 + //菜单
  14 + Route::prefix('menu')->group(function () {
  15 + Route::get('/', [Aside\MenuController::class, 'index'])->name('admin.menu');
  16 + Route::get('/info', [Aside\MenuController::class, 'info'])->name('admin.menu_info');
  17 + Route::post('/save', [Aside\MenuController::class, 'save'])->name('admin.menu_save');
  18 + Route::any('/delete', [Aside\MenuController::class, 'delete'])->name('admin.menu_delete');
  19 + });
  20 + });
11 21
12 //无需登录验证的路由组 22 //无需登录验证的路由组
13 -Route::group([], function ($route) {  
14 - //demo  
15 - $route->post('/demo', [Aside\DemoController::class, 'test']); 23 + Route::group([], function () {
  24 + Route::any('/login', [Aside\LoginController::class, 'login'])->name('admin.login');
  25 + });
16 }); 26 });
  27 +
@@ -82,6 +82,10 @@ Route::middleware(['bloginauth'])->group(function () { @@ -82,6 +82,10 @@ Route::middleware(['bloginauth'])->group(function () {
82 Route::any('/del', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'del'])->name('blog_del'); 82 Route::any('/del', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'del'])->name('blog_del');
83 Route::any('/status', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'status'])->name('blog_status'); 83 Route::any('/status', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'status'])->name('blog_status');
84 }); 84 });
  85 + //ai指令
  86 + Route::prefix('command')->group(function () {
  87 + Route::any('/', [\App\Http\Controllers\Bside\Blog\AiCommandController::class, 'lists'])->name('command_lists');
  88 + });
85 89
86 //产品 90 //产品
87 Route::prefix('product')->group(function () { 91 Route::prefix('product')->group(function () {