作者 邓超

Merge branch 'develop' into dc

正在显示 53 个修改的文件 包含 3567 行增加523 行删除

要显示太多修改。

为保证性能只显示 53 of 53+ 个文件。

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 /public/storage 3 /public/storage
4 /storage 4 /storage
5 /vendor 5 /vendor
  6 +/uploads
6 .env 7 .env
7 .env.backup 8 .env.backup
8 .phpunit.result.cache 9 .phpunit.result.cache
@@ -14,4 +15,6 @@ yarn-error.log @@ -14,4 +15,6 @@ yarn-error.log
14 /.idea 15 /.idea
15 /.vscode 16 /.vscode
16 composer.lock 17 composer.lock
  18 +app/Console/Commands/Test/Demo.php
17 /public/upload 19 /public/upload
  20 +/public/runtime
  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +
  6 +use App\Models\Devops\DevopsTaskLog;
  7 +use App\Models\Project\Project;
  8 +use Illuminate\Console\Command;
  9 +use App\Models\Devops\DevopsTask as DevopsTaskModel;
  10 +
  11 +/**
  12 + * Class DevopsTask
  13 + * @package App\Console\Commands
  14 + * @author zbj
  15 + * @date 2023/4/25
  16 + */
  17 +class DevopsTask extends Command
  18 +{
  19 + /**
  20 + * The name and signature of the console command.
  21 + *
  22 + * @var string
  23 + */
  24 + protected $signature = 'devops_task';
  25 +
  26 + /**
  27 + * The console command description.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $description = '运维任务执行';
  32 +
  33 + /**
  34 + * Create a new command instance.
  35 + *
  36 + * @return void
  37 + */
  38 + public function __construct()
  39 + {
  40 + parent::__construct();
  41 + }
  42 +
  43 + /**
  44 + * @return bool
  45 + */
  46 + public function handle()
  47 + {
  48 + while (true){
  49 + $tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();
  50 + foreach ($tasks as $task){
  51 + echo "Start task " . $task->id . PHP_EOL;
  52 + if($task->type == DevopsTaskModel::TYPE_MYSQL){
  53 + $this->updateTable($task);
  54 + }
  55 + echo "End task " . $task->id . PHP_EOL;
  56 + }
  57 + sleep(10);
  58 + }
  59 + }
  60 +
  61 + public function updateTable($task){
  62 + $projects = Project::all();
  63 + foreach ($projects as $project){
  64 + echo "project " . $project->id;
  65 + $log = DevopsTaskLog::addLog($task->id, $project->id);
  66 + if($log->status == DevopsTaskModel::STATUS_ACTIVE){
  67 + continue;
  68 + }
  69 + if(!$project->mysqlConfig){
  70 + $log->status = DevopsTaskLog::STATUS_ERROR;
  71 + $log->remark = '未配置数据库';
  72 + $log->save();
  73 + continue;
  74 + }
  75 + //DB类是单例模式,生命周期内修改配置不会生效
  76 + $conn = new \mysqli(
  77 + $project->mysqlConfig->host,
  78 + $project->mysqlConfig->user,
  79 + $project->mysqlConfig->password,
  80 + $project->databaseName(),
  81 + $project->mysqlConfig->port,
  82 + );
  83 + $res = $conn->query($task->sql);
  84 +
  85 + $log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR;
  86 + $log->remark = $res ? '成功' : 'sql执行失败';
  87 + $log->save();
  88 + echo '-->' . $log->remark . PHP_EOL;
  89 + }
  90 + $task->status = DevopsTaskModel::STATUS_ACTIVE;
  91 + $task->save();
  92 + }
  93 +}
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 +namespace App\Console\Commands\Test;
  4 +
  5 +
  6 +
  7 +
  8 +use App\Helper\Arr;
  9 +use Illuminate\Console\Command;
  10 +use Illuminate\Support\Facades\DB;
  11 +
  12 +class DiffDb extends Command
  13 +{
  14 + protected $signature = 'project:diff_db';
  15 +
  16 + /**
  17 + * The console command description.
  18 + *
  19 + * @var string
  20 + */
  21 + protected $description = '对比数据库结构';
  22 +
  23 + /**
  24 + * Create a new command instance.
  25 + *
  26 + * @return void
  27 + */
  28 + public function __construct()
  29 + {
  30 + parent::__construct();
  31 + }
  32 +
  33 + public function handle()
  34 + {
  35 + $custom_mysql_config = [
  36 + 'database.connections.custom_mysql.host' => '127.0.0.1',
  37 + 'database.connections.custom_mysql.port' => '3306',
  38 + 'database.connections.custom_mysql.database' => 'globalso_project_1',
  39 + 'database.connections.custom_mysql.username' => 'root',
  40 + 'database.connections.custom_mysql.password' => 'root',
  41 + ];
  42 + config($custom_mysql_config);
  43 +
  44 + $this->output->writeln("开始进行数据表对比!");
  45 + $tablesSource = DB::select("show tables");
  46 + $tablesRemote = DB::connection('custom_mysql')->select("show tables");
  47 + $tablesSource = array_map(function($item){
  48 + return Arr::first($item);
  49 + }, $tablesSource);
  50 + $tablesRemote = array_map(function($item){
  51 + return Arr::first($item);
  52 + }, $tablesRemote);
  53 +
  54 +
  55 + $tablesNotInRemote = [];
  56 + $tablesInRemote = [];
  57 +
  58 + foreach ($tablesSource as $t) {
  59 + if (!in_array($t, $tablesRemote)) {
  60 + $tablesNotInRemote[] = $t;
  61 + } else {
  62 + $tablesInRemote[] = $t;
  63 + }
  64 + }
  65 +
  66 + //print reports
  67 + echo "本地存在,但是不在custom_mysql中的表:" . PHP_EOL;
  68 + echo ">>>>>>==================================<<<<<<" . PHP_EOL;
  69 + foreach ($tablesNotInRemote as $t) {
  70 + echo $t . PHP_EOL;
  71 + }
  72 + echo ">>>>>>==================================<<<<<<" . PHP_EOL . PHP_EOL . PHP_EOL;
  73 +
  74 +
  75 + echo "本地与custom_mysql结构不一致的表:" . PHP_EOL;
  76 + echo ">>>>>>==================================<<<<<<" . PHP_EOL;
  77 +
  78 + $only127 = $onlyRemote = $modify127 = [];
  79 + foreach ($tablesInRemote as $t) {
  80 + $columns127 = DB::select("show columns from `{$t}`");
  81 + foreach ($columns127 as &$item){
  82 + $item = get_object_vars($item);
  83 + }
  84 + $columnsRemote = DB::connection('custom_mysql')->select("show columns from `{$t}`");
  85 + foreach ($columnsRemote as &$item){
  86 + $item = get_object_vars($item);
  87 + }
  88 +
  89 + $fields127 = $fieldsRemote = [];
  90 + foreach ($columns127 as $v) {
  91 + $fields127[$v['Field']] = $v;
  92 + }
  93 + foreach ($columnsRemote as $v) {
  94 + $fieldsRemote[$v['Field']] = $v;
  95 + }
  96 +
  97 + foreach ($fields127 as $f => $column) {
  98 + if (!isset($fieldsRemote[$f])) {
  99 + $only127[$t][] = $f;
  100 + } else if ($column !== $fieldsRemote[$f]) {
  101 + dump($column);
  102 + dump($fieldsRemote[$f]);
  103 + $modify127[$t][] = $f;
  104 + }
  105 + }
  106 +
  107 + foreach ($fieldsRemote as $f => $column) {
  108 + if (!isset($fields127[$f])) {
  109 + $onlyRemote[$t][] = $f;
  110 + }
  111 + }
  112 + }
  113 +
  114 + if (!empty($only127)) {
  115 + echo "只本地存在:" . PHP_EOL;
  116 + foreach ($only127 as $t => $columns) {
  117 + echo $t . ":";
  118 + foreach ($columns as $field) {
  119 + echo $field . "\t";
  120 + }
  121 + echo PHP_EOL;
  122 + }
  123 + }
  124 + if (!empty($onlyRemote)) {
  125 + echo "只custom_mysql存在:" . PHP_EOL;
  126 + foreach ($onlyRemote as $t => $columns) {
  127 + echo $t . ":";
  128 + foreach ($columns as $field) {
  129 + echo $field . "\t";
  130 + }
  131 + echo PHP_EOL;
  132 + }
  133 + }
  134 + if (!empty($modify127)) {
  135 + echo "本地更新:" . PHP_EOL;
  136 + foreach ($modify127 as $t => $columns) {
  137 + echo $t . ":";
  138 + foreach ($columns as $field) {
  139 + echo $field . "\t";
  140 + }
  141 + echo PHP_EOL;
  142 + }
  143 + }
  144 + echo ">>>>>>==================================<<<<<<" . PHP_EOL . PHP_EOL . PHP_EOL;
  145 + }
  146 +}
@@ -18,4 +18,5 @@ final class Common extends Enum @@ -18,4 +18,5 @@ final class Common extends Enum
18 //端 18 //端
19 const A='a'; 19 const A='a';
20 const B='b'; 20 const B='b';
  21 + const C='c';
21 } 22 }
  1 +<?php
  2 +
  3 +namespace App\Exceptions;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use Exception;
  7 +use Throwable;
  8 +
  9 +/**
  10 + * @notes: C端接口统一错误格式
  11 + * Class CsideGlobalException
  12 + * @package App\Exceptions
  13 + */
  14 +class CsideGlobalException extends Exception
  15 +{
  16 + public function __construct($code = 0, $message = "", Throwable $previous = null)
  17 + {
  18 + $this->code = $code;
  19 + $this->message = $message;
  20 + if (empty($this->message)) {
  21 + $this->message = Code::fromValue($code)->description;
  22 + }
  23 + }
  24 +}
@@ -3,13 +3,13 @@ @@ -3,13 +3,13 @@
3 namespace App\Exceptions; 3 namespace App\Exceptions;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 -use App\Enums\Common\Common;  
7 use App\Services\DingService; 6 use App\Services\DingService;
8 use App\Utils\EncryptUtils; 7 use App\Utils\EncryptUtils;
9 use App\Utils\LogUtils; 8 use App\Utils\LogUtils;
10 use Illuminate\Database\Eloquent\ModelNotFoundException; 9 use Illuminate\Database\Eloquent\ModelNotFoundException;
11 use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; 10 use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
12 use Illuminate\Support\Arr; 11 use Illuminate\Support\Arr;
  12 +use Illuminate\Support\Facades\Cache;
