Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
33 个修改的文件
包含
571 行增加
和
84 行删除
app/Exceptions/CsideGlobalException.php
0 → 100644
| 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 | +} |
| @@ -72,6 +72,10 @@ class Handler extends ExceptionHandler | @@ -72,6 +72,10 @@ class Handler extends ExceptionHandler | ||
| 72 | elseif($exception instanceof BsideGlobalException) { | 72 | elseif($exception instanceof BsideGlobalException) { |
| 73 | LogUtils::error("BsideGlobalException", [], $exceptionMessage); | 73 | LogUtils::error("BsideGlobalException", [], $exceptionMessage); |
| 74 | } | 74 | } |
| 75 | + //C端错误 | ||
| 76 | + elseif($exception instanceof CsideGlobalException) { | ||
| 77 | + LogUtils::error("CsideGlobalException", [], $exceptionMessage); | ||
| 78 | + } | ||
| 75 | //验证错误(非手动抛出) | 79 | //验证错误(非手动抛出) |
| 76 | elseif ($exception instanceof ValidationException) { | 80 | elseif ($exception instanceof ValidationException) { |
| 77 | LogUtils::error("参数验证失败", [], $exceptionMessage); | 81 | LogUtils::error("参数验证失败", [], $exceptionMessage); |
| @@ -110,6 +114,8 @@ class Handler extends ExceptionHandler | @@ -110,6 +114,8 @@ class Handler extends ExceptionHandler | ||
| 110 | $code = $exception->getCode(); | 114 | $code = $exception->getCode(); |
| 111 | }elseif ($exception instanceof BsideGlobalException) { | 115 | }elseif ($exception instanceof BsideGlobalException) { |
| 112 | $code = $exception->getCode(); | 116 | $code = $exception->getCode(); |
| 117 | + }elseif ($exception instanceof CsideGlobalException) { | ||
| 118 | + $code = $exception->getCode(); | ||
| 113 | } elseif ($exception instanceof ValidationException) { | 119 | } elseif ($exception instanceof ValidationException) { |
| 114 | $code = Code::USER_PARAMS_ERROE(); | 120 | $code = Code::USER_PARAMS_ERROE(); |
| 115 | $message = $code->description = Arr::first(Arr::first($exception->errors())); | 121 | $message = $code->description = Arr::first(Arr::first($exception->errors())); |
app/Helper/AyrShare.php
0 → 100644
| 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/api'; | ||
| 13 | + //api_key | ||
| 14 | + public $api_key = 'G8GQW3X-XBTMGXW-QPDDZ9A-WE1Z5SB'; | ||
| 15 | + //系统设置 | ||
| 16 | + public $config = [ | ||
| 17 | + | ||
| 18 | + ]; | ||
| 19 | + //profile_key | ||
| 20 | + public $profile_key = "-----BEGIN RSA PRIVATE KEY----- | ||
| 21 | + MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq | ||
| 22 | + 9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi | ||
| 23 | + h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC | ||
| 24 | + gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc | ||
| 25 | + Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa | ||
| 26 | + uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG | ||
| 27 | + DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa | ||
| 28 | + 52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT | ||
| 29 | + CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J | ||
| 30 | + EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU | ||
| 31 | + yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe | ||
| 32 | + yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j | ||
| 33 | + zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 34 | + -----END RSA PRIVATE KEY-----"; | ||
| 35 | + //设置请求头 | ||
| 36 | + public $headers = [ | ||
| 37 | + 'Authorization' => 'Bearer ', | ||
| 38 | + 'Content-Type' => 'application/json', | ||
| 39 | +// 'Accept-Encoding' => 'deflate, gzip', | ||
| 40 | + ]; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * @name :参数构建 | ||
| 44 | + */ | ||
| 45 | + public function __construct() | ||
| 46 | + { | ||
| 47 | + $this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * @name :获取过去30天发布的历史记录(1-30) | ||
| 52 | + * @author :lyh | ||
| 53 | + * @method :get | ||
| 54 | + * @time :2023/5/5 10:00 | ||
| 55 | + */ | ||
| 56 | + public function get_analytics_links($to_day){ | ||
| 57 | + $last_days = (string)$to_day; | ||
| 58 | + $url = $this->path.'/analytics/links?lastDays='.$last_days; | ||
| 59 | + return $this->http_click('get',$url); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * @name :(通过 Ayrshare 获取给定帖子的实时分析,例如点赞、印象、转推等)post_analytics | ||
| 64 | + * @author :lyh | ||
| 65 | + * @method :post | ||
| 66 | + * @time :2023/5/5 11:56 | ||
| 67 | + */ | ||
| 68 | + public function post_analytics($id){ | ||
| 69 | + $param = [ | ||
| 70 | + 'id'=>$id, | ||
| 71 | + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'], | ||
| 72 | + ]; | ||
| 73 | + $url = $this->path.'/api/analytics/post'; | ||
| 74 | + return $this->http_click('post', $url, $param); | ||
| 75 | + } | ||
| 76 | + /** | ||
| 77 | + * @name :(获取特定用户个人资料)analytics_post | ||
| 78 | + * @author :lyh | ||
| 79 | + * @method :post | ||
| 80 | + * @time :2023/5/5 10:43 | ||
| 81 | + */ | ||
| 82 | + public function post_analytics_social(){ | ||
| 83 | + $post_data = [ | ||
| 84 | + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'], | ||
| 85 | + ]; | ||
| 86 | + $url = $this->path.'/api/analytics/social'; | ||
| 87 | + return $this->http_click('post',$url,$post_data); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * @name :(设置自动计划)post_schedule_set | ||
| 92 | + * @author :lyh | ||
| 93 | + * @method :post | ||
| 94 | + * @time :2023/5/5 13:58 | ||
| 95 | + */ | ||
| 96 | + public function post_schedule_set($data){ | ||
| 97 | + $param = [ | ||
| 98 | + 'schedule'=>["13:05Z", "20:14Z"], | ||
| 99 | + 'title'=>$data['title'], | ||
| 100 | + ]; | ||
| 101 | + $url = $this->path.'/api/auto-schedule/set'; | ||
| 102 | + return $this->http_click('post',$url,$param); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * @name :(删除自动计划)delete_schedule | ||
| 107 | + * @author :lyh | ||
| 108 | + * @method :post | ||
| 109 | + * @time :2023/5/5 14:04 | ||
| 110 | + */ | ||
| 111 | + public function delete_schedule($data){ | ||
| 112 | + $param = [ | ||
| 113 | + 'title'=>$data['title'], | ||
| 114 | + ]; | ||
| 115 | + $url = $this->path.'/api/auto-schedule/delete'; | ||
| 116 | + return $this->http_click('delete',$url,$param); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * @name :(列出自动计划)get_schedule_list | ||
| 121 | + * @author :lyh | ||
| 122 | + * @method :post | ||
| 123 | + * @time :2023/5/5 14:08 | ||
| 124 | + */ | ||
| 125 | + public function get_schedule_list(){ | ||
| 126 | + $url = $this->path.'/api/auto-schedule/list'; | ||
| 127 | + return $this->http_click('get',$url); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + /** | ||
| 131 | + * @name :(发布到用户个人资料)post_user | ||
| 132 | + * @author :lyh | ||
| 133 | + * @method :post | ||
| 134 | + * @time :2023/5/5 15:00 | ||
| 135 | + */ | ||
| 136 | + public function post_user($data){ | ||
| 137 | + $param = [ | ||
| 138 | + 'post'=>$data['post'], | ||
| 139 | + 'platforms'=>$data['platforms'], | ||
| 140 | + 'profileKey'=>$this->profile_key, | ||
| 141 | + 'mediaUrls'=>$data['mediaUrls'] | ||
| 142 | + ]; | ||
| 143 | + $url = $this->path.'/api/post'; | ||
| 144 | + return $this->http_click('post',$url,$param); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + /** | ||
| 148 | + * @name :(创建子账户相关操作)post_create_profiles | ||
| 149 | + * @author :lyh | ||
| 150 | + * @method :post | ||
| 151 | + * @time :2023/5/5 15:16 | ||
| 152 | + */ | ||
| 153 | + public function post_create_profiles($data){ | ||
| 154 | + $param = [ | ||
| 155 | + 'title'=>$data['title'], | ||
| 156 | + ]; | ||
| 157 | + $url = $this->path.'/profiles/profile'; | ||
| 158 | + return $this->http_click('post',$url,$param); | ||
| 159 | + } | ||
| 160 | + /** | ||
| 161 | + * @name :(删除子账户相关操作)post_create_profiles | ||
| 162 | + * @author :lyh | ||
| 163 | + * @method :post | ||
| 164 | + * @time :2023/5/5 15:16 | ||
| 165 | + */ | ||
| 166 | + public function deleted_create_profiles($data){ | ||
| 167 | + $param = [ | ||
| 168 | + 'title'=>$data['title'], | ||
| 169 | + 'profileKey'=>$this->profile_key, | ||
| 170 | + ]; | ||
| 171 | + $url = $this->path.'/profiles/profile'; | ||
| 172 | + return $this->http_click('delete',$url,$param); | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + public function put_update_profiles($data){ | ||
| 176 | + $param = [ | ||
| 177 | + 'title'=>$data['title'], | ||
| 178 | + 'profileKey'=>$this->profile_key, | ||
| 179 | + ]; | ||
| 180 | + $url = $this->path.'/profiles/profile'; | ||
| 181 | + return $this->http_click('put',$url,$param); | ||
| 182 | + } | ||
| 183 | + /** | ||
| 184 | + * @name :(获取有关用户社交资料的分析和人口统计,例如印象,视图和关注着)post_social | ||
| 185 | + * @author :lyh | ||
| 186 | + * @method :post | ||
| 187 | + * @time :2023/5/5 10:37 | ||
| 188 | + */ | ||
| 189 | + public function api_user(){ | ||
| 190 | + $post_data = [ | ||
| 191 | + 'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'], | ||
| 192 | + ]; | ||
| 193 | + $url = $this->path.'/api/user'; | ||
| 194 | + return $this->http_click('post',$url,$post_data); | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * 发送http post,get,put,delete请求 | ||
| 200 | + * @param type $url | ||
| 201 | + * @param type $post_data | ||
| 202 | + */ | ||
| 203 | + function http_click($method = 'post',$url, $param = [],$header = []) | ||
| 204 | + { | ||
| 205 | + if(!empty($param)){ | ||
| 206 | + $post_data['json'] = $param; | ||
| 207 | + } | ||
| 208 | + $post_data['headers'] = !empty($header) ? $header : $this->headers; | ||
| 209 | + $client = new Client(); | ||
| 210 | + try { | ||
| 211 | + $res = $client->request(strtoupper($method), $url, $post_data)->getBody()->getContents(); | ||
| 212 | + return $res; | ||
| 213 | + } catch (\Exception $e) { | ||
| 214 | + return json_encode(["status"=>"fail","message"=>$e->getMessage()]); | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | +} |
| @@ -7,6 +7,9 @@ use App\Models\User\UserLog as UserLogModel; | @@ -7,6 +7,9 @@ use App\Models\User\UserLog as UserLogModel; | ||
| 7 | use App\Models\User\UserLogin as UserLoginModel; | 7 | use App\Models\User\UserLogin as UserLoginModel; |
| 8 | use Illuminate\Support\Facades\Cache; | 8 | use Illuminate\Support\Facades\Cache; |
| 9 | 9 | ||
| 10 | +/** | ||
| 11 | + * @name: | ||
| 12 | + */ | ||
| 10 | class Common | 13 | class Common |
| 11 | { | 14 | { |
| 12 | /** | 15 | /** |
| @@ -4,6 +4,9 @@ namespace App\Helper; | @@ -4,6 +4,9 @@ namespace App\Helper; | ||
| 4 | 4 | ||
| 5 | use App\Models\WebSetting\WebSettingCountry; | 5 | use App\Models\WebSetting\WebSettingCountry; |
| 6 | 6 | ||
| 7 | +/** | ||
| 8 | + * @name:多语言国家设置 | ||
| 9 | + */ | ||
| 7 | class Country | 10 | class Country |
| 8 | { | 11 | { |
| 9 | public $tls_list = [ | 12 | public $tls_list = [ |
| @@ -681,6 +684,6 @@ class Country | @@ -681,6 +684,6 @@ class Country | ||
| 681 | } | 684 | } |
| 682 | $webCountry = new WebSettingCountry(); | 685 | $webCountry = new WebSettingCountry(); |
| 683 | $webCountry->insert($data); | 686 | $webCountry->insert($data); |
| 684 | - return; | 687 | + return true; |
| 685 | } | 688 | } |
| 686 | } | 689 | } |
| @@ -37,12 +37,14 @@ if(!function_exists('http_post')){ | @@ -37,12 +37,14 @@ if(!function_exists('http_post')){ | ||
| 37 | * @param type $url | 37 | * @param type $url |
| 38 | * @param type $post_data | 38 | * @param type $post_data |
| 39 | */ | 39 | */ |
| 40 | - function http_post($url, $post_data) | 40 | + function http_post($url, $post_data,$header = []) |
| 41 | { | 41 | { |
| 42 | - $header = array( | ||
| 43 | - "Accept: application/json", | ||
| 44 | - "Content-Type:application/json;charset=utf-8", | ||
| 45 | - ); | 42 | + if(empty($header)){ |
| 43 | + $header = array( | ||
| 44 | + "Accept: application/json", | ||
| 45 | + "Content-Type:application/json;charset=utf-8", | ||
| 46 | + ); | ||
| 47 | + } | ||
| 46 | $ch = curl_init(); | 48 | $ch = curl_init(); |
| 47 | curl_setopt($ch, CURLOPT_URL, $url); | 49 | curl_setopt($ch, CURLOPT_URL, $url); |
| 48 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | 50 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
| @@ -69,10 +71,12 @@ if(!function_exists('http_get')){ | @@ -69,10 +71,12 @@ if(!function_exists('http_get')){ | ||
| 69 | * @param type $url | 71 | * @param type $url |
| 70 | * @return type | 72 | * @return type |
| 71 | */ | 73 | */ |
| 72 | - function http_get($url) | 74 | + function http_get($url,$header = []) |
| 73 | { | 75 | { |
| 74 | - $header[] = "content-type: application/x-www-form-urlencoded; | 76 | + if(empty($header)){ |
| 77 | + $header[] = "content-type: application/json; | ||
| 75 | charset = UTF-8"; | 78 | charset = UTF-8"; |
| 79 | + } | ||
| 76 | $ch1 = curl_init(); | 80 | $ch1 = curl_init(); |
| 77 | $timeout = 5; | 81 | $timeout = 5; |
| 78 | curl_setopt($ch1, CURLOPT_URL, $url); | 82 | curl_setopt($ch1, CURLOPT_URL, $url); |
| @@ -39,12 +39,6 @@ class InquiryController extends BaseController | @@ -39,12 +39,6 @@ class InquiryController extends BaseController | ||
| 39 | return $this->success(Arr::twoKeepKeys($data, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'content', 'trans_content', 'created_at'])); | 39 | return $this->success(Arr::twoKeepKeys($data, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'content', 'trans_content', 'created_at'])); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - public function save(InquiryRequest $request, InquiryLogic $logic) | ||
| 43 | - { | ||
| 44 | - $data = $logic->save($this->param); | ||
| 45 | - return $this->success($data); | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | public function delete(Request $request, InquiryLogic $logic) | 42 | public function delete(Request $request, InquiryLogic $logic) |
| 49 | { | 43 | { |
| 50 | $request->validate([ | 44 | $request->validate([ |
| @@ -25,7 +25,7 @@ class NewsController extends BaseController | @@ -25,7 +25,7 @@ class NewsController extends BaseController | ||
| 25 | public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){ | 25 | public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){ |
| 26 | $this->map['project_id'] = $this->user['project_id']; | 26 | $this->map['project_id'] = $this->user['project_id']; |
| 27 | $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','name','sort','url']); | 28 | + ['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']); |
| 29 | if(!empty($lists['list'])){ | 29 | if(!empty($lists['list'])){ |
| 30 | foreach ($lists['list'] as $k => $v){ | 30 | foreach ($lists['list'] as $k => $v){ |
| 31 | $v = $newsCategoryLogic->get_category_name($v); | 31 | $v = $newsCategoryLogic->get_category_name($v); |
| @@ -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) |
| @@ -43,7 +43,7 @@ class ProductController extends BaseController | @@ -43,7 +43,7 @@ class ProductController extends BaseController | ||
| 43 | $map[] = ['status', $this->param['status']]; | 43 | $map[] = ['status', $this->param['status']]; |
| 44 | } | 44 | } |
| 45 | $sort = ['id' => 'desc']; | 45 | $sort = ['id' => 'desc']; |
| 46 | - $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keywords', 'status', 'created_uid', 'created_at', 'updated_at']); | 46 | + $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']); |
| 47 | return $this->success($data); | 47 | return $this->success($data); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| @@ -54,8 +54,8 @@ class ProductController extends BaseController | @@ -54,8 +54,8 @@ class ProductController extends BaseController | ||
| 54 | 'id.required' => 'ID不能为空' | 54 | 'id.required' => 'ID不能为空' |
| 55 | ]); | 55 | ]); |
| 56 | $data = $logic->getInfo($this->param['id']); | 56 | $data = $logic->getInfo($this->param['id']); |
| 57 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keywords', 'intro', 'content', | ||
| 58 | - 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'status_text', 'created_uid', 'created_uid_text'])); | 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'])); | ||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | public function save(ProductRequest $request, ProductLogic $logic) | 61 | public function save(ProductRequest $request, ProductLogic $logic) |
| @@ -6,8 +6,6 @@ use App\Enums\Common\Code; | @@ -6,8 +6,6 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Models\Image as ImageModel; | 6 | use App\Models\Image as ImageModel; |
| 7 | use Illuminate\Http\Exceptions\HttpResponseException; | 7 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 8 | use Illuminate\Http\JsonResponse; | 8 | use Illuminate\Http\JsonResponse; |
| 9 | -use Illuminate\Http\Request; | ||
| 10 | -use Illuminate\Support\Facades\DB; | ||
| 11 | use Illuminate\Support\Facades\Storage; | 9 | use Illuminate\Support\Facades\Storage; |
| 12 | use Intervention\Image\Facades\Image; | 10 | use Intervention\Image\Facades\Image; |
| 13 | 11 | ||
| @@ -32,9 +30,9 @@ class ImageController | @@ -32,9 +30,9 @@ class ImageController | ||
| 32 | 30 | ||
| 33 | public $request = ''; | 31 | public $request = ''; |
| 34 | 32 | ||
| 35 | - public function __construct(Request $request) | 33 | + public function __construct() |
| 36 | { | 34 | { |
| 37 | - $this->request = $request; | 35 | + $this->request = request(); |
| 38 | $this->config = config('filesystems.disks.upload'); | 36 | $this->config = config('filesystems.disks.upload'); |
| 39 | $this->path = $this->config['root']; | 37 | $this->path = $this->config['root']; |
| 40 | } | 38 | } |
| @@ -11,6 +11,7 @@ use App\Http\Middleware\Bside\EnableCrossRequestMiddleware; | @@ -11,6 +11,7 @@ use App\Http\Middleware\Bside\EnableCrossRequestMiddleware; | ||
| 11 | use App\Http\Middleware\Bside\ParamMiddleware as BsideParamMiddleware; | 11 | use App\Http\Middleware\Bside\ParamMiddleware as BsideParamMiddleware; |
| 12 | use App\Http\Middleware\Aside\LoginAuthMiddleware as AsideLoginAuthMiddleware; | 12 | use App\Http\Middleware\Aside\LoginAuthMiddleware as AsideLoginAuthMiddleware; |
| 13 | use App\Http\Middleware\Bside\LoginAuthMiddleware as BsideLoginAuthMiddleware; | 13 | use App\Http\Middleware\Bside\LoginAuthMiddleware as BsideLoginAuthMiddleware; |
| 14 | +use App\Http\Middleware\Cside\ParamMiddleware as CsideParamMiddleware; | ||
| 14 | use App\Http\Middleware\PreventRepeatQuitCallMiddleware; | 15 | use App\Http\Middleware\PreventRepeatQuitCallMiddleware; |
| 15 | use Illuminate\Foundation\Http\Kernel as HttpKernel; | 16 | use Illuminate\Foundation\Http\Kernel as HttpKernel; |
| 16 | 17 | ||
| @@ -75,6 +76,11 @@ class Kernel extends HttpKernel | @@ -75,6 +76,11 @@ class Kernel extends HttpKernel | ||
| 75 | PreventRepeatQuitCallMiddleware::class, | 76 | PreventRepeatQuitCallMiddleware::class, |
| 76 | //允许跨域请求 | 77 | //允许跨域请求 |
| 77 | EnableCrossRequestMiddleware::class | 78 | EnableCrossRequestMiddleware::class |
| 79 | + ], | ||
| 80 | + //C端中间件组 | ||
| 81 | + 'cside'=>[ | ||
| 82 | + //参数处理中间件--涉及-参数记录-参数加解密等 | ||
| 83 | + CsideParamMiddleware::class, | ||
| 78 | ] | 84 | ] |
| 79 | ]; | 85 | ]; |
| 80 | 86 |
| @@ -2,13 +2,11 @@ | @@ -2,13 +2,11 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside; | 3 | namespace App\Http\Logic\Bside; |
| 4 | 4 | ||
| 5 | -use App\Enums\Common\Code; | 5 | + |
| 6 | +use App\Enums\Common\Common; | ||
| 6 | use App\Exceptions\BsideGlobalException; | 7 | use App\Exceptions\BsideGlobalException; |
| 7 | -use App\Helper\Common; | ||
| 8 | use App\Http\Controllers\ImageController; | 8 | use App\Http\Controllers\ImageController; |
| 9 | use App\Http\Logic\Logic; | 9 | use App\Http\Logic\Logic; |
| 10 | -use App\Models\Image as ImageModel; | ||
| 11 | -use Illuminate\Http\Request; | ||
| 12 | use Illuminate\Support\Facades\Cache; | 10 | use Illuminate\Support\Facades\Cache; |
| 13 | 11 | ||
| 14 | /** | 12 | /** |
| @@ -25,6 +23,8 @@ class BaseLogic extends Logic | @@ -25,6 +23,8 @@ class BaseLogic extends Logic | ||
| 25 | 23 | ||
| 26 | protected $user; | 24 | protected $user; |
| 27 | 25 | ||
| 26 | + protected $side = Common::B; | ||
| 27 | + | ||
| 28 | public function __construct() | 28 | public function __construct() |
| 29 | { | 29 | { |
| 30 | $this->request = request(); | 30 | $this->request = request(); |
| @@ -32,15 +32,4 @@ class InquiryLogic extends BaseLogic | @@ -32,15 +32,4 @@ class InquiryLogic extends BaseLogic | ||
| 32 | } | 32 | } |
| 33 | return $this->success($info->toArray()); | 33 | return $this->success($info->toArray()); |
| 34 | } | 34 | } |
| 35 | - | ||
| 36 | - | ||
| 37 | - public function save($param) | ||
| 38 | - { | ||
| 39 | - //todo 根据域名 判断 project_id | ||
| 40 | - $param['ip_info'] = Arr::s2a($param['ip_info']); | ||
| 41 | - $param['ip'] = $param['ip_info']['ip'] ?? ''; | ||
| 42 | - $param['ip_country'] = $param['ip_info']['country'] ?? ''; | ||
| 43 | - Logic::save($param); | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | } | 35 | } |
| @@ -60,19 +60,19 @@ class NewsLogic extends BaseLogic | @@ -60,19 +60,19 @@ class NewsLogic extends BaseLogic | ||
| 60 | $this->param['project_id'] = $this->user['project_id']; | 60 | $this->param['project_id'] = $this->user['project_id']; |
| 61 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); | 61 | $this->param['created_at'] = date('Y-m-d H:i:s',time()); |
| 62 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); | 62 | $this->param['updated_at'] = date('Y-m-d H:i:s',time()); |
| 63 | - DB::beginTransaction(); | ||
| 64 | - try { | 63 | +// DB::beginTransaction(); |
| 64 | +// try { | ||
| 65 | if(isset($this->param['image'])){ | 65 | if(isset($this->param['image'])){ |
| 66 | $data = $this->upload(); | 66 | $data = $this->upload(); |
| 67 | $this->param['image'] = $data; | 67 | $this->param['image'] = $data; |
| 68 | } | 68 | } |
| 69 | $rs = $this->model->insertGetId($this->param); | 69 | $rs = $this->model->insertGetId($this->param); |
| 70 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | 70 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); |
| 71 | - DB::commit(); | ||
| 72 | - }catch (\Exception $e){ | ||
| 73 | - DB::rollBack(); | ||
| 74 | - $this->fail('添加失败'); | ||
| 75 | - } | 71 | +// DB::commit(); |
| 72 | +// }catch (\Exception $e){ | ||
| 73 | +// DB::rollBack(); | ||
| 74 | +// $this->fail('添加失败'); | ||
| 75 | +// } | ||
| 76 | return $this->success(); | 76 | return $this->success(); |
| 77 | } | 77 | } |
| 78 | 78 |
| @@ -30,12 +30,7 @@ class ProductLogic extends BaseLogic | @@ -30,12 +30,7 @@ class ProductLogic extends BaseLogic | ||
| 30 | { | 30 | { |
| 31 | $data = parent::getList($map, $sort, $columns, $limit); | 31 | $data = parent::getList($map, $sort, $columns, $limit); |
| 32 | foreach ($data['list'] as &$v){ | 32 | foreach ($data['list'] as &$v){ |
| 33 | - foreach ($v['category_id'] as $category_id){ | ||
| 34 | - $v['category_id_text'][] =(new CategoryLogic())->getCacheInfo($category_id)['title']??''; | ||
| 35 | - } | ||
| 36 | - $v['category_id_text'] = Arr::arrToSet($v['category_id_text'], 'trim'); | ||
| 37 | - $v['status_text'] = Product::statusMap()[$v['status']] ?? ''; | ||
| 38 | - $v['created_uid_text'] = (new UserLogic())->getCacheInfo($v['created_uid'])['name'] ?? ''; | 33 | + $v = $this->formatData($v); |
| 39 | } | 34 | } |
| 40 | return $this->success($data); | 35 | return $this->success($data); |
| 41 | } | 36 | } |
| @@ -43,13 +38,22 @@ class ProductLogic extends BaseLogic | @@ -43,13 +38,22 @@ class ProductLogic extends BaseLogic | ||
| 43 | public function getInfo($id) | 38 | public function getInfo($id) |
| 44 | { | 39 | { |
| 45 | $info = parent::getInfo($id); | 40 | $info = parent::getInfo($id); |
| 41 | + $info = $this->formatData($info); | ||
| 42 | + return $this->success($info); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public function formatData($info){ | ||
| 46 | foreach ($info['category_id'] as $category_id) { | 46 | foreach ($info['category_id'] as $category_id) { |
| 47 | $info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? ''; | 47 | $info['category_id_text'][] = (new CategoryLogic())->getCacheInfo($category_id)['title'] ?? ''; |
| 48 | } | 48 | } |
| 49 | + foreach ($info['keyword_id'] as $keyword_id){ | ||
| 50 | + $info['keyword_id_text'][] =(new KeywordLogic())->getCacheInfo($keyword_id)['title']??''; | ||
| 51 | + } | ||
| 49 | $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim'); | 52 | $info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim'); |
| 53 | + $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim'); | ||
| 50 | $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; | 54 | $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; |
| 51 | $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? ''; | 55 | $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? ''; |
| 52 | - return $this->success($info); | 56 | + return $info; |
| 53 | } | 57 | } |
| 54 | 58 | ||
| 55 | public function save($param){ | 59 | public function save($param){ |
app/Http/Logic/Cside/BaseLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Cside; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Enums\Common\Common; | ||
| 7 | +use App\Exceptions\BsideGlobalException; | ||
| 8 | +use App\Http\Logic\Logic; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 | ||
| 12 | + */ | ||
| 13 | +class BaseLogic extends Logic | ||
| 14 | +{ | ||
| 15 | + | ||
| 16 | + protected $requestAll; | ||
| 17 | + | ||
| 18 | + protected $param; | ||
| 19 | + | ||
| 20 | + protected $request; | ||
| 21 | + | ||
| 22 | + protected $project; | ||
| 23 | + | ||
| 24 | + protected $side = Common::C; | ||
| 25 | + | ||
| 26 | + public function __construct() | ||
| 27 | + { | ||
| 28 | + $this->request = request(); | ||
| 29 | + $this->requestAll = request()->all(); | ||
| 30 | + $this->project = $this->request->get('project'); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 列表 | ||
| 36 | + * @param array $map | ||
| 37 | + * @param array $sort | ||
| 38 | + * @param array $columns | ||
| 39 | + * @param int $limit | ||
| 40 | + * @return array | ||
| 41 | + * @author zbj | ||
| 42 | + * @date 2023/4/13 | ||
| 43 | + */ | ||
| 44 | + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 45 | + { | ||
| 46 | + $map[] = ['project_id' => $this->project['id']]; | ||
| 47 | + return parent::getList($map, $sort, $columns, $limit); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * @param $id | ||
| 52 | + * @return mixed | ||
| 53 | + * @author zbj | ||
| 54 | + * @date 2023/4/15 | ||
| 55 | + */ | ||
| 56 | + public function getCacheInfo($id) | ||
| 57 | + { | ||
| 58 | + $info = parent::getCacheInfo($id); | ||
| 59 | + if ($info && $info['project_id'] != $this->project['id']) { | ||
| 60 | + $info = null; | ||
| 61 | + } | ||
| 62 | + return $info; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * 保存 | ||
| 67 | + * @param $param | ||
| 68 | + * @return array | ||
| 69 | + * @throws BsideGlobalException | ||
| 70 | + * @author zbj | ||
| 71 | + * @date 2023/4/13 | ||
| 72 | + */ | ||
| 73 | + public function save($param) | ||
| 74 | + { | ||
| 75 | + $param['project_id'] = $this->project['id']; | ||
| 76 | + return parent::save($param); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 批量删除 | ||
| 81 | + * @param $ids | ||
| 82 | + * @param array $map | ||
| 83 | + * @return array | ||
| 84 | + * @author zbj | ||
| 85 | + * @date 2023/4/13 | ||
| 86 | + */ | ||
| 87 | + public function delete($ids, $map = []) | ||
| 88 | + { | ||
| 89 | + $map[] = ['project_id' => $this->project['id']]; | ||
| 90 | + return parent::delete($ids, $map); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | +} |
app/Http/Logic/Cside/InquiryLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Cside; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Models\Inquiry; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Class InquiryLogic | ||
| 10 | + * @package App\Http\Logic\Bside | ||
| 11 | + * @author zbj | ||
| 12 | + * @date 2023/5/4 | ||
| 13 | + */ | ||
| 14 | +class InquiryLogic extends BaseLogic | ||
| 15 | +{ | ||
| 16 | + public function __construct() | ||
| 17 | + { | ||
| 18 | + parent::__construct(); | ||
| 19 | + | ||
| 20 | + $this->model = new Inquiry(); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public function save($param) | ||
| 24 | + { | ||
| 25 | + $param['ip_info'] = Arr::s2a($param['ip_info']); | ||
| 26 | + $param['ip'] = $param['ip_info']['ip'] ?? ''; | ||
| 27 | + $param['ip_country'] = $param['ip_info']['country'] ?? ''; | ||
| 28 | + return parent::save($param); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | +} |
| @@ -4,6 +4,7 @@ namespace App\Http\Logic; | @@ -4,6 +4,7 @@ namespace App\Http\Logic; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Enums\Common\Common; | 6 | use App\Enums\Common\Common; |
| 7 | +use App\Exceptions\CsideGlobalException; | ||
| 7 | use \App\Helper\Common as CommonHelper; | 8 | use \App\Helper\Common as CommonHelper; |
| 8 | use App\Exceptions\AsideGlobalException; | 9 | use App\Exceptions\AsideGlobalException; |
| 9 | use App\Exceptions\BsideGlobalException; | 10 | use App\Exceptions\BsideGlobalException; |
| @@ -45,6 +46,9 @@ class Logic | @@ -45,6 +46,9 @@ class Logic | ||
| 45 | if((request()->path()[0]) == Common::B){ | 46 | if((request()->path()[0]) == Common::B){ |
| 46 | throw new BsideGlobalException($code, $message); | 47 | throw new BsideGlobalException($code, $message); |
| 47 | } | 48 | } |
| 49 | + if((request()->path()[0]) == Common::C){ | ||
| 50 | + throw new CsideGlobalException($code, $message); | ||
| 51 | + } | ||
| 48 | throw new AsideGlobalException($code, $message); | 52 | throw new AsideGlobalException($code, $message); |
| 49 | } | 53 | } |
| 50 | 54 |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Middleware\Cside; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Models\Project\Project; | ||
| 7 | +use App\Services\ProjectServer; | ||
| 8 | +use Closure; | ||
| 9 | +use Illuminate\Http\Request; | ||
| 10 | + | ||
| 11 | +class ParamMiddleware | ||
| 12 | +{ | ||
| 13 | + protected $param = []; | ||
| 14 | + | ||
| 15 | + protected $project = []; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * Handle an incoming request. | ||
| 19 | + * | ||
| 20 | + * @param \Illuminate\Http\Request $request | ||
| 21 | + * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next | ||
| 22 | + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse | ||
| 23 | + */ | ||
| 24 | + public function handle(Request $request, Closure $next) | ||
| 25 | + { | ||
| 26 | + $this->param = $request->all(); | ||
| 27 | + $domain = $request->header('domain'); | ||
| 28 | + if(!isset($domain) || empty($domain)){ | ||
| 29 | + return response(['code'=>Code::USER_ERROR,'msg'=>'非法请求']); | ||
| 30 | + } | ||
| 31 | + $project = Project::getProjectByDomain($domain); | ||
| 32 | + if(empty($project)){ | ||
| 33 | + return response(['code'=>Code::USER_ERROR,'msg'=>'非法请求']); | ||
| 34 | + } | ||
| 35 | + // 设置数据信息 | ||
| 36 | +// $project = ProjectServer::useProject($project['id']); | ||
| 37 | +// if($project){ | ||
| 38 | +// return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']); | ||
| 39 | +// } | ||
| 40 | + $request->attributes->add(['project' => $project]); | ||
| 41 | + return $next($request); | ||
| 42 | + } | ||
| 43 | +} |
| @@ -31,29 +31,14 @@ class ProjectRequest extends FormRequest | @@ -31,29 +31,14 @@ class ProjectRequest extends FormRequest | ||
| 31 | public function rules() | 31 | public function rules() |
| 32 | { | 32 | { |
| 33 | return [ | 33 | return [ |
| 34 | -// 'id' => 'required', | ||
| 35 | -// 'title' => 'max:100', | ||
| 36 | -// 'company' => 'max:100', | ||
| 37 | -// 'lead_name' => 'max:20', | ||
| 38 | -// 'mobile' => [new Mobile()], | ||
| 39 | -// 'qq' => 'max:20', | ||
| 40 | -// 'cooperate_date' => 'date_format:Y-m-d', | ||
| 41 | -// 'province' => 'max:20', | ||
| 42 | -// 'city' => 'max:20', | 34 | + |
| 43 | ]; | 35 | ]; |
| 44 | } | 36 | } |
| 45 | 37 | ||
| 46 | public function messages() | 38 | public function messages() |
| 47 | { | 39 | { |
| 48 | return [ | 40 | return [ |
| 49 | - 'id.required' => 'ID不能为空', | ||
| 50 | - 'title.max' => '项目名称不能超过100个字符', | ||
| 51 | - 'company.max' => '公司名不能超过100个字符', | ||
| 52 | - 'lead_name.max' => '联系人不能超过20个字符', | ||
| 53 | - 'qq.max' => 'QQ号不能超过20个字符', | ||
| 54 | - 'cooperate_date.date_format' => '合作时间格式不正确', | ||
| 55 | - 'province.max' => '省份不能超过20个字符', | ||
| 56 | - 'city.max' => '城市不能超过20个字符', | 41 | + |
| 57 | ]; | 42 | ]; |
| 58 | } | 43 | } |
| 59 | 44 |
| @@ -25,7 +25,7 @@ class NewsRequest extends FormRequest | @@ -25,7 +25,7 @@ class NewsRequest extends FormRequest | ||
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | 'name'=>'required|max:100', | 27 | 'name'=>'required|max:100', |
| 28 | - 'remark'=>'required|max:100', | 28 | + 'remark'=>'required|max:255', |
| 29 | 'text'=>'required|min:10', | 29 | 'text'=>'required|min:10', |
| 30 | 'category_id'=>'required', | 30 | 'category_id'=>'required', |
| 31 | ]; | 31 | ]; |
| @@ -31,7 +31,7 @@ class DescribeRequest extends FormRequest | @@ -31,7 +31,7 @@ class DescribeRequest extends FormRequest | ||
| 31 | { | 31 | { |
| 32 | return [ | 32 | return [ |
| 33 | 'title'=>'required|max:50', | 33 | 'title'=>'required|max:50', |
| 34 | - 'describe'=>'required', | 34 | + 'text'=>'required', |
| 35 | ]; | 35 | ]; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| @@ -40,7 +40,7 @@ class DescribeRequest extends FormRequest | @@ -40,7 +40,7 @@ class DescribeRequest extends FormRequest | ||
| 40 | return [ | 40 | return [ |
| 41 | 'title.required' => '请输入描述名称', | 41 | 'title.required' => '请输入描述名称', |
| 42 | 'title.max' => '描述名称不能超过50个字符', | 42 | 'title.max' => '描述名称不能超过50个字符', |
| 43 | - 'seo_title.required' => '请输入描述内容', | 43 | + 'text.required' => '请输入描述内容', |
| 44 | ]; | 44 | ]; |
| 45 | } | 45 | } |
| 46 | 46 |
| @@ -48,7 +48,7 @@ class ProductRequest extends FormRequest | @@ -48,7 +48,7 @@ class ProductRequest extends FormRequest | ||
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | }], | 50 | }], |
| 51 | - 'attrs' => ['required', 'array', function ($attribute, $value, $fail) { | 51 | + 'attrs' => ['array', function ($attribute, $value, $fail) { |
| 52 | foreach ($value as $v) { | 52 | foreach ($value as $v) { |
| 53 | if (empty($v['key'])) { | 53 | if (empty($v['key'])) { |
| 54 | $fail('产品属性名不能为空'); | 54 | $fail('产品属性名不能为空'); |
| @@ -59,11 +59,9 @@ class ProductRequest extends FormRequest | @@ -59,11 +59,9 @@ class ProductRequest extends FormRequest | ||
| 59 | } | 59 | } |
| 60 | }], | 60 | }], |
| 61 | 'category_id' => 'required', | 61 | 'category_id' => 'required', |
| 62 | - 'keywords' => 'required', | ||
| 63 | 'intro' => 'required|max:500', | 62 | 'intro' => 'required|max:500', |
| 64 | 'content' => 'required', | 63 | 'content' => 'required', |
| 65 | - 'describe' => 'required|array', | ||
| 66 | - 'seo_mate' => ['required', 'array', function ($attribute, $value, $fail) { | 64 | + 'seo_mate' => ['array', function ($attribute, $value, $fail) { |
| 67 | if(empty($value['title'])){ | 65 | if(empty($value['title'])){ |
| 68 | $fail('SEO标题不能为空'); | 66 | $fail('SEO标题不能为空'); |
| 69 | } | 67 | } |
| @@ -74,7 +72,7 @@ class ProductRequest extends FormRequest | @@ -74,7 +72,7 @@ class ProductRequest extends FormRequest | ||
| 74 | $fail('SEO关键词不能为空'); | 72 | $fail('SEO关键词不能为空'); |
| 75 | } | 73 | } |
| 76 | }], | 74 | }], |
| 77 | - 'related_product_id' => ['required', function ($attribute, $value, $fail) { | 75 | + 'related_product_id' => [function ($attribute, $value, $fail) { |
| 78 | $value = array_filter(Arr::splitFilterToArray($value), 'intval'); | 76 | $value = array_filter(Arr::splitFilterToArray($value), 'intval'); |
| 79 | if(count($value) > 16){ | 77 | if(count($value) > 16){ |
| 80 | $fail('关联产品不能超过16个'); | 78 | $fail('关联产品不能超过16个'); |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | -namespace App\Http\Requests\Bside; | 3 | +namespace App\Http\Requests\Cside; |
| 4 | 4 | ||
| 5 | use Illuminate\Foundation\Http\FormRequest; | 5 | use Illuminate\Foundation\Http\FormRequest; |
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | * Class InquiryRequest | 8 | * Class InquiryRequest |
| 9 | - * @package App\Http\Requests\Bside | 9 | + * @package App\Http\Requests\Cside |
| 10 | * @author zbj | 10 | * @author zbj |
| 11 | * @date 2023/5/4 | 11 | * @date 2023/5/4 |
| 12 | */ | 12 | */ |
| @@ -85,12 +85,28 @@ class Product extends Base | @@ -85,12 +85,28 @@ class Product extends Base | ||
| 85 | return Arr::setToArr($value); | 85 | return Arr::setToArr($value); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | - public function setKeywordsAttribute($value){ | ||
| 89 | - $this->attributes['keywords'] = Arr::arrToSet($value, 'trim'); | 88 | + public function setAttrIdAttribute($value){ |
| 89 | + $this->attributes['attr_id'] = Arr::arrToSet($value); | ||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | - public function getKeywordsAttribute($value){ | ||
| 93 | - return Arr::setToArr($value, 'trim'); | 92 | + public function getAttrIdAttribute($value){ |
| 93 | + return Arr::setToArr($value); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public function setDescribeIdAttribute($value){ | ||
| 97 | + $this->attributes['describe_id'] = Arr::arrToSet($value); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public function getDescribeIdAttribute($value){ | ||
| 101 | + return Arr::setToArr($value); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public function setKeywordIdAttribute($value){ | ||
| 105 | + $this->attributes['keyword_id'] = Arr::arrToSet($value); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public function getKeywordIdAttribute($value){ | ||
| 109 | + return Arr::setToArr($value); | ||
| 94 | } | 110 | } |
| 95 | 111 | ||
| 96 | public function setRelatedProductIdAttribute($value){ | 112 | public function setRelatedProductIdAttribute($value){ |
| @@ -4,6 +4,7 @@ namespace App\Models\Project; | @@ -4,6 +4,7 @@ namespace App\Models\Project; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | use App\Models\Base; | 6 | use App\Models\Base; |
| 7 | +use Illuminate\Support\Facades\Cache; | ||
| 7 | 8 | ||
| 8 | class DeployBuild extends Base | 9 | class DeployBuild extends Base |
| 9 | { | 10 | { |
| @@ -19,4 +20,8 @@ class DeployBuild extends Base | @@ -19,4 +20,8 @@ class DeployBuild extends Base | ||
| 19 | return Arr::setToArr($value); | 20 | return Arr::setToArr($value); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | + public static function clearCache($row){ | ||
| 24 | + $cache_key = 'project_' . $row->original['test_domain']; | ||
| 25 | + Cache::forget($cache_key); | ||
| 26 | + } | ||
| 22 | } | 27 | } |
| @@ -4,6 +4,7 @@ namespace App\Models\Project; | @@ -4,6 +4,7 @@ namespace App\Models\Project; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | use App\Models\Base; | 6 | use App\Models\Base; |
| 7 | +use Illuminate\Support\Facades\Cache; | ||
| 7 | 8 | ||
| 8 | class DeployOptimize extends Base | 9 | class DeployOptimize extends Base |
| 9 | { | 10 | { |
| @@ -19,4 +20,9 @@ class DeployOptimize extends Base | @@ -19,4 +20,9 @@ class DeployOptimize extends Base | ||
| 19 | return Arr::s2a($value); | 20 | return Arr::s2a($value); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | + public static function clearCache($row){ | ||
| 24 | + $cache_key = 'project_' . $row->original['domain']; | ||
| 25 | + Cache::forget($cache_key); | ||
| 26 | + } | ||
| 27 | + | ||
| 22 | } | 28 | } |
| @@ -5,6 +5,7 @@ namespace App\Models\Project; | @@ -5,6 +5,7 @@ namespace App\Models\Project; | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | use App\Models\Base; | 6 | use App\Models\Base; |
| 7 | use App\Models\Devops\ServerConfig; | 7 | use App\Models\Devops\ServerConfig; |
| 8 | +use Illuminate\Support\Facades\Cache; | ||
| 8 | 9 | ||
| 9 | class Project extends Base | 10 | class Project extends Base |
| 10 | { | 11 | { |
| @@ -144,4 +145,30 @@ class Project extends Base | @@ -144,4 +145,30 @@ class Project extends Base | ||
| 144 | return Arr::s2a($value); | 145 | return Arr::s2a($value); |
| 145 | } | 146 | } |
| 146 | 147 | ||
| 148 | + /** | ||
| 149 | + * 根据域名获取项目信息 | ||
| 150 | + * @author zbj | ||
| 151 | + * @date 2023/5/5 | ||
| 152 | + */ | ||
| 153 | + public static function getProjectByDomain($domain){ | ||
| 154 | + $cache_key = 'project_'.$domain; | ||
| 155 | + $data = Cache::get($cache_key); | ||
| 156 | + if(!$data){ | ||
| 157 | + //是否测试域名 | ||
| 158 | + $project_id = DeployBuild::where('test_domain', $domain)->value('project_id'); | ||
| 159 | + //是否正式域名 | ||
| 160 | + if(!$project_id){ | ||
| 161 | + $project_id = DeployOptimize::where('domain', $domain)->value('project_id'); | ||
| 162 | + } | ||
| 163 | + if(!$project_id){ | ||
| 164 | + return []; | ||
| 165 | + } | ||
| 166 | + $data = self::find($project_id); | ||
| 167 | + if($data){ | ||
| 168 | + Cache::put($cache_key, $data); | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + return $data; | ||
| 172 | + } | ||
| 173 | + | ||
| 147 | } | 174 | } |
| @@ -40,6 +40,7 @@ class RouteServiceProvider extends ServiceProvider | @@ -40,6 +40,7 @@ class RouteServiceProvider extends ServiceProvider | ||
| 40 | //预定义两个端的API路由 | 40 | //预定义两个端的API路由 |
| 41 | $this->mapAsideRoute(); | 41 | $this->mapAsideRoute(); |
| 42 | $this->mapBsideRoute(); | 42 | $this->mapBsideRoute(); |
| 43 | + $this->mapCsideRoute(); | ||
| 43 | 44 | ||
| 44 | // 暂时无用 | 45 | // 暂时无用 |
| 45 | $this->routes(function () { | 46 | $this->routes(function () { |
| @@ -74,6 +75,16 @@ class RouteServiceProvider extends ServiceProvider | @@ -74,6 +75,16 @@ class RouteServiceProvider extends ServiceProvider | ||
| 74 | ->namespace($this->namespace . '\Bside') | 75 | ->namespace($this->namespace . '\Bside') |
| 75 | ->group(base_path('routes/bside.php')); | 76 | ->group(base_path('routes/bside.php')); |
| 76 | } | 77 | } |
| 78 | + /** | ||
| 79 | + *C端API路由 | ||
| 80 | + * @return void | ||
| 81 | + */ | ||
| 82 | + protected function mapCsideRoute(){ | ||
| 83 | + Route::middleware('cside') | ||
| 84 | + ->prefix('c') | ||
| 85 | + ->namespace($this->namespace . '\Cside') | ||
| 86 | + ->group(base_path('routes/cside.php')); | ||
| 87 | + } | ||
| 77 | 88 | ||
| 78 | /** | 89 | /** |
| 79 | * Configure the rate limiters for the application. | 90 | * Configure the rate limiters for the application. |
| @@ -60,6 +60,12 @@ return [ | @@ -60,6 +60,12 @@ return [ | ||
| 60 | 'via' => \App\Factory\LogFormatterFactory::class, | 60 | 'via' => \App\Factory\LogFormatterFactory::class, |
| 61 | 'prefix' => 'bside', | 61 | 'prefix' => 'bside', |
| 62 | ], | 62 | ], |
| 63 | + //自定义B端错误日志 | ||
| 64 | + 'cside' => [ | ||
| 65 | + 'driver' => 'custom', | ||
| 66 | + 'via' => \App\Factory\LogFormatterFactory::class, | ||
| 67 | + 'prefix' => 'cside', | ||
| 68 | + ], | ||
| 63 | 69 | ||
| 64 | 'stack' => [ | 70 | 'stack' => [ |
| 65 | 'driver' => 'stack', | 71 | 'driver' => 'stack', |
routes/cside.php
0 → 100644
-
请 注册 或 登录 后发表评论