13 use Illuminate\Support\Facades\Route; 13 use Illuminate\Support\Facades\Route;
14 use Illuminate\Validation\ValidationException; 14 use Illuminate\Validation\ValidationException;
15 use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; 15 use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
@@ -59,7 +59,6 @@ class Handler extends ExceptionHandler @@ -59,7 +59,6 @@ class Handler extends ExceptionHandler
59 */ 59 */
60 public function report(Throwable $exception) 60 public function report(Throwable $exception)
61 { 61 {
62 -  
63 //日志记录 62 //日志记录
64 $exceptionMessage = "错误CODE:" . $exception->getCode() . 63 $exceptionMessage = "错误CODE:" . $exception->getCode() .
65 "-----错误message:" . $exception->getMessage() . 64 "-----错误message:" . $exception->getMessage() .
@@ -73,6 +72,10 @@ class Handler extends ExceptionHandler @@ -73,6 +72,10 @@ class Handler extends ExceptionHandler
73 elseif($exception instanceof BsideGlobalException) { 72 elseif($exception instanceof BsideGlobalException) {
74 LogUtils::error("BsideGlobalException", [], $exceptionMessage); 73 LogUtils::error("BsideGlobalException", [], $exceptionMessage);
75 } 74 }
  75 + //C端错误
  76 + elseif($exception instanceof CsideGlobalException) {
  77 + LogUtils::error("CsideGlobalException", [], $exceptionMessage);
  78 + }
76 //验证错误(非手动抛出) 79 //验证错误(非手动抛出)
77 elseif ($exception instanceof ValidationException) { 80 elseif ($exception instanceof ValidationException) {
78 LogUtils::error("参数验证失败", [], $exceptionMessage); 81 LogUtils::error("参数验证失败", [], $exceptionMessage);
@@ -111,6 +114,8 @@ class Handler extends ExceptionHandler @@ -111,6 +114,8 @@ class Handler extends ExceptionHandler
111 $code = $exception->getCode(); 114 $code = $exception->getCode();
112 }elseif ($exception instanceof BsideGlobalException) { 115 }elseif ($exception instanceof BsideGlobalException) {
113 $code = $exception->getCode(); 116 $code = $exception->getCode();
  117 + }elseif ($exception instanceof CsideGlobalException) {
  118 + $code = $exception->getCode();
114 } elseif ($exception instanceof ValidationException) { 119 } elseif ($exception instanceof ValidationException) {
115 $code = Code::USER_PARAMS_ERROE(); 120 $code = Code::USER_PARAMS_ERROE();
116 $message = $code->description = Arr::first(Arr::first($exception->errors())); 121 $message = $code->description = Arr::first(Arr::first($exception->errors()));
@@ -131,7 +136,6 @@ class Handler extends ExceptionHandler @@ -131,7 +136,6 @@ class Handler extends ExceptionHandler
131 //开启debug 错误原样输出 136 //开启debug 错误原样输出
132 $debub = config('app.debug'); 137 $debub = config('app.debug');
133 $message = $debub ? $message : ($code->description ?? $message); 138 $message = $debub ? $message : ($code->description ?? $message);
134 -  
135 $response = [ 139 $response = [
136 'code' => $code, 140 'code' => $code,
137 'message' => $message 141 'message' => $message
  1 +<?php
  2 +
  3 +namespace App\Helper;
  4 +
  5 +use GuzzleHttp\Client;
  6 +
  7 +/**
  8 + * @name: ayr_share社交绑定
  9 + */
  10 +class AyrShare
  11 +{
  12 + public $path = 'https://app.ayrshare.com';
  13 + //api_key
  14 + public $api_key = 'G8GQW3X-XBTMGXW-QPDDZ9A-WE1Z5SB';
  15 + //系统设置
  16 + public $config = [
  17 + 'facebook'=>'#best https://www.facebook.com',
  18 + 'google'=>'#best https://www.google.com',
  19 + 'instagram'=>'#best https://www.instagram.com',
  20 + 'linkedin'=>'#best https://www.linkedin.com',
  21 + 'twitter'=>'#best https://www.twitter.com',
  22 + 'telegram'=>'#best https://www.telegram.com',
  23 + 'tiktok'=>'#bestvideo',
  24 + ];
  25 + //profile_key
  26 + public $profile_key = '';
  27 + //设置请求头
  28 + public $headers = [
  29 + 'Authorization' => 'Bearer ',
  30 + 'Content-Type' => 'application/json',
  31 + ];
  32 + //私钥
  33 + private $private_key = "-----BEGIN RSA PRIVATE KEY-----
  34 +MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq
  35 +9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi
  36 +h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC
  37 +gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc
  38 +Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa
  39 +uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG
  40 +DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa
  41 +52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT
  42 +CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J
  43 +EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU
  44 +yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
  45 +yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
  46 +zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
  47 +-----END RSA PRIVATE KEY-----";
  48 +
  49 + /**
  50 + * @name :(创建子账户配置文件)post_create_profiles
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/5/5 15:16
  54 + */
  55 + public function post_create_profiles($data){
  56 + $param = [
  57 + 'title'=>$data['title'],
  58 + ];
  59 + $url = $this->path.'/api/profiles/profile';
  60 + return $this->http_click('post',$url,$param);
  61 + }
  62 + /**
  63 + * @name :(删除子账户配置文件)deleted_profiles
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2023/5/5 15:16
  67 + */
  68 + public function deleted_profiles($data){
  69 + $param = [
  70 + 'title'=>$data['title'],
  71 + 'profileKey'=>$this->profile_key,
  72 + ];
  73 + $url = $this->path.'/api/profiles/profile';
  74 + return $this->http_click('delete',$url,$param);
  75 + }
  76 +
  77 + /**
  78 + * @name :(跳转第三方生成jwt令牌)post_generate_jwt
  79 + * @author :lyh
  80 + * @method :post
  81 + * @time :2023/5/5 18:07 https://app.ayrshare.com/api/profiles/generateJWT
  82 + */
  83 + public function post_generate_jwt($data,$domain = 'globalso'){
  84 + $param = [
  85 + 'domain'=>$domain,
  86 + 'privateKey'=>$this->private_key,
  87 + 'profileKey'=>$data['profileKey'],
  88 +// 'logout'=>true
  89 + ];
  90 + $url = $this->path.'/api/profiles/generateJWT';
  91 + return $this->http_click('post',$url,$param);
  92 + }
  93 +
  94 + /**
  95 + * @name :(获取指定api_key的配置文件)get_profiles_users
  96 + * @author :lyh
  97 + * @method :post
  98 + * @time :2023/5/6 16:44
  99 + */
  100 + public function get_profiles_users($api_key){
  101 + $this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
  102 + $url = $this->path.'/api/user';
  103 + return $this->http_click('get',$url,[],$this->headers);
  104 + }
  105 +
  106 + /**
  107 + * @name :(发帖)post_send_msg
  108 + * @author :lyh
  109 + * @method :post
  110 + * @time :2023/5/8 9:22
  111 + * @param :platforms: "facebook", "fbg", "twitter",
  112 + * "linkedin", "instagram","youtube", "reddit" ,"telegram""
  113 + */
  114 + public function post_send_msg($param){
  115 + //平台参数处理
  116 + $this->headers['Accept-Encoding'] = 'gzip';
  117 + $this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key'];
  118 + $url = $this->path.'/api/post';
  119 + return $this->http_click('posts',$url,$param,$this->headers);
  120 + }
  121 +
  122 + /**
  123 + * @name :(上传图片或视频到ayr_share)post_media_upload
  124 + * @author :lyh
  125 + * @method :post
  126 + * @time :2023/5/8 9:47
  127 + * https://app.ayrshare.com/api/media/upload
  128 + */
  129 + public function post_media_upload($data){
  130 + $param = [
  131 + 'file'=>$data['file'],//base64编码
  132 + 'fileName'=>$data['file_name'],//生成图片名称
  133 + 'description'=>$data['description'],//描述
  134 + ];
  135 + $this->headers['Authorization'] = $this->headers['Authorization'].$data['profile_key'];
  136 + $url = $this->path.'/api/media/upload';
  137 + return $this->http_click('posts',$url,$param,$this->headers);
  138 + }
  139 +
  140 + /**
  141 + * @name :获取过去30天发布的历史记录(1-30)
  142 + * @author :lyh
  143 + * @method :get
  144 + * @time :2023/5/5 10:00
  145 + */
  146 + public function get_analytics_links($to_day){
  147 + $last_days = (string)$to_day;
  148 + $url = $this->path.'/analytics/links?lastDays='.$last_days;
  149 + return $this->http_click('get',$url);
  150 + }
  151 +
  152 + /**
  153 + * @name :(通过 Ayrshare 获取给定帖子的实时分析,例如点赞、印象、转推等)post_analytics
  154 + * @author :lyh
  155 + * @method :post
  156 + * @time :2023/5/5 11:56
  157 + */
  158 + public function post_analytics($id){
  159 + $param = [
  160 + 'id'=>$id,
  161 + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'],
  162 + ];
  163 + $url = $this->path.'/api/analytics/post';
  164 + return $this->http_click('post', $url, $param);
  165 + }
  166 + /**
  167 + * @name :(获取特定用户个人资料)analytics_post
  168 + * @author :lyh
  169 + * @method :post
  170 + * @time :2023/5/5 10:43
  171 + */
  172 + public function post_analytics_social(){
  173 + $post_data = [
  174 + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'],
  175 + ];
  176 + $url = $this->path.'/api/analytics/social';
  177 + return $this->http_click('post',$url,$post_data);
  178 + }
  179 +
  180 + /**
  181 + * @name :(设置自动计划)post_schedule_set
  182 + * @author :lyh
  183 + * @method :post
  184 + * @time :2023/5/5 13:58
  185 + */
  186 + public function post_schedule_set($data){
  187 + $param = [
  188 + 'schedule'=>["13:05Z", "20:14Z"],
  189 + 'title'=>$data['title'],
  190 + ];
  191 + $url = $this->path.'/api/auto-schedule/set';
  192 + return $this->http_click('post',$url,$param);
  193 + }
  194 +
  195 + /**
  196 + * @name :(删除自动计划)delete_schedule
  197 + * @author :lyh
  198 + * @method :post
  199 + * @time :2023/5/5 14:04
  200 + */
  201 + public function delete_schedule($data){
  202 + $param = [
  203 + 'title'=>$data['title'],
  204 + ];
  205 + $url = $this->path.'/api/auto-schedule/delete';
  206 + return $this->http_click('delete',$url,$param);
  207 + }
  208 +
  209 + /**
  210 + * @name :(列出自动计划)get_schedule_list
  211 + * @author :lyh
  212 + * @method :post
  213 + * @time :2023/5/5 14:08
  214 + */
  215 + public function get_schedule_list(){
  216 + $url = $this->path.'/api/auto-schedule/list';
  217 + return $this->http_click('get',$url);
  218 + }
  219 +
  220 + /**
  221 + * @name :(发布到用户个人资料)post_user
  222 + * @author :lyh
  223 + * @method :post
  224 + * @time :2023/5/5 15:00
  225 + */
  226 + public function post_profiles($data){
  227 + $param = [
  228 + 'post'=>$data['post'],
  229 + 'platforms'=>$data['platforms'],
  230 + 'profileKey'=>$this->profile_key,
  231 + 'mediaUrls'=>$data['mediaUrls']
  232 + ];
  233 + $url = $this->path.'/api/post';
  234 + return $this->http_click('post',$url,$param);
  235 + }
  236 +
  237 + /**
  238 + * 发送http post,get,put,delete请求
  239 + * @param type $url
  240 + * @param type $post_data
  241 + */
  242 + function http_click($method = 'post',$url, $param = [],$header = [])
  243 + {
  244 + if(!empty($param)){
  245 + $post_data['json'] = $param;
  246 + }
  247 + if(empty($header)){
  248 + $this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key;
  249 + }
  250 + $post_data['headers'] = !empty($header) ? $header : $this->headers;
  251 + $client = new Client();
  252 + try {
  253 + $res = $client->request(strtoupper($method), $url, $post_data)->getBody()->getContents();
  254 + return (array)json_decode($res);
  255 + } catch (\Exception $e) {
  256 + return ["status"=>"fail","message"=>$e->getMessage()];
  257 + }
  258 + }
  259 +}
  1 +<?php
  2 +
  3 +namespace App\Helper;
  4 +
  5 +use App\Models\Ai\AiCommand as AiCommandModel;
  6 +use App\Models\User\UserLog as UserLogModel;
  7 +use App\Models\User\UserLogin as UserLoginModel;
  8 +use Illuminate\Support\Facades\Cache;
  9 +
  10 +/**
  11 + * @name:
  12 + */
  13 +class Common
  14 +{
  15 + /**
  16 + * @name :生成用户操作日志
  17 + * @return void
  18 + * @author :liyuhang
  19 + * @method
  20 + */
  21 + public static function set_user_log($param = []){
  22 + $data = [
  23 + 'operator_id'=>$param['operator_id'],
  24 + 'model'=>$param['model'],
  25 + 'remark'=>$param['remark']
  26 + ];
  27 + $model = new UserLogModel();
  28 + return $model->add($data);
  29 + }
  30 +
  31 + /**
  32 + * @name :写入登录日志
  33 + * @return void
  34 + * @author :liyuhang
  35 + * @method
  36 + */
  37 + public static function set_user_login($param = []){
  38 + $data = [
  39 + 'user_id'=>$param['user_id'],
  40 + 'ip'=>$param['ip']
  41 + ];
  42 + $model = new UserLoginModel();
  43 + return $model->add($data);
  44 + }
  45 +
  46 + /**
  47 + * @name :ai自动生成
  48 + * @return mixed
  49 + * @author :liyuhang
  50 + * @method
  51 + */
  52 + public static function send_openai_msg($url,$param){
  53 + $url = HTTP_OPENAI_URL.$url;
  54 + $aiCommandModel = New AiCommandModel();
  55 + //指定库获取指令
  56 + $info = $aiCommandModel->read(['key'=>$param['key']]);
  57 + if($info === false){
  58 + response('指令不存在',400);
  59 + }
  60 + //替换关键字
  61 + $content = str_replace('$keyword$', $param['keywords'], $info['ai']);
  62 + $data = [
  63 + 'messages'=>[
  64 + ['role'=>'system','content'=>$info['scene']],
  65 + ['role'=>'assistant','content'=>$content],
  66 + ]
  67 + ];
  68 + return http_post($url,json_encode($data));
  69 + }
  70 +
  71 + /**
  72 + * @name :获取缓存
  73 + * @return void
  74 + * @author :liyuhang
  75 + * @method
  76 + */
  77 + public static function get_user_cache($table,$id,$type = 'B'){
  78 + $data = [];
  79 + $cache = config('cache.user_is_cache');
  80 + if(isset($cache) && ($cache['is_cache'] == true)){
  81 + $key = 'cache_'.$table.'_'.$id.'_type';
  82 + $data = Cache::store('file')->get($key);
  83 + }
  84 + return $data;
  85 + }
  86 +
  87 + /**
  88 + * @name :写入缓存
  89 + * @return bool
  90 + * @author :liyuhang
  91 + * @method
  92 + */
  93 + public static function set_user_cache($data = [],$table,$id,$type = 'B'){
  94 + $cache = config('cache.user_is_cache');
  95 + if(isset($cache) && ($cache['is_cache'] == true)){
  96 + $key = 'cache_'.$table.'_'.$id.'_type';
  97 + Cache::store('file')->set($key,$data,3600);
  98 + }
  99 + return true;
  100 + }
  101 +
  102 + /**
  103 + * @name :清除缓存
  104 + * @return bool
  105 + * @author :liyuhang
  106 + * @method
  107 + */
  108 + public static function del_user_cache($table,$id,$type = 'B'){
  109 + $cache = config('cache.user_is_cache');
  110 + if(isset($cache) && ($cache['is_cache'] == true)){
  111 + if(is_array($id)){
  112 + foreach ($id as $v){
  113 + $key = 'cache_'.$table.'_'.$v.'_type';
  114 + Cache::store('file')->pull($key);
  115 + }
  116 + }else{
  117 + $key = 'cache_'.$table.'_'.$id.'_type';
  118 + }
  119 + Cache::store('file')->pull($key);
  120 + }
  121 + return true;
  122 + }
  123 +
  124 + /**
  125 + * @name :(多维数组去重)array_deduplication
  126 + * @author :lyh
  127 + * @method :post
  128 + * @time :2023/5/9 10:47
  129 + */
  130 + public static function uniqueMultiArray($multiArray) {
  131 + $flatArray = array();
  132 + foreach ($multiArray as $item) {
  133 + if (is_array($item)) {
  134 + $flatArray = array_merge($flatArray, uniqueMultiArray($item));
  135 + } else {
  136 + $flatArray[] = $item;
  137 + }
  138 + }
  139 + return array_map("unserialize", array_unique(array_map("serialize", $flatArray)));
  140 + }
  141 +}
  1 +<?php
  2 +
  3 +namespace App\Helper;
  4 +
  5 +use App\Models\WebSetting\WebSettingCountry;
  6 +
  7 +/**
  8 + * @name:多语言国家设置
  9 + */
  10 +class Country
  11 +{
  12 + public $tls_list = [
  13 + 'en' => [
  14 + 'text' => '英语',
  15 + 'lang_text' => 'English',
  16 + 'con_flag' => 'con_flag/en.jfif',
  17 + 'shop_lang' => 'en-gb',
  18 + ],
  19 + 'zh' => [
  20 + 'text' => '中文',
  21 + 'lang_text' => '简体中文',
  22 + 'con_flag' => 'con_flag/zh.jfif',
  23 + 'shop_lang' => 'zh-cn',
  24 + ],
  25 + 'fr' => [
  26 + 'text' => '法语',
  27 + 'lang_text' => 'En français',
  28 + 'con_flag' => '',
  29 +
  30 + ],
  31 + 'de' => [
  32 + 'text' => '德语',
  33 + 'lang_text' => 'Das ist Deutsch.',
  34 + 'con_flag' => '',
  35 +
  36 + ],
  37 + 'ko' => [
  38 + 'text' => '韩语',
  39 + 'lang_text' => '',
  40 + 'con_flag' => '',
  41 +
  42 + ],
  43 + 'ja' => [
  44 + 'text' => '日语',
  45 + 'lang_text' => '',
  46 + 'con_flag' => '',
  47 +
  48 + ],
  49 + 'es' => [
  50 + 'text' => '西班牙语',
  51 + 'lang_text' => 'Español.',
  52 + 'con_flag' => '',
  53 +
  54 + ],
  55 + 'ar' => [
  56 + 'text' => '阿拉伯语',
  57 + 'lang_text' => '',
  58 + 'con_flag' => '',
  59 +
  60 + ],
  61 + 'pt' => [
  62 + 'text' => '葡萄牙语(葡萄牙、巴西)',
  63 + 'lang_text' => 'Língua portuguesa',
  64 + 'con_flag' => '',
  65 +
  66 + ],
  67 + 'ru' => [
  68 + 'text' => '俄语',
  69 + 'lang_text' => '',
  70 + 'con_flag' => '',
  71 +
  72 + ],
  73 + 'af' => [
  74 + 'text' => '南非荷兰语',
  75 + 'lang_text' => '',
  76 + 'con_flag' => '',
  77 +
  78 + ],
  79 + 'sq' => [
  80 + 'text' => '阿尔巴尼亚语',
  81 + 'lang_text' => '',
  82 + 'con_flag' => '',
  83 +
  84 + ],
  85 + 'am' => [
  86 + 'text' => '阿姆哈拉语',
  87 + 'lang_text' => '',
  88 + 'con_flag' => '',
  89 +
  90 + ],
  91 + 'hy' => [
  92 + 'text' => '亚美尼亚语',
  93 + 'lang_text' => '',
  94 + 'con_flag' => '',
  95 +
  96 + ],
  97 + 'az' => [
  98 + 'text' => '阿塞拜疆语',
  99 + 'lang_text' => '',
  100 + 'con_flag' => '',
  101 +
  102 + ],
  103 + 'eu' => [
  104 + 'text' => '巴斯克语',
  105 + 'lang_text' => '',
  106 + 'con_flag' => '',
  107 +
  108 + ],
  109 + 'be' => [
  110 + 'text' => '白俄罗斯语',
  111 + 'lang_text' => '',
  112 + 'con_flag' => '',
  113 +
  114 + ],
  115 + 'bn' => [
  116 + 'text' => '孟加拉语',
  117 + 'lang_text' => '',
  118 + 'con_flag' => '',
  119 +
  120 + ],
  121 + 'bs' => [
  122 + 'text' => '波斯尼亚语',
  123 + 'lang_text' => '',
  124 + 'con_flag' => '',
  125 +
  126 + ],
  127 + 'bg' => [
  128 + 'text' => '保加利亚语',
  129 + 'lang_text' => '',
  130 + 'con_flag' => '',
  131 +
  132 + ],
  133 + 'ca' => [
  134 + 'text' => '加泰罗尼亚语',
  135 + 'lang_text' => '',
  136 + 'con_flag' => '',
  137 +
  138 + ],
  139 + 'ceb' => [
  140 + 'text' => '宿务语',
  141 + 'lang_text' => '',
  142 + 'con_flag' => '',
  143 +
  144 + ],
  145 + 'zh-CN' => [
  146 + 'text' => '中文(简体)',
  147 + 'lang_text' => '简体中文',
  148 + 'con_flag' => 'con_flag/zh.jfif',
  149 + 'shop_lang' => 'zh-cn',
  150 + ],
  151 + 'zh-TW' => [
  152 + 'text' => '中文(繁体)',
  153 + 'lang_text' => '繁体中文',
  154 + 'con_flag' => 'con_flag/zh.jfif',
  155 +
  156 + ],
  157 + 'co' => [
  158 + 'text' => '科西嘉语',
  159 + 'lang_text' => '',
  160 + 'con_flag' => '',
  161 +
  162 + ],
  163 + 'hr' => [
  164 + 'text' => '克罗地亚语',
  165 + 'lang_text' => '',
  166 + 'con_flag' => '',
  167 +
  168 + ],
  169 + 'cs' => [
  170 + 'text' => '捷克语',
  171 + 'lang_text' => '',
  172 + 'con_flag' => '',
  173 +
  174 + ],
  175 + 'da' => [
  176 + 'text' => '丹麦语',
  177 + 'lang_text' => '',
  178 + 'con_flag' => '',
  179 +
  180 + ],
  181 + 'nl' => [
  182 + 'text' => '荷兰语',
  183 + 'lang_text' => '',
  184 + 'con_flag' => '',
  185 +
  186 + ],
  187 + 'eo' => [
  188 + 'text' => '世界语',
  189 + 'lang_text' => '',
  190 + 'con_flag' => '',
  191 +
  192 + ],
  193 + 'et' => [
  194 + 'text' => '爱沙尼亚语',
  195 + 'lang_text' => '',
  196 + 'con_flag' => '',
  197 +
  198 + ],
  199 + 'fi' => [
  200 + 'text' => '芬兰语',
  201 + 'lang_text' => '',
  202 + 'con_flag' => '',
  203 +
  204 + ],
  205 + 'fy' => [
  206 + 'text' => '弗里斯兰语',
  207 + 'lang_text' => '',
  208 + 'con_flag' => '',
  209 +
  210 + ],
  211 + 'gl' => [
  212 + 'text' => '加利西亚语',
  213 + 'lang_text' => '',
  214 + 'con_flag' => '',
  215 +
  216 + ],
  217 + 'ka' => [
  218 + 'text' => '格鲁吉亚语',
  219 + 'lang_text' => '',
  220 + 'con_flag' => '',
  221 +
  222 + ],
  223 + 'el' => [
  224 + 'text' => '希腊语',
  225 + 'lang_text' => '',
  226 + 'con_flag' => '',
  227 +
  228 + ],
  229 + 'gu' => [
  230 + 'text' => '古吉拉特语',
  231 + 'lang_text' => '',
  232 + 'con_flag' => '',
  233 +
  234 + ],
  235 + 'ht' => [
  236 + 'text' => '海地克里奥尔语',
  237 + 'lang_text' => '',
  238 + 'con_flag' => '',
  239 +
  240 + ],
  241 + 'ha' => [
  242 + 'text' => '豪萨语',
  243 + 'lang_text' => '',
  244 + 'con_flag' => '',
  245 +
  246 + ],
  247 + 'haw' => [
  248 + 'text' => '夏威夷语',
  249 + 'lang_text' => '',
  250 + 'con_flag' => '',
  251 +
  252 + ],
  253 + 'iw' => [
  254 + 'text' => '希伯来语',
  255 + 'lang_text' => '',
  256 + 'con_flag' => '',
  257 +
  258 + ],
  259 + 'hi' => [
  260 + 'text' => '印地语',
  261 + 'lang_text' => '',
  262 + 'con_flag' => '',
  263 +
  264 + ],
  265 + 'hmn' => [
  266 + 'text' => '苗语',
  267 + 'lang_text' => '',
  268 + 'con_flag' => '',
  269 +
  270 + ],
  271 + 'hu' => [
  272 + 'text' => '匈牙利语',
  273 + 'lang_text' => '',
  274 + 'con_flag' => '',
  275 +
  276 + ],
  277 + 'is' => [
  278 + 'text' => '冰岛语',
  279 + 'lang_text' => '',
  280 + 'con_flag' => '',
  281 +
  282 + ],
  283 + 'ig' => [
  284 + 'text' => '伊博语',
  285 + 'lang_text' => '',
  286 + 'con_flag' => '',
  287 +
  288 + ],
  289 + 'id' => [
  290 + 'text' => '印度尼西亚语',
  291 + 'lang_text' => 'Bahasa Indonesia',
  292 + 'con_flag' => 'con_flag/id.jfif',
  293 + 'shop_lang' => 'id',
  294 + ],
  295 + 'ga' => [
  296 + 'text' => '爱尔兰语',
  297 + 'lang_text' => '',
  298 + 'con_flag' => '',
  299 +
  300 + ],
  301 + 'it' => [
  302 + 'text' => '意大利语',
  303 + 'lang_text' => 'Lingua italiana',
  304 + 'con_flag' => '',
  305 +
  306 + ],
  307 + 'jw' => [
  308 + 'text' => '爪哇语',
  309 + 'lang_text' => '',
  310 + 'con_flag' => '',
  311 +
  312 + ],
  313 + 'kn' => [
  314 + 'text' => '卡纳达语',
  315 + 'lang_text' => '',
  316 + 'con_flag' => '',
  317 +
  318 + ],
  319 + 'kk' => [
  320 + 'text' => '哈萨克语',
  321 + 'lang_text' => '',
  322 + 'con_flag' => '',
  323 +
  324 + ],
  325 + 'km' => [
  326 + 'text' => '高棉语',
  327 + 'lang_text' => '',
  328 + 'con_flag' => '',
  329 +
  330 + ],
  331 + 'rw' => [
  332 + 'text' => '卢旺达语',
  333 + 'lang_text' => '',
  334 + 'con_flag' => '',
  335 +
  336 + ],
  337 + 'ku' => [
  338 + 'text' => '库尔德语',
  339 + 'lang_text' => '',
  340 + 'con_flag' => '',
  341 +
  342 + ],
  343 + 'ky' => [
  344 + 'text' => '吉尔吉斯语',
  345 + 'lang_text' => '',
  346 + 'con_flag' => '',
  347 +
  348 + ],
  349 + 'lo' => [
  350 + 'text' => '老挝文',
  351 + 'lang_text' => '',
  352 + 'con_flag' => '',
  353 +
  354 + ],
  355 + 'la' => [
  356 + 'text' => '拉丁文',
  357 + 'lang_text' => '',
  358 + 'con_flag' => '',
  359 +
  360 + ],
  361 + 'lv' => [
  362 + 'text' => '拉脱维亚语',
  363 + 'lang_text' => '',
  364 + 'con_flag' => '',
  365 +
  366 + ],
  367 + 'lt' => [
  368 + 'text' => '立陶宛语',
  369 + 'lang_text' => '',
  370 + 'con_flag' => '',
  371 +
  372 + ],
  373 + 'lb' => [
  374 + 'text' => '卢森堡语',
  375 + 'lang_text' => '',
  376 + 'con_flag' => '',
  377 +
  378 + ],
  379 + 'mk' => [
  380 + 'text' => '马其顿语',
  381 + 'lang_text' => '',
  382 + 'con_flag' => '',
  383 +
  384 + ],
  385 + 'mg' => [
  386 + 'text' => '马尔加什语',
  387 + 'lang_text' => '',
  388 + 'con_flag' => '',
  389 +
  390 + ],
  391 + 'ms' => [
  392 + 'text' => '马来语',
  393 + 'lang_text' => 'Bahasa Melayu',
  394 + 'con_flag' => 'con_flag/ms.jfif',
  395 + 'shop_lang' => 'ms-my',
  396 + ],
  397 + 'ml' => [
  398 + 'text' => '马拉雅拉姆文',
  399 + 'lang_text' => '',
  400 + 'con_flag' => '',
  401 +
  402 + ],
  403 + 'mt' => [
  404 + 'text' => '马耳他语',
  405 + 'lang_text' => '',
  406 + 'con_flag' => '',
  407 +
  408 + ],
  409 + 'mi' => [
  410 + 'text' => '毛利语',
  411 + 'lang_text' => '',
  412 + 'con_flag' => '',
  413 +
  414 + ],
  415 + 'mr' => [
  416 + 'text' => '马拉地语',
  417 + 'lang_text' => '',
  418 + 'con_flag' => '',
  419 +
  420 + ],
  421 + 'mn' => [
  422 + 'text' => '蒙古文',
  423 + 'lang_text' => '',
  424 + 'con_flag' => '',
  425 +
  426 + ],
  427 + 'my' => [
  428 + 'text' => '缅甸语',
  429 + 'lang_text' => '',
  430 + 'con_flag' => '',
  431 +
  432 + ],
  433 + 'ne' => [
  434 + 'text' => '尼泊尔语',
  435 + 'lang_text' => '',
  436 + 'con_flag' => '',
  437 +
  438 + ],
  439 + 'no' => [
  440 + 'text' => '挪威语',
  441 + 'lang_text' => '',
  442 + 'con_flag' => '',
  443 +
  444 + ],
  445 + 'ny' => [
  446 + 'text' => '尼杨扎语(齐切瓦语)',
  447 + 'lang_text' => '',
  448 + 'con_flag' => '',
  449 +
  450 + ],
  451 + 'or' => [
  452 + 'text' => '奥里亚语(奥里亚)',
  453 + 'lang_text' => '',
  454 + 'con_flag' => '',
  455 +
  456 + ],
  457 + 'ps' => [
  458 + 'text' => '普什图语',
  459 + 'lang_text' => '',
  460 + 'con_flag' => '',
  461 +
  462 + ],
  463 + 'fa' => [
  464 + 'text' => '波斯语',
  465 + 'lang_text' => '',
  466 + 'con_flag' => '',
  467 +
  468 + ],
  469 + 'pl' => [
  470 + 'text' => '波兰语',
  471 + 'lang_text' => '',
  472 + 'con_flag' => '',
  473 +
  474 + ],
  475 + 'pa' => [
  476 + 'text' => '旁遮普语',
  477 + 'lang_text' => '',
  478 + 'con_flag' => '',
  479 +
  480 + ],
  481 + 'ro' => [
  482 + 'text' => '罗马尼亚语',
  483 + 'lang_text' => '',
  484 + 'con_flag' => '',
  485 +
  486 + ],
  487 + 'sm' => [
  488 + 'text' => '萨摩亚语',
  489 + 'lang_text' => '',
  490 + 'con_flag' => '',
  491 +
  492 + ],
  493 + 'gd' => [
  494 + 'text' => '苏格兰盖尔语',
  495 + 'lang_text' => '',
  496 + 'con_flag' => '',
  497 +
  498 + ],
  499 + 'sr' => [
  500 + 'text' => '塞尔维亚语',
  501 + 'lang_text' => '',
  502 + 'con_flag' => '',
  503 +
  504 + ],
  505 + 'st' => [
  506 + 'text' => '塞索托语',
  507 + 'lang_text' => '',
  508 + 'con_flag' => '',
  509 +
  510 + ],
  511 + 'sn' => [
  512 + 'text' => '修纳语',
  513 + 'lang_text' => '',
  514 + 'con_flag' => '',
  515 +
  516 + ],
  517 + 'sd' => [
  518 + 'text' => '信德语',
  519 + 'lang_text' => '',
  520 + 'con_flag' => '',
  521 +
  522 + ],
  523 + 'si' => [
  524 + 'text' => '僧伽罗语',
  525 + 'lang_text' => '',
  526 + 'con_flag' => '',
  527 +
  528 + ],
  529 + 'sk' => [
  530 + 'text' => '斯洛伐克语',
  531 + 'lang_text' => '',
  532 + 'con_flag' => '',
  533 +
  534 + ],
  535 + 'sl' => [
  536 + 'text' => '斯洛文尼亚语',
  537 + 'lang_text' => '',
  538 + 'con_flag' => '',
  539 +
  540 + ],
  541 + 'so' => [
  542 + 'text' => '索马里语',
  543 + 'lang_text' => '',
  544 + 'con_flag' => '',
  545 +
  546 + ],
  547 + 'su' => [
  548 + 'text' => '巽他语',
  549 + 'lang_text' => '',
  550 + 'con_flag' => '',
  551 +
  552 + ],
  553 + 'sw' => [
  554 + 'text' => '斯瓦希里语',
  555 + 'lang_text' => '',
  556 + 'con_flag' => '',
  557 +
  558 + ],
  559 + 'sv' => [
  560 + 'text' => '瑞典语',
  561 + 'lang_text' => '',
  562 + 'con_flag' => '',
  563 +
  564 + ],
  565 + 'tl' => [
  566 + 'text' => '塔加路语(菲律宾语)',
  567 + 'lang_text' => 'Pilipino',
  568 + 'con_flag' => 'con_flag/tl.jfif',
  569 + 'shop_lang' => 'tl',
  570 + ],
  571 + 'tg' => [
  572 + 'text' => '塔吉克语',
  573 + 'lang_text' => '',
  574 + 'con_flag' => '',
  575 +
  576 + ],
  577 + 'ta' => [
  578 + 'text' => '泰米尔语',
  579 + 'lang_text' => '',
  580 + 'con_flag' => '',
  581 +
  582 + ],
  583 + 'tt' => [
  584 + 'text' => '鞑靼语',
  585 + 'lang_text' => '',
  586 + 'con_flag' => '',
  587 +
  588 + ],
  589 + 'te' => [
  590 + 'text' => '泰卢固语',
  591 + 'lang_text' => '',
  592 + 'con_flag' => '',
  593 +
  594 + ],
  595 + 'th' => [
  596 + 'text' => '泰文',
  597 + 'lang_text' => 'ไทย',
  598 + 'con_flag' => 'con_flag/th.jfif',
  599 + 'shop_lang' => 'th',
  600 + ],
  601 + 'tr' => [
  602 + 'text' => '土耳其语',
  603 + 'lang_text' => '',
  604 + 'con_flag' => '',
  605 +
  606 + ],
  607 + 'tk' => [
  608 + 'text' => '土库曼语',
  609 + 'lang_text' => '',
  610 + 'con_flag' => '',
  611 +
  612 + ],
  613 + 'uk' => [
  614 + 'text' => '乌克兰语',
  615 + 'lang_text' => '',
  616 + 'con_flag' => '',
  617 +
  618 + ],
  619 + 'ur' => [
  620 + 'text' => '乌尔都语',
  621 + 'lang_text' => '',
  622 + 'con_flag' => '',
  623 +
  624 + ],
  625 + 'ug' => [
  626 + 'text' => '维吾尔语',
  627 + 'lang_text' => '',
  628 + 'con_flag' => '',
  629 +
  630 + ],
  631 + 'uz' => [
  632 + 'text' => '乌兹别克语',
  633 + 'lang_text' => '',
  634 + 'con_flag' => '',
  635 +
  636 + ],
  637 + 'vi' => [
  638 + 'text' => '越南语',
  639 + 'lang_text' => '',
  640 + 'con_flag' => '',
  641 +
  642 + ],
  643 + 'cy' => [
  644 + 'text' => '威尔士语',
  645 + 'lang_text' => '',
  646 + 'con_flag' => '',
  647 +
  648 + ],
  649 + 'xh' => [
  650 + 'text' => '班图语',
  651 + 'lang_text' => '',
  652 + 'con_flag' => '',
  653 +
  654 + ],
  655 + 'yi' => [
  656 + 'text' => '意第绪语',
  657 + 'lang_text' => '',
  658 + 'con_flag' => '',
  659 +
  660 + ],
  661 + 'yo' => [
  662 + 'text' => '约鲁巴语',
  663 + 'lang_text' => '',
  664 + 'con_flag' => '',
  665 +
  666 + ],
  667 + 'zu' => [
  668 + 'text' => '祖鲁语',
  669 + 'lang_text' => '',
  670 + 'con_flag' => '',
  671 + ],
  672 + ];
  673 +
  674 + /**
  675 + * @name :(获取翻译国家)set_country
  676 + * @author :lyh
  677 + * @method :post
  678 + * @time :2023/5/4 17:57
  679 + */
  680 + public function set_country(){
  681 + $data = [];
  682 + foreach ($this->tls_list as $k=>$v){
  683 + $data[] = ['name'=>$v['text'],'alias'=>$k];
  684 + }
  685 + $webCountry = new WebSettingCountry();
  686 + $webCountry->insert($data);
  687 + return true;
  688 + }
  689 +}
  1 +<?php
  2 +
  3 +
  4 +namespace App\Helper;
  5 +
  6 +use Illuminate\Support\Facades\Http;
  7 +
  8 +
  9 +/**
  10 + * 翻译接口
  11 + * Class Translate
  12 + * @package App\Service
  13 + * @author zbj
  14 + * @date 2023/2/7
  15 + */
  16 +class Translate
  17 +{
  18 + //接口地址
  19 + public static $url = 'https://translate.hbb618.cn/translates';
  20 +
  21 + public static $tls_list = [
  22 + 'en' => [
  23 + 'text' => '英语',
  24 + 'lang_text' => 'English',
  25 + 'con_flag' => 'con_flag/en.jfif',
  26 + 'shop_lang' => 'en-gb',
  27 + ],
  28 + 'zh' => [
  29 + 'text' => '中文',
  30 + 'lang_text' => '简体中文',
  31 + 'con_flag' => 'con_flag/zh.jfif',
  32 + 'shop_lang' => 'zh-cn',
  33 + ],
  34 + 'fr' => [
  35 + 'text' => '法语',
  36 + 'lang_text' => 'En français',
  37 + 'con_flag' => '',
  38 +
  39 + ],
  40 + 'de' => [
  41 + 'text' => '德语',
  42 + 'lang_text' => 'Das ist Deutsch.',
  43 + 'con_flag' => '',
  44 +
  45 + ],
  46 + 'ko' => [
  47 + 'text' => '韩语',
  48 + 'lang_text' => '',
  49 + 'con_flag' => '',
  50 +
  51 + ],
  52 + 'ja' => [
  53 + 'text' => '日语',
  54 + 'lang_text' => '',
  55 + 'con_flag' => '',
  56 +
  57 + ],
  58 + 'es' => [
  59 + 'text' => '西班牙语',
  60 + 'lang_text' => 'Español.',
  61 + 'con_flag' => '',
  62 +
  63 + ],
  64 + 'ar' => [
  65 + 'text' => '阿拉伯语',
  66 + 'lang_text' => '',
  67 + 'con_flag' => '',
  68 +
  69 + ],
  70 + 'pt' => [
  71 + 'text' => '葡萄牙语(葡萄牙、巴西)',
  72 + 'lang_text' => 'Língua portuguesa',
  73 + 'con_flag' => '',
  74 +
  75 + ],
  76 + 'ru' => [
  77 + 'text' => '俄语',
  78 + 'lang_text' => '',
  79 + 'con_flag' => '',
  80 +
  81 + ],
  82 + 'af' => [
  83 + 'text' => '南非荷兰语',
  84 + 'lang_text' => '',
  85 + 'con_flag' => '',
  86 +
  87 + ],
  88 + 'sq' => [
  89 + 'text' => '阿尔巴尼亚语',
  90 + 'lang_text' => '',
  91 + 'con_flag' => '',
  92 +
  93 + ],
  94 + 'am' => [
  95 + 'text' => '阿姆哈拉语',
  96 + 'lang_text' => '',
  97 + 'con_flag' => '',
  98 +
  99 + ],
  100 + 'hy' => [
  101 + 'text' => '亚美尼亚语',
  102 + 'lang_text' => '',
  103 + 'con_flag' => '',
  104 +
  105 + ],
  106 + 'az' => [
  107 + 'text' => '阿塞拜疆语',
  108 + 'lang_text' => '',
  109 + 'con_flag' => '',
  110 +
  111 + ],
  112 + 'eu' => [
  113 + 'text' => '巴斯克语',
  114 + 'lang_text' => '',
  115 + 'con_flag' => '',
  116 +
  117 + ],
  118 + 'be' => [
  119 + 'text' => '白俄罗斯语',
  120 + 'lang_text' => '',
  121 + 'con_flag' => '',
  122 +
  123 + ],
  124 + 'bn' => [
  125 + 'text' => '孟加拉语',
  126 + 'lang_text' => '',
  127 + 'con_flag' => '',
  128 +
  129 + ],
  130 + 'bs' => [
  131 + 'text' => '波斯尼亚语',
  132 + 'lang_text' => '',
  133 + 'con_flag' => '',
  134 +
  135 + ],
  136 + 'bg' => [
  137 + 'text' => '保加利亚语',
  138 + 'lang_text' => '',
  139 + 'con_flag' => '',
  140 +
  141 + ],
  142 + 'ca' => [
  143 + 'text' => '加泰罗尼亚语',
  144 + 'lang_text' => '',
  145 + 'con_flag' => '',
  146 +
  147 + ],
  148 + 'ceb' => [
  149 + 'text' => '宿务语',
  150 + 'lang_text' => '',
  151 + 'con_flag' => '',
  152 +
  153 + ],
  154 + 'zh-CN' => [
  155 + 'text' => '中文(简体)',
  156 + 'lang_text' => '简体中文',
  157 + 'con_flag' => 'con_flag/zh.jfif',
  158 + 'shop_lang' => 'zh-cn',
  159 + ],
  160 + 'zh-TW' => [
  161 + 'text' => '中文(繁体)',
  162 + 'lang_text' => '繁体中文',
  163 + 'con_flag' => 'con_flag/zh.jfif',
  164 +
  165 + ],
  166 + 'co' => [
  167 + 'text' => '科西嘉语',
  168 + 'lang_text' => '',
  169 + 'con_flag' => '',
  170 +
  171 + ],
  172 + 'hr' => [
  173 + 'text' => '克罗地亚语',
  174 + 'lang_text' => '',
  175 + 'con_flag' => '',
  176 +
  177 + ],
  178 + 'cs' => [
  179 + 'text' => '捷克语',
  180 + 'lang_text' => '',
  181 + 'con_flag' => '',
  182 +
  183 + ],
  184 + 'da' => [
  185 + 'text' => '丹麦语',
  186 + 'lang_text' => '',
  187 + 'con_flag' => '',
  188 +
  189 + ],
  190 + 'nl' => [
  191 + 'text' => '荷兰语',
  192 + 'lang_text' => '',
  193 + 'con_flag' => '',
  194 +
  195 + ],
  196 + 'eo' => [
  197 + 'text' => '世界语',
  198 + 'lang_text' => '',
  199 + 'con_flag' => '',
  200 +
  201 + ],
  202 + 'et' => [
  203 + 'text' => '爱沙尼亚语',
  204 + 'lang_text' => '',
  205 + 'con_flag' => '',
  206 +
  207 + ],
  208 + 'fi' => [
  209 + 'text' => '芬兰语',
  210 + 'lang_text' => '',
  211 + 'con_flag' => '',
  212 +
  213 + ],
  214 + 'fy' => [
  215 + 'text' => '弗里斯兰语',
  216 + 'lang_text' => '',
  217 + 'con_flag' => '',
  218 +
  219 + ],
  220 + 'gl' => [
  221 + 'text' => '加利西亚语',
  222 + 'lang_text' => '',
  223 + 'con_flag' => '',
  224 +
  225 + ],
  226 + 'ka' => [
  227 + 'text' => '格鲁吉亚语',
  228 + 'lang_text' => '',
  229 + 'con_flag' => '',
  230 +
  231 + ],
  232 + 'el' => [
  233 + 'text' => '希腊语',
  234 + 'lang_text' => '',
  235 + 'con_flag' => '',
  236 +
  237 + ],
  238 + 'gu' => [
  239 + 'text' => '古吉拉特语',
  240 + 'lang_text' => '',
  241 + 'con_flag' => '',
  242 +
  243 + ],
  244 + 'ht' => [
  245 + 'text' => '海地克里奥尔语',
  246 + 'lang_text' => '',
  247 + 'con_flag' => '',
  248 +
  249 + ],
  250 + 'ha' => [
  251 + 'text' => '豪萨语',
  252 + 'lang_text' => '',
  253 + 'con_flag' => '',
  254 +
  255 + ],
  256 + 'haw' => [
  257 + 'text' => '夏威夷语',
  258 + 'lang_text' => '',
  259 + 'con_flag' => '',
  260 +
  261 + ],
  262 + 'iw' => [
  263 + 'text' => '希伯来语',
  264 + 'lang_text' => '',
  265 + 'con_flag' => '',
  266 +
  267 + ],
  268 + 'hi' => [
  269 + 'text' => '印地语',
  270 + 'lang_text' => '',
  271 + 'con_flag' => '',
  272 +
  273 + ],
  274 + 'hmn' => [
  275 + 'text' => '苗语',
  276 + 'lang_text' => '',
  277 + 'con_flag' => '',
  278 +
  279 + ],
  280 + 'hu' => [
  281 + 'text' => '匈牙利语',
  282 + 'lang_text' => '',
  283 + 'con_flag' => '',
  284 +
  285 + ],
  286 + 'is' => [
  287 + 'text' => '冰岛语',
  288 + 'lang_text' => '',
  289 + 'con_flag' => '',
  290 +
  291 + ],
  292 + 'ig' => [
  293 + 'text' => '伊博语',
  294 + 'lang_text' => '',
  295 + 'con_flag' => '',
  296 +
  297 + ],
  298 + 'id' => [
  299 + 'text' => '印度尼西亚语',
  300 + 'lang_text' => 'Bahasa Indonesia',
  301 + 'con_flag' => 'con_flag/id.jfif',
  302 + 'shop_lang' => 'id',
  303 + ],
  304 + 'ga' => [
  305 + 'text' => '爱尔兰语',
  306 + 'lang_text' => '',
  307 + 'con_flag' => '',
  308 +
  309 + ],
  310 + 'it' => [
  311 + 'text' => '意大利语',
  312 + 'lang_text' => 'Lingua italiana',
  313 + 'con_flag' => '',
  314 +
  315 + ],
  316 + 'jw' => [
  317 + 'text' => '爪哇语',
  318 + 'lang_text' => '',
  319 + 'con_flag' => '',
  320 +
  321 + ],
  322 + 'kn' => [
  323 + 'text' => '卡纳达语',
  324 + 'lang_text' => '',
  325 + 'con_flag' => '',
  326 +
  327 + ],
  328 + 'kk' => [
  329 + 'text' => '哈萨克语',
  330 + 'lang_text' => '',
  331 + 'con_flag' => '',
  332 +
  333 + ],
  334 + 'km' => [
  335 + 'text' => '高棉语',
  336 + 'lang_text' => '',
  337 + 'con_flag' => '',
  338 +
  339 + ],
  340 + 'rw' => [
  341 + 'text' => '卢旺达语',
  342 + 'lang_text' => '',
  343 + 'con_flag' => '',
  344 +
  345 + ],
  346 + 'ku' => [
  347 + 'text' => '库尔德语',
  348 + 'lang_text' => '',
  349 + 'con_flag' => '',
  350 +
  351 + ],
  352 + 'ky' => [
  353 + 'text' => '吉尔吉斯语',
  354 + 'lang_text' => '',
  355 + 'con_flag' => '',
  356 +
  357 + ],
  358 + 'lo' => [
  359 + 'text' => '老挝文',
  360 + 'lang_text' => '',
  361 + 'con_flag' => '',
  362 +
  363 + ],
  364 + 'la' => [
  365 + 'text' => '拉丁文',
  366 + 'lang_text' => '',
  367 + 'con_flag' => '',
  368 +
  369 + ],
  370 + 'lv' => [
  371 + 'text' => '拉脱维亚语',
  372 + 'lang_text' => '',
  373 + 'con_flag' => '',
  374 +
  375 + ],
  376 + 'lt' => [
  377 + 'text' => '立陶宛语',
  378 + 'lang_text' => '',
  379 + 'con_flag' => '',
  380 +
  381 + ],
  382 + 'lb' => [
  383 + 'text' => '卢森堡语',
  384 + 'lang_text' => '',
  385 + 'con_flag' => '',
  386 +
  387 + ],
  388 + 'mk' => [
  389 + 'text' => '马其顿语',
  390 + 'lang_text' => '',
  391 + 'con_flag' => '',
  392 +
  393 + ],
  394 + 'mg' => [
  395 + 'text' => '马尔加什语',
  396 + 'lang_text' => '',
  397 + 'con_flag' => '',
  398 +
  399 + ],
  400 + 'ms' => [
  401 + 'text' => '马来语',
  402 + 'lang_text' => 'Bahasa Melayu',
  403 + 'con_flag' => 'con_flag/ms.jfif',
  404 + 'shop_lang' => 'ms-my',
  405 + ],
  406 + 'ml' => [
  407 + 'text' => '马拉雅拉姆文',
  408 + 'lang_text' => '',
  409 + 'con_flag' => '',
  410 +
  411 + ],
  412 + 'mt' => [
  413 + 'text' => '马耳他语',
  414 + 'lang_text' => '',
  415 + 'con_flag' => '',
  416 +
  417 + ],
  418 + 'mi' => [
  419 + 'text' => '毛利语',
  420 + 'lang_text' => '',
  421 + 'con_flag' => '',
  422 +
  423 + ],
  424 + 'mr' => [
  425 + 'text' => '马拉地语',
  426 + 'lang_text' => '',
  427 + 'con_flag' => '',
  428 +
  429 + ],
  430 + 'mn' => [
  431 + 'text' => '蒙古文',
  432 + 'lang_text' => '',
  433 + 'con_flag' => '',
  434 +
  435 + ],
  436 + 'my' => [
  437 + 'text' => '缅甸语',
  438 + 'lang_text' => '',
  439 + 'con_flag' => '',
  440 +
  441 + ],
  442 + 'ne' => [
  443 + 'text' => '尼泊尔语',
  444 + 'lang_text' => '',
  445 + 'con_flag' => '',
  446 +
  447 + ],
  448 + 'no' => [
  449 + 'text' => '挪威语',
  450 + 'lang_text' => '',
  451 + 'con_flag' => '',
  452 +
  453 + ],
  454 + 'ny' => [
  455 + 'text' => '尼杨扎语(齐切瓦语)',
  456 + 'lang_text' => '',
  457 + 'con_flag' => '',
  458 +
  459 + ],
  460 + 'or' => [
  461 + 'text' => '奥里亚语(奥里亚)',
  462 + 'lang_text' => '',
  463 + 'con_flag' => '',
  464 +
  465 + ],
  466 + 'ps' => [
  467 + 'text' => '普什图语',
  468 + 'lang_text' => '',
  469 + 'con_flag' => '',
  470 +
  471 + ],
  472 + 'fa' => [
  473 + 'text' => '波斯语',
  474 + 'lang_text' => '',
  475 + 'con_flag' => '',
  476 +
  477 + ],
  478 + 'pl' => [
  479 + 'text' => '波兰语',
  480 + 'lang_text' => '',
  481 + 'con_flag' => '',
  482 +
  483 + ],
  484 + 'pa' => [
  485 + 'text' => '旁遮普语',
  486 + 'lang_text' => '',
  487 + 'con_flag' => '',
  488 +
  489 + ],
  490 + 'ro' => [
  491 + 'text' => '罗马尼亚语',
  492 + 'lang_text' => '',
  493 + 'con_flag' => '',
  494 +
  495 + ],
  496 + 'sm' => [
  497 + 'text' => '萨摩亚语',
  498 + 'lang_text' => '',
  499 + 'con_flag' => '',
  500 +
  501 + ],
  502 + 'gd' => [
  503 + 'text' => '苏格兰盖尔语',
  504 + 'lang_text' => '',
  505 + 'con_flag' => '',
  506 +
  507 + ],
  508 + 'sr' => [
  509 + 'text' => '塞尔维亚语',
  510 + 'lang_text' => '',
  511 + 'con_flag' => '',
  512 +
  513 + ],
  514 + 'st' => [
  515 + 'text' => '塞索托语',
  516 + 'lang_text' => '',
  517 + 'con_flag' => '',
  518 +
  519 + ],
  520 + 'sn' => [
  521 + 'text' => '修纳语',
  522 + 'lang_text' => '',
  523 + 'con_flag' => '',
  524 +
  525 + ],
  526 + 'sd' => [
  527 + 'text' => '信德语',
  528 + 'lang_text' => '',
  529 + 'con_flag' => '',
  530 +
  531 + ],
  532 + 'si' => [
  533 + 'text' => '僧伽罗语',
  534 + 'lang_text' => '',
  535 + 'con_flag' => '',
  536 +
  537 + ],
  538 + 'sk' => [
  539 + 'text' => '斯洛伐克语',
  540 + 'lang_text' => '',
  541 + 'con_flag' => '',
  542 +
  543 + ],
  544 + 'sl' => [
  545 + 'text' => '斯洛文尼亚语',
  546 + 'lang_text' => '',
  547 + 'con_flag' => '',
  548 +
  549 + ],
  550 + 'so' => [
  551 + 'text' => '索马里语',
  552 + 'lang_text' => '',
  553 + 'con_flag' => '',
  554 +
  555 + ],
  556 + 'su' => [
  557 + 'text' => '巽他语',
  558 + 'lang_text' => '',
  559 + 'con_flag' => '',
  560 +
  561 + ],
  562 + 'sw' => [
  563 + 'text' => '斯瓦希里语',
  564 + 'lang_text' => '',
  565 + 'con_flag' => '',
  566 +
  567 + ],
  568 + 'sv' => [
  569 + 'text' => '瑞典语',
  570 + 'lang_text' => '',
  571 + 'con_flag' => '',
  572 +
  573 + ],
  574 + 'tl' => [
  575 + 'text' => '塔加路语(菲律宾语)',
  576 + 'lang_text' => 'Pilipino',
  577 + 'con_flag' => 'con_flag/tl.jfif',
  578 + 'shop_lang' => 'tl',
  579 + ],
  580 + 'tg' => [
  581 + 'text' => '塔吉克语',
  582 + 'lang_text' => '',
  583 + 'con_flag' => '',
  584 +
  585 + ],
  586 + 'ta' => [
  587 + 'text' => '泰米尔语',
  588 + 'lang_text' => '',
  589 + 'con_flag' => '',
  590 +
  591 + ],
  592 + 'tt' => [
  593 + 'text' => '鞑靼语',
  594 + 'lang_text' => '',
  595 + 'con_flag' => '',
  596 +
  597 + ],
  598 + 'te' => [
  599 + 'text' => '泰卢固语',
  600 + 'lang_text' => '',
  601 + 'con_flag' => '',
  602 +
  603 + ],
  604 + 'th' => [
  605 + 'text' => '泰文',
  606 + 'lang_text' => 'ไทย',
  607 + 'con_flag' => 'con_flag/th.jfif',
  608 + 'shop_lang' => 'th',
  609 + ],
  610 + 'tr' => [
  611 + 'text' => '土耳其语',
  612 + 'lang_text' => '',
  613 + 'con_flag' => '',
  614 +
  615 + ],
  616 + 'tk' => [
  617 + 'text' => '土库曼语',
  618 + 'lang_text' => '',
  619 + 'con_flag' => '',
  620 +
  621 + ],
  622 + 'uk' => [
  623 + 'text' => '乌克兰语',
  624 + 'lang_text' => '',
  625 + 'con_flag' => '',
  626 +
  627 + ],
  628 + 'ur' => [
  629 + 'text' => '乌尔都语',
  630 + 'lang_text' => '',
  631 + 'con_flag' => '',
  632 +
  633 + ],
  634 + 'ug' => [
  635 + 'text' => '维吾尔语',
  636 + 'lang_text' => '',
  637 + 'con_flag' => '',
  638 +
  639 + ],
  640 + 'uz' => [
  641 + 'text' => '乌兹别克语',
  642 + 'lang_text' => '',
  643 + 'con_flag' => '',
  644 +
  645 + ],
  646 + 'vi' => [
  647 + 'text' => '越南语',
  648 + 'lang_text' => '',
  649 + 'con_flag' => '',
  650 +
  651 + ],
  652 + 'cy' => [
  653 + 'text' => '威尔士语',
  654 + 'lang_text' => '',
  655 + 'con_flag' => '',
  656 +
  657 + ],
  658 + 'xh' => [
  659 + 'text' => '班图语',
  660 + 'lang_text' => '',
  661 + 'con_flag' => '',
  662 +
  663 + ],
  664 + 'yi' => [
  665 + 'text' => '意第绪语',
  666 + 'lang_text' => '',
  667 + 'con_flag' => '',
  668 +
  669 + ],
  670 + 'yo' => [
  671 + 'text' => '约鲁巴语',
  672 + 'lang_text' => '',
  673 + 'con_flag' => '',
  674 +
  675 + ],
  676 + 'zu' => [
  677 + 'text' => '祖鲁语',
  678 + 'lang_text' => '',
  679 + 'con_flag' => '',
  680 + ],
  681 + ];
  682 +
  683 + /**
  684 + * 获取语种列表
  685 + * @return array|string
  686 + * @author:dc
  687 + * @time 2022/3/30 13:52
  688 + */
  689 + public static function getTls($lang = null){
  690 + $tls = array_combine(array_keys(static::$tls_list),array_column(static::$tls_list, 'text'));
  691 +
  692 + if($lang === null){
  693 + return $tls;
  694 + }
  695 +
  696 + if (is_array($lang)){
  697 + foreach ($lang as $key=>$item){
  698 + unset($lang[$key]);
  699 + $lang[$item] = $tls[$item]??'';
  700 + }
  701 + return $lang;
  702 + }
  703 +
  704 + return $tls[$lang]??'';
  705 + }
  706 +
  707 + /**
  708 + * 翻译
  709 + * @param $texts
  710 + * @param $tls
  711 + * @return \Illuminate\Http\Client\Response
  712 + * @time 2022/3/30 15:58
  713 + */
  714 + public static function translate($texts, $tls)
  715 + {
  716 + if (is_string($texts)) {
  717 + $texts = [$texts];
  718 + }
  719 + if (is_string($tls)) {
  720 + $tls = [$tls];
  721 + }
  722 + $data = [
  723 + 'texts' => $texts,
  724 + 'sl' => 'auto',
  725 + 'tls' => $tls,
  726 + ];
  727 + return Http::post(self::$url, $data);
  728 + }
  729 +
  730 + /**
  731 + * @param $texts
  732 + * @param $tls
  733 + * @return string|array
  734 + * @author:dc
  735 + * @time 2022/3/30 15:59
  736 + */
  737 + public static function tran($texts, $tls)
  738 + {
  739 + if (!$texts) {
  740 + return '';
  741 + }
  742 +
  743 + $retsult = self::translate($texts, $tls)->json();
  744 +
  745 + return $retsult[0]['texts'] ?? '';
  746 +
  747 + }
  748 +
  749 +
  750 +}
1 <?php 1 <?php
  2 +
  3 +use App\Utils\LogUtils;
  4 +
2 define('HTTP_OPENAI_URL','http://openai.waimaoq.com/'); 5 define('HTTP_OPENAI_URL','http://openai.waimaoq.com/');
3 /** 6 /**
4 * 生成路由标识 7 * 生成路由标识
@@ -7,23 +10,46 @@ define('HTTP_OPENAI_URL','http://openai.waimaoq.com/'); @@ -7,23 +10,46 @@ define('HTTP_OPENAI_URL','http://openai.waimaoq.com/');
7 * @author zbj 10 * @author zbj
8 * @date 2023/4/15 11 * @date 2023/4/15
9 */ 12 */
10 -function generateRoute($string){  
11 - return trim(strtolower(preg_replace( '/[\W]+/', '-', trim($string))), '-'); 13 +
  14 +if (!function_exists('generateRoute')) {
  15 + function generateRoute($string)
  16 + {
  17 + return trim(strtolower(preg_replace('/[\W]+/', '-', trim($string))), '-');
  18 + }
12 } 19 }
13 20
14 21
  22 +/**
  23 + * 手动记录错误日志
  24 + * @param $title
  25 + * @param $params
  26 + * @param Throwable $exception
  27 + * @author zbj
  28 + * @date 2023/4/27
  29 + */
  30 +function errorLog($title, $params, Throwable $exception){
  31 + $exceptionMessage = "错误CODE:" . $exception->getCode() .
  32 + "-----错误message:" . $exception->getMessage() .
  33 + '------错误文件:' . $exception->getFile() .
  34 + '-------错误行数:' . $exception->getLine();
  35 +
  36 + LogUtils::error($title, $params, $exceptionMessage);
  37 +}
  38 +
15 if(!function_exists('http_post')){ 39 if(!function_exists('http_post')){
16 /** 40 /**
17 * 发送http post请求 41 * 发送http post请求
18 * @param type $url 42 * @param type $url
19 * @param type $post_data 43 * @param type $post_data
20 */ 44 */
21 - function http_post($url, $post_data) 45 + function http_post($url, $post_data,$header = [])
22 { 46 {
23 - $header = array(  
24 - "Accept: application/json",  
25 - "Content-Type:application/json;charset=utf-8",  
26 - ); 47 + if(empty($header)){
  48 + $header = array(
  49 + "Accept: application/json",
  50 + "Content-Type:application/json;charset=utf-8",
  51 + );
  52 + }
27 $ch = curl_init(); 53 $ch = curl_init();
28 curl_setopt($ch, CURLOPT_URL, $url); 54 curl_setopt($ch, CURLOPT_URL, $url);
29 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 55 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -50,10 +76,12 @@ if(!function_exists('http_get')){ @@ -50,10 +76,12 @@ if(!function_exists('http_get')){
50 * @param type $url 76 * @param type $url
51 * @return type 77 * @return type
52 */ 78 */
53 - function http_get($url) 79 + function http_get($url,$header = [])
54 { 80 {
55 - $header[] = "content-type: application/x-www-form-urlencoded; 81 + if(empty($header)){
  82 + $header[] = "content-type: application/json;
56 charset = UTF-8"; 83 charset = UTF-8";
  84 + }
57 $ch1 = curl_init(); 85 $ch1 = curl_init();
58 $timeout = 5; 86 $timeout = 5;
59 curl_setopt($ch1, CURLOPT_URL, $url); 87 curl_setopt($ch1, CURLOPT_URL, $url);
@@ -91,68 +119,28 @@ if(!function_exists('_get_child')){ @@ -91,68 +119,28 @@ if(!function_exists('_get_child')){
91 119
92 120
93 121
94 -/**  
95 - * 把返回的数据集转换成Tree  
96 - * @param $list array 数据列表  
97 - * @param string|int $pk 主键|root  
98 - * @param string $pid 父id  
99 - * @param string $child 子键  
100 - * @param int $root 获取哪个id下面  
101 - * @param bool $empty_child 当子数据不存在,是否要返回空子数据  
102 - * @return array  
103 - */  
104 -function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0,$empty_child=true) {  
105 - // 如果是数字,则是root  
106 - if(is_numeric($pk)){  
107 - $root = $pk;  
108 - $pk = 'id';  
109 - }  
110 - // 创建Tree  
111 - $tree = array();  
112 - if(is_array($list)) {  
113 - // 创建基于主键的数组引用  
114 - $refer = array();  
115 - foreach ($list as $key => $data) {  
116 - if($empty_child){  
117 - $list[$key][$child] = [];  
118 - }  
119 - $refer[$data[$pk]] =& $list[$key]; 122 +if (!function_exists('checkDomain')) {
  123 + /**
  124 + * 检查并补全域名协议
  125 + * @return false|string
  126 + * @author zbj
  127 + * @date 2023/5/5
  128 + */
  129 + function checkDomain($value)
  130 + {
  131 + $urlParts = parse_url(strtolower($value));
  132 + if(empty($urlParts['host'])){
  133 + $urlParts = parse_url('https://' . $value);
120 } 134 }
121 - foreach ($list as $key => $data) {  
122 - // 判断是否存在parent  
123 - $parentId = $data[$pid];  
124 - if ($root == $parentId) {  
125 - $tree[] =& $list[$key];  
126 - }else{  
127 - if (isset($refer[$parentId])) {  
128 - $refer[$parentId][$child][] = & $list[$key];  
129 - }  
130 - } 135 + $host = $urlParts['host'] ?? '';
  136 + $scheme = $urlParts['scheme'] ?? 'https';
  137 + if(!in_array($scheme, ['http', 'https'])){
  138 + return false;
131 } 139 }
132 - }  
133 - return $tree;  
134 -}  
135 -  
136 -/**  
137 - * tree数据转list  
138 - * @param $tree  
139 - * @param string $child  
140 - * @return array  
141 - * @author:dc  
142 - * @time 2022/1/11 10:13  
143 - */  
144 -function tree_to_list($tree, $child='_child'){  
145 - $lists = [];  
146 - foreach ($tree as $item){  
147 - $c = $item[$child]??[];  
148 - unset($item[$child]);  
149 - $lists[] = $item;  
150 - if ($c){  
151 - $lists = array_merge($lists,tree_to_list($c, $child)); 140 + if (preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $host)) {
  141 + return $scheme . '://' . $host;
  142 + } else {
  143 + return false;
152 } 144 }
153 } 145 }
154 - return $lists;  
155 } 146 }
156 -  
157 -  
158 -  
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Aside; 3 +namespace App\Http\Controllers\Aside\Ai;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 -use App\Models\AiCommand as AiCommandModel; 7 +use App\Http\Logic\Aside\Ai\AiCommandLogic;
  8 +use App\Http\Requests\Aside\Ai\AiCommandRequest;
  9 +use App\Models\Ai\AiCommand as AiCommandModel;
  10 +use Illuminate\Http\Request;
8 use function App\Helper\send_openai_msg; 11 use function App\Helper\send_openai_msg;
9 12
  13 +/**
  14 + * @name:ai指令
  15 + */
10 class AiCommandController extends BaseController 16 class AiCommandController extends BaseController
11 { 17 {
12 /** 18 /**
@@ -16,18 +22,35 @@ class AiCommandController extends BaseController @@ -16,18 +22,35 @@ class AiCommandController extends BaseController
16 * @method 22 * @method
17 */ 23 */
18 public function lists(AiCommandModel $aiCommandModel){ 24 public function lists(AiCommandModel $aiCommandModel){
19 - $lists = $aiCommandModel->lists($this->map); 25 + $lists = $aiCommandModel->lists($this->map,$this->page,$this->row,$this->order);
20 $this->response('success',Code::SUCCESS,$lists); 26 $this->response('success',Code::SUCCESS,$lists);
21 } 27 }
22 28
23 /** 29 /**
  30 + * @name :详情
  31 + * @return void
  32 + * @author :liyuhang
  33 + * @method
  34 + */
  35 + public function info(Request $request,AiCommandLogic $aiCommandLogic){
  36 + $request->validate([
  37 + 'id'=>'required'
  38 + ],[
  39 + 'id.required' => 'ID不能为空'
  40 + ]);
  41 + $aiCommandLogic->ai_info();
  42 + $this->response('success');
  43 + }
  44 + /**
24 * @name 45 * @name
25 * @return void 46 * @return void
26 * @author :liyuhang 47 * @author :liyuhang
27 * @method 48 * @method
28 */ 49 */
29 - public function add(){  
30 - 50 + public function add(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){
  51 + $request->validated();
  52 + $aiCommandLogic->ai_add();
  53 + $this->response('success');
31 } 54 }
32 55
33 /** 56 /**
@@ -36,8 +59,14 @@ class AiCommandController extends BaseController @@ -36,8 +59,14 @@ class AiCommandController extends BaseController
36 * @author :liyuhang 59 * @author :liyuhang
37 * @method 60 * @method
38 */ 61 */
39 - public function edit(){  
40 - 62 + public function edit(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){
  63 + $request->validate([
  64 + 'id'=>'required'
  65 + ],[
  66 + 'id.required' => 'ID不能为空'
  67 + ]);
  68 + $aiCommandLogic->ai_edit();
  69 + $this->response('success');
41 } 70 }
42 71
43 /** 72 /**
@@ -46,7 +75,13 @@ class AiCommandController extends BaseController @@ -46,7 +75,13 @@ class AiCommandController extends BaseController
46 * @author :liyuhang 75 * @author :liyuhang
47 * @method 76 * @method
48 */ 77 */
49 - public function del(){  
50 - 78 + public function del(AiCommandLogic $aiCommandLogic){
  79 + $this->request->validate([
  80 + 'id'=>'required'
  81 + ],[
  82 + 'id.required' => 'ID不能为空'
  83 + ]);
  84 + $aiCommandLogic->ai_del();
  85 + $this->response('success');
51 } 86 }
52 } 87 }
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Aside; 3 +namespace App\Http\Controllers\Aside\Ai;
4 4
5 -class ProjectMenuController extends BaseController 5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Models\Ai\AiLog as AiLogModel;
  8 +
  9 +
  10 +class AiLogController extends BaseController
6 { 11 {
7 /** 12 /**
8 - * @name :用户菜单列表 13 + * @name :ai日志列表
9 * @return void 14 * @return void
10 * @author :liyuhang 15 * @author :liyuhang
11 * @method 16 * @method
12 */ 17 */
13 - public function lists(){  
14 - 18 + public function lists(AiLogModel $aiLogModel){
  19 + $lists = $aiLogModel->lists($this->map,$this->page,$this->row,$this->order);
  20 + $this->response('success',Code::SUCCESS,$lists);
15 } 21 }
16 } 22 }
@@ -34,20 +34,10 @@ class BaseController extends Controller @@ -34,20 +34,10 @@ class BaseController extends Controller
34 $info = Cache::get($this->token); 34 $info = Cache::get($this->token);
35 $this->user = $info; 35 $this->user = $info;
36 $this->uid = $info['id']; 36 $this->uid = $info['id'];
37 - }else{  
38 - return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']); 37 + //参数处理
  38 + $this->get_param();
39 } 39 }
40 - $this->get_param();  
41 - }  
42 40
43 - /**  
44 - * admin端用渲染 不走接口  
45 - * @return mixed  
46 - * @author zbj  
47 - * @date 2023/4/19  
48 - */  
49 - public function manage(){  
50 - return Session::get('manage');  
51 } 41 }
52 42
53 43
@@ -75,8 +65,7 @@ class BaseController extends Controller @@ -75,8 +65,7 @@ class BaseController extends Controller
75 return response()->json($response,200,$this->header); 65 return response()->json($response,200,$this->header);
76 } 66 }
77 /** 67 /**
78 - * @name 参数过滤  
79 - * @return void 68 + * @name :参数过滤
80 * @author :liyuhang 69 * @author :liyuhang
81 * @method 70 * @method
82 */ 71 */
@@ -138,23 +127,12 @@ class BaseController extends Controller @@ -138,23 +127,12 @@ class BaseController extends Controller
138 127
139 128
140 /** 129 /**
141 - * 菜单权限->得到子级数组  
142 - * @param int  
143 - * @return array 130 + * @param $data
  131 + * @name :返回参数统一处理
  132 + * @return array|string
  133 + * @author :liyuhang
  134 + * @method
144 */ 135 */
145 - public function _get_child($my_id, $arr)  
146 - {  
147 - $new_arr = array();  
148 - foreach ($arr as $k => $v) {  
149 - $v = (array)$v;  
150 - if ($v['pid'] == $my_id) {  
151 - $v['sub'] = $this->_get_child($v['id'],$arr);  
152 - $new_arr[] = $v;  
153 - }  
154 - }  
155 - return $new_arr ? $new_arr : false;  
156 - }  
157 -  
158 protected function _extents($data) { 136 protected function _extents($data) {
159 137
160 if (empty($data) || !is_array($data)) { 138 if (empty($data) || !is_array($data)) {
@@ -170,7 +148,7 @@ class BaseController extends Controller @@ -170,7 +148,7 @@ class BaseController extends Controller
170 } 148 }
171 switch ((string) $k) { 149 switch ((string) $k) {
172 case 'image': 150 case 'image':
173 - $v['image_link'] = file_get_contents($v); 151 + $v['image_link'] = url('/a/image/' . $v);
174 break; 152 break;
175 } 153 }
176 } 154 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\Devops;
  4 +
  5 +use App\Http\Controllers\Aside\BaseController;
  6 +
  7 +use App\Http\Logic\Aside\Devops\ServerConfigLogic;
  8 +use App\Http\Requests\Aside\Devops\ServerConfigRequest;
  9 +use Illuminate\Http\Request;
  10 +use Illuminate\Support\Str;
  11 +use Illuminate\Validation\Rule;
  12 +
  13 +/**
  14 + * 项目服务器、数据库配置
  15 + * Class ServerConfigController
  16 + * @package App\Http\Controllers\Aside
  17 + * @author zbj
  18 + * @date 2023/4/24
  19 + */
  20 +class ServerConfigController extends BaseController
  21 +{
  22 +
  23 + /**
  24 + * 保存配置
  25 + * @param ServerConfigRequest $request
  26 + * @param ServerConfigLogic $logic
  27 + * @author zbj
  28 + * @date 2023/4/23
  29 + */
  30 + public function save(ServerConfigRequest $request, ServerConfigLogic $logic){
  31 + $data = $logic->save($this->param);
  32 + return $this->success($data);
  33 + }
  34 +
  35 + /**
  36 + * 更新表结构
  37 + * @param ServerConfigLogic $logic
  38 + * @author zbj
  39 + * @date 2023/4/24
  40 + */
  41 + public function updateDatabase(Request $request, ServerConfigLogic $logic){
  42 + $request->validate([
  43 + 'type' => 'in:1,2,3',
  44 + 'id'=> Rule::requiredIf($request->type == 1),
  45 + 'sql' => ['required', function ($attribute, $value, $fail) {
  46 + if(Str::contains(Str::lower($value), ['drop', 'delete', 'truncate'])){
  47 + $fail('危险操作');
  48 + }
  49 + }]
  50 + ],[
  51 + 'id.required' => 'ID不能为空',
  52 + 'sql.required' => '请输入Sql语句',
  53 + ]);
  54 +
  55 + switch ($this->param['type']){
  56 + case "1":
  57 + $data = $logic->updateTable($this->param);
  58 + break;
  59 + case "2":
  60 + $data = $logic->updateLocalTable($this->param);
  61 + break;
  62 + case "3":
  63 + $data = $logic->updateAllTable($this->param);
  64 + break;
  65 + }
  66 +
  67 + return $this->success($data);
  68 + }
  69 +
  70 + /**
  71 + * 更新代码
  72 + * @param ServerConfigLogic $logic
  73 + * @author zbj
  74 + * @date 2023/4/24
  75 + */
  76 + public function updateCode(){
  77 + //todo
  78 + //C端
  79 +// $process = new Process(['git', 'pull']);
  80 +// $process->run();
  81 +// dump($process->getExitCodeText());
  82 +// dump($process->getExitCode());
  83 +// dump($process->getErrorOutput());
  84 +// $output = explode(PHP_EOL, $process->getOutput());
  85 +// dump($output);
  86 +// exit;
  87 + }
  88 +}
@@ -31,6 +31,9 @@ class LoginController extends BaseController @@ -31,6 +31,9 @@ class LoginController extends BaseController
31 31
32 return $this->success(); 32 return $this->success();
33 } 33 }
  34 + if($logic->manage()){
  35 + return redirect(route('admin.home.white'));
  36 + }
34 return view('admin.login'); 37 return view('admin.login');
35 } 38 }
36 39
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\Mail;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Http\Logic\Aside\Mail\MailLogic;
  8 +use App\Http\Requests\Aside\Mail\MailRequest;
  9 +use App\Models\Mail\Mail as MailModel;
  10 +
  11 +/**
  12 + * @name:站内信
  13 + */
  14 +class MailController extends BaseController
  15 +{
  16 + public function lists(){
  17 + $mailModel = new MailModel();
  18 + $lists = $mailModel->lists($this->map,$this->page,$this->row,$this->order);
  19 + $this->response('列表',Code::SUCCESS,$lists);
  20 + }
  21 +
  22 + /**
  23 + * @name :详情
  24 + * @return void
  25 + * @author :liyuhang
  26 + * @method
  27 + */
  28 + public function info(MailLogic $mailLogic){
  29 + $this->request->validate([
  30 + 'id'=>'required'
  31 + ],[
  32 + 'id.required' => 'ID不能为空'
  33 + ]);
  34 + $info = $mailLogic->mail_info();
  35 + $this->response('success',Code::SUCCESS,$info);
  36 + }
  37 +
  38 +
  39 + /**
  40 + * @name :添加站内信
  41 + * @return void
  42 + * @author :liyuhang
  43 + * @method
  44 + */
  45 + public function add(MailRequest $mailRequest,MailLogic $mailLogic){
  46 + $mailRequest->validated();
  47 + $mailLogic->mail_add();
  48 + $this->response('success');
  49 + }
  50 +
  51 + /**
  52 + * @name :编辑站内信
  53 + * @return void
  54 + * @author :liyuhang
  55 + * @method
  56 + */
  57 + public function edit(MailRequest $mailRequest,MailLogic $mailLogic){
  58 + $mailRequest->validate([
  59 + 'id'=>'required'
  60 + ],[
  61 + 'id.required' => 'ID不能为空'
  62 + ]);
  63 + $mailLogic->mail_edit();
  64 + $this->response('success');
  65 + }
  66 +
  67 + /**
  68 + * @name :逻辑删除站内信
  69 + * @return void
  70 + * @author :liyuhang
  71 + * @method
  72 + */
  73 + public function del(MailLogic $mailLogic){
  74 + $this->request->validate([
  75 + 'id'=>'required'
  76 + ],[
  77 + 'id.required' => 'ID不能为空'
  78 + ]);
  79 + $mailLogic->mail_del();
  80 + $this->response('success');
  81 + }
  82 +}
@@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage; @@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 -use App\Http\Logic\Aside\DeptLogic;  
8 -use App\Http\Requests\Aside\DeptRequest; 7 +use App\Http\Logic\Aside\Manage\DeptLogic;
  8 +use App\Http\Requests\Aside\Manage\DeptRequest;
9 use App\Rules\Ids; 9 use App\Rules\Ids;
10 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
11 11
@@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage; @@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 -use App\Http\Logic\Aside\GroupLogic;  
8 -use App\Http\Requests\Aside\GroupRequest; 7 +use App\Http\Logic\Aside\Manage\GroupLogic;
  8 +use App\Http\Requests\Aside\Manage\GroupRequest;
9 use App\Rules\Ids; 9 use App\Rules\Ids;
10 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
11 11
@@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage; @@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 -use App\Http\Logic\Aside\ManageLogic;  
8 -use App\Http\Requests\Aside\ManageRequest; 7 +use App\Http\Logic\Aside\Manage\ManageLogic;
  8 +use App\Http\Requests\Aside\Manage\ManageRequest;
9 use App\Rules\Ids; 9 use App\Rules\Ids;
10 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
11 11
@@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage; @@ -4,8 +4,8 @@ namespace App\Http\Controllers\Aside\Manage;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 -use App\Http\Logic\Aside\MenuLogic;  
8 -use App\Http\Requests\Aside\MenuRequest; 7 +use App\Http\Logic\Aside\Manage\MenuLogic;
  8 +use App\Http\Requests\Aside\Manage\MenuRequest;
9 use App\Rules\Ids; 9 use App\Rules\Ids;
10 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
11 11
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\Project;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Http\Logic\Aside\Project\ProjectLogic;
  8 +use App\Http\Requests\Aside\Project\ProjectRequest;
  9 +use App\Rules\Ids;
  10 +use Illuminate\Http\Request;
  11 +
  12 +
  13 +/**
  14 + * 项目管理
  15 + * Class ProjectController
  16 + * @package App\Http\Controllers\Aside\Project
  17 + * @author zbj
  18 + * @date 2023/4/25
  19 + */
  20 +class ProjectController extends BaseController
  21 +{
  22 +
  23 + public function list(ProjectLogic $logic)
  24 + {
  25 + $map = [];
  26 + if(!empty($this->param['search'])){
  27 + $map[] = ['title', 'like', "%{$this->param['search']}%"];
  28 + }
  29 + $sort = ['id' => 'desc'];
  30 + $data = $logic->getList($map, $sort);
  31 +
  32 + return view("admin.project", ["list" => $data]);
  33 + }
  34 +
  35 + public function info(Request $request, ProjectLogic $logic){
  36 + $request->validate([
  37 + 'id'=>'required'
  38 + ],[
  39 + 'id.required' => 'ID不能为空'
  40 + ]);
  41 + $data = $logic->getInfo($this->param['id']);
  42 + return $this->success($data);
  43 + }
  44 +
  45 + public function save(ProjectRequest $request, ProjectLogic $logic)
  46 + {
  47 + $data = $logic->save($this->param);
  48 + return $this->success($data);
  49 + }
  50 +}
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Aside;  
4 -  
5 -class ProjectRoleController extends BaseController  
6 -{  
7 - /**  
8 - * @name :列表  
9 - * @return void  
10 - * @author :liyuhang  
11 - * @method  
12 - */  
13 - public function lists (){  
14 -  
15 - }  
16 -}  
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\Task;
  4 +
  5 +use App\Http\Controllers\Aside\BaseController;
  6 +use App\Http\Logic\Aside\Task\TaskFollowLogic;
  7 +use App\Http\Logic\Aside\Task\TaskLogic;
  8 +use App\Http\Requests\Aside\Task\TaskFollowRequest;
  9 +use App\Http\Requests\Aside\Task\TaskRequest;
  10 +use App\Models\Task\Task;
  11 +use Illuminate\Support\Facades\Request;
  12 +use Illuminate\Validation\Rule;
  13 +
  14 +
  15 +/**
  16 + * 工单管理
  17 + * Class TaskController
  18 + * @package App\Http\Controllers\Aside\Task
  19 + * @author zbj
  20 + * @date 2023/4/27
  21 + */
  22 +class TaskController extends BaseController
  23 +{
  24 +
  25 + public function list(TaskLogic $logic)
  26 + {
  27 + $map = [];
  28 + if(!empty($this->param['search'])){
  29 + $map[] = ['title', 'like', "%{$this->param['search']}%"];
  30 + }
  31 + $sort = ['id' => 'desc'];
  32 + $data = $logic->getList($map, $sort);
  33 +
  34 + return view("admin.task", ["list" => $data]);
  35 + }
  36 +
  37 + public function info(Request $request, TaskLogic $logic){
  38 + $request->validate([
  39 + 'id'=>'required'
  40 + ],[
  41 + 'id.required' => 'ID不能为空'
  42 + ]);
  43 + $data = $logic->getInfo($this->param['id']);
  44 + return $this->success($data);
  45 + }
  46 +
  47 + public function save(TaskRequest $request, TaskLogic $logic)
  48 + {
  49 + $data = $logic->save($this->param);
  50 + return $this->success($data);
  51 + }
  52 +
  53 + /**
  54 + * 修改状态
  55 + * @param Request $request
  56 + * @param TaskLogic $logic
  57 + * @author zbj
  58 + * @date 2023/4/27
  59 + */
  60 + public function status(Request $request, TaskLogic $logic){
  61 + $request->validate([
  62 + 'id'=>'required',
  63 + 'status' => ['required', Rule::in(array_keys(Task::statusMap()))]
  64 + ],[
  65 + 'id.required' => 'ID不能为空',
  66 + 'status.required' => '请选择状态',
  67 + 'status.in' => '状态值不正确',
  68 + ]);
  69 + $data = $logic->status($this->param['id'], $this->param['status']);
  70 + return $this->success($data);
  71 + }
  72 +
  73 +
  74 + /**
  75 + * 添加跟进记录
  76 + * @param TaskFollowRequest $request
  77 + * @param TaskFollowLogic $logic
  78 + * @author zbj
  79 + * @date 2023/4/27
  80 + */
  81 + public function save_follow(TaskFollowRequest $request, TaskFollowLogic $logic){
  82 + $data = $logic->save($this->param);
  83 + return $this->success($data);
  84 + }
  85 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\User;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Http\Logic\Aside\User\ProjectGroupLogic;
  8 +use App\Http\Requests\Aside\User\ProjectGroupRequest;
  9 +use App\Models\ProjectGroup as ProjectGroupModel;
  10 +
  11 +class ProjectGroupController extends BaseController
  12 +{
  13 + /**
  14 + * @name:用户组列表
  15 + */
  16 + public function lists(ProjectGroupModel $projectGroupModel){
  17 + $lists = $projectGroupModel->lists($this->map,$this->page,$this->row,$this->order);
  18 + $this->response('success',Code::SUCCESS,$lists);
  19 + }
  20 +
  21 + /**
  22 + * @name :添加用户组
  23 + * @return void
  24 + * @author :liyuhang
  25 + * @method
  26 + */
  27 + public function add(ProjectGroupRequest $request,ProjectGroupLogic $projectGroupLogic){
  28 + $request->validated();
  29 + $projectGroupLogic->group_add();
  30 + $this->response('success');
  31 + }
  32 +
  33 + /**
  34 + * @name :编辑用户组
  35 + * @return void
  36 + * @author :liyuhang
  37 + * @method
  38 + */
  39 + public function edit(ProjectGroupRequest $request,ProjectGroupLogic $projectGroupLogic){
  40 + $request->validate([
  41 + 'id'=>'required'
  42 + ],[
  43 + 'id.required' => 'ID不能为空'
  44 + ]);
  45 + $projectGroupLogic->group_edit();
  46 + $this->response('success');
  47 + }
  48 +
  49 + /**
  50 + * @name :用户组详情
  51 + * @return void
  52 + * @author :liyuhang
  53 + * @method
  54 + */
  55 + public function info(ProjectGroupLogic $projectGroupLogic){
  56 + $this->request->validate([
  57 + 'id'=>'required'
  58 + ],[
  59 + 'id.required' => 'ID不能为空'
  60 + ]);
  61 + $projectGroupLogic->group_info();
  62 + $this->success('success');
  63 + }
  64 +
  65 + /**
  66 + * @name :删除用户组
  67 + * @return void
  68 + * @author :liyuhang
  69 + * @method
  70 + */
  71 + public function del(ProjectGroupLogic $projectGroupLogic){
  72 + $this->request->validate([
  73 + 'id'=>'required'
  74 + ],[
  75 + 'id.required' => 'ID不能为空'
  76 + ]);
  77 + $projectGroupLogic->group_del();
  78 + $this->success('success');
  79 + }
  80 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\User;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Http\Logic\Aside\User\ProjectMenuLogic;
  8 +use App\Http\Requests\Aside\User\ProjectRoleRequest;
  9 +use App\Models\User\ProjectMenu;
  10 +use App\Models\User\ProjectMenu as ProjectMenuModel;
  11 +use Illuminate\Http\Request;
  12 +
  13 +class ProjectMenuController extends BaseController
  14 +{
  15 + /**
  16 + * @name :用户菜单列表
  17 + * @return json
  18 + * @author :liyuhang
  19 + * @method
  20 + */
  21 + public function lists(){
  22 + $menuModel = new ProjectMenuModel();
  23 + $lists = $menuModel->lists($this->map,$this->page,$this->row,$this->order,['*']);
  24 + $this->response('success',Code::SUCCESS,$lists);
  25 + }
  26 +
  27 + /**
  28 + * @name :详情
  29 + * @return void
  30 + * @author :liyuhang
  31 + * @method
  32 + */
  33 + public function info(ProjectMenuLogic $projectMenuLogic){
  34 + $this->request->validate([
  35 + 'id'=>'required'
  36 + ],[
  37 + 'id.required' => 'ID不能为空'
  38 + ]);
  39 + $info = $projectMenuLogic->menu_info();
  40 + $this->response('success',Code::SUCCESS,$info);
  41 + }
  42 +
  43 + /**
  44 + * @name :添加菜单
  45 + * @return void
  46 + * @author :liyuhang
  47 + * @method
  48 + */
  49 + public function add(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){
  50 + $request->validated();
  51 + $projectMenuLogic->menu_add();
  52 + $this->response('success');
  53 + }
  54 +
  55 + /**
  56 + * @name :编辑菜单
  57 + * @return void
  58 + * @author :liyuhang
  59 + * @method
  60 + */
  61 + public function edit(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){
  62 + $request->validate([
  63 + 'id'=>'required'
  64 + ],[
  65 + 'id.required' => 'ID不能为空'
  66 + ]);
  67 + $projectMenuLogic->menu_edit();
  68 + $this->response('success');
  69 + }
  70 +
  71 + /**
  72 + * @name :删除菜单
  73 + * @return void
  74 + * @author :liyuhang
  75 + * @method
  76 + */
  77 + public function del(ProjectMenuLogic $projectMenuLogic){
  78 + $this->request->validate([
  79 + 'id'=>['required','array'],
  80 + ],[
  81 + 'id.required' => 'ID不能为空',
  82 + 'id.array' => 'ID为数组',
  83 + ]);
  84 + $projectMenuLogic->menu_del();
  85 + $this->response('success');
  86 + }
  87 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\User;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Http\Logic\Aside\User\ProjectRoleLogic;
  8 +use App\Http\Requests\Aside\User\ProjectRoleRequest;
  9 +use App\Models\User\ProjectRole as ProjectRoleModel;
  10 +use Illuminate\Http\Request;
  11 +
  12 +class ProjectRoleController extends BaseController
  13 +{
  14 + /**
  15 + * @name :列表
  16 + * @return json
  17 + * @author :liyuhang
  18 + * @method
  19 + */
  20 + public function lists (){
  21 + $roleModel = new ProjectRoleModel();
  22 + $lists = $roleModel->lists($this->map,$this->page,$this->row,$this->order,['*']);
  23 + $this->response('success',Code::SUCCESS,$lists);
  24 + }
  25 +
  26 + /**
  27 + * @name :详情
  28 + * @return void
  29 + * @author :liyuhang
  30 + * @method
  31 + */
  32 + public function info(ProjectRoleLogic $roleLogic){
  33 + $this->request->validate([
  34 + 'id'=>'required'
  35 + ],[
  36 + 'id.required' => 'ID不能为空'
  37 + ]);
  38 + //TODO::详情
  39 + $roleLogic->role_info();
  40 + $this->response('success');
  41 + }
  42 +
  43 + /**
  44 + * @name :添加角色时获取菜单列表
  45 + * @return void
  46 + * @author :liyuhang
  47 + * @method
  48 + */
  49 + public function get_menu(ProjectRoleLogic $roleLogic){
  50 + $list = $roleLogic->role_get_menu();
  51 + $this->response('success',Code::SUCCESS,$list);
  52 + }
  53 + /**
  54 + * @name :添加角色
  55 + * @return void
  56 + * @author :liyuhang
  57 + * @method
  58 + */
  59 + public function add(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){
  60 + $request->validated();
  61 + //TODO::添加
  62 + $roleLogic->role_add();
  63 + $this->response('success');
  64 + }
  65 +
  66 + /**
  67 + * @name :编辑角色
  68 + * @return void
  69 + * @author :liyuhang
  70 + * @method
  71 + */
  72 + public function edit(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){
  73 + $request->validate([
  74 + 'id'=>'required'
  75 + ],[
  76 + 'id.required' => 'ID不能为空'
  77 + ]);
  78 + //TODO::编辑
  79 + $roleLogic->role_edit();
  80 + $this->response('success');
  81 + }
  82 +
  83 + /**
  84 + * @name :删除角色
  85 + * @return void
  86 + * @author :liyuhang
  87 + * @method
  88 + */
  89 + public function del(ProjectRoleLogic $roleLogic){
  90 + $this->request->validate([
  91 + 'id'=>['required','array'],
  92 + ],[
  93 + 'id.required' => 'ID不能为空',
  94 + 'id.array' => 'ID为数组',
  95 + ]);
  96 + $roleLogic->role_del();
  97 + //TODO::删除
  98 + $this->response('success');
  99 + }
  100 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\User;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Aside\BaseController;
  7 +use App\Http\Logic\Aside\User\UserLogic;
  8 +use App\Http\Requests\Aside\User\UserRequest;
  9 +use App\Models\User\User as UserModel;
  10 +use Illuminate\Http\Request;
  11 +
  12 +class ProjectUserController extends BaseController
  13 +{
  14 + /**
  15 + * @name :用户列表
  16 + * @return void
  17 + * @author :liyuhang
  18 + * @method
  19 + */
  20 + public function lists(){
  21 + $userModel = new UserModel();
  22 + $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,
  23 + ['id','mobile','name','created_at','updated_at','image','operator_id']);
  24 + $this->response('列表',Code::SUCCESS,$lists);
  25 + }
  26 +
  27 + /**
  28 + * @name :详情
  29 + * @return void
  30 + * @author :liyuhang
  31 + * @method
  32 + */
  33 + public function info(UserLogic $userLogic){
  34 + $this->request->validate([
  35 + 'id'=>'required'
  36 + ],[
  37 + 'id.required' => 'ID不能为空'
  38 + ]);
  39 + $userLogic->user_info();
  40 + $this->response('success');
  41 + }
  42 + /**
  43 + * @name :添加用户
  44 + * @return void
  45 + * @author :liyuhang
  46 + * @method
  47 + */
  48 + public function add(UserRequest $request,UserLogic $userLogic){
  49 + $request->validated();
  50 + $userLogic->user_add();
  51 + $this->response('success');
  52 + }
  53 +
  54 + /**
  55 + * @name : 编辑
  56 + * @return void
  57 + * @author :liyuhang
  58 + * @method
  59 + */
  60 + public function edit(UserRequest $request,UserLogic $userLogic){
  61 + $request->validate([
  62 + 'id'=>'required'
  63 + ],[
  64 + 'id.required' => 'ID不能为空'
  65 + ]);
  66 + $userLogic->user_edit();
  67 + $this->response('success');
  68 + }
  69 +
  70 + /**
  71 + * @name :批量删除
  72 + * @return void
  73 + * @author :liyuhang
  74 + * @method
  75 + */
  76 + public function del(UserLogic $userLogic){
  77 + $this->request->validate([
  78 + 'id'=>['required','array'],
  79 + ],[
  80 + 'id.required' => 'ID不能为空',
  81 + 'id.array' => 'ID为数组',
  82 + ]);
  83 + $userLogic->user_del();
  84 + $this->response('success');
  85 + }
  86 +}
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Bside; 3 +namespace App\Http\Controllers\Bside\Ai;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 -use Illuminate\Http\Request; 6 +use App\Helper\Common;
  7 +use App\Http\Controllers\Bside\BaseController;
  8 +use App\Http\Controllers\Bside\:写入日志;
  9 +use App\Models\Ai\AiLog;
7 10
8 class AiCommandController extends BaseController 11 class AiCommandController extends BaseController
9 { 12 {
  13 + //获取文本内容
10 public $chat_url = 'v2/openai_chat'; 14 public $chat_url = 'v2/openai_chat';
11 /** 15 /**
12 * @name :ai生成 16 * @name :ai生成
@@ -14,8 +18,8 @@ class AiCommandController extends BaseController @@ -14,8 +18,8 @@ class AiCommandController extends BaseController
14 * @author :liyuhang 18 * @author :liyuhang
15 * @method 19 * @method
16 */ 20 */
17 - public function ai_http_post(Request $request){  
18 - $request->validate([ 21 + public function ai_http_post(){
  22 + $this->request->validate([
19 'keywords'=>['required'], 23 'keywords'=>['required'],
20 'key'=>['required'] 24 'key'=>['required']
21 ],[ 25 ],[
@@ -23,7 +27,31 @@ class AiCommandController extends BaseController @@ -23,7 +27,31 @@ class AiCommandController extends BaseController
23 'key.required' => '场景不能为空', 27 'key.required' => '场景不能为空',
24 ]); 28 ]);
25 #TODO 通过key获取到ai指令对象 29 #TODO 通过key获取到ai指令对象
26 - $data = $this->send_openai_msg($this->chat_url); 30 + $data = Common::send_openai_msg($this->chat_url,$this->param);
  31 + $param = [
  32 + 'key'=>$this->param['key'],
  33 + 'keywords'=>$this->param['keywords'],
  34 + 'remark'=>json_encode($data)
  35 + ];
  36 + $this->set_ai_log($param);
27 $this->response('success',Code::SUCCESS,$data); 37 $this->response('success',Code::SUCCESS,$data);
28 } 38 }
  39 +
  40 + /**
  41 + * @name :写入日志
  42 + * @return void
  43 + * @author :liyuhang
  44 + * @method
  45 + */
  46 + public function set_ai_log($data){
  47 + //写入日志
  48 + $param = [
  49 + 'key'=> $this->param['key'],
  50 + 'keywords'=>$this->param['keywords'],
  51 + 'remark' =>$data['remark'],
  52 + 'operator_id'=>$this->uid
  53 + ];
  54 + $aiLog = new AiLog();
  55 + return $aiLog->add($param);
  56 + }
29 } 57 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\AyrShare;
  4 +
  5 +use App\Http\Controllers\Bside\BaseController;
  6 +use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic;
  7 +
  8 +/**
  9 + * @name:社交发布
  10 + */
  11 +class AyrReleaseController extends BaseController
  12 +{
  13 + /**
  14 + * @name :(发布社交)send_post
  15 + * @author :lyh
  16 + * @method :post
  17 + * @time :2023/5/9 9:36
  18 + */
  19 + public function send_post(AyrReleaseLogic $ayrReleaseLogic){
  20 + //保存数据库
  21 + $ayrReleaseLogic->release_add();
  22 +
  23 + }
  24 +
  25 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\AyrShare;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Helper\AyrShare as AyrShareHelper;
  7 +use App\Http\Controllers\Bside\BaseController;
  8 +use App\Http\Logic\Bside\AyrShare\AyrShareLogic;
  9 +use App\Models\AyrShare\AyrShare as AyrShareModel;
  10 +
  11 +/**
  12 + * @name:社交绑定
  13 + */
  14 +class AyrShareController extends BaseController
  15 +{
  16 + /**
  17 + * @name :(社交列表)lists
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2023/5/5 16:06
  21 + */
  22 + public function lists(AyrShareModel $ayrShareModel){
  23 + $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']);
  24 + $ayrShareHelper = new AyrShareHelper();
  25 + foreach ($lists['list'] as $k=>$v){
  26 + $lists['list'][$k]['ayr'] = $ayrShareHelper->get_profiles_users($v['profile_key']);
  27 + }
  28 + $this->response('列表',Code::SUCCESS,$lists);
  29 + }
  30 +
  31 + /**
  32 + * @name :(创建ayr_share账户)create_account
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2023/5/5 16:44
  36 + */
  37 + public function create_account(AyrShareLogic $ayrShareLogic){
  38 + $param = [
  39 + 'title'=>md5(uniqid().time()),
  40 + ];
  41 + //发送请求注册社交用户
  42 + $ayrShareHelper = new AyrShareHelper();
  43 + $res = $ayrShareHelper->post_create_profiles($param);
  44 + if($res['status'] == 'fail'){
  45 + $this->response('同步绑定失败');
  46 + }
  47 + //执行数据库操作
  48 + $ayrShareLogic->ayr_share_add($res);
  49 + $this->response('success');
  50 + }
  51 +
  52 + /**
  53 + * @name :(删除用户账号并同步ayr_share账号)edit_account
  54 + * @author :lyh
  55 + * @method :post
  56 + * @time :2023/5/6 10:11
  57 + */
  58 + public function del_account(AyrShareLogic $ayrShareLogic){
  59 + $this->request->validate([
  60 + 'id'=>['required']
  61 + ],[
  62 + 'id.required' => 'ID不能为空'
  63 + ]);
  64 + $info = $ayrShareLogic->ayr_share_info();
  65 + $data = [
  66 + 'title'=>$info['title'],
  67 + 'profileKey'=>$info['profile_key']
  68 + ];
  69 + //发送请求注册社交用户
  70 + $ayrShareHelper = new AyrShareHelper();
  71 + $res = $ayrShareHelper->deleted_profiles($data);
  72 + if($res['status'] == 'fail'){
  73 + $this->response('同步删除失败');
  74 + }
  75 + $ayrShareLogic->ayr_share_del();
  76 + $this->response('success');
  77 + }
  78 +
  79 + /**
  80 + * @name :(授权绑定第三方平台,生成jwt令牌)ayr_share_bind
  81 + * @author :lyh
  82 + * @method :post
  83 + * @time :2023/5/6 10:24
  84 + */
  85 + public function bind_account(AyrShareLogic $ayrShareLogic){
  86 + $this->request->validate([
  87 + 'id'=>['required']
  88 + ],[
  89 + 'id.required' => 'ID不能为空'
  90 + ]);
  91 + $info = $ayrShareLogic->ayr_share_info();
  92 + //发送请求注册社交用户
  93 + $ayrShareHelper = new AyrShareHelper();
  94 + $data = [
  95 + 'profileKey'=>$info['profile_key']
  96 + ];
  97 + $res = $ayrShareHelper->post_generate_jwt($data);
  98 + if($res['status'] == 'fail'){
  99 + $this->response($res['message'],Code::USER_ERROR);
  100 + }
  101 + $this->response('success',Code::SUCCESS,$res);
  102 + }
  103 +
  104 +}
@@ -3,8 +3,9 @@ @@ -3,8 +3,9 @@
3 namespace App\Http\Controllers\Bside; 3 namespace App\Http\Controllers\Bside;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\Common;
6 use App\Http\Controllers\Controller; 7 use App\Http\Controllers\Controller;
7 -use App\Models\AiCommand as AiCommandModel; 8 +use App\Models\User\User as UserModel;
8 use Illuminate\Http\JsonResponse; 9 use Illuminate\Http\JsonResponse;
9 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
10 use Illuminate\Http\Exceptions\HttpResponseException; 11 use Illuminate\Http\Exceptions\HttpResponseException;
@@ -34,33 +35,21 @@ class BaseController extends Controller @@ -34,33 +35,21 @@ class BaseController extends Controller
34 $info = Cache::get($this->token); 35 $info = Cache::get($this->token);
35 $this->user = $info; 36 $this->user = $info;
36 $this->uid = $info['id']; 37 $this->uid = $info['id'];
37 - }else{  
38 - throw new HttpResponseException(response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录'])); 38 + //参数处理
  39 + $this->get_param();
  40 + //日志记录
  41 + $this->set_user_log();
39 } 42 }
40 - $this->get_param();  
41 } 43 }
  44 +
42 /** 45 /**
43 - * 成功返回  
44 - * @param array $data  
45 - * @param string $code  
46 - * @param bool $objectData  
47 - * @return JsonResponse  
48 - * @throws \Psr\Container\ContainerExceptionInterface  
49 - * @throws \Psr\Container\NotFoundExceptionInterface 46 + * @name :ceshi
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2023/5/9 11:43
50 */ 50 */
51 - function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse  
52 - {  
53 - if ($objectData) {  
54 - $data = (object)$data;  
55 - }  
56 - $code = Code::fromValue($code);  
57 - $response = [  
58 - 'code' => $code->value,  
59 - 'data' => $data,  
60 - 'msg' => $code->description,  
61 - ];  
62 - $this->header['token'] = $this->token;  
63 - return response()->json($response,200,$this->header); 51 + public function ceshi(){
  52 +
64 } 53 }
65 /** 54 /**
66 * @name 参数过滤 55 * @name 参数过滤
@@ -84,26 +73,38 @@ class BaseController extends Controller @@ -84,26 +73,38 @@ class BaseController extends Controller
84 case 'row': 73 case 'row':
85 $this->row = $v; 74 $this->row = $v;
86 break; 75 break;
  76 + case "status":
  77 + $this->map['status'] = $v;
  78 + break;
  79 + case "category_id":
  80 + $this->map['category_id'] = $v;
  81 + break;
87 case "name": 82 case "name":
88 $this->map['name'] = ['like','%'.$v.'%']; 83 $this->map['name'] = ['like','%'.$v.'%'];
89 break; 84 break;
90 case "start_at": 85 case "start_at":
91 - $this->_btw[0] = $v;  
92 - $this->_btw[1] = date('Y-m-d H:i:s',time());  
93 - $this->map['created_at'] = ['between', $this->_btw]; 86 + if(!empty($v)){
  87 + $this->_btw[0] = $v;
  88 + $this->_btw[1] = date('Y-m-d H:i:s',time());
  89 + $this->map['created_at'] = ['between', $this->_btw];
  90 + }
94 break; 91 break;
95 case "end_at": 92 case "end_at":
96 - $this->_btw[1] = $v;  
97 - $this->map['updated_at'] = ['between', $this->_btw]; 93 + if(!empty($v)){
  94 + $this->_btw[1] = $v;
  95 + $this->map['updated_at'] = ['between', $this->_btw];
  96 + }
98 break; 97 break;
99 default: 98 default:
100 - $this->map[$k] = $v; 99 + if(!empty($v)){
  100 + $this->map[$k] = $v;
  101 + }
101 break; 102 break;
102 } 103 }
103 } 104 }
104 } 105 }
105 /** 106 /**
106 - * @name 统一返回参数 107 + * @name :统一返回参数
107 * @return JsonResponse 108 * @return JsonResponse
108 * @author :liyuhang 109 * @author :liyuhang
109 * @method 110 * @method
@@ -122,25 +123,34 @@ class BaseController extends Controller @@ -122,25 +123,34 @@ class BaseController extends Controller
122 throw new HttpResponseException($response); 123 throw new HttpResponseException($response);
123 } 124 }
124 125
125 -  
126 /** 126 /**
127 - * 菜单权限->得到子级数组  
128 - * @param int  
129 - * @return array 127 + * 成功返回
  128 + * @param array $data
  129 + * @param string $code
  130 + * @param bool $objectData
  131 + * @return JsonResponse
130 */ 132 */
131 - public function _get_child($my_id, $arr) 133 + function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
132 { 134 {
133 - $new_arr = array();  
134 - foreach ($arr as $k => $v) {  
135 - $v = (array)$v;  
136 - if ($v['pid'] == $my_id) {  
137 - $v['sub'] = $this->_get_child($v['id'],$arr);  
138 - $new_arr[] = $v;  
139 - } 135 + if ($objectData) {
  136 + $data = (object)$data;
140 } 137 }
141 - return $new_arr ? $new_arr : false; 138 + $code = Code::fromValue($code);
  139 + $response = [
  140 + 'code' => $code->value,
  141 + 'data' => $data,
  142 + 'msg' => $code->description,
  143 + ];
  144 + $this->header['token'] = $this->token;
  145 + return response()->json($response,200,$this->header);
142 } 146 }
143 - 147 + /**
  148 + * @param $data
  149 + * @name :返回参数处理
  150 + * @return array|string
  151 + * @author :liyuhang
  152 + * @method
  153 + */
144 protected function _extents($data) { 154 protected function _extents($data) {
145 155
146 if (empty($data) || !is_array($data)) { 156 if (empty($data) || !is_array($data)) {
@@ -154,10 +164,20 @@ class BaseController extends Controller @@ -154,10 +164,20 @@ class BaseController extends Controller
154 $data[$k] = ''; 164 $data[$k] = '';
155 continue; 165 continue;
156 } 166 }
  167 + //获取操作人
157 switch ((string) $k) { 168 switch ((string) $k) {
158 case 'image': 169 case 'image':
159 $data['image_link'] = url('/b/image/' . $v); 170 $data['image_link'] = url('/b/image/' . $v);
160 break; 171 break;
  172 + case 'file':
  173 + $data['file_link'] = url('/b/file_hash/' . $v);
  174 + break;
  175 + case 'operator_id':
  176 + if(!empty($v)){
  177 + $name = (new UserModel())->read(['operator_id'=>$v],['id','name']);
  178 + $data['operator_name'] = (isset($name['name']) && !empty($name['name'])) ? $name['name'] : '无名称';
  179 + }
  180 + break;
161 } 181 }
162 } 182 }
163 } 183 }
@@ -165,27 +185,19 @@ class BaseController extends Controller @@ -165,27 +185,19 @@ class BaseController extends Controller
165 } 185 }
166 186
167 /** 187 /**
168 - * @name :ai自动生成  
169 - * @return mixed 188 + * @name :写入操作日志
  189 + * @return void
170 * @author :liyuhang 190 * @author :liyuhang
171 * @method 191 * @method
172 */ 192 */
173 - public function send_openai_msg($url){  
174 - $url = HTTP_OPENAI_URL.$url;  
175 - $aiCommandModel = New AiCommandModel();  
176 - //指定库获取指令  
177 - $info = $aiCommandModel->read(['key'=>$this->param['key']]);  
178 - if($info === false){  
179 - $this->response('指令不存在',Code::USER_ERROR); 193 + public function set_user_log(){
  194 + //生成日志
  195 + $log = config('logging.operator_log');
  196 + if(isset($log) && $log['log'] == true){
  197 + if(empty($log['action']) || (strpos($log['action'],$this->request->route()->getName()) < 0)){
  198 + Common::set_user_log(['model'=>$this->request->route()->getName(),'remark'=>'请求的参数:param = '.json_encode($this->param),'operator_id'=>$this->uid]);
  199 + }
180 } 200 }
181 - //替换关键字  
182 - $content = str_replace('$keyword$', $this->param['keywords'], $info['ai']);  
183 - $data = [  
184 - 'messages'=>[  
185 - ['role'=>'system','content'=>$info['scene']],  
186 - ['role'=>'assistant','content'=>$content],  
187 - ]  
188 - ];  
189 - return http_post($url,json_encode($data)); 201 + return true;
190 } 202 }
191 } 203 }
@@ -8,7 +8,6 @@ use App\Http\Logic\Bside\Blog\BlogCategoryLogic; @@ -8,7 +8,6 @@ use App\Http\Logic\Bside\Blog\BlogCategoryLogic;
8 use App\Http\Requests\Bside\Blog\BlogCategoryRequest; 8 use App\Http\Requests\Bside\Blog\BlogCategoryRequest;
9 use App\Models\Blog\Blog as BlogModel; 9 use App\Models\Blog\Blog as BlogModel;
10 use App\Models\Blog\BlogCategory as BlogCategoryModel; 10 use App\Models\Blog\BlogCategory as BlogCategoryModel;
11 -use Illuminate\Http\Request;  
12 11
13 class BlogCategoryController extends BaseController 12 class BlogCategoryController extends BaseController
14 { 13 {
@@ -21,7 +20,15 @@ class BlogCategoryController extends BaseController @@ -21,7 +20,15 @@ class BlogCategoryController extends BaseController
21 public function lists(BlogCategoryModel $blogCategoryModel){ 20 public function lists(BlogCategoryModel $blogCategoryModel){
22 //搜索条件 21 //搜索条件
23 $this->map['project_id'] = $this->user['project_id']; 22 $this->map['project_id'] = $this->user['project_id'];
24 - $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row); 23 + $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order,
  24 + ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']);
  25 + if(!empty($lists['list'])){
  26 + $blogModel = new BlogModel();
  27 + foreach ($lists['list'] as $k => $v){
  28 + $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
  29 + $lists['list'][$k] = $v;
  30 + }
  31 + }
25 $this->response('success',Code::SUCCESS,$lists); 32 $this->response('success',Code::SUCCESS,$lists);
26 } 33 }
27 34
@@ -31,8 +38,8 @@ class BlogCategoryController extends BaseController @@ -31,8 +38,8 @@ class BlogCategoryController extends BaseController
31 * @author :liyuhang 38 * @author :liyuhang
32 * @method 39 * @method
33 */ 40 */
34 - public function info(Request $request,BlogCategoryLogic $blogCategoryLogic){  
35 - $request->validate([ 41 + public function info(BlogCategoryLogic $blogCategoryLogic){
  42 + $this->request->validate([
36 'id'=>['required'] 43 'id'=>['required']
37 ],[ 44 ],[
38 'id.required' => 'ID不能为空' 45 'id.required' => 'ID不能为空'
@@ -76,8 +83,8 @@ class BlogCategoryController extends BaseController @@ -76,8 +83,8 @@ class BlogCategoryController extends BaseController
76 * @author :liyuhang 83 * @author :liyuhang
77 * @method 84 * @method
78 */ 85 */
79 - public function status(Request $request,BlogCategoryLogic $blogCategoryLogic){  
80 - $request->validate([ 86 + public function status(BlogCategoryLogic $blogCategoryLogic){
  87 + $this->request->validate([
81 'id'=>['required'], 88 'id'=>['required'],
82 ],[ 89 ],[
83 'id.required' => 'ID不能为空', 90 'id.required' => 'ID不能为空',
@@ -92,11 +99,12 @@ class BlogCategoryController extends BaseController @@ -92,11 +99,12 @@ class BlogCategoryController extends BaseController
92 * @author :liyuhang 99 * @author :liyuhang
93 * @method 100 * @method
94 */ 101 */
95 - public function del(Request $request,BlogCategoryLogic $blogCategoryLogic){  
96 - $request->validate([  
97 - 'id'=>['required'], 102 + public function del(BlogCategoryLogic $blogCategoryLogic){
  103 + $this->request->validate([
  104 + 'id'=>['required','array'],
98 ],[ 105 ],[
99 'id.required' => 'ID不能为空', 106 'id.required' => 'ID不能为空',
  107 + 'id.array' => 'ID为数组',
100 ]); 108 ]);
101 $blogCategoryLogic->del_blog_category(); 109 $blogCategoryLogic->del_blog_category();
102 //TODO::写入操作日志 110 //TODO::写入操作日志
@@ -4,11 +4,12 @@ namespace App\Http\Controllers\Bside\Blog; @@ -4,11 +4,12 @@ namespace App\Http\Controllers\Bside\Blog;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\Blog\BlogCategoryLogic;
  8 +use App\Http\Logic\Bside\Blog\BlogLabelLogic;
7 use App\Http\Logic\Bside\Blog\BlogLogic; 9 use App\Http\Logic\Bside\Blog\BlogLogic;
8 use App\Http\Requests\Bside\Blog\BlogRequest; 10 use App\Http\Requests\Bside\Blog\BlogRequest;
9 use App\Models\Blog\Blog as BlogModel; 11 use App\Models\Blog\Blog as BlogModel;
10 -use App\Models\Blog\BlogCategory as BlogCategoryModel;  
11 -use Illuminate\Http\Request; 12 +
12 class BlogController extends BaseController 13 class BlogController extends BaseController
13 { 14 {
14 /** 15 /**
@@ -17,21 +18,17 @@ class BlogController extends BaseController @@ -17,21 +18,17 @@ class BlogController extends BaseController
17 * @author :liyuhang 18 * @author :liyuhang
18 * @method 19 * @method
19 */ 20 */
20 - public function lists(BlogModel $blogModel){ 21 + public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){
21 //搜索条件 22 //搜索条件
22 $this->map['project_id'] = $this->user['project_id']; 23 $this->map['project_id'] = $this->user['project_id'];
23 - $lists = $blogModel->lists($this->map,$this->page,$this->row); 24 + $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order,
  25 + ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']);
24 if(!empty($lists['list'])){ 26 if(!empty($lists['list'])){
25 foreach ($lists['list'] as $k => $v){ 27 foreach ($lists['list'] as $k => $v){
26 - $blogCategoryModel= new BlogCategoryModel();  
27 - //获取用户已读还是未读  
28 - $category_info = $blogCategoryModel->  
29 - list(['id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']);  
30 - $str = '';  
31 - foreach ($category_info as $v1){  
32 - $str .= $v1['name'].',';  
33 - }  
34 - $v['category_id'] = trim($str,','); 28 + //获取分类名称
  29 + $v = $blogCategoryLogic->get_category_name($v);
  30 + //获取标签名称
  31 + $v = $blogLabelLogic->get_label_name($v);
35 $lists['list'][$k] = $v; 32 $lists['list'][$k] = $v;
36 } 33 }
37 } 34 }
@@ -55,8 +52,8 @@ class BlogController extends BaseController @@ -55,8 +52,8 @@ class BlogController extends BaseController
55 * @author :liyuhang 52 * @author :liyuhang
56 * @method 53 * @method
57 */ 54 */
58 - public function info(Request $request,BlogLogic $blogLogic){  
59 - $request->validate([ 55 + public function info(BlogLogic $blogLogic){
  56 + $this->request->validate([
60 'id'=>['required'] 57 'id'=>['required']
61 ],[ 58 ],[
62 'id.required' => 'ID不能为空' 59 'id.required' => 'ID不能为空'
@@ -95,55 +92,58 @@ class BlogController extends BaseController @@ -95,55 +92,58 @@ class BlogController extends BaseController
95 } 92 }
96 93
97 /** 94 /**
98 - * @name :编辑博客状态/排序 95 + * @name :编辑新闻seo
99 * @return void 96 * @return void
100 * @author :liyuhang 97 * @author :liyuhang
101 * @method 98 * @method
102 */ 99 */
103 - public function status(Request $request,BlogLogic $blogLogic){  
104 - $request->validate([ 100 + public function edit_seo(BlogLogic $blogLogic){
  101 + $this->request->validate([
105 'id'=>['required'], 102 'id'=>['required'],
  103 + 'seo_title'=>['required'],
  104 + 'seo_description'=>['required'],
  105 + 'seo_keywords'=>['required'],
106 ],[ 106 ],[
107 'id.required' => 'ID不能为空', 107 'id.required' => 'ID不能为空',
  108 + 'seo_title.required' => 'seo_title不能为空',
  109 + 'seo_description.required' => 'seo_description不能为空',
  110 + 'seo_keywords.required' => 'seo_description不能为空',
108 ]); 111 ]);
109 - $blogLogic->blog_status();  
110 - //TODO::写入日志 112 + $blogLogic->edit_seo();
111 $this->response('success'); 113 $this->response('success');
112 } 114 }
113 -  
114 /** 115 /**
115 - * @name :删除博客(批量逻辑删除) 116 + * @name :编辑博客状态/排序
116 * @return void 117 * @return void
117 * @author :liyuhang 118 * @author :liyuhang
118 * @method 119 * @method
119 */ 120 */
120 - public function del(Request $request,BlogLogic $blogLogic){  
121 - $request->validate([ 121 + public function status(BlogLogic $blogLogic){
  122 + $this->request->validate([
122 'id'=>['required'], 123 'id'=>['required'],
123 ],[ 124 ],[
124 'id.required' => 'ID不能为空', 125 'id.required' => 'ID不能为空',
125 ]); 126 ]);
126 - $blogLogic->blog_del(); 127 + $blogLogic->blog_status();
  128 + //TODO::写入日志
127 $this->response('success'); 129 $this->response('success');
128 } 130 }
  131 +
129 /** 132 /**
130 - * @name :ai生成 133 + * @name :删除博客(批量逻辑删除)
131 * @return void 134 * @return void
132 * @author :liyuhang 135 * @author :liyuhang
133 * @method 136 * @method
134 */ 137 */
135 - public function ai_blog(Request $request){  
136 - $request->validate([  
137 - 'keywords'=>['required'],  
138 - 'key'=>['required'] 138 + public function del(BlogLogic $blogLogic){
  139 + $this->request->validate([
  140 + 'id'=>['required','array'],
139 ],[ 141 ],[
140 - 'keywords.required' => '关键字不能为空',  
141 - 'key.required' => '场景不能为空', 142 + 'id.required' => 'ID不能为空',
  143 + 'id.array' => 'ID为数组',
142 ]); 144 ]);
143 - #TODO 通过key获取到ai指令对象  
144 - $url = 'v2/openai_chat';  
145 - $data = $this->send_openai_msg($url);  
146 - $this->response('success',Code::SUCCESS,$data); 145 + $blogLogic->blog_del();
  146 + $this->response('success');
147 } 147 }
148 148
149 } 149 }
@@ -59,13 +59,13 @@ class BlogLabelController extends BaseController @@ -59,13 +59,13 @@ class BlogLabelController extends BaseController
59 * @author :liyuhang 59 * @author :liyuhang
60 * @method 60 * @method
61 */ 61 */
62 - public function status(Request $request,BlogLabelLogic $blogLabelLogic){  
63 - $request->validate([ 62 + public function status(BlogLabelLogic $blogLabelLogic){
  63 + $this->request->validate([
64 'id'=>['required'], 64 'id'=>['required'],
65 ],[ 65 ],[
66 'id.required' => 'ID不能为空', 66 'id.required' => 'ID不能为空',
67 ]); 67 ]);
68 - $blogLabelLogic->edit_blog_label(); 68 + $blogLabelLogic->status_blog_label();
69 //TODO::写入日志 69 //TODO::写入日志
70 $this->response('success'); 70 $this->response('success');
71 } 71 }
@@ -76,11 +76,12 @@ class BlogLabelController extends BaseController @@ -76,11 +76,12 @@ class BlogLabelController extends BaseController
76 * @author :liyuhang 76 * @author :liyuhang
77 * @method 77 * @method
78 */ 78 */
79 - public function del(Request $request,BlogLabelLogic $blogLabelLogic){  
80 - $request->validate([  
81 - 'id'=>['required'], 79 + public function del(BlogLabelLogic $blogLabelLogic){
  80 + $this->request->validate([
  81 + 'id'=>['required','array'],
82 ],[ 82 ],[
83 'id.required' => 'ID不能为空', 83 'id.required' => 'ID不能为空',
  84 + 'id.array' => 'ID为数组',
84 ]); 85 ]);
85 $blogLabelLogic->del_blog_label(); 86 $blogLabelLogic->del_blog_label();
86 $this->response('success'); 87 $this->response('success');
@@ -3,13 +3,15 @@ @@ -3,13 +3,15 @@
3 namespace App\Http\Controllers\Bside; 3 namespace App\Http\Controllers\Bside;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 -use App\Models\Project;  
7 -use App\Models\Project as ProjectModel;  
8 -use App\Models\ProjectMenu as ProjectMenuModel;  
9 -use App\Models\ProjectRole as ProjectRoleModel;  
10 -use App\Models\User as UserModel; 6 +use App\Helper\Country;
  7 +use App\Models\Project\Project;
  8 +use App\Models\Project\Project as ProjectModel;
  9 +use App\Models\User\ProjectMenu as ProjectMenuModel;
  10 +use App\Models\User\ProjectRole as ProjectRoleModel;
  11 +use App\Models\User\User as UserModel;
11 use Illuminate\Http\Request; 12 use Illuminate\Http\Request;
12 use Illuminate\Support\Facades\Cache; 13 use Illuminate\Support\Facades\Cache;
  14 +
13 /*** 15 /***
14 * 当前为公共类 所有方法均不需要验证登录token 16 * 当前为公共类 所有方法均不需要验证登录token
15 */ 17 */
@@ -21,8 +23,8 @@ class ComController extends BaseController @@ -21,8 +23,8 @@ class ComController extends BaseController
21 * @author :liyuhang 23 * @author :liyuhang
22 * @method 24 * @method
23 */ 25 */
24 - public function login(Request $request){  
25 - $request->validate([ 26 + public function login(){
  27 + $this->request->validate([
26 'mobile'=>['required'], 28 'mobile'=>['required'],
27 'password'=>['required'], 29 'password'=>['required'],
28 ],[ 30 ],[
@@ -56,7 +58,7 @@ class ComController extends BaseController @@ -56,7 +58,7 @@ class ComController extends BaseController
56 foreach ($lists as $k => $v){ 58 foreach ($lists as $k => $v){
57 $v = (array)$v; 59 $v = (array)$v;
58 if ($v['pid'] == 0) { 60 if ($v['pid'] == 0) {
59 - $v['sub'] = $this->_get_child($v['id'], $lists); 61 + $v['sub'] = _get_child($v['id'], $lists);
60 $menu[] = $v; 62 $menu[] = $v;
61 } 63 }
62 } 64 }
@@ -83,8 +85,8 @@ class ComController extends BaseController @@ -83,8 +85,8 @@ class ComController extends BaseController
83 * @author :liyuhang 85 * @author :liyuhang
84 * @method 86 * @method
85 */ 87 */
86 - public function edit_info(Request $request){  
87 - $request->validate([ 88 + public function edit_info(){
  89 + $this->request->validate([
88 'password'=>['required'], 90 'password'=>['required'],
89 'name'=>['required'], 91 'name'=>['required'],
90 ],[ 92 ],[
@@ -114,4 +116,8 @@ class ComController extends BaseController @@ -114,4 +116,8 @@ class ComController extends BaseController
114 $this->response('success'); 116 $this->response('success');
115 } 117 }
116 118
  119 + public function get_country(){
  120 + $country = new Country();
  121 + return $country->set_country();
  122 + }
117 } 123 }
@@ -21,7 +21,7 @@ class FileController extends BaseController @@ -21,7 +21,7 @@ class FileController extends BaseController
21 */ 21 */
22 public function upload(Request $request){ 22 public function upload(Request $request){
23 // 上传文件 23 // 上传文件
24 - $files = Upload::puts('files', $this->param['config']); 24 + $files = Upload::puts('files', $this->param['config'] ?? 'default');
25 foreach ($files as &$file){ 25 foreach ($files as &$file){
26 $file = Upload::path2url($file); 26 $file = Upload::path2url($file);
27 } 27 }
@@ -36,7 +36,7 @@ class FileController extends BaseController @@ -36,7 +36,7 @@ class FileController extends BaseController
36 * @date 2023/4/20 36 * @date 2023/4/20
37 */ 37 */
38 public function download(Request $request){ 38 public function download(Request $request){
39 - $path = Upload::url2path($this->param['url']); 39 + $path = Upload::url2path($this->param['url'] ?? '');
40 return Storage::disk('upload')->download($path); 40 return Storage::disk('upload')->download($path);
41 } 41 }
42 } 42 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside;
  4 +
  5 +use App\Exceptions\BsideGlobalException;
  6 +use App\Helper\Arr;
  7 +use App\Http\Logic\Bside\InquiryLogic;
  8 +use App\Http\Requests\Bside\InquiryRequest;
  9 +use App\Rules\Ids;
  10 +use App\Services\BatchExportService;
  11 +use Illuminate\Http\Request;
  12 +use Illuminate\Support\Facades\Storage;
  13 +use Illuminate\Validation\ValidationException;
  14 +use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
  15 +
  16 +/**
  17 + * 精准询盘
  18 + * Class InquiryController
  19 + * @package App\Http\Controllers\Bside
  20 + * @author zbj
  21 + * @date 2023/5/4
  22 + */
  23 +class InquiryController extends BaseController
  24 +{
  25 +
  26 + public function index(InquiryLogic $logic)
  27 + {
  28 + $map = [];
  29 + if(!empty($this->param['search'])){
  30 + $map[] = ['name|email|content', 'like', "%{$this->param['search']}%"];
  31 + }
  32 + $sort = ['id' => 'desc'];
  33 + $data = $logic->getList($map, $sort, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'created_at']);
  34 + return $this->success($data);
  35 + }
  36 +
  37 + public function info(Request $request, InquiryLogic $logic){
  38 + $request->validate([
  39 + 'id'=>'required'
  40 + ],[
  41 + 'id.required' => 'ID不能为空'
  42 + ]);
  43 + $data = $logic->getInfo($this->param['id']);
  44 + return $this->success(Arr::twoKeepKeys($data, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'content', 'trans_content', 'created_at']));
  45 + }
  46 +
  47 + public function delete(Request $request, InquiryLogic $logic)
  48 + {
  49 + $request->validate([
  50 + 'ids'=>['required', new Ids()]
  51 + ],[
  52 + 'ids.required' => 'ID不能为空'
  53 + ]);
  54 +
  55 + $data = $logic->delete($this->param['ids']);
  56 + return $this->success($data);
  57 + }
  58 +
  59 + /**
  60 + * 导出
  61 + * @param InquiryLogic $logic
  62 + * @return \Illuminate\Http\JsonResponse
  63 + * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  64 + * @author zbj
  65 + * @date 2023/5/8
  66 + */
  67 + public function export(InquiryLogic $logic)
  68 + {
  69 + $sort = ['id' => 'desc'];
  70 + //最多到1w条
  71 + $data = $logic->getList([], $sort, ['name', 'email', 'phone', 'url', 'ip', 'ip_country', 'content', 'created_at'], 10000);
  72 + $data = $data['list'] ?? [];
  73 + foreach ($data as &$item){
  74 + $item['ip_address'] = "{$item['ip_country']}({$item['ip']})";
  75 + }
  76 +
  77 + $map = [
  78 + 'created_at' => '询盘发送时间',
  79 + 'name' => '姓名',
  80 + 'email' => '邮箱',
  81 + 'phone' => '电话',
  82 + 'ip_address' => '访问国家/地区(IP)',
  83 + 'url' => '发送页面',
  84 + 'content' => '询盘内容',
  85 + ];
  86 +
  87 + //生成文件,发送到客户端
  88 + $table = new BatchExportService("询盘数据导出");
  89 + $file = $table->head($map)->data($data)->save();
  90 + if (!$file) {
  91 + throw new \Exception('文件生成失败,请重试');
  92 + }
  93 + $fileurl = Storage::disk('runtime')->url($file);
  94 +// return Storage::disk('runtime')->download($file); //直接下载
  95 + return $this->success(['url' => $fileurl]);
  96 + }
  97 +}
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Bside; 3 +namespace App\Http\Controllers\Bside\Mail;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 -use App\Http\Logic\Bside\MailLogic;  
7 -use App\Models\Mail as MailModel;  
8 -use App\Models\MailUser as MailUserModel;  
9 -use Illuminate\Http\Request; 6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\Mail\MailLogic;
  8 +use App\Models\Mail\Mail as MailModel;
  9 +use App\Models\Mail\MailUser as MailUserModel;
10 10
11 class MailController extends BaseController 11 class MailController extends BaseController
12 { 12 {
@@ -22,7 +22,7 @@ class MailController extends BaseController @@ -22,7 +22,7 @@ class MailController extends BaseController
22 $mailModel = new MailModel(); 22 $mailModel = new MailModel();
23 //获取当前用户下的所有站内信 23 //获取当前用户下的所有站内信
24 $this->map['user_list'] = ['like','%,'.$this->uid.',%']; 24 $this->map['user_list'] = ['like','%,'.$this->uid.',%'];
25 - $this->map['status'] = $this::STATUS_ZERO; 25 + $this->map['user_list'] = ['or',null];
26 $lists = $mailModel->lists($this->map,$this->page,$this->row); 26 $lists = $mailModel->lists($this->map,$this->page,$this->row);
27 if(!empty($lists['list'])){ 27 if(!empty($lists['list'])){
28 foreach ($lists['list'] as $k => $v){ 28 foreach ($lists['list'] as $k => $v){
@@ -46,8 +46,8 @@ class MailController extends BaseController @@ -46,8 +46,8 @@ class MailController extends BaseController
46 * @author :liyuhang 46 * @author :liyuhang
47 * @method 47 * @method
48 */ 48 */
49 - public function info(Request $request,MailLogic $mailLogic){  
50 - $request->validate([ 49 + public function info(MailLogic $mailLogic){
  50 + $this->request->validate([
51 'id'=>['required'] 51 'id'=>['required']
52 ],[ 52 ],[
53 'id.required' => 'ID不能为空' 53 'id.required' => 'ID不能为空'
@@ -6,8 +6,8 @@ use App\Enums\Common\Code; @@ -6,8 +6,8 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\News\NewsCategoryLogic; 7 use App\Http\Logic\Bside\News\NewsCategoryLogic;
8 use App\Http\Requests\Bside\News\NewsCategoryRequest; 8 use App\Http\Requests\Bside\News\NewsCategoryRequest;
  9 +use App\Models\News\News as NewsModel;
9 use App\Models\News\NewsCategory as NewsCategoryModel; 10 use App\Models\News\NewsCategory as NewsCategoryModel;
10 -use Illuminate\Http\Request;  
11 11
12 class NewsCategoryController extends BaseController 12 class NewsCategoryController extends BaseController
13 { 13 {
@@ -20,7 +20,15 @@ class NewsCategoryController extends BaseController @@ -20,7 +20,15 @@ class NewsCategoryController extends BaseController
20 public function lists(NewsCategoryModel $newsCategory){ 20 public function lists(NewsCategoryModel $newsCategory){
21 //搜索条件 21 //搜索条件
22 $this->map['project_id'] = $this->user['project_id']; 22 $this->map['project_id'] = $this->user['project_id'];
23 - $lists = $newsCategory->lists($this->map,$this->page,$this->row,'sort'); 23 + $lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order,
  24 + ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']);
  25 + if(!empty($lists['list'])){
  26 + $newsModel = new NewsModel();
  27 + foreach ($lists['list'] as $k => $v){
  28 + $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
  29 + $lists['list'][$k] = $v;
  30 + }
  31 + }
24 $this->response('success',Code::SUCCESS,$lists); 32 $this->response('success',Code::SUCCESS,$lists);
25 } 33 }
26 34
@@ -30,8 +38,8 @@ class NewsCategoryController extends BaseController @@ -30,8 +38,8 @@ class NewsCategoryController extends BaseController
30 * @author :liyuhang 38 * @author :liyuhang
31 * @method 39 * @method
32 */ 40 */
33 - public function info(Request $request,NewsCategoryLogic $newsCategoryLogic){  
34 - $request->validate([ 41 + public function info(NewsCategoryLogic $newsCategoryLogic){
  42 + $this->request->validate([
35 'id'=>['required'] 43 'id'=>['required']
36 ],[ 44 ],[
37 'id.required' => 'ID不能为空' 45 'id.required' => 'ID不能为空'
@@ -49,8 +57,7 @@ class NewsCategoryController extends BaseController @@ -49,8 +57,7 @@ class NewsCategoryController extends BaseController
49 $request->validated(); 57 $request->validated();
50 //添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加 58 //添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加
51 $newsCategoryLogic->add_news_category(); 59 $newsCategoryLogic->add_news_category();
52 - //TODO::写入日志  
53 - $this->response('success',Code::SUCCESS,[]); 60 + $this->response('success');
54 } 61 }
55 62
56 /** 63 /**
@@ -66,7 +73,6 @@ class NewsCategoryController extends BaseController @@ -66,7 +73,6 @@ class NewsCategoryController extends BaseController
66 'id.required' => 'ID不能为空' 73 'id.required' => 'ID不能为空'
67 ]); 74 ]);
68 $newsCategoryLogic->edit_news_category(); 75 $newsCategoryLogic->edit_news_category();
69 - //TODO::写入日志  
70 $this->response('success'); 76 $this->response('success');
71 } 77 }
72 78
@@ -76,8 +82,8 @@ class NewsCategoryController extends BaseController @@ -76,8 +82,8 @@ class NewsCategoryController extends BaseController
76 * @author :liyuhang 82 * @author :liyuhang
77 * @method 83 * @method
78 */ 84 */
79 - public function status(Request $request,NewsCategoryLogic $newsCategoryLogic){  
80 - $request->validate([ 85 + public function status(NewsCategoryLogic $newsCategoryLogic){
  86 + $this->request->validate([
81 'id'=>['required'], 87 'id'=>['required'],
82 ],[ 88 ],[
83 'id.required' => 'ID不能为空', 89 'id.required' => 'ID不能为空',
@@ -92,11 +98,12 @@ class NewsCategoryController extends BaseController @@ -92,11 +98,12 @@ class NewsCategoryController extends BaseController
92 * @author :liyuhang 98 * @author :liyuhang
93 * @method 99 * @method
94 */ 100 */
95 - public function del(Request $request,NewsCategoryLogic $newsCategoryLogic){  
96 - $request->validate([  
97 - 'id'=>['required'], 101 + public function del(NewsCategoryLogic $newsCategoryLogic){
  102 + $this->request->validate([
  103 + 'id'=>['required','array'],
98 ],[ 104 ],[
99 'id.required' => 'ID不能为空', 105 'id.required' => 'ID不能为空',
  106 + 'id.array' => 'ID为数组',
100 ]); 107 ]);
101 $newsCategoryLogic->del_news_category(); 108 $newsCategoryLogic->del_news_category();
102 $this->response('success'); 109 $this->response('success');
@@ -3,11 +3,12 @@ @@ -3,11 +3,12 @@
3 namespace App\Http\Controllers\Bside\News; 3 namespace App\Http\Controllers\Bside\News;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\Common;
6 use App\Http\Controllers\Bside\BaseController; 7 use App\Http\Controllers\Bside\BaseController;
  8 +use App\Http\Logic\Bside\News\NewsCategoryLogic;
7 use App\Http\Logic\Bside\News\NewsLogic; 9 use App\Http\Logic\Bside\News\NewsLogic;
8 use App\Http\Requests\Bside\News\NewsRequest; 10 use App\Http\Requests\Bside\News\NewsRequest;
9 use App\Models\News\News as NewsModel; 11 use App\Models\News\News as NewsModel;
10 -use App\Models\News\NewsCategory as NewsCategoryModel;  
11 use Illuminate\Http\Request; 12 use Illuminate\Http\Request;
12 13
13 /** 14 /**
@@ -21,20 +22,13 @@ class NewsController extends BaseController @@ -21,20 +22,13 @@ class NewsController extends BaseController
21 * @author :liyuhang 22 * @author :liyuhang
22 * @method 23 * @method
23 */ 24 */
24 - public function lists(NewsModel $news){ 25 + public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){
25 $this->map['project_id'] = $this->user['project_id']; 26 $this->map['project_id'] = $this->user['project_id'];
26 - $lists = $news->lists($this->map,$this->page,$this->row,$this->order); 27 + $lists = $news->lists($this->map,$this->page,$this->row,$this->order,
  28 + ['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']);
27 if(!empty($lists['list'])){ 29 if(!empty($lists['list'])){
28 foreach ($lists['list'] as $k => $v){ 30 foreach ($lists['list'] as $k => $v){
29 - $newsCategoryModel= new NewsCategoryModel();  
30 - //获取用户已读还是未读  
31 - $category_info = $newsCategoryModel->  
32 - list(['id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']);  
33 - $str = '';  
34 - foreach ($category_info as $v1){  
35 - $str .= $v1['name'].',';  
36 - }  
37 - $v['category_id'] = trim($str,','); 31 + $v = $newsCategoryLogic->get_category_name($v);
38 $lists['list'][$k] = $v; 32 $lists['list'][$k] = $v;
39 } 33 }
40 } 34 }
@@ -57,14 +51,13 @@ class NewsController extends BaseController @@ -57,14 +51,13 @@ class NewsController extends BaseController
57 * @author :liyuhang 51 * @author :liyuhang
58 * @method 52 * @method
59 */ 53 */
60 - public function info(Request $request,NewsLogic $newsLogic){  
61 - $request->validate([ 54 + public function info(NewsLogic $newsLogic){
  55 + $this->request->validate([
62 'id'=>['required'], 56 'id'=>['required'],
63 ],[ 57 ],[
64 'id.required' => 'ID不能为空', 58 'id.required' => 'ID不能为空',
65 ]); 59 ]);
66 $info = $newsLogic->news_info(); 60 $info = $newsLogic->news_info();
67 - //TODO::清空相关资源  
68 $this->response('success',Code::SUCCESS,$info); 61 $this->response('success',Code::SUCCESS,$info);
69 } 62 }
70 /** 63 /**
@@ -76,7 +69,6 @@ class NewsController extends BaseController @@ -76,7 +69,6 @@ class NewsController extends BaseController
76 public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ 69 public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){
77 $newsRequest->validated(); 70 $newsRequest->validated();
78 $newsLogic->news_add(); 71 $newsLogic->news_add();
79 - //TODO::写入日志  
80 $this->response('success'); 72 $this->response('success');
81 } 73 }
82 74
@@ -93,62 +85,63 @@ class NewsController extends BaseController @@ -93,62 +85,63 @@ class NewsController extends BaseController
93 'id.required' => 'ID不能为空', 85 'id.required' => 'ID不能为空',
94 ]); 86 ]);
95 $newsLogic->news_edit(); 87 $newsLogic->news_edit();
96 - //TODO::写入日志  
97 - $this->response('success',Code::SUCCESS); 88 + $this->response('success');
98 } 89 }
99 90
100 /** 91 /**
101 - * @name :编辑状态/与排序 92 + * @name :编辑新闻seo
102 * @return void 93 * @return void
103 * @author :liyuhang 94 * @author :liyuhang
104 * @method 95 * @method
105 */ 96 */
106 - public function status(Request $request,NewsLogic $newsLogic){  
107 - $request->validate([ 97 + public function edit_seo(NewsLogic $newsLogic){
  98 + $this->request->validate([
108 'id'=>['required'], 99 'id'=>['required'],
  100 + 'seo_title'=>['required'],
  101 + 'seo_description'=>['required'],
  102 + 'seo_keywords'=>['required'],
109 ],[ 103 ],[
110 'id.required' => 'ID不能为空', 104 'id.required' => 'ID不能为空',
  105 + 'seo_title.required' => 'seo_title不能为空',
  106 + 'seo_description.required' => 'seo_description不能为空',
  107 + 'seo_keywords.required' => 'seo_description不能为空',
111 ]); 108 ]);
112 - $newsLogic->news_status();  
113 - //TODO::写入日志 109 + $newsLogic->edit_seo();
114 $this->response('success'); 110 $this->response('success');
115 } 111 }
  112 +
116 /** 113 /**
117 - * @name :删除新闻(逻辑删除) 114 + * @name :编辑状态/与排序
118 * @return void 115 * @return void
119 * @author :liyuhang 116 * @author :liyuhang
120 * @method 117 * @method
121 */ 118 */
122 - public function del(Request $request,NewsLogic $newsLogic){  
123 - $request->validate([ 119 + public function status(NewsLogic $newsLogic){
  120 + $this->request->validate([
124 'id'=>['required'], 121 'id'=>['required'],
125 ],[ 122 ],[
126 'id.required' => 'ID不能为空', 123 'id.required' => 'ID不能为空',
127 ]); 124 ]);
128 - $newsLogic->news_del();  
129 - //TODO::清空相关资源/写入日志 125 + $newsLogic->news_status();
  126 + //TODO::写入日志
130 $this->response('success'); 127 $this->response('success');
131 } 128 }
132 -  
133 /** 129 /**
134 - * @name :ai生成 130 + * @name :删除新闻(逻辑删除)
135 * @return void 131 * @return void
136 * @author :liyuhang 132 * @author :liyuhang
137 * @method 133 * @method
138 */ 134 */
139 - public function ai_news(Request $request){  
140 - # id, key, scene, ai  
141 - $request->validate([  
142 - 'keywords'=>['required'],  
143 - 'key'=>['required'] 135 + public function del(NewsLogic $newsLogic){
  136 + $this->request->validate([
  137 + 'id'=>['required','array'],
144 ],[ 138 ],[
145 - 'keywords.required' => '关键字不能为空',  
146 - 'key.required' => '场景不能为空', 139 + 'id.required' => 'ID不能为空',
  140 + 'id.array' => 'ID为数组',
147 ]); 141 ]);
148 - #TODO 通过key获取到ai指令对象  
149 - $url = 'v2/openai_chat';  
150 - $data = $this->send_openai_msg($url);  
151 - $this->response('success',Code::SUCCESS,$data); 142 + $newsLogic->news_del();
  143 + //TODO::清空相关资源/写入日志
  144 + $this->response('success');
152 } 145 }
153 146
154 } 147 }
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bside\Product; @@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bside\Product;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\Product\AttrLogic; 7 use App\Http\Logic\Bside\Product\AttrLogic;
8 -use App\Http\Requests\Bside\product\AttrRequest; 8 +use App\Http\Requests\Bside\Product\AttrRequest;
9 use App\Rules\Ids; 9 use App\Rules\Ids;
10 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
11 11
@@ -25,7 +25,7 @@ class AttrController extends BaseController @@ -25,7 +25,7 @@ class AttrController extends BaseController
25 $map[] = ['title', 'like', "%{$this->param['search']}%"]; 25 $map[] = ['title', 'like', "%{$this->param['search']}%"];
26 } 26 }
27 $sort = ['id' => 'desc']; 27 $sort = ['id' => 'desc'];
28 - $data = $logic->getList($map, $sort, ['id', 'title', 'remark', 'value_num']); 28 + $data = $logic->getList($map, $sort, ['id', 'title', 'attrs']);
29 return $this->success($data); 29 return $this->success($data);
30 } 30 }
31 31
@@ -36,7 +36,7 @@ class AttrController extends BaseController @@ -36,7 +36,7 @@ class AttrController extends BaseController
36 'id.required' => 'ID不能为空' 36 'id.required' => 'ID不能为空'
37 ]); 37 ]);
38 $data = $logic->getInfo($this->param['id']); 38 $data = $logic->getInfo($this->param['id']);
39 - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'remark', 'values'])); 39 + return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'attrs']));
40 } 40 }
41 41
42 public function save(AttrRequest $request, AttrLogic $logic) 42 public function save(AttrRequest $request, AttrLogic $logic)
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bside\Product; @@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bside\Product;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\Product\CategoryLogic; 7 use App\Http\Logic\Bside\Product\CategoryLogic;
8 -use App\Http\Requests\Bside\product\CategoryRequest; 8 +use App\Http\Requests\Bside\Product\CategoryRequest;
9 use App\Rules\Ids; 9 use App\Rules\Ids;
10 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
11 11
@@ -26,7 +26,13 @@ class CategoryController extends BaseController @@ -26,7 +26,13 @@ class CategoryController extends BaseController
26 } 26 }
27 $sort = ['id' => 'desc']; 27 $sort = ['id' => 'desc'];
28 $data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); 28 $data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0);
29 - return $this->success(Arr::listToTree($data)); 29 + foreach ($data as &$v){
  30 + $v['product_num'] = $logic->getProductNum($v['id']);
  31 + }
  32 + if(!$map){
  33 + $data = Arr::listToTree($data);
  34 + }
  35 + return $this->success($data);
30 } 36 }
31 37
32 public function info(Request $request, CategoryLogic $logic){ 38 public function info(Request $request, CategoryLogic $logic){
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bside\Product; @@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bside\Product;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\Product\DescribeLogic; 7 use App\Http\Logic\Bside\Product\DescribeLogic;
8 -use App\Http\Requests\Bside\product\DescribeRequest; 8 +use App\Http\Requests\Bside\Product\DescribeRequest;
9 use App\Rules\Ids; 9 use App\Rules\Ids;
10 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
11 11
@@ -25,7 +25,7 @@ class DescribeController extends BaseController @@ -25,7 +25,7 @@ class DescribeController extends BaseController
25 $map[] = ['title', 'like', "%{$this->param['search']}%"]; 25 $map[] = ['title', 'like', "%{$this->param['search']}%"];
26 } 26 }
27 $sort = ['id' => 'desc']; 27 $sort = ['id' => 'desc'];
28 - $data = $logic->getList($map, $sort, ['id', 'title', 'describe', 'status', 'created_at']); 28 + $data = $logic->getList($map, $sort, ['id', 'title', 'text', 'status', 'created_at']);
29 return $this->success($data); 29 return $this->success($data);
30 } 30 }
31 31
@@ -36,7 +36,7 @@ class DescribeController extends BaseController @@ -36,7 +36,7 @@ class DescribeController extends BaseController
36 'id.required' => 'ID不能为空' 36 'id.required' => 'ID不能为空'
37 ]); 37 ]);
38 $data = $logic->getInfo($this->param['id']); 38 $data = $logic->getInfo($this->param['id']);
39 - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'describe', 'created_at'])); 39 + return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'text', 'created_at']));
40 } 40 }
41 41
42 public function save(DescribeRequest $request, DescribeLogic $logic) 42 public function save(DescribeRequest $request, DescribeLogic $logic)
@@ -5,7 +5,8 @@ namespace App\Http\Controllers\Bside\Product; @@ -5,7 +5,8 @@ namespace App\Http\Controllers\Bside\Product;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\Product\KeywordLogic; 7 use App\Http\Logic\Bside\Product\KeywordLogic;
8 -use App\Http\Requests\Bside\product\KeywordRequest; 8 +use App\Http\Requests\Bside\Product\KeywordRequest;
  9 +use App\Models\Project\Project;
9 use App\Rules\Ids; 10 use App\Rules\Ids;
10 use Illuminate\Http\Request; 11 use Illuminate\Http\Request;
11 12
@@ -25,7 +26,13 @@ class KeywordController extends BaseController @@ -25,7 +26,13 @@ class KeywordController extends BaseController
25 $map[] = ['title', 'like', "%{$this->param['search']}%"]; 26 $map[] = ['title', 'like', "%{$this->param['search']}%"];
26 } 27 }
27 $sort = ['id' => 'desc']; 28 $sort = ['id' => 'desc'];
28 - $data = $logic->getList($map, $sort, ['id', 'title', 'route', 'status', 'created_at']); 29 + $data = $logic->getList($map, $sort, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']);
  30 + foreach ($data['list'] as &$v){
  31 + $v['product_num'] = $logic->getProductNum($v['id']);
  32 + $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
  33 + //todo 获取域名 拼接链接
  34 + $v['url'] = $v['route'];
  35 + }
29 return $this->success($data); 36 return $this->success($data);
30 } 37 }
31 38
@@ -36,7 +43,7 @@ class KeywordController extends BaseController @@ -36,7 +43,7 @@ class KeywordController extends BaseController
36 'id.required' => 'ID不能为空' 43 'id.required' => 'ID不能为空'
37 ]); 44 ]);
38 $data = $logic->getInfo($this->param['id']); 45 $data = $logic->getInfo($this->param['id']);
39 - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'route', 'created_at'])); 46 + return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at']));
40 } 47 }
41 48
42 public function save(KeywordRequest $request, KeywordLogic $logic) 49 public function save(KeywordRequest $request, KeywordLogic $logic)
@@ -7,7 +7,9 @@ use App\Exceptions\BsideGlobalException; @@ -7,7 +7,9 @@ use App\Exceptions\BsideGlobalException;
7 use App\Helper\Arr; 7 use App\Helper\Arr;
8 use App\Http\Controllers\Bside\BaseController; 8 use App\Http\Controllers\Bside\BaseController;
9 use App\Http\Logic\Bside\Product\ProductLogic; 9 use App\Http\Logic\Bside\Product\ProductLogic;
10 -use App\Http\Requests\Bside\product\ProductRequest; 10 +use App\Http\Requests\Bside\Product\ProductRequest;
  11 +use App\Models\Product\CategoryRelated;
  12 +use App\Models\Product\KeywordRelated;
11 use App\Rules\Ids; 13 use App\Rules\Ids;
12 use Illuminate\Http\Request; 14 use Illuminate\Http\Request;
13 15
@@ -26,11 +28,22 @@ class ProductController extends BaseController @@ -26,11 +28,22 @@ class ProductController extends BaseController
26 if(!empty($this->param['search'])){ 28 if(!empty($this->param['search'])){
27 $map[] = ['title', 'like', "%{$this->param['search']}%"]; 29 $map[] = ['title', 'like', "%{$this->param['search']}%"];
28 } 30 }
29 - if(!empty($this->param['created_at'])){ 31 + if(!empty($this->param['created_at'][0]) && !empty($this->param['created_at'][1])){
30 $map[] = ['created_at', 'between', $this->param['created_at']]; 32 $map[] = ['created_at', 'between', $this->param['created_at']];
31 } 33 }
  34 + if(!empty($this->param['category_id'])){
  35 + $ids = CategoryRelated::where('cate_id', $this->param['category_id'])->pluck('product_id')->toArray();
  36 + $map[] = ['id', 'in', $ids];
  37 + }
  38 + if(!empty($this->param['keyword_id'])){
  39 + $ids = KeywordRelated::where('keyword_id', $this->param['keyword_id'])->pluck('product_id')->toArray();
  40 + $map[] = ['id', 'in', $ids];
  41 + }
  42 + if(isset($this->param['status'])){
  43 + $map[] = ['status', $this->param['status']];
  44 + }
32 $sort = ['id' => 'desc']; 45 $sort = ['id' => 'desc'];
33 - $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_at', 'updated_at']); 46 + $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']);
34 return $this->success($data); 47 return $this->success($data);
35 } 48 }
36 49
@@ -41,15 +54,12 @@ class ProductController extends BaseController @@ -41,15 +54,12 @@ class ProductController extends BaseController
41 'id.required' => 'ID不能为空' 54 'id.required' => 'ID不能为空'
42 ]); 55 ]);
43 $data = $logic->getInfo($this->param['id']); 56 $data = $logic->getInfo($this->param['id']);
44 - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content',  
45 - 'describe', 'seo_mate', 'related_product_id', 'status'])); 57 + return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content',
  58 + 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route']));
46 } 59 }
47 60
48 public function save(ProductRequest $request, ProductLogic $logic) 61 public function save(ProductRequest $request, ProductLogic $logic)
49 { 62 {
50 - //封面取第一个图片  
51 - $this->param['thumb'] = $this->param['gallery'][0] ?? '';  
52 -  
53 $data = $logic->save($this->param); 63 $data = $logic->save($this->param);
54 return $this->success($data); 64 return $this->success($data);
55 } 65 }
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Aside; 3 +namespace App\Http\Controllers\Bside\Project;
4 4
5 -class ProjectUserController extends BaseController 5 +use App\Http\Controllers\Bside\BaseController;
  6 +
  7 +class ProjectController extends BaseController
6 { 8 {
7 /** 9 /**
8 - * @name :用户列表  
9 - * @return void  
10 - * @author :liyuhang  
11 - * @method 10 + * @name :lists
  11 + * @author :lyh
  12 + * @method :post
  13 + * @time :2023/4/28 14:48
12 */ 14 */
13 public function lists(){ 15 public function lists(){
14 16
  1 +<?php
  2 +
  3 +
  4 +namespace App\Http\Controllers\Bside;
  5 +
  6 +
  7 +use App\Helper\Translate;
  8 +use App\Models\RouteMap;
  9 +use App\Rules\Ids;
  10 +use Illuminate\Http\Request;
  11 +
  12 +class RouteController extends BaseController
  13 +{
  14 +
  15 + /**
  16 + * 生成路由
  17 + * @param Request $request
  18 + * @return \Illuminate\Http\JsonResponse
  19 + * @author zbj
  20 + * @date 2023/5/5
  21 + */
  22 + public function create(Request $request){
  23 + $title = $request->input('title');
  24 + $source = $request->input('source');
  25 + $source_id = $request->input('source_id');
  26 + $project_id = $this->user['project_id'];
  27 +
  28 + $route = RouteMap::generateRoute($title, $source, $source_id, $project_id);
  29 + return $this->success(['route' => $route]);
  30 + }
  31 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\Setting;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\Setting\ProjectCountryLogic;
  8 +
  9 +/**
  10 + * @name:项目配置多语言设置
  11 + */
  12 +class ProjectCountryController extends BaseController
  13 +{
  14 + /**
  15 + * @name :(当前项目的多语言列表)lists
  16 + * @author :lyh
  17 + * @method :post
  18 + * @time :2023/4/28 14:49
  19 + */
  20 + public function info(ProjectCountryLogic $projectCountryLogic){
  21 + $lists = $projectCountryLogic->country_info();
  22 + $this->response('success',Code::SUCCESS,$lists);
  23 + }
  24 +
  25 + /**
  26 + * @name :(更新当前项目多语言设置)edit
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/4/28 17:53
  30 + */
  31 + public function edit(ProjectCountryLogic $projectCountryLogic){
  32 + $projectCountryLogic->country_edit();
  33 + $this->response('success');
  34 + }
  35 +}
1 <?php 1 <?php
2 2
3 -namespace App\Http\Controllers\Aside; 3 +namespace App\Http\Controllers\Bside\Setting;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 -  
8 -use App\Models\Project as ProjectModel; 7 +use App\Http\Logic\Bside\Setting\WebSettingLogic;
9 8
10 /** 9 /**
11 - * @name:项目信息 10 + * @name:项目首页设置
12 */ 11 */
13 -class ProjectController extends BaseController 12 +class WebSettingController extends BaseController
14 { 13 {
15 /** 14 /**
16 - * @name :项目列表 15 + * @name :首页设置
17 * @return void 16 * @return void
18 * @author :liyuhang 17 * @author :liyuhang
19 * @method 18 * @method
20 */ 19 */
21 - public function lists(){  
22 - $projectModel = new ProjectModel();  
23 - $lists = $projectModel->lists($this->map,$this->p,$this->row,$this->order);  
24 - $this->response('success',Code::SUCCESS,$lists); 20 + public function lists(WebSettingLogic $webSettingLogic){
  21 + $info = $webSettingLogic->setting_read();
  22 + $this->response('success',Code::SUCCESS,$info);
25 } 23 }
26 24
27 /** 25 /**
28 - * @name :添加项目  
29 - * @return void  
30 - * @author :liyuhang  
31 - * @method 26 + * @name :添加数据add
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/4/28 15:17
32 */ 30 */
33 - public function add(){  
34 - $projectModel = new ProjectModel(); 31 + public function save(WebSettingLogic $webSettingLogic){
  32 + $webSettingLogic->setting_save();
  33 + $this->response('success');
35 } 34 }
36 } 35 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\Setting;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\Setting\WebSettingCountryLogic;
  8 +use App\Models\Project\Country as CountryModel;
  9 +
  10 +/**
  11 + * @name:多语言国家配置列
  12 + */
  13 +class WebSettingCountryController extends BaseController
  14 +{
  15 + /**
  16 + * @name :列表lists
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2023/4/28 14:40
  20 + */
  21 + public function lists(WebSettingCountryLogic $webSettingCountryLogic){
  22 + $lists = $webSettingCountryLogic->country_list();
  23 + $this->response('success',Code::SUCCESS,$lists);
  24 + }
  25 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\Setting;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\Setting\WebSettingFromLogic;
  8 +
  9 +/**
  10 + * @name:表单设置
  11 + */
  12 +class WebSettingFromController extends BaseController
  13 +{
  14 + /**
  15 + * @name :(表单设置详情)info
  16 + * @author :lyh
  17 + * @method :post
  18 + * @time :2023/5/4 13:44
  19 + */
  20 + public function info(WebSettingFromLogic $webSettingFromLogic){
  21 + $info = $webSettingFromLogic->setting_from_info();
  22 + $this->response('success',Code::SUCCESS,$info);
  23 + }
  24 +
  25 + /**
  26 + * @name :(添加或编辑表单设置)lists
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/4/28 14:41
  30 + */
  31 + public function save(WebSettingFromLogic $webSettingFromLogic){
  32 + $webSettingFromLogic->setting_from_save();
  33 + $this->response('success');
  34 + }
  35 +}