Merge branch 'develop' into dc
正在显示
75 个修改的文件
包含
2151 行增加
和
762 行删除
| @@ -47,7 +47,7 @@ class ShareUser extends Command | @@ -47,7 +47,7 @@ class ShareUser extends Command | ||
| 47 | foreach ($ayr_share_list as $k => $v){ | 47 | foreach ($ayr_share_list as $k => $v){ |
| 48 | //查询当前用户是否有未推送的博文 | 48 | //查询当前用户是否有未推送的博文 |
| 49 | $ayr_release = new AyrReleaseModel(); | 49 | $ayr_release = new AyrReleaseModel(); |
| 50 | - $release_info = $ayr_release->read(['idempotency_key'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]); | 50 | + $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]); |
| 51 | //有推文时,直接跳出循环 | 51 | //有推文时,直接跳出循环 |
| 52 | if($release_info !== false){ | 52 | if($release_info !== false){ |
| 53 | continue; | 53 | continue; |
| @@ -45,7 +45,6 @@ class RankData extends BaseCommands | @@ -45,7 +45,6 @@ class RankData extends BaseCommands | ||
| 45 | if(!$site_res){ | 45 | if(!$site_res){ |
| 46 | return false; | 46 | return false; |
| 47 | } | 47 | } |
| 48 | - | ||
| 49 | foreach ($list as $item){ | 48 | foreach ($list as $item){ |
| 50 | $model = GoogleRankModel::where('project_id', $item['project_id'])->where('lang', '')->first(); | 49 | $model = GoogleRankModel::where('project_id', $item['project_id'])->where('lang', '')->first(); |
| 51 | if (!$model || $model->updated_date != date('Y-m-d')) { | 50 | if (!$model || $model->updated_date != date('Y-m-d')) { |
| @@ -61,7 +60,8 @@ class RankData extends BaseCommands | @@ -61,7 +60,8 @@ class RankData extends BaseCommands | ||
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | //有小语种的 | 62 | //有小语种的 |
| 64 | - if($item['minor_languages']){ | 63 | + $lang_list = $api->getLangList(); |
| 64 | + if(!empty($lang_list[$item['api_no']])){ | ||
| 65 | $model = GoogleRankModel::where('project_id', $item['project_id'])->where('lang', '<>', '')->first(); | 65 | $model = GoogleRankModel::where('project_id', $item['project_id'])->where('lang', '<>', '')->first(); |
| 66 | if (!$model || $model->updated_date != date('Y-m-d')) { | 66 | if (!$model || $model->updated_date != date('Y-m-d')) { |
| 67 | $res = $api->getGoogleRank($item['api_no'], 1); | 67 | $res = $api->getGoogleRank($item['api_no'], 1); |
app/Console/Commands/WebTraffic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Models\Product\Category; | ||
| 7 | +use App\Models\Product\Product; | ||
| 8 | +use App\Models\RouteMap; | ||
| 9 | +use GuzzleHttp\Client; | ||
| 10 | +use GuzzleHttp\Promise\Utils; | ||
| 11 | +use Illuminate\Console\Command; | ||
| 12 | +use Illuminate\Support\Facades\DB; | ||
| 13 | +use Illuminate\Support\Str; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 网站引流 | ||
| 17 | + * Class Traffic | ||
| 18 | + * @package App\Console\Commands | ||
| 19 | + * @author zbj | ||
| 20 | + * @date 2023/5/18 | ||
| 21 | + */ | ||
| 22 | +class WebTraffic extends Command | ||
| 23 | +{ | ||
| 24 | + /** | ||
| 25 | + * The name and signature of the console command. | ||
| 26 | + * | ||
| 27 | + * @var string | ||
| 28 | + */ | ||
| 29 | + protected $signature = 'web_traffic {type}'; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * The console command description. | ||
| 33 | + * | ||
| 34 | + * @var string | ||
| 35 | + */ | ||
| 36 | + protected $description = '网站引流'; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Create a new command instance. | ||
| 40 | + * | ||
| 41 | + * @return void | ||
| 42 | + */ | ||
| 43 | + public function __construct() | ||
| 44 | + { | ||
| 45 | + parent::__construct(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * google域名后缀 | ||
| 50 | + * @var string[] | ||
| 51 | + */ | ||
| 52 | + protected $suffix = [ | ||
| 53 | + 'co.jp' => '日本', | ||
| 54 | + 'com.tr' => '土耳其', | ||
| 55 | + 'nl' => '荷兰', | ||
| 56 | + 'ru' => '俄罗斯', | ||
| 57 | + 'fr' => '法国', | ||
| 58 | + 'co.kr' => '韩国', | ||
| 59 | + 'fi' => '芬兰', | ||
| 60 | + 'be' => '比利时', | ||
| 61 | + 'lt' => '立陶宛', | ||
| 62 | + 'es' => '西班牙', | ||
| 63 | + 'it' => '意大利', | ||
| 64 | + 'com.au' => '澳大利亚', | ||
| 65 | + 'no' => '挪威', | ||
| 66 | + 'al' => '阿尔巴尼亚', | ||
| 67 | + 'pt' => '葡萄牙', | ||
| 68 | + 'lv' => '拉脱维亚', | ||
| 69 | + 'hu' => '匈牙利', | ||
| 70 | + 'cz' => '捷克', | ||
| 71 | + 'de' => '德国', | ||
| 72 | + 'ca' => '加拿大', | ||
| 73 | + 'co.in' => '印度', | ||
| 74 | + 'co.uk' => '英国', | ||
| 75 | + 'com.vn' => '越南', | ||
| 76 | + 'com.br' => '巴西', | ||
| 77 | + 'co.il' => '以色列', | ||
| 78 | + 'pl' => '波兰', | ||
| 79 | + 'com.eg' => '埃及', | ||
| 80 | + 'co.th' => '泰国', | ||
| 81 | + 'sk' => '斯洛伐克', | ||
| 82 | + 'ro' => '罗马尼亚', | ||
| 83 | + 'com.mx' => '墨西哥', | ||
| 84 | + 'com.my' => '马来西亚', | ||
| 85 | + 'com.pk' => '巴基斯坦', | ||
| 86 | + 'co.nz' => '新西兰', | ||
| 87 | + 'co.za' => '南非', | ||
| 88 | + 'com.ar' => '阿根廷', | ||
| 89 | + 'com.kw' => '科威特', | ||
| 90 | + 'com.sg' => '新加坡', | ||
| 91 | + 'com.co' => '哥伦比亚', | ||
| 92 | + 'co.id' => '印度尼西亚', | ||
| 93 | + 'gr' => '希腊', | ||
| 94 | + 'bg' => '保加利亚', | ||
| 95 | + 'mn' => '蒙古', | ||
| 96 | + 'dk' => '丹麦', | ||
| 97 | + 'com.sa' => '沙特阿拉伯', | ||
| 98 | + 'com.pe' => '秘鲁', | ||
| 99 | + 'com.ph' => '菲律宾', | ||
| 100 | + 'com.ua' => '乌克兰', | ||
| 101 | + 'ge' => '格鲁吉亚', | ||
| 102 | + 'ae' => '阿拉伯联合酋长国', | ||
| 103 | + 'tn' => '突尼斯', | ||
| 104 | + ]; | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * 概率值 | ||
| 108 | + * @var int[] | ||
| 109 | + */ | ||
| 110 | + protected $sjjg = [720, 280];//访问间隔占比 访问|不访问 | ||
| 111 | + //访问页面类型占比 产品详情页、单页|产品分类页 | ||
| 112 | + protected $ymzb = [ | ||
| 113 | + 'urls_cats' => 700, | ||
| 114 | + 'urls_details' => 300 | ||
| 115 | + ]; | ||
| 116 | + protected $sdzb = [600, 200, 150, 50]; //访问页面深度占比 1页|2页|3-6页|7-11页 | ||
| 117 | + protected $yddzb = [1 => 700, 2 => 300]; //移动端占比 pc|mobile | ||
| 118 | + //模拟访问来源占比 (美国) | ||
| 119 | + protected $lyzb = [ | ||
| 120 | + 'https://www.google.com/' => 630, | ||
| 121 | + 'http://www.google.com/' => 30, | ||
| 122 | + 'http://www.bing.com/' => 20, | ||
| 123 | + 'https://www.bing.com/' => 5, | ||
| 124 | + 'https://www.youtube.com/' => 5, | ||
| 125 | + 'https://search.yahoo.com/' => 5, | ||
| 126 | + 'https://www.facebook.com/' => 5, | ||
| 127 | + ]; | ||
| 128 | + protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀 | ||
| 129 | + | ||
| 130 | + protected $pc_ua = [ | ||
| 131 | + 0 => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11', | ||
| 132 | + 1 => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', | ||
| 133 | + 2 => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' | ||
| 134 | + ]; | ||
| 135 | + | ||
| 136 | + protected $mobile_ua = [ | ||
| 137 | + 0 => 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19', | ||
| 138 | + ]; | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * @return bool | ||
| 142 | + */ | ||
| 143 | + public function handle() | ||
| 144 | + { | ||
| 145 | + $type = $this->argument('type'); | ||
| 146 | + | ||
| 147 | + $this->sleep($type); | ||
| 148 | + | ||
| 149 | + $project_list = $this->getProjectList($type); | ||
| 150 | + $project_chunk = array_chunk($project_list,500,true); | ||
| 151 | + | ||
| 152 | + foreach ($project_chunk as $chunk) { | ||
| 153 | + $need_project = []; | ||
| 154 | + foreach ($chunk as $project) { | ||
| 155 | + //随机引流间隔 | ||
| 156 | + $res_sjjg = $this->get_rand($this->sjjg); | ||
| 157 | + if ($res_sjjg == 1) { | ||
| 158 | + continue; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + $project_urls = $this->getProductUrls($project['project_id']); | ||
| 162 | + $project_urls['home'] = $project['domain']; | ||
| 163 | + //随机访问页面 | ||
| 164 | + $project['visit_urls'] = $this->getVisitUrls($project_urls); | ||
| 165 | + //随机客户端 | ||
| 166 | + $project['device_port'] = $this->get_rand($this->yddzb); | ||
| 167 | + $project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua); | ||
| 168 | + | ||
| 169 | + $need_project[] = $project; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + //随机访问ip | ||
| 173 | + $ips = $this->getIpAreas(count($need_project)); | ||
| 174 | + //最多10层深度 | ||
| 175 | + $client = new Client(['verify' => false]); | ||
| 176 | + for ($j = 0; $j < 10; $j++) { | ||
| 177 | + for ($j = 0; $j < 10; $j++) { | ||
| 178 | + //并发请求 | ||
| 179 | + $promises = []; | ||
| 180 | + foreach ($need_project as $project_key => $project) { | ||
| 181 | + if (empty($project['visit_urls'][$j])) { | ||
| 182 | + continue; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + $data = [ | ||
| 186 | + 'ip' => $ips[$project_key]['ip'], | ||
| 187 | + 'referer' => $this->getReferer($ips[$project_key]['ip_area']), | ||
| 188 | + 'url' => $project['visit_urls'][$j], | ||
| 189 | + 'device_port' => $this->get_rand($this->yddzb) | ||
| 190 | + ]; | ||
| 191 | + $promises[] = $client->postAsync($project['domain'] . 'api/customerVisit', ['form_params' => $data]); | ||
| 192 | + } | ||
| 193 | + Utils::settle($promises)->wait(); | ||
| 194 | + | ||
| 195 | + //每个深度随机等待 | ||
| 196 | + sleep(rand(2, 10)); | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + /** | ||
| 203 | + * 不同项目 休眠 | ||
| 204 | + */ | ||
| 205 | + protected function sleep($type){ | ||
| 206 | + if($type == 1){ //1-3个月的项目 | ||
| 207 | + sleep(rand(5,480)); | ||
| 208 | + }elseif($type == 2){ //4-8个月的项目 | ||
| 209 | + sleep(rand(5,240)); | ||
| 210 | + }elseif($type == 3){ // 大于9个月的项目 | ||
| 211 | + sleep(rand(5,120)); | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * 引流的项目 | ||
| 217 | + */ | ||
| 218 | + protected function getProjectList($type){ | ||
| 219 | + //todo 根据type获取需要引流的项目 | ||
| 220 | + return [ | ||
| 221 | + [ | ||
| 222 | + 'project_id' => 1, | ||
| 223 | + 'domain' => 'https://demomark.globalso.com/', | ||
| 224 | + ] | ||
| 225 | + ]; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * 获取产品分类、单页和详情链接 | ||
| 230 | + */ | ||
| 231 | + protected function getProductUrls($project_id){ | ||
| 232 | + //产品分类页面 | ||
| 233 | + $product_cate_ids = Category::where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('id')->toArray(); | ||
| 234 | + $data['urls_cats'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT_CATE)->whereIn('source_id', $product_cate_ids)->get()->toArray(); | ||
| 235 | + //单页面 | ||
| 236 | + //todo 发布状态的单页面id | ||
| 237 | + $data['urls_page'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PAGE)->get()->toArray(); | ||
| 238 | + //产品详情页 | ||
| 239 | + $product_ids = Product::where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('id')->toArray(); | ||
| 240 | + $data['urls_details'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->whereIn('source_id', $product_ids)->get()->toArray(); | ||
| 241 | + | ||
| 242 | + $data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']); | ||
| 243 | + if(empty($data['urls_cats'])){ | ||
| 244 | + $data['urls_cats'] = $data['urls_details']; | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + return $data; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * 获取地区IP | ||
| 252 | + */ | ||
| 253 | + protected function getIpAreas($num) | ||
| 254 | + { | ||
| 255 | + //本地时间为7-23点的地区 | ||
| 256 | + $h = date('H'); | ||
| 257 | + $areas = []; | ||
| 258 | + $list = DB::table('gl_area_timezone')->get(); | ||
| 259 | + foreach ($list as $v) { | ||
| 260 | + $v = (array)$v; | ||
| 261 | + $country_hour = $h + $v['diff']; | ||
| 262 | + if ($country_hour < 0) { | ||
| 263 | + $country_hour = 24 + $country_hour; | ||
| 264 | + } | ||
| 265 | + if ($country_hour >= 7 && $country_hour < 23) { | ||
| 266 | + $areas[] = $v['name']; | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + //根据地区随机取该地区的IP | ||
| 270 | + $data = DB::table('gl_xunpan_ipdata')->whereIn('ip_area', $areas)->inRandomOrder()->limit($num)->get(); | ||
| 271 | + return Arr::s2a(Arr::a2s($data)); | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + /** | ||
| 275 | + * 概率算法 | ||
| 276 | + */ | ||
| 277 | + protected function get_rand($proArr) { | ||
| 278 | + $result = ''; | ||
| 279 | + $proSum = array_sum($proArr); | ||
| 280 | + foreach ($proArr as $key => $proCur) { | ||
| 281 | + $randNum = mt_rand(1, $proSum); | ||
| 282 | + if ($randNum <= $proCur) { | ||
| 283 | + $result = $key; | ||
| 284 | + break; | ||
| 285 | + } else { | ||
| 286 | + $proSum -= $proCur; | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + unset ($proArr); | ||
| 290 | + return $result; | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + /** | ||
| 294 | + * 根据随机访问深度 随机获取访问页面 | ||
| 295 | + */ | ||
| 296 | + protected function getVisitUrls($project_urls){ | ||
| 297 | + //没有分类页 就只访问首页 | ||
| 298 | + if(!$project_urls['urls_cats']){ | ||
| 299 | + $url[] = $project_urls['home']; | ||
| 300 | + return $url; | ||
| 301 | + } | ||
| 302 | + //随机访问深度 | ||
| 303 | + $res_sdzb = $this->get_rand($this->sdzb); | ||
| 304 | + //随机访问页面类型 | ||
| 305 | + $res_ymzb = $this->get_rand($this->ymzb); | ||
| 306 | + | ||
| 307 | + $all_url = array_merge($project_urls['urls_cats'],$project_urls['urls_details']); | ||
| 308 | + if(!$all_url){ | ||
| 309 | + $url[] = $project_urls['home']; | ||
| 310 | + return $url; | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + $url = []; | ||
| 314 | + if($res_sdzb == 0){//深度一页 | ||
| 315 | + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; | ||
| 316 | + }elseif($res_sdzb == 1){//深度两页 | ||
| 317 | + $url[] = $project_urls['home']; | ||
| 318 | + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; | ||
| 319 | + }elseif($res_sdzb == 2){//深度3-6页 | ||
| 320 | + $yms = rand(2,5); //随机页面数 | ||
| 321 | + $url = Arr::pluck(Arr::random($all_url, $yms), 'route'); | ||
| 322 | + $url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去 | ||
| 323 | + }elseif($res_sdzb == 3){//深度7-11页 | ||
| 324 | + $yms = rand(6,10); //随机页面数 | ||
| 325 | + $url = Arr::pluck(Arr::random($all_url, $yms), 'route'); | ||
| 326 | + $url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去 | ||
| 327 | + } | ||
| 328 | + foreach ($url as &$v){ | ||
| 329 | + if(!Str::contains($v, $project_urls['home'])){ | ||
| 330 | + $v = $project_urls['home'] . $v; | ||
| 331 | + } | ||
| 332 | + } | ||
| 333 | + return array_unique(array_filter($url)); | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + /** | ||
| 337 | + * 获取访问来路 | ||
| 338 | + */ | ||
| 339 | + protected function getReferer($ip_area){ | ||
| 340 | + if($ip_area == '美国'){ | ||
| 341 | + $referer = $this->get_rand($this->lyzb); | ||
| 342 | + }else{ | ||
| 343 | + $referer = 'https://www.google.com/'; | ||
| 344 | + | ||
| 345 | + $suffix = array_search($ip_area, $this->suffix); | ||
| 346 | + if($suffix){ | ||
| 347 | + $res_qtzb = $this->get_rand($this->otherzb); | ||
| 348 | + if($res_qtzb == 1){ | ||
| 349 | + $referer = 'https://www.google.'.$suffix.'/'; | ||
| 350 | + } | ||
| 351 | + } | ||
| 352 | + } | ||
| 353 | + return $referer; | ||
| 354 | + } | ||
| 355 | +} |
| @@ -23,6 +23,9 @@ class Kernel extends ConsoleKernel | @@ -23,6 +23,9 @@ class Kernel extends ConsoleKernel | ||
| 23 | $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 | 23 | $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 |
| 24 | $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 | 24 | $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 |
| 25 | $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 | 25 | $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 |
| 26 | + $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | ||
| 27 | + $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 | ||
| 28 | + $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 | ||
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | /** | 31 | /** |
app/Exceptions/CsideGlobalException.php
已删除
100644 → 0
| 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,10 +72,6 @@ class Handler extends ExceptionHandler | @@ -72,10 +72,6 @@ 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 | - } | ||
| 79 | //验证错误(非手动抛出) | 75 | //验证错误(非手动抛出) |
| 80 | elseif ($exception instanceof ValidationException) { | 76 | elseif ($exception instanceof ValidationException) { |
| 81 | LogUtils::error("参数验证失败", [], $exceptionMessage); | 77 | LogUtils::error("参数验证失败", [], $exceptionMessage); |
| @@ -114,9 +110,7 @@ class Handler extends ExceptionHandler | @@ -114,9 +110,7 @@ class Handler extends ExceptionHandler | ||
| 114 | $code = $exception->getCode(); | 110 | $code = $exception->getCode(); |
| 115 | }elseif ($exception instanceof BsideGlobalException) { | 111 | }elseif ($exception instanceof BsideGlobalException) { |
| 116 | $code = $exception->getCode(); | 112 | $code = $exception->getCode(); |
| 117 | - }elseif ($exception instanceof CsideGlobalException) { | ||
| 118 | - $code = $exception->getCode(); | ||
| 119 | - } elseif ($exception instanceof ValidationException) { | 113 | + }elseif ($exception instanceof ValidationException) { |
| 120 | $code = Code::USER_PARAMS_ERROE(); | 114 | $code = Code::USER_PARAMS_ERROE(); |
| 121 | $message = $code->description = Arr::first(Arr::first($exception->errors())); | 115 | $message = $code->description = Arr::first(Arr::first($exception->errors())); |
| 122 | } elseif ($exception instanceof NotFoundHttpException || $exception instanceof MethodNotAllowedHttpException) { | 116 | } elseif ($exception instanceof NotFoundHttpException || $exception instanceof MethodNotAllowedHttpException) { |
| @@ -3,6 +3,8 @@ | @@ -3,6 +3,8 @@ | ||
| 3 | namespace App\Helper; | 3 | namespace App\Helper; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use Illuminate\Support\Collection; | ||
| 7 | + | ||
| 6 | /** | 8 | /** |
| 7 | * 数组类函数 | 9 | * 数组类函数 |
| 8 | * Class Arrays | 10 | * Class Arrays |
| @@ -185,4 +187,29 @@ class Arr extends \Illuminate\Support\Arr | @@ -185,4 +187,29 @@ class Arr extends \Illuminate\Support\Arr | ||
| 185 | } | 187 | } |
| 186 | return $str ?: []; | 188 | return $str ?: []; |
| 187 | } | 189 | } |
| 190 | + | ||
| 191 | + | ||
| 192 | + /** | ||
| 193 | + * 将数组设置成某个键的值 | ||
| 194 | + * @param $arr | ||
| 195 | + * @param $key | ||
| 196 | + * @return array | ||
| 197 | + * @author zbj | ||
| 198 | + * @date 2023/5/16 | ||
| 199 | + */ | ||
| 200 | + public static function setValueToKey($arr, $key) | ||
| 201 | + { | ||
| 202 | + $data = []; | ||
| 203 | + if (!$arr) { | ||
| 204 | + return $data; | ||
| 205 | + } | ||
| 206 | + foreach ($arr as $v) { | ||
| 207 | + $data[$v[$key]] = $v; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + if ($arr instanceof Collection) { | ||
| 211 | + $data = new Collection($data); | ||
| 212 | + } | ||
| 213 | + return $data; | ||
| 214 | + } | ||
| 188 | } | 215 | } |
| @@ -67,7 +67,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | @@ -67,7 +67,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 67 | */ | 67 | */ |
| 68 | public function deleted_profiles($data){ | 68 | public function deleted_profiles($data){ |
| 69 | $param = [ | 69 | $param = [ |
| 70 | - 'title'=>$data['title'], | 70 | +// 'title'=>$data['title'], |
| 71 | 'profileKey'=>$data['profileKey'], | 71 | 'profileKey'=>$data['profileKey'], |
| 72 | ]; | 72 | ]; |
| 73 | $url = $this->path.'/api/profiles/profile'; | 73 | $url = $this->path.'/api/profiles/profile'; |
| @@ -103,6 +103,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | @@ -103,6 +103,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 103 | return $this->http_click('get',$url,[],$this->headers); | 103 | return $this->http_click('get',$url,[],$this->headers); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | + | ||
| 106 | /** | 107 | /** |
| 107 | * @name :(发帖)post_send_msg | 108 | * @name :(发帖)post_send_msg |
| 108 | * @author :lyh | 109 | * @author :lyh |
| @@ -113,12 +114,31 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | @@ -113,12 +114,31 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 113 | */ | 114 | */ |
| 114 | public function post_send_msg($param,$api_key){ | 115 | public function post_send_msg($param,$api_key){ |
| 115 | //平台参数处理 | 116 | //平台参数处理 |
| 116 | - $this->headers['Accept-Encoding'] = 'gzip'; | ||
| 117 | - $this->headers['Authorization'] = $this->headers['Authorization'].$api_key; | 117 | + $param['idempotencyKey'] = uniqid().time(); |
| 118 | $url = $this->path.'/api/post'; | 118 | $url = $this->path.'/api/post'; |
| 119 | - return $this->http_click('posts',$url,$param,$this->headers); | 119 | + return $this->http_post_ayr($url,$param,$api_key); |
| 120 | + } | ||
| 121 | + public function http_post_ayr($url,$param,$api_key){ | ||
| 122 | + $curl = curl_init(); | ||
| 123 | + curl_setopt_array($curl, array( | ||
| 124 | + CURLOPT_URL => $url, | ||
| 125 | + CURLOPT_RETURNTRANSFER => true, | ||
| 126 | + CURLOPT_ENCODING => '', | ||
| 127 | + CURLOPT_MAXREDIRS => 10, | ||
| 128 | + CURLOPT_TIMEOUT => 0, | ||
| 129 | + CURLOPT_FOLLOWLOCATION => true, | ||
| 130 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | ||
| 131 | + CURLOPT_CUSTOMREQUEST => 'POST', | ||
| 132 | + CURLOPT_POSTFIELDS => http_build_query($param), | ||
| 133 | + CURLOPT_HTTPHEADER => array( | ||
| 134 | + 'Authorization: Bearer '.$api_key, | ||
| 135 | + 'Accept-Encoding: gzip' | ||
| 136 | + ), | ||
| 137 | + )); | ||
| 138 | + $response = curl_exec($curl); | ||
| 139 | + curl_close($curl); | ||
| 140 | + return $response; | ||
| 120 | } | 141 | } |
| 121 | - | ||
| 122 | /** | 142 | /** |
| 123 | * @name :(上传图片或视频到ayr_share)post_media_upload | 143 | * @name :(上传图片或视频到ayr_share)post_media_upload |
| 124 | * @author :lyh | 144 | * @author :lyh |
app/Helper/FormGlobalsoApi.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +namespace App\Helper; | ||
| 5 | + | ||
| 6 | +use App\Utils\HttpUtils; | ||
| 7 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Class FormGlobalsoApi | ||
| 12 | + * @package App\Helper | ||
| 13 | + * @author zbj | ||
| 14 | + * @date 2023/5/17 | ||
| 15 | + */ | ||
| 16 | +class FormGlobalsoApi | ||
| 17 | +{ | ||
| 18 | + //接口地址 | ||
| 19 | + protected $url = 'https://form.globalso.com'; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 设置询盘通知 | ||
| 23 | + * @author zbj | ||
| 24 | + * @date 2023/5/17 | ||
| 25 | + */ | ||
| 26 | + public function setInquiry($domain, $emails, $phones) | ||
| 27 | + { | ||
| 28 | + $api_url = $this->url . '/api/external-project/save/dc77a54480b184c4'; | ||
| 29 | + | ||
| 30 | + $params = [ | ||
| 31 | + 'token' => md5($domain.$emails.$phones.date("Y-m-d")), | ||
| 32 | + 'domain' => $domain, | ||
| 33 | + 'email' => $emails, | ||
| 34 | + 'phone' => $phones, | ||
| 35 | + ]; | ||
| 36 | + | ||
| 37 | + try { | ||
| 38 | + $res = HttpUtils::get($api_url, $params); | ||
| 39 | + $res = Arr::s2a($res); | ||
| 40 | + } catch (\Exception | GuzzleException $e) { | ||
| 41 | + errorLog('设置询盘通知', $params, $e); | ||
| 42 | + return false; | ||
| 43 | + } | ||
| 44 | + return $res; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 询盘列表 | ||
| 49 | + * @author zbj | ||
| 50 | + * @date 2023/5/17 | ||
| 51 | + */ | ||
| 52 | + public function getInquiryList($domain, $search = '', $page = 1, $page_size = 20) | ||
| 53 | + { | ||
| 54 | + $api_url = $this->url . '/api/external-interface/6a1bd159b1fd60af'; | ||
| 55 | + | ||
| 56 | + $params = [ | ||
| 57 | + 'token' => md5($domain.$search.date("Y-m-d")), | ||
| 58 | + 'domain' => $domain, | ||
| 59 | + 'limit' => $page_size, | ||
| 60 | + 'page' => $page, | ||
| 61 | + 'source' => '1,3' //来源类型 新项目用1,3 | ||
| 62 | + ]; | ||
| 63 | + if($search){ | ||
| 64 | + $params['name'] = $search; | ||
| 65 | + } | ||
| 66 | + try { | ||
| 67 | + $res = HttpUtils::get($api_url, $params); | ||
| 68 | + $res = Arr::s2a($res); | ||
| 69 | + } catch (\Exception | GuzzleException $e) { | ||
| 70 | + errorLog('询盘列表', $params, $e); | ||
| 71 | + return false; | ||
| 72 | + } | ||
| 73 | + return $res; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 设置询盘信息已读 | ||
| 78 | + * @author zbj | ||
| 79 | + * @date 2023/5/17 | ||
| 80 | + */ | ||
| 81 | + public function saveInquiryRead($domain, $id) | ||
| 82 | + { | ||
| 83 | + $api_url = $this->url . '/api/external-interface/save/d1483a8e57cb485a'; | ||
| 84 | + | ||
| 85 | + $params = [ | ||
| 86 | + 'token' => md5($domain.$id.date("Y-m-d")), | ||
| 87 | + 'domain' => $domain, | ||
| 88 | + 'id' => $id, | ||
| 89 | + ]; | ||
| 90 | + | ||
| 91 | + try { | ||
| 92 | + $res = HttpUtils::get($api_url, $params); | ||
| 93 | + $res = Arr::s2a($res); | ||
| 94 | + } catch (\Exception | GuzzleException $e) { | ||
| 95 | + errorLog('设置询盘信息已读', $params, $e); | ||
| 96 | + return false; | ||
| 97 | + } | ||
| 98 | + return $res; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * 删除询盘信息 | ||
| 103 | + * @author zbj | ||
| 104 | + * @date 2023/5/17 | ||
| 105 | + */ | ||
| 106 | + public function delInquiry($domain, $ids) | ||
| 107 | + { | ||
| 108 | + $api_url = $this->url . '/api/external-interface/del/c4b11cf6f1508489'; | ||
| 109 | + $ids = Arr::arrToSet($ids); | ||
| 110 | + $params = [ | ||
| 111 | + 'token' => md5($domain.$ids.date("Y-m-d")), | ||
| 112 | + 'domain' => $domain, | ||
| 113 | + 'id' => $ids, | ||
| 114 | + ]; | ||
| 115 | + try { | ||
| 116 | + $res = HttpUtils::get($api_url, $params); | ||
| 117 | + $res = Arr::s2a($res); | ||
| 118 | + } catch (\Exception | GuzzleException $e) { | ||
| 119 | + errorLog('删除询盘信息', $params, $e); | ||
| 120 | + return false; | ||
| 121 | + } | ||
| 122 | + return $res; | ||
| 123 | + } | ||
| 124 | +} |
| @@ -202,5 +202,34 @@ class QuanqiusouApi | @@ -202,5 +202,34 @@ class QuanqiusouApi | ||
| 202 | return $res; | 202 | return $res; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | + /** | ||
| 206 | + * 获取项目小语种信息 | ||
| 207 | + * @return array|false|int|mixed|null | ||
| 208 | + * @author zbj | ||
| 209 | + * @date 2023/5/15 | ||
| 210 | + */ | ||
| 211 | + public function getLangRankData($api_no) | ||
| 212 | + { | ||
| 213 | + $key = "quanqiusou_get_language_rank_data_{$api_no}_" . date('Y-m-d'); | ||
| 214 | + $res = Cache::get($key); | ||
| 215 | + if (!$res) { | ||
| 216 | + $api_url = $this->url . '/api/index/get_language_rank_data'; | ||
| 217 | + $param = [ | ||
| 218 | + 'apino' => $api_no, | ||
| 219 | + ]; | ||
| 220 | + try { | ||
| 221 | + $res = HttpUtils::get($api_url, $param); | ||
| 222 | + if($res){ | ||
| 223 | + $res = Arr::s2a($res); | ||
| 224 | + Cache::put($key, $res, 24 * 3600); | ||
| 225 | + } | ||
| 226 | + } catch (\Exception | GuzzleException $e) { | ||
| 227 | + errorLog('获取项目小语种数据失败', [], $e); | ||
| 228 | + return false; | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + return $res; | ||
| 232 | + } | ||
| 233 | + | ||
| 205 | 234 | ||
| 206 | } | 235 | } |
| @@ -64,7 +64,7 @@ if(!function_exists('http_post')){ | @@ -64,7 +64,7 @@ if(!function_exists('http_post')){ | ||
| 64 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | 64 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 65 | $res = curl_exec($ch); | 65 | $res = curl_exec($ch); |
| 66 | if (curl_errno($ch)) { | 66 | if (curl_errno($ch)) { |
| 67 | - Log::write(print_r(curl_errno($ch),1),'debug---1'); | 67 | + \Illuminate\Support\Facades\Log::write(print_r(curl_errno($ch),1),'debug---1'); |
| 68 | } | 68 | } |
| 69 | curl_close($ch); | 69 | curl_close($ch); |
| 70 | return json_decode($res, true); | 70 | return json_decode($res, true); |
| @@ -139,7 +139,7 @@ if (!function_exists('checkDomain')) { | @@ -139,7 +139,7 @@ if (!function_exists('checkDomain')) { | ||
| 139 | return false; | 139 | return false; |
| 140 | } | 140 | } |
| 141 | if (preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $host)) { | 141 | if (preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $host)) { |
| 142 | - return $scheme . '://' . $host; | 142 | + return $scheme . '://' . $host . '/'; |
| 143 | } else { | 143 | } else { |
| 144 | return false; | 144 | return false; |
| 145 | } | 145 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Devops; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Exceptions\AsideGlobalException; | ||
| 7 | +use App\Exceptions\BsideGlobalException; | ||
| 8 | +use App\Http\Controllers\Aside\BaseController; | ||
| 9 | +use App\Http\Logic\Aside\Devops\ServerInformationLogic; | ||
| 10 | +use App\Http\Requests\Aside\Devops\ServerInformationRequest; | ||
| 11 | +use App\Models\Devops\ServerInformation; | ||
| 12 | +use App\Models\Devops\ServerInformationLog; | ||
| 13 | +use Illuminate\Http\JsonResponse; | ||
| 14 | +use Illuminate\Http\Request; | ||
| 15 | +use Psr\Container\ContainerExceptionInterface; | ||
| 16 | +use Psr\Container\NotFoundExceptionInterface; | ||
| 17 | + | ||
| 18 | +class ServerInformationController extends BaseController | ||
| 19 | +{ | ||
| 20 | + /** | ||
| 21 | + * @return JsonResponse | ||
| 22 | + */ | ||
| 23 | + public function lists($deleted = ServerInformation::DELETED_NORMAL) | ||
| 24 | + { | ||
| 25 | + $size = request()->input('size', $this->row); | ||
| 26 | + $data = ServerInformation::query()->select(['id', 'title', 'ip']) | ||
| 27 | + ->where('deleted', $deleted) | ||
| 28 | + ->orderBy('id', 'desc') | ||
| 29 | + ->paginate($size); | ||
| 30 | + return $this->response('success', Code::SUCCESS, $data); | ||
| 31 | + | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 添加 | ||
| 36 | + * @param ServerInformationRequest $serverInformationRequest | ||
| 37 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 38 | + * @return void | ||
| 39 | + * @throws AsideGlobalException | ||
| 40 | + * @throws BsideGlobalException | ||
| 41 | + */ | ||
| 42 | + public function add(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic) | ||
| 43 | + { | ||
| 44 | + | ||
| 45 | + $serverInformationRequest->validated(); | ||
| 46 | + $serverInformationLogic->create(); | ||
| 47 | + $this->response('服务器添加成功!'); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 编辑 | ||
| 52 | + * @param ServerInformationRequest $serverInformationRequest | ||
| 53 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 54 | + * @return void | ||
| 55 | + * @throws AsideGlobalException | ||
| 56 | + * @throws BsideGlobalException | ||
| 57 | + */ | ||
| 58 | + public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic) | ||
| 59 | + { | ||
| 60 | + $serverInformationRequest->validate([ | ||
| 61 | + 'id' => ['required'], | ||
| 62 | + ], [ | ||
| 63 | + 'id.required' => 'ID不能为空', | ||
| 64 | + ]); | ||
| 65 | + $serverInformationLogic->update(); | ||
| 66 | + $this->response('服务器修改成功!'); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 删除 | ||
| 71 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 72 | + * @return void | ||
| 73 | + * @throws AsideGlobalException | ||
| 74 | + * @throws BsideGlobalException | ||
| 75 | + */ | ||
| 76 | + public function delete(ServerInformationLogic $serverInformationLogic) | ||
| 77 | + { | ||
| 78 | + $serverInformationLogic->get_batch_update(); | ||
| 79 | + $this->response('服务器删除成功!'); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 获取软删除的数据 | ||
| 84 | + * @return JsonResponse | ||
| 85 | + */ | ||
| 86 | + public function delete_list() | ||
| 87 | + { | ||
| 88 | + return $this->lists(ServerInformation::DELETED_DELETE); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 恢复数据 | ||
| 93 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 94 | + * @return void | ||
| 95 | + * @throws AsideGlobalException | ||
| 96 | + * @throws BsideGlobalException | ||
| 97 | + */ | ||
| 98 | + public function restore(ServerInformationLogic $serverInformationLogic) | ||
| 99 | + { | ||
| 100 | + $serverInformationLogic->get_batch_update(ServerInformationLog::ACTION_RECOVER, ServerInformation::DELETED_DELETE); | ||
| 101 | + $this->response('服务器恢复成功!'); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * 搜索 | ||
| 107 | + * @param Request $request | ||
| 108 | + * @return JsonResponse | ||
| 109 | + */ | ||
| 110 | + public function search(Request $request) | ||
| 111 | + { | ||
| 112 | + $search = []; | ||
| 113 | + $ip = $request->input('ip'); | ||
| 114 | + if ($ip) { | ||
| 115 | + $search['ip'] = $ip; | ||
| 116 | + } | ||
| 117 | + $remark = $request->input('title'); | ||
| 118 | + if ($remark) { | ||
| 119 | + $search['title'] = $remark; | ||
| 120 | + } | ||
| 121 | + if (empty($search)) { | ||
| 122 | + return $this->response('请输入搜索内容', Code::USER_ERROR); | ||
| 123 | + } | ||
| 124 | + $query = ServerInformation::query()->select(['id', 'title', 'ip']); | ||
| 125 | + foreach ($search as $key => $item) { | ||
| 126 | + $query = $query->Where("{$key}", 'like', "%{$item}%"); | ||
| 127 | + } | ||
| 128 | + $size = $request->input('size', $this->row); | ||
| 129 | + $query = $query->orderBy('id', 'desc')->paginate($size); | ||
| 130 | + return $this->response('success', Code::SUCCESS, $query); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * 服务器信息 | ||
| 135 | + * @param int $deleted | ||
| 136 | + * @return JsonResponse | ||
| 137 | + * @throws AsideGlobalException | ||
| 138 | + * @throws BsideGlobalException | ||
| 139 | + * @throws ContainerExceptionInterface | ||
| 140 | + * @throws NotFoundExceptionInterface | ||
| 141 | + */ | ||
| 142 | + public function getServerInfo(int $deleted = ServerInformation::DELETED_NORMAL) | ||
| 143 | + { | ||
| 144 | + $serverInformationLogic = new ServerInformationLogic(); | ||
| 145 | + $data = $serverInformationLogic->serverInfo($deleted); | ||
| 146 | + if (!$data) { | ||
| 147 | + return $this->response('服务器信息不存在', Code::USER_ERROR); | ||
| 148 | + } | ||
| 149 | + return $this->success($data->toArray()); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + /** | ||
| 153 | + * @return JsonResponse | ||
| 154 | + * @throws AsideGlobalException | ||
| 155 | + * @throws BsideGlobalException | ||
| 156 | + * @throws ContainerExceptionInterface | ||
| 157 | + * @throws NotFoundExceptionInterface | ||
| 158 | + */ | ||
| 159 | + public function getDeleteServerInfo() | ||
| 160 | + { | ||
| 161 | + return $this->getServerInfo(ServerInformation::DELETED_DELETE); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + | ||
| 165 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Devops; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Exceptions\AsideGlobalException; | ||
| 7 | +use App\Exceptions\BsideGlobalException; | ||
| 8 | +use App\Http\Controllers\Aside\BaseController; | ||
| 9 | +use App\Http\Logic\Aside\Devops\ServerInformationLogic; | ||
| 10 | +use App\Http\Requests\Aside\Devops\ServerInformationRequest; | ||
| 11 | +use App\Models\Devops\ServerInformation; | ||
| 12 | +use App\Models\Devops\ServerInformationLog; | ||
| 13 | +use Illuminate\Http\JsonResponse; | ||
| 14 | +use Illuminate\Http\Request; | ||
| 15 | +use Illuminate\Support\Facades\DB; | ||
| 16 | +use Psr\Container\ContainerExceptionInterface; | ||
| 17 | +use Psr\Container\NotFoundExceptionInterface; | ||
| 18 | + | ||
| 19 | +class ServerInformationLogController extends BaseController | ||
| 20 | +{ | ||
| 21 | + public function lists(Request $request) | ||
| 22 | + { | ||
| 23 | + $size = $request->input('size', $this->row); | ||
| 24 | + $data = ServerInformationLog::query() | ||
| 25 | + ->orderBy('id', 'desc') | ||
| 26 | + ->paginate($size); | ||
| 27 | + return $this->response('success', Code::SUCCESS, $data); | ||
| 28 | + | ||
| 29 | + } | ||
| 30 | +} |
| @@ -6,6 +6,7 @@ use App\Helper\Arr; | @@ -6,6 +6,7 @@ use App\Helper\Arr; | ||
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | use App\Http\Logic\Aside\Project\ProjectLogic; | 7 | use App\Http\Logic\Aside\Project\ProjectLogic; |
| 8 | use App\Http\Requests\Aside\Project\ProjectRequest; | 8 | use App\Http\Requests\Aside\Project\ProjectRequest; |
| 9 | +use App\Models\InquirySet; | ||
| 9 | use App\Rules\Ids; | 10 | use App\Rules\Ids; |
| 10 | use Illuminate\Http\Request; | 11 | use Illuminate\Http\Request; |
| 11 | 12 | ||
| @@ -47,4 +48,34 @@ class ProjectController extends BaseController | @@ -47,4 +48,34 @@ class ProjectController extends BaseController | ||
| 47 | $data = $logic->save($this->param); | 48 | $data = $logic->save($this->param); |
| 48 | return $this->success($data); | 49 | return $this->success($data); |
| 49 | } | 50 | } |
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 询盘通知设置 | ||
| 54 | + * @param ProjectRequest $request | ||
| 55 | + * @param ProjectLogic $logic | ||
| 56 | + * @return \Illuminate\Http\JsonResponse | ||
| 57 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 58 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 59 | + * @author zbj | ||
| 60 | + * @date 2023/5/17 | ||
| 61 | + */ | ||
| 62 | + public function inquiry_set(Request $request, ProjectLogic $logic){ | ||
| 63 | + $request->validate([ | ||
| 64 | + 'project_id'=>'required' | ||
| 65 | + ],[ | ||
| 66 | + 'project_id.required' => '项目ID不能为空' | ||
| 67 | + ]); | ||
| 68 | + if($request->isMethod('get')){ | ||
| 69 | + $data = InquirySet::where('project_id', $request->project_id)->first(); | ||
| 70 | + if(!$data){ | ||
| 71 | + $data = ['emails' => '', 'phones' => '']; | ||
| 72 | + }else{ | ||
| 73 | + $data = $data->toArray(); | ||
| 74 | + } | ||
| 75 | + return $this->success($data); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + $data = $logic->saveInquirySet($this->param); | ||
| 79 | + return $this->success($data); | ||
| 80 | + } | ||
| 50 | } | 81 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Template; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Aside\BaseController; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 模板header footer | ||
| 9 | + * @author:dc | ||
| 10 | + * @time 2023/4/26 11:10 | ||
| 11 | + * Class HeaderFooterController | ||
| 12 | + * @package App\Http\Controllers\Aside\Template | ||
| 13 | + */ | ||
| 14 | +class HeaderFooterController extends BaseController | ||
| 15 | +{ | ||
| 16 | + | ||
| 17 | +} |
| @@ -7,7 +7,7 @@ use App\Helper\AyrShare as AyrShareHelper; | @@ -7,7 +7,7 @@ use App\Helper\AyrShare as AyrShareHelper; | ||
| 7 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; | 8 | use App\Http\Logic\Bside\AyrShare\AyrReleaseLogic; |
| 9 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; | 9 | use App\Http\Logic\Bside\AyrShare\AyrShareLogic; |
| 10 | -use App\Http\Requests\Bside\AyrRelease\AyrReleaseRequest; | 10 | +use App\Http\Requests\Bside\AyrShare\AyrReleaseRequest; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | * @name:社交发布 | 13 | * @name:社交发布 |
| @@ -34,7 +34,7 @@ class AyrReleaseController extends BaseController | @@ -34,7 +34,7 @@ class AyrReleaseController extends BaseController | ||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | - * @name :(获取当前用户已绑定的社交链接)info | 37 | + * @name :(获取当前用户已绑定的社交链接) |
| 38 | * @author :lyh | 38 | * @author :lyh |
| 39 | * @method :post | 39 | * @method :post |
| 40 | * @time :2023/5/9 16:00 | 40 | * @time :2023/5/9 16:00 |
| @@ -43,9 +43,9 @@ class AyrReleaseController extends BaseController | @@ -43,9 +43,9 @@ class AyrReleaseController extends BaseController | ||
| 43 | $this->request->validate([ | 43 | $this->request->validate([ |
| 44 | 'share_id'=>['required'] | 44 | 'share_id'=>['required'] |
| 45 | ],[ | 45 | ],[ |
| 46 | - 'share_id.required' => 'SHARE_ID不能为空' | 46 | + 'share_id.required' => 'share_id不能为空' |
| 47 | ]); | 47 | ]); |
| 48 | - $info = $ayrShareLogic->ayr_share_info(); | 48 | + $info = $ayrShareLogic->ayr_share_info($this->param['share_id']); |
| 49 | $this->response('success',Code::SUCCESS,$info); | 49 | $this->response('success',Code::SUCCESS,$info); |
| 50 | } | 50 | } |
| 51 | /** | 51 | /** |
| @@ -58,27 +58,32 @@ class AyrReleaseController extends BaseController | @@ -58,27 +58,32 @@ class AyrReleaseController extends BaseController | ||
| 58 | AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ | 58 | AyrShareLogic $ayrShareLogic,AyrShareHelper $ayrShare){ |
| 59 | $ayrReleaseRequest->validated(); | 59 | $ayrReleaseRequest->validated(); |
| 60 | //获取发送账号详情 | 60 | //获取发送账号详情 |
| 61 | - $share_info = $ayrShareLogic->ayr_share_info(); | 61 | + $share_info = $ayrShareLogic->ayr_share_info($this->param['share_id']); |
| 62 | //验证发送平台 | 62 | //验证发送平台 |
| 63 | $ayrShareLogic->verify_param($share_info); | 63 | $ayrShareLogic->verify_param($share_info); |
| 64 | - $data = [ | ||
| 65 | - 'images'=>$this->param['images'], | ||
| 66 | - 'files'=>$this->param['video'], | ||
| 67 | - ]; | 64 | + if(isset($this->param['video']) && !empty($this->param['video'])){ |
| 65 | + $data['files'] = $this->param['video']; | ||
| 66 | + } | ||
| 67 | + if(isset($this->param['images']) && !empty($this->param['images'])){ | ||
| 68 | + $data['images'] = $this->param['images']; | ||
| 69 | + } | ||
| 68 | //参数处理 | 70 | //参数处理 |
| 69 | - $this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);; | 71 | + $this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data); |
| 72 | + //时间处理 | ||
| 73 | + $datetime = new \DateTime($this->param['schedule_date']); | ||
| 74 | + $formattedTime = $datetime->format("Y-m-d\TH:i:s\Z"); | ||
| 70 | //统一生成发布 | 75 | //统一生成发布 |
| 71 | $param = [ | 76 | $param = [ |
| 72 | 'post'=>$this->param['content'], | 77 | 'post'=>$this->param['content'], |
| 73 | 'platforms'=>$this->param['platforms'], | 78 | 'platforms'=>$this->param['platforms'], |
| 74 | 'mediaUrls'=>$this->param['mediaUrls'],//参数处理 | 79 | 'mediaUrls'=>$this->param['mediaUrls'],//参数处理 |
| 75 | - 'idempotencyKey'=>$this->param['idempotency_key'],//时间(如是过去时间,立即发布) | 80 | + 'scheduleDate'=>$formattedTime,//时间(如是过去时间,立即发布) |
| 76 | ]; | 81 | ]; |
| 77 | //发送请求发布社交文章 | 82 | //发送请求发布社交文章 |
| 78 | $res = $ayrShare->post_send_msg($param,$share_info['profile_key']); | 83 | $res = $ayrShare->post_send_msg($param,$share_info['profile_key']); |
| 79 | //保存数据库 | 84 | //保存数据库 |
| 80 | $ayrReleaseLogic->release_add(); | 85 | $ayrReleaseLogic->release_add(); |
| 81 | - $this->response('success',Code::SUCCESS,$res); | 86 | + $this->response('success',Code::SUCCESS,json_decode($res)); |
| 82 | } | 87 | } |
| 83 | 88 | ||
| 84 | /** | 89 | /** |
| @@ -95,19 +100,16 @@ class AyrReleaseController extends BaseController | @@ -95,19 +100,16 @@ class AyrReleaseController extends BaseController | ||
| 95 | 'share_id.required' => 'SHARE_ID不能为空', | 100 | 'share_id.required' => 'SHARE_ID不能为空', |
| 96 | 'hash.required' => 'HASH不能为空' | 101 | 'hash.required' => 'HASH不能为空' |
| 97 | ]); | 102 | ]); |
| 98 | - $image_info = $ayrShareLogic->save_img_info($this->param['hash']); | ||
| 99 | - if(empty($image_info['ayr_id'])){ | ||
| 100 | - //获取发送账号详情 | ||
| 101 | - $share_info = $ayrShareLogic->ayr_share_info(); | ||
| 102 | - //向第三方存储图片 | ||
| 103 | - $param = [ | ||
| 104 | - 'file'=>$ayrShareLogic->base_img_content($this->param['hash']),//base64编码 | ||
| 105 | - ]; | ||
| 106 | - $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); | ||
| 107 | - //更新图片库 | ||
| 108 | - $ayrShareLogic->save_img($param_data); | ||
| 109 | - } | ||
| 110 | - $this->response('success',Code::SUCCESS,$image_info); | 103 | + //获取发送账号详情 |
| 104 | + $share_info = $ayrShareLogic->ayr_share_info(); | ||
| 105 | + //向第三方存储图片 | ||
| 106 | + $param = [ | ||
| 107 | + 'file'=>$ayrShareLogic->base_img_content($this->param['hash']),//base64编码 | ||
| 108 | + ]; | ||
| 109 | + $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); | ||
| 110 | + //更新图片库 | ||
| 111 | + $ayrShareLogic->save_img($param_data); | ||
| 112 | + $this->response('success',Code::SUCCESS,$param_data); | ||
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | /** | 115 | /** |
| @@ -124,18 +126,15 @@ class AyrReleaseController extends BaseController | @@ -124,18 +126,15 @@ class AyrReleaseController extends BaseController | ||
| 124 | 'share_id.required' => 'SHARE_ID不能为空', | 126 | 'share_id.required' => 'SHARE_ID不能为空', |
| 125 | 'hash.required' => 'HASH不能为空' | 127 | 'hash.required' => 'HASH不能为空' |
| 126 | ]); | 128 | ]); |
| 127 | - $image_info = $ayrShareLogic->save_file_info($this->param['hash']); | ||
| 128 | - if(empty($image_info['ayr_id'])){ | ||
| 129 | - //获取发送账号详情 | ||
| 130 | - $share_info = $ayrShareLogic->ayr_share_info(); | ||
| 131 | - //向第三方存储图片 | ||
| 132 | - $param = [ | ||
| 133 | - 'file'=>$ayrShareLogic->base_img_content($this->param['hash']),//base64编码 | ||
| 134 | - ]; | ||
| 135 | - $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); | ||
| 136 | - //更新图片库 | ||
| 137 | - $ayrShareLogic->save_file($param_data); | ||
| 138 | - } | 129 | + //获取发送账号详情 |
| 130 | + $share_info = $ayrShareLogic->ayr_share_info(); | ||
| 131 | + //向第三方存储图片 | ||
| 132 | + $param = [ | ||
| 133 | + 'file'=>$ayrShareLogic->base_img_content($this->param['hash']),//base64编码 | ||
| 134 | + ]; | ||
| 135 | + $param_data = $ayrShare->post_media_upload($param,$share_info['profile_key']); | ||
| 136 | + //更新图片库 | ||
| 137 | + $ayrShareLogic->save_file($param_data); | ||
| 139 | $this->response('success'); | 138 | $this->response('success'); |
| 140 | } | 139 | } |
| 141 | } | 140 | } |
| @@ -40,7 +40,7 @@ class AyrShareController extends BaseController | @@ -40,7 +40,7 @@ class AyrShareController extends BaseController | ||
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | - $lists['list']['share_list'] = $share_list; | 43 | + $lists['share_list'] = $share_list; |
| 44 | $this->response('列表',Code::SUCCESS,$lists); | 44 | $this->response('列表',Code::SUCCESS,$lists); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| @@ -52,9 +52,9 @@ class AyrShareController extends BaseController | @@ -52,9 +52,9 @@ class AyrShareController extends BaseController | ||
| 52 | */ | 52 | */ |
| 53 | public function save_account(AyrShareLogic $ayrShareLogic){ | 53 | public function save_account(AyrShareLogic $ayrShareLogic){ |
| 54 | $this->request->validate([ | 54 | $this->request->validate([ |
| 55 | - 'share_id'=>['required'], | 55 | + 'id'=>['required'], |
| 56 | ],[ | 56 | ],[ |
| 57 | - 'share_id.required' => 'SHARE_ID不能为空', | 57 | + 'id.required' => 'ID不能为空', |
| 58 | ]); | 58 | ]); |
| 59 | $info = $ayrShareLogic->ayr_share_info(); | 59 | $info = $ayrShareLogic->ayr_share_info(); |
| 60 | $ayrShareHelper = new AyrShareHelper(); | 60 | $ayrShareHelper = new AyrShareHelper(); |
| @@ -62,12 +62,14 @@ class AyrShareController extends BaseController | @@ -62,12 +62,14 @@ class AyrShareController extends BaseController | ||
| 62 | if(isset($share_info['activeSocialAccounts'])){ | 62 | if(isset($share_info['activeSocialAccounts'])){ |
| 63 | $str = json_encode($share_info['activeSocialAccounts']); | 63 | $str = json_encode($share_info['activeSocialAccounts']); |
| 64 | if($str != $info['bind_platforms']){ | 64 | if($str != $info['bind_platforms']){ |
| 65 | - $res = $ayrShareLogic->ayr_share_edit(['bind_platforms'=>$str],$this->param['share_id']); | 65 | + $ayrShareLogic->ayr_share_edit(['bind_platforms'=>$str],$this->param['id']); |
| 66 | + $res = true; | ||
| 66 | }else{ | 67 | }else{ |
| 67 | $res = false; | 68 | $res = false; |
| 68 | } | 69 | } |
| 69 | }else{ | 70 | }else{ |
| 70 | - $res = $ayrShareLogic->ayr_share_edit(['bind_platforms'=>''],$this->param['share_id']); | 71 | + $ayrShareLogic->ayr_share_edit(['bind_platforms'=>''],$this->param['id']); |
| 72 | + $res = true; | ||
| 71 | } | 73 | } |
| 72 | $this->response('success',Code::SUCCESS,['is_true'=>$res]); | 74 | $this->response('success',Code::SUCCESS,['is_true'=>$res]); |
| 73 | } | 75 | } |
| @@ -107,7 +109,7 @@ class AyrShareController extends BaseController | @@ -107,7 +109,7 @@ class AyrShareController extends BaseController | ||
| 107 | ]); | 109 | ]); |
| 108 | $info = $ayrShareLogic->ayr_share_info(); | 110 | $info = $ayrShareLogic->ayr_share_info(); |
| 109 | $data = [ | 111 | $data = [ |
| 110 | - 'title'=>$info['title'], | 112 | +// 'title'=>$info['title'], |
| 111 | 'profileKey'=>$info['profile_key'] | 113 | 'profileKey'=>$info['profile_key'] |
| 112 | ]; | 114 | ]; |
| 113 | //发送请求删除社交用户 | 115 | //发送请求删除社交用户 |
| @@ -3,12 +3,16 @@ | @@ -3,12 +3,16 @@ | ||
| 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\AyrShare as AyrShareHelper; | ||
| 6 | use App\Helper\Country; | 7 | use App\Helper\Country; |
| 8 | +use App\Models\AyrShare\AyrRelease as AyrReleaseModel; | ||
| 9 | +use App\Models\AyrShare\AyrShare as AyrShareModel; | ||
| 7 | use App\Models\Project\Project; | 10 | use App\Models\Project\Project; |
| 8 | use App\Models\Project\Project as ProjectModel; | 11 | use App\Models\Project\Project as ProjectModel; |
| 9 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 12 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 10 | use App\Models\User\ProjectRole as ProjectRoleModel; | 13 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 11 | use App\Models\User\User as UserModel; | 14 | use App\Models\User\User as UserModel; |
| 15 | +use Carbon\Carbon; | ||
| 12 | use Illuminate\Http\Request; | 16 | use Illuminate\Http\Request; |
| 13 | use Illuminate\Support\Facades\Cache; | 17 | use Illuminate\Support\Facades\Cache; |
| 14 | 18 | ||
| @@ -116,8 +120,60 @@ class ComController extends BaseController | @@ -116,8 +120,60 @@ class ComController extends BaseController | ||
| 116 | $this->response('success'); | 120 | $this->response('success'); |
| 117 | } | 121 | } |
| 118 | 122 | ||
| 119 | - public function get_country(){ | ||
| 120 | - $country = new Country(); | ||
| 121 | - return $country->set_country(); | ||
| 122 | - } | 123 | + |
| 124 | + /** | ||
| 125 | + * @name : (测试定时任务)检测用户是否无操作记录 | ||
| 126 | + * @author :lyh | ||
| 127 | + * @method :post | ||
| 128 | + * @time :2023/5/12 14:55 | ||
| 129 | + */ | ||
| 130 | +// protected function ceShi(){ | ||
| 131 | +// $this->error = 0; | ||
| 132 | +// //获取所有ayr_share用户 | ||
| 133 | +// $ayr_share_model = new AyrShareModel(); | ||
| 134 | +// $ayr_share_list = $ayr_share_model->list($this->map); | ||
| 135 | +// if(!empty($ayr_share_list)){ | ||
| 136 | +// foreach ($ayr_share_list as $k => $v){ | ||
| 137 | +// //查询当前用户是否有未推送的博文 | ||
| 138 | +// $ayr_release = new AyrReleaseModel(); | ||
| 139 | +// $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]); | ||
| 140 | +// //有推文时,直接跳出循环 | ||
| 141 | +// if($release_info !== false){ | ||
| 142 | +// continue; | ||
| 143 | +// } | ||
| 144 | +// //查看用户是否在一周内有发送博客 | ||
| 145 | +// $start_at = Carbon::now()->modify('-7 days')->toDateString(); | ||
| 146 | +// $end_at = Carbon::now()->toDateString(); | ||
| 147 | +// $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]); | ||
| 148 | +// //有发送博文,则跳出循环 | ||
| 149 | +// if($release_info == false){ | ||
| 150 | +// continue; | ||
| 151 | +// } | ||
| 152 | +// //删除用户第三方配置 | ||
| 153 | +// $ayr_share_helper = new AyrShareHelper(); | ||
| 154 | +// $data_profiles = [ | ||
| 155 | +// 'title'=>$v['title'], | ||
| 156 | +// 'profileKey'=>$v['profile_key'] | ||
| 157 | +// ]; | ||
| 158 | +// $res = $ayr_share_helper->deleted_profiles($data_profiles); | ||
| 159 | +// if($res['status'] == 'fail'){ | ||
| 160 | +// $this->error++; | ||
| 161 | +// continue; | ||
| 162 | +// } | ||
| 163 | +// //更新数据库 | ||
| 164 | +// $data = [ | ||
| 165 | +// 'title'=>null, | ||
| 166 | +// 'bind_plat_from'=>null, | ||
| 167 | +// 'profile_key'=>null, | ||
| 168 | +// 'ref_id'=>null, | ||
| 169 | +// ]; | ||
| 170 | +// $res = $ayr_share_model->edit($data,['id'=>$v['id']]); | ||
| 171 | +// if($res == false){ | ||
| 172 | +// $this->error++; | ||
| 173 | +// } | ||
| 174 | +// } | ||
| 175 | +// } | ||
| 176 | +// return $this->error; | ||
| 177 | +// } | ||
| 178 | + | ||
| 123 | } | 179 | } |
| @@ -2,16 +2,12 @@ | @@ -2,16 +2,12 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | namespace App\Http\Controllers\Bside; |
| 4 | 4 | ||
| 5 | -use App\Exceptions\BsideGlobalException; | ||
| 6 | -use App\Helper\Arr; | 5 | + |
| 7 | use App\Http\Logic\Bside\InquiryLogic; | 6 | use App\Http\Logic\Bside\InquiryLogic; |
| 8 | -use App\Http\Requests\Bside\InquiryRequest; | ||
| 9 | use App\Rules\Ids; | 7 | use App\Rules\Ids; |
| 10 | use App\Services\BatchExportService; | 8 | use App\Services\BatchExportService; |
| 11 | use Illuminate\Http\Request; | 9 | use Illuminate\Http\Request; |
| 12 | use Illuminate\Support\Facades\Storage; | 10 | use Illuminate\Support\Facades\Storage; |
| 13 | -use Illuminate\Validation\ValidationException; | ||
| 14 | -use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; | ||
| 15 | 11 | ||
| 16 | /** | 12 | /** |
| 17 | * 精准询盘 | 13 | * 精准询盘 |
| @@ -25,23 +21,18 @@ class InquiryController extends BaseController | @@ -25,23 +21,18 @@ class InquiryController extends BaseController | ||
| 25 | 21 | ||
| 26 | public function index(InquiryLogic $logic) | 22 | public function index(InquiryLogic $logic) |
| 27 | { | 23 | { |
| 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']); | 24 | + $data = $logic->getApiList(); |
| 34 | return $this->success($data); | 25 | return $this->success($data); |
| 35 | } | 26 | } |
| 36 | 27 | ||
| 37 | public function info(Request $request, InquiryLogic $logic){ | 28 | public function info(Request $request, InquiryLogic $logic){ |
| 38 | $request->validate([ | 29 | $request->validate([ |
| 39 | - 'id'=>'required' | 30 | + 'id' => 'required', |
| 40 | ],[ | 31 | ],[ |
| 41 | 'id.required' => 'ID不能为空' | 32 | 'id.required' => 'ID不能为空' |
| 42 | ]); | 33 | ]); |
| 43 | $data = $logic->getInfo($this->param['id']); | 34 | $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'])); | 35 | + return $this->success($data); |
| 45 | } | 36 | } |
| 46 | 37 | ||
| 47 | public function delete(Request $request, InquiryLogic $logic) | 38 | public function delete(Request $request, InquiryLogic $logic) |
| @@ -52,8 +43,8 @@ class InquiryController extends BaseController | @@ -52,8 +43,8 @@ class InquiryController extends BaseController | ||
| 52 | 'ids.required' => 'ID不能为空' | 43 | 'ids.required' => 'ID不能为空' |
| 53 | ]); | 44 | ]); |
| 54 | 45 | ||
| 55 | - $data = $logic->delete($this->param['ids']); | ||
| 56 | - return $this->success($data); | 46 | + $logic->delete($this->param['ids']); |
| 47 | + return $this->success(); | ||
| 57 | } | 48 | } |
| 58 | 49 | ||
| 59 | /** | 50 | /** |
| @@ -66,22 +57,20 @@ class InquiryController extends BaseController | @@ -66,22 +57,20 @@ class InquiryController extends BaseController | ||
| 66 | */ | 57 | */ |
| 67 | public function export(InquiryLogic $logic) | 58 | public function export(InquiryLogic $logic) |
| 68 | { | 59 | { |
| 69 | - $sort = ['id' => 'desc']; | ||
| 70 | - //最多到1w条 | ||
| 71 | - $data = $logic->getList([], $sort, ['name', 'email', 'phone', 'url', 'ip', 'ip_country', 'content', 'created_at'], 10000); | 60 | + $data = $logic->getApiList(true); |
| 72 | $data = $data['list'] ?? []; | 61 | $data = $data['list'] ?? []; |
| 73 | foreach ($data as &$item){ | 62 | foreach ($data as &$item){ |
| 74 | - $item['ip_address'] = "{$item['ip_country']}({$item['ip']})"; | 63 | + $item['ip_address'] = "{$item['country']}({$item['ip']})"; |
| 75 | } | 64 | } |
| 76 | 65 | ||
| 77 | $map = [ | 66 | $map = [ |
| 78 | - 'created_at' => '询盘发送时间', | 67 | + 'submit_time' => '询盘发送时间', |
| 79 | 'name' => '姓名', | 68 | 'name' => '姓名', |
| 80 | 'email' => '邮箱', | 69 | 'email' => '邮箱', |
| 81 | 'phone' => '电话', | 70 | 'phone' => '电话', |
| 82 | 'ip_address' => '访问国家/地区(IP)', | 71 | 'ip_address' => '访问国家/地区(IP)', |
| 83 | - 'url' => '发送页面', | ||
| 84 | - 'content' => '询盘内容', | 72 | + 'refer' => '发送页面', |
| 73 | + 'message' => '询盘内容', | ||
| 85 | ]; | 74 | ]; |
| 86 | 75 | ||
| 87 | //生成文件,发送到客户端 | 76 | //生成文件,发送到客户端 |
| @@ -25,13 +25,7 @@ class CategoryController extends BaseController | @@ -25,13 +25,7 @@ class CategoryController 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', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); | ||
| 29 | - foreach ($data as &$v){ | ||
| 30 | - $v['product_num'] = $logic->getProductNum($v['id']); | ||
| 31 | - } | ||
| 32 | - if(!$map){ | ||
| 33 | - $data = Arr::listToTree($data); | ||
| 34 | - } | 28 | + $data = $logic->getList($map, $sort, ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); |
| 35 | return $this->success($data); | 29 | return $this->success($data); |
| 36 | } | 30 | } |
| 37 | 31 | ||
| @@ -42,7 +36,7 @@ class CategoryController extends BaseController | @@ -42,7 +36,7 @@ class CategoryController extends BaseController | ||
| 42 | 'id.required' => 'ID不能为空' | 36 | 'id.required' => 'ID不能为空' |
| 43 | ]); | 37 | ]); |
| 44 | $data = $logic->getInfo($this->param['id']); | 38 | $data = $logic->getInfo($this->param['id']); |
| 45 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status'])); | 39 | + return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'pid', 'title', 'image', 'keywords', 'describe', 'status', 'route', 'url'])); |
| 46 | } | 40 | } |
| 47 | 41 | ||
| 48 | public function save(CategoryRequest $request, CategoryLogic $logic) | 42 | public function save(CategoryRequest $request, CategoryLogic $logic) |
| @@ -26,13 +26,7 @@ class KeywordController extends BaseController | @@ -26,13 +26,7 @@ class KeywordController extends BaseController | ||
| 26 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; | 26 | $map[] = ['title', 'like', "%{$this->param['search']}%"]; |
| 27 | } | 27 | } |
| 28 | $sort = ['id' => 'desc']; | 28 | $sort = ['id' => 'desc']; |
| 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 | + $data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at']); |
| 36 | return $this->success($data); | 30 | return $this->success($data); |
| 37 | } | 31 | } |
| 38 | 32 | ||
| @@ -43,7 +37,7 @@ class KeywordController extends BaseController | @@ -43,7 +37,7 @@ class KeywordController extends BaseController | ||
| 43 | 'id.required' => 'ID不能为空' | 37 | 'id.required' => 'ID不能为空' |
| 44 | ]); | 38 | ]); |
| 45 | $data = $logic->getInfo($this->param['id']); | 39 | $data = $logic->getInfo($this->param['id']); |
| 46 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at'])); | 40 | + return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'created_at', 'route', 'url'])); |
| 47 | } | 41 | } |
| 48 | 42 | ||
| 49 | public function save(KeywordRequest $request, KeywordLogic $logic) | 43 | public function save(KeywordRequest $request, KeywordLogic $logic) |
| @@ -55,7 +55,7 @@ class ProductController extends BaseController | @@ -55,7 +55,7 @@ class ProductController extends BaseController | ||
| 55 | $map[] = ['status', $this->param['status']]; | 55 | $map[] = ['status', $this->param['status']]; |
| 56 | } | 56 | } |
| 57 | $sort = ['id' => 'desc']; | 57 | $sort = ['id' => 'desc']; |
| 58 | - $data = $logic->getList($map, $sort, ['id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']); | 58 | + $data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']); |
| 59 | return $this->success($data); | 59 | return $this->success($data); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| @@ -66,8 +66,8 @@ class ProductController extends BaseController | @@ -66,8 +66,8 @@ class ProductController extends BaseController | ||
| 66 | 'id.required' => 'ID不能为空' | 66 | 'id.required' => 'ID不能为空' |
| 67 | ]); | 67 | ]); |
| 68 | $data = $logic->getInfo($this->param['id']); | 68 | $data = $logic->getInfo($this->param['id']); |
| 69 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content', | ||
| 70 | - 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route'])); | 69 | + return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content', |
| 70 | + 'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route', 'url'])); | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | public function save(ProductRequest $request, ProductLogic $logic) | 73 | public function save(ProductRequest $request, ProductLogic $logic) |
| @@ -3,12 +3,17 @@ | @@ -3,12 +3,17 @@ | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | namespace App\Http\Controllers\Bside; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use App\Helper\Arr; | ||
| 6 | use App\Helper\GoogleSpeedApi; | 7 | use App\Helper\GoogleSpeedApi; |
| 7 | use App\Helper\QuanqiusouApi; | 8 | use App\Helper\QuanqiusouApi; |
| 8 | use App\Http\Logic\Aside\Project\ProjectLogic; | 9 | use App\Http\Logic\Aside\Project\ProjectLogic; |
| 9 | use App\Http\Logic\Bside\RankDataLogic; | 10 | use App\Http\Logic\Bside\RankDataLogic; |
| 11 | +use App\Models\RankData\RankData; | ||
| 10 | use App\Models\RankData\Speed as GoogleSpeedModel; | 12 | use App\Models\RankData\Speed as GoogleSpeedModel; |
| 11 | use App\Services\BatchExportService; | 13 | use App\Services\BatchExportService; |
| 14 | +use App\Utils\HttpUtils; | ||
| 15 | +use GuzzleHttp\Client; | ||
| 16 | +use GuzzleHttp\Promise\Utils; | ||
| 12 | use Illuminate\Support\Facades\Storage; | 17 | use Illuminate\Support\Facades\Storage; |
| 13 | 18 | ||
| 14 | /** | 19 | /** |
| @@ -70,14 +75,23 @@ class RankDataController extends BaseController | @@ -70,14 +75,23 @@ class RankDataController extends BaseController | ||
| 70 | * @date 2023/5/15 | 75 | * @date 2023/5/15 |
| 71 | */ | 76 | */ |
| 72 | public function export(RankDataLogic $logic){ | 77 | public function export(RankDataLogic $logic){ |
| 78 | + $lang = $this->request['lang'] ??''; | ||
| 73 | $data = $logic->keywords_rank_list(true); | 79 | $data = $logic->keywords_rank_list(true); |
| 80 | + $img_position = $video_position= false; | ||
| 74 | foreach ($data as &$item){ | 81 | foreach ($data as &$item){ |
| 75 | - $item['domain'] = explode(':', $item['domain'])[1]; | ||
| 76 | $item['lang'] = $this->request['lang'] ?: 'en'; | 82 | $item['lang'] = $this->request['lang'] ?: 'en'; |
| 77 | - $item['g_text'] = $item['g'] == 1 ? '主关键词' : '拓展关键词'; | 83 | + $item['g_text'] = RankData::gMap()[$item['g']]??''; |
| 84 | + $item['img_position'] = $item['img_position'] ?? ''; | ||
| 85 | + $item['video_position'] = $item['video_position'] ?? ''; | ||
| 78 | foreach ($item['position'] as $date => $position){ | 86 | foreach ($item['position'] as $date => $position){ |
| 79 | $item[$date] = $position; | 87 | $item[$date] = $position; |
| 80 | } | 88 | } |
| 89 | + if(!empty($item['img_position'])){ | ||
| 90 | + $img_position = true; | ||
| 91 | + } | ||
| 92 | + if(!empty($item['video_position'])){ | ||
| 93 | + $video_position = true; | ||
| 94 | + } | ||
| 81 | } | 95 | } |
| 82 | 96 | ||
| 83 | $map = [ | 97 | $map = [ |
| @@ -89,9 +103,11 @@ class RankDataController extends BaseController | @@ -89,9 +103,11 @@ class RankDataController extends BaseController | ||
| 89 | foreach ($data[0]['position'] as $date => $position){ | 103 | foreach ($data[0]['position'] as $date => $position){ |
| 90 | $map[$date] = $date; | 104 | $map[$date] = $date; |
| 91 | } | 105 | } |
| 106 | + $img_position && $map['img_position'] = '图片'; | ||
| 107 | + $video_position && $map['video_position'] = '视频'; | ||
| 92 | 108 | ||
| 93 | //生成文件,发送到客户端 | 109 | //生成文件,发送到客户端 |
| 94 | - $table = new BatchExportService("关键词数据导出"); | 110 | + $table = new BatchExportService($lang . "关键词数据导出"); |
| 95 | $file = $table->head($map)->data($data)->save(); | 111 | $file = $table->head($map)->data($data)->save(); |
| 96 | if (!$file) { | 112 | if (!$file) { |
| 97 | throw new \Exception('文件生成失败,请重试'); | 113 | throw new \Exception('文件生成失败,请重试'); |
| @@ -102,7 +118,7 @@ class RankDataController extends BaseController | @@ -102,7 +118,7 @@ class RankDataController extends BaseController | ||
| 102 | } | 118 | } |
| 103 | 119 | ||
| 104 | /** | 120 | /** |
| 105 | - * 数据导出 | 121 | + * 历史数据导出 |
| 106 | * @author zbj | 122 | * @author zbj |
| 107 | * @date 2023/5/15 | 123 | * @date 2023/5/15 |
| 108 | */ | 124 | */ |
| @@ -148,4 +164,56 @@ class RankDataController extends BaseController | @@ -148,4 +164,56 @@ class RankDataController extends BaseController | ||
| 148 | // return Storage::disk('runtime')->download($file); //直接下载 | 164 | // return Storage::disk('runtime')->download($file); //直接下载 |
| 149 | return $this->success(['url' => $fileurl]); | 165 | return $this->success(['url' => $fileurl]); |
| 150 | } | 166 | } |
| 167 | + | ||
| 168 | + /** | ||
| 169 | + * 实时获取关键词排名 | ||
| 170 | + * @author zbj | ||
| 171 | + * @date 2023/5/16 | ||
| 172 | + */ | ||
| 173 | + public function get_google_rank(){ | ||
| 174 | + $url_arr = parse_url($this->request['url']); | ||
| 175 | + $param = [ | ||
| 176 | + 'keyword' => trim($this->request['keyword']), | ||
| 177 | + 'url' => $url_arr['host'] ?? $url_arr['path'], | ||
| 178 | + 'extend_urls' => $this->request['extend_urls'], | ||
| 179 | + 'lang' => $this->request['lang'], | ||
| 180 | + 'use_groups' => 2 | ||
| 181 | + ]; | ||
| 182 | + | ||
| 183 | + | ||
| 184 | + if ($this->request['w']) { | ||
| 185 | + $data = [ | ||
| 186 | + 'position' => 0, | ||
| 187 | + 'image_position' => 0, | ||
| 188 | + 'video_position' => 0, | ||
| 189 | + ]; | ||
| 190 | + $client = new Client([ | ||
| 191 | + 'base_uri' => 'http://45.136.131.71:8000', | ||
| 192 | + 'timeout' => '20' | ||
| 193 | + ]); | ||
| 194 | + | ||
| 195 | + $promises['position'] = $client->getAsync('/luminati_rank?'.Arr::query($param)); | ||
| 196 | + $promises['image_position'] = $client->getAsync('/google_image?'.Arr::query($param)); | ||
| 197 | + $promises['video_position'] = $client->getAsync('/google_video?'.Arr::query($param)); | ||
| 198 | + | ||
| 199 | + // 等待所有请求响应完成 | ||
| 200 | + $results = Utils::settle($promises)->wait(); | ||
| 201 | + foreach ($results as $key => $result) { | ||
| 202 | + if ($result['state'] == 'fulfilled') { | ||
| 203 | + $res = Arr::s2a($result['value']->getBody()->getContents()); | ||
| 204 | + $data[$key] = $res['position'] ?? 0; | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + }else{ | ||
| 208 | + $data = [ | ||
| 209 | + 'position' => 0, | ||
| 210 | + ]; | ||
| 211 | + $res = HttpUtils::get('http://45.136.131.71:8000/luminati_rank', $param); | ||
| 212 | + if ($res) { | ||
| 213 | + $res = Arr::s2a($res); | ||
| 214 | + $data['position'] = $res['position']; | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | + return $this->success($data); | ||
| 218 | + } | ||
| 151 | } | 219 | } |
| @@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController | @@ -29,7 +29,7 @@ class WebSettingReceivingController extends BaseController | ||
| 29 | * @time :2023/5/8 16:23 | 29 | * @time :2023/5/8 16:23 |
| 30 | */ | 30 | */ |
| 31 | public function save(WebSettingReceivingLogic $webSettingReceivingLogic){ | 31 | public function save(WebSettingReceivingLogic $webSettingReceivingLogic){ |
| 32 | - $lists = $webSettingReceivingLogic->setting_receiving_save(); | 32 | + $webSettingReceivingLogic->setting_receiving_save(); |
| 33 | $this->response('success'); | 33 | $this->response('success'); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Template; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Bside\BaseController; | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 模板header footer | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/4/26 11:10 | ||
| 12 | + * Class HeaderFooterController | ||
| 13 | + * @package App\Http\Controllers\Bside\Template | ||
| 14 | + */ | ||
| 15 | +class HeaderFooterController extends BaseController | ||
| 16 | +{ | ||
| 17 | + | ||
| 18 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\User; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Bside\BaseController; | ||
| 7 | +use App\Http\Logic\Bside\User\DeptUserLogic; | ||
| 8 | +use App\Models\User\ViewDeptUser; | ||
| 9 | + | ||
| 10 | +class DeptUserController extends BaseController | ||
| 11 | +{ | ||
| 12 | + /** | ||
| 13 | + * @name :name | ||
| 14 | + * @return void | ||
| 15 | + * @author :liyuhang | ||
| 16 | + * @method | ||
| 17 | + */ | ||
| 18 | + public function lists(ViewDeptUser $viewDeptUser){ | ||
| 19 | + $this->map['project_id'] = $this->user['project_id']; | ||
| 20 | + $lists = $viewDeptUser->lists($this->map,$this->page,$this->row,'user_id'); | ||
| 21 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 22 | + } | ||
| 23 | + /** | ||
| 24 | + * @param ViewDeptUser $viewDeptUser | ||
| 25 | + * @name :(详情)info | ||
| 26 | + * @author :lyh | ||
| 27 | + * @method :post | ||
| 28 | + * @time :2023/5/18 9:32 | ||
| 29 | + */ | ||
| 30 | + public function info(ViewDeptUser $viewDeptUser){ | ||
| 31 | + $this->request->validate([ | ||
| 32 | + 'id'=>['required'] | ||
| 33 | + ],[ | ||
| 34 | + 'id.required' => 'id不能为空' | ||
| 35 | + ]); | ||
| 36 | + $info = $viewDeptUser->read($this->param); | ||
| 37 | + $this->response('success',Code::SUCCESS,$info); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * @name :(部门添加与更新用户)add | ||
| 42 | + * @author :lyh | ||
| 43 | + * @method :post | ||
| 44 | + * @time :2023/5/17 17:36 | ||
| 45 | + */ | ||
| 46 | + public function save(DeptUserLogic $deptUserLogic){ | ||
| 47 | + $this->request->validate([ | ||
| 48 | + 'dept_id'=>['required'], | ||
| 49 | + 'user_id'=>['required'] | ||
| 50 | + ],[ | ||
| 51 | + 'dept_id.required' => '组织架构id不能为空', | ||
| 52 | + 'user_id.required' => '用户id不能为空', | ||
| 53 | + ]); | ||
| 54 | + $deptUserLogic->dept_user_save(); | ||
| 55 | + $this->response('success'); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @name :(设置管理员)set_admin | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2023/5/18 10:32 | ||
| 63 | + */ | ||
| 64 | + public function set_admin(DeptUserLogic $deptUserLogic){ | ||
| 65 | + $this->request->validate([ | ||
| 66 | + 'id'=>['required'], | ||
| 67 | + 'is_admin'=>['required'], | ||
| 68 | + ],[ | ||
| 69 | + 'id.required' => 'id不能为空', | ||
| 70 | + 'is_admin.required' => 'is_admin不能为空', | ||
| 71 | + ]); | ||
| 72 | + $deptUserLogic->dept_user_edit(); | ||
| 73 | + $this->response('success'); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * @name :(设置用户角色)set_role | ||
| 78 | + * @author :lyh | ||
| 79 | + * @method :post | ||
| 80 | + * @time :2023/5/19 9:32 | ||
| 81 | + */ | ||
| 82 | + public function set_role(DeptUserLogic $deptUserLogic){ | ||
| 83 | + $this->request->validate([ | ||
| 84 | + 'id'=>['required'], | ||
| 85 | + 'role_id'=>['required'], | ||
| 86 | + ],[ | ||
| 87 | + 'id.required' => '用户id不能为空', | ||
| 88 | + 'role_id.required' => 'role_id不能为空', | ||
| 89 | + ]); | ||
| 90 | + $deptUserLogic->user_edit_role(); | ||
| 91 | + $this->response('success'); | ||
| 92 | + } | ||
| 93 | +} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Bside\User; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Http\Controllers\Bside\BaseController; | ||
| 7 | -use App\Http\Controllers\Bside\Ids; | ||
| 8 | -use App\Http\Controllers\Bside\json; | ||
| 9 | -use App\Http\Logic\Bside\ProjectGroupLogic; | ||
| 10 | -use App\Http\Logic\Bside\User\GroupLogic; | ||
| 11 | -use App\Http\Requests\Bside\User\ProjectGroupRequest; | ||
| 12 | -use App\Models\User\ProjectGroup; | ||
| 13 | - | ||
| 14 | - | ||
| 15 | -/** | ||
| 16 | - * @name:用户组相关 | ||
| 17 | - */ | ||
| 18 | -class ProjectGroupController extends BaseController | ||
| 19 | -{ | ||
| 20 | - /** | ||
| 21 | - * @name :用户组列表 | ||
| 22 | - * @return json | ||
| 23 | - * @author :liyuhang | ||
| 24 | - * @method | ||
| 25 | - */ | ||
| 26 | - public function lists(ProjectGroup $projectGroup) | ||
| 27 | - { | ||
| 28 | - $lists = $projectGroup->list($this->map,'id',['name','user_list','pid','id']); | ||
| 29 | - $menu = []; | ||
| 30 | - foreach ($lists as $k => $v){ | ||
| 31 | - $v = (array)$v; | ||
| 32 | - if ($v['pid'] == 0) { | ||
| 33 | - $v['sub'] = _get_child($v['id'], $lists); | ||
| 34 | - $menu[] = $v; | ||
| 35 | - } | ||
| 36 | - } | ||
| 37 | - $this->response('success',Code::SUCCESS,$menu); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * @name :详情 | ||
| 42 | - * @return json | ||
| 43 | - * @author :liyuhang | ||
| 44 | - * @method | ||
| 45 | - */ | ||
| 46 | - public function info(GroupLogic $groupLogic){ | ||
| 47 | - $this->request->validate([ | ||
| 48 | - 'id'=>['required', new Ids()], | ||
| 49 | - ],[ | ||
| 50 | - 'id.required' => 'ID不能为空', | ||
| 51 | - ]); | ||
| 52 | - $groupLogic->group_info(); | ||
| 53 | - $this->response('success'); | ||
| 54 | - } | ||
| 55 | - /** | ||
| 56 | - * @name:添加用户组获取用户列表 | ||
| 57 | - * @return void | ||
| 58 | - * @author :liyuhang | ||
| 59 | - * @method | ||
| 60 | - */ | ||
| 61 | - public function get_user_lists(GroupLogic $groupLogic){ | ||
| 62 | - $lists = $groupLogic->user_list(); | ||
| 63 | - $this->response('success',Code::SUCCESS,$lists); | ||
| 64 | - } | ||
| 65 | - /** | ||
| 66 | - * @param ProjectGroupRequest $request | ||
| 67 | - * @param ProjectGroupLogic $logic | ||
| 68 | - * @name : 添加用户组 | ||
| 69 | - * @return void | ||
| 70 | - * @author :liyuhang | ||
| 71 | - * @method | ||
| 72 | - */ | ||
| 73 | - public function add(ProjectGroupRequest $request,GroupLogic $groupLogic){ | ||
| 74 | - $request->validated(); | ||
| 75 | - $groupLogic->group_add(); | ||
| 76 | - $this->response('success'); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - /** | ||
| 80 | - * @param ProjectGroupRequest $request | ||
| 81 | - * @param ProjectGroupLogic $logic | ||
| 82 | - * @name :编辑用户组 | ||
| 83 | - * @return void | ||
| 84 | - * @author :liyuhang | ||
| 85 | - * @method | ||
| 86 | - */ | ||
| 87 | - public function edit(ProjectGroupRequest $request,GroupLogic $groupLogic){ | ||
| 88 | - $request->validate([ | ||
| 89 | - 'id'=>['required'], | ||
| 90 | - ],[ | ||
| 91 | - 'id.required' => 'ID不能为空', | ||
| 92 | - ]); | ||
| 93 | - $groupLogic->group_edit(); | ||
| 94 | - $this->response('success'); | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - /** | ||
| 98 | - * @name :删除用户组 | ||
| 99 | - * @return void | ||
| 100 | - * @author :liyuhang | ||
| 101 | - * @method | ||
| 102 | - */ | ||
| 103 | - public function del(GroupLogic $groupLogic){ | ||
| 104 | - $this->request->validate([ | ||
| 105 | - 'id'=>['required','array'], | ||
| 106 | - ],[ | ||
| 107 | - 'id.required' => 'ID不能为空', | ||
| 108 | - 'id.array' => 'ID为数组', | ||
| 109 | - ]); | ||
| 110 | - $groupLogic->group_del(); | ||
| 111 | - $this->response('success'); | ||
| 112 | - } | ||
| 113 | -} |
| @@ -7,7 +7,9 @@ use App\Http\Controllers\Bside\BaseController; | @@ -7,7 +7,9 @@ use App\Http\Controllers\Bside\BaseController; | ||
| 7 | use App\Http\Controllers\Bside\json; | 7 | use App\Http\Controllers\Bside\json; |
| 8 | use App\Http\Logic\Bside\User\UserLogic; | 8 | use App\Http\Logic\Bside\User\UserLogic; |
| 9 | use App\Http\Requests\Bside\User\UserRequest; | 9 | use App\Http\Requests\Bside\User\UserRequest; |
| 10 | +use App\Models\User\ProjectRole; | ||
| 10 | use App\Models\User\User as UserModel; | 11 | use App\Models\User\User as UserModel; |
| 12 | +use App\Models\User\ViewDeptUser; | ||
| 11 | use Illuminate\Http\Request; | 13 | use Illuminate\Http\Request; |
| 12 | use Illuminate\Support\Facades\Cache; | 14 | use Illuminate\Support\Facades\Cache; |
| 13 | 15 | ||
| @@ -23,13 +25,21 @@ class UserController extends BaseController | @@ -23,13 +25,21 @@ class UserController extends BaseController | ||
| 23 | //TODO::搜索参数统一处理 | 25 | //TODO::搜索参数统一处理 |
| 24 | $this->map['project_id'] = $this->user['project_id']; | 26 | $this->map['project_id'] = $this->user['project_id']; |
| 25 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); | 27 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); |
| 26 | - if(empty($lists)){ | ||
| 27 | - $this->response('error',Code::USER_ERROR,[]); | ||
| 28 | - } | ||
| 29 | $this->response('success',Code::SUCCESS,$lists); | 28 | $this->response('success',Code::SUCCESS,$lists); |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | /** | 31 | /** |
| 32 | + * @name :(添加管理员获取角色菜单)role_list | ||
| 33 | + * @author :lyh | ||
| 34 | + * @method :post | ||
| 35 | + * @time :2023/5/18 17:04 | ||
| 36 | + */ | ||
| 37 | + public function role_list(ProjectRole $projectRole){ | ||
| 38 | + $list = $projectRole->list(['status'=>0,'project_id'=>$this->user['project_id']],'id'); | ||
| 39 | + $this->response('success',Code::SUCCESS,$list); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 33 | * @name :添加管理员 | 43 | * @name :添加管理员 |
| 34 | * @return void | 44 | * @return void |
| 35 | * @author :liyuhang | 45 | * @author :liyuhang |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Cside; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Http\Controllers\Controller; | ||
| 7 | -use Illuminate\Http\JsonResponse; | ||
| 8 | -use Illuminate\Http\Request; | ||
| 9 | -use Illuminate\Http\Exceptions\HttpResponseException; | ||
| 10 | -use Illuminate\Support\Facades\Cache; | ||
| 11 | -use Illuminate\Support\Facades\Session; | ||
| 12 | - | ||
| 13 | -class BaseController extends Controller | ||
| 14 | -{ | ||
| 15 | - protected $param = [];//所有请求参数 | ||
| 16 | - protected $token = ''; //token | ||
| 17 | - protected $request = [];//助手函数 | ||
| 18 | - protected $project = [];//当前登录用户详情 | ||
| 19 | - /** | ||
| 20 | - * 获取所有参数 | ||
| 21 | - */ | ||
| 22 | - public function __construct(Request $request) | ||
| 23 | - { | ||
| 24 | - $this->request = $request; | ||
| 25 | - $this->param = $this->request->all(); | ||
| 26 | - $this->token = $this->request->header('token'); | ||
| 27 | - if(!empty($this->token) && !empty(Cache::get($this->token))){ | ||
| 28 | - $info = Cache::get($this->token); | ||
| 29 | - $this->user = $info; | ||
| 30 | - $this->uid = $info['id']; | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * 成功返回 | ||
| 38 | - * @param array $data | ||
| 39 | - * @param string $code | ||
| 40 | - * @param bool $objectData | ||
| 41 | - * @return JsonResponse | ||
| 42 | - * @throws \Psr\Container\ContainerExceptionInterface | ||
| 43 | - * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 44 | - */ | ||
| 45 | - function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse | ||
| 46 | - { | ||
| 47 | - if ($objectData) { | ||
| 48 | - $data = (object)$data; | ||
| 49 | - } | ||
| 50 | - $code = Code::fromValue($code); | ||
| 51 | - $response = [ | ||
| 52 | - 'code' => $code->value, | ||
| 53 | - 'data' => $data, | ||
| 54 | - 'msg' => $code->description, | ||
| 55 | - ]; | ||
| 56 | - return response()->json($response,200); | ||
| 57 | - } | ||
| 58 | -} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Cside; | ||
| 4 | - | ||
| 5 | -use App\Http\Logic\Cside\InquiryLogic; | ||
| 6 | -use App\Http\Requests\Cside\InquiryRequest; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 精准询盘 | ||
| 10 | - * Class InquiryController | ||
| 11 | - * @package App\Http\Controllers\Bside | ||
| 12 | - * @author zbj | ||
| 13 | - * @date 2023/5/4 | ||
| 14 | - */ | ||
| 15 | -class InquiryController extends BaseController | ||
| 16 | -{ | ||
| 17 | - | ||
| 18 | - public function save(InquiryRequest $request, InquiryLogic $logic) | ||
| 19 | - { | ||
| 20 | - $data = $logic->save($this->param); | ||
| 21 | - return $this->success($data); | ||
| 22 | - } | ||
| 23 | -} |
| @@ -44,7 +44,7 @@ class FileController | @@ -44,7 +44,7 @@ class FileController | ||
| 44 | * @method :post | 44 | * @method :post |
| 45 | * @time :2023/5/9 9:15 | 45 | * @time :2023/5/9 9:15 |
| 46 | */ | 46 | */ |
| 47 | - public function index($hash = '', $type = 1) | 47 | + public function index($hash = '', $w = 1) |
| 48 | { | 48 | { |
| 49 | // 检查是否有修改日期或ETag头部 | 49 | // 检查是否有修改日期或ETag头部 |
| 50 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { | 50 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { |
| @@ -11,7 +11,6 @@ use App\Http\Middleware\Bside\EnableCrossRequestMiddleware; | @@ -11,7 +11,6 @@ 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; | ||
| 15 | use App\Http\Middleware\PreventRepeatQuitCallMiddleware; | 14 | use App\Http\Middleware\PreventRepeatQuitCallMiddleware; |
| 16 | use Illuminate\Foundation\Http\Kernel as HttpKernel; | 15 | use Illuminate\Foundation\Http\Kernel as HttpKernel; |
| 17 | 16 | ||
| @@ -77,11 +76,6 @@ class Kernel extends HttpKernel | @@ -77,11 +76,6 @@ class Kernel extends HttpKernel | ||
| 77 | //允许跨域请求 | 76 | //允许跨域请求 |
| 78 | EnableCrossRequestMiddleware::class | 77 | EnableCrossRequestMiddleware::class |
| 79 | ], | 78 | ], |
| 80 | - //C端中间件组 | ||
| 81 | - 'cside'=>[ | ||
| 82 | - //参数处理中间件--涉及-参数记录-参数加解密等 | ||
| 83 | - CsideParamMiddleware::class, | ||
| 84 | - ] | ||
| 85 | ]; | 79 | ]; |
| 86 | 80 | ||
| 87 | /** | 81 | /** |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Aside\Devops; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Enums\Common\Code; | ||
| 7 | +use App\Exceptions\AsideGlobalException; | ||
| 8 | +use App\Exceptions\BsideGlobalException; | ||
| 9 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 10 | +use App\Models\Devops\ServerInformation; | ||
| 11 | +use App\Models\Devops\ServerInformationLog; | ||
| 12 | +use Illuminate\Database\Eloquent\Builder; | ||
| 13 | +use Illuminate\Database\Eloquent\Collection; | ||
| 14 | +use Illuminate\Database\Eloquent\Model; | ||
| 15 | +use Illuminate\Http\JsonResponse; | ||
| 16 | +use Illuminate\Support\Facades\DB; | ||
| 17 | +use Illuminate\Support\Facades\Log; | ||
| 18 | + | ||
| 19 | +class ServerInformationLogic extends BaseLogic | ||
| 20 | +{ | ||
| 21 | + /** | ||
| 22 | + * @var array | ||
| 23 | + */ | ||
| 24 | + private $param; | ||
| 25 | + | ||
| 26 | + public function __construct() | ||
| 27 | + { | ||
| 28 | + parent::__construct(); | ||
| 29 | + | ||
| 30 | + $this->model = new ServerInformation(); | ||
| 31 | + | ||
| 32 | + $this->param = $this->requestAll; | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 添加数据 | ||
| 38 | + * @return array | ||
| 39 | + * @throws AsideGlobalException | ||
| 40 | + * @throws BsideGlobalException | ||
| 41 | + */ | ||
| 42 | + public function create() | ||
| 43 | + { | ||
| 44 | + $request = $this->param; | ||
| 45 | + $service = new ServerInformation(); | ||
| 46 | + $this->extracted($request, $service); | ||
| 47 | + if ($this->checkIp($service->ip)) { | ||
| 48 | + return $this->fail('服务器信息添加失败,ip已存在'); | ||
| 49 | + } | ||
| 50 | + DB::beginTransaction(); | ||
| 51 | + | ||
| 52 | + if ($service->save()) { | ||
| 53 | + $original = [ | ||
| 54 | + 'id' => $service->id, | ||
| 55 | + 'type' => $service->type, | ||
| 56 | + 'ip' => $service->ip, | ||
| 57 | + 'title' => $service->title, | ||
| 58 | + 'belong_to' => $service->belong_to, | ||
| 59 | + 'sshpass' => $service->sshpass, | ||
| 60 | + 'ports' => $service->ports, | ||
| 61 | + ]; | ||
| 62 | + // 添加日志 | ||
| 63 | + $this->server_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id); | ||
| 64 | + DB::commit(); | ||
| 65 | + return $this->success(); | ||
| 66 | + } | ||
| 67 | + DB::rollBack(); | ||
| 68 | + return $this->fail('服务器信息添加失败'); | ||
| 69 | + | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 修改数据 | ||
| 74 | + * @return array | ||
| 75 | + * @throws AsideGlobalException | ||
| 76 | + * @throws BsideGlobalException | ||
| 77 | + */ | ||
| 78 | + public function update() | ||
| 79 | + { | ||
| 80 | + | ||
| 81 | + $service = new ServerInformation(); | ||
| 82 | + $fields_array = $service->FieldsArray(); | ||
| 83 | + $request = $this->param; | ||
| 84 | + $service = $this->ServerInfo(); | ||
| 85 | + $original = $service->toArray(); | ||
| 86 | + $this->extracted($request, $service); | ||
| 87 | + | ||
| 88 | + // 检查ip是否存在 | ||
| 89 | + if ($service->ip != $request['ip']) { | ||
| 90 | + if ($this->checkIp($request['ip'])) { | ||
| 91 | + $this->fail('服务器信息修改失败,ip已存在', Code::USER_ERROR); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + DB::beginTransaction(); | ||
| 95 | + if ($service->save()) { | ||
| 96 | + $revised = [ | ||
| 97 | + 'id' => $service->id, | ||
| 98 | + 'type' => $service->type, | ||
| 99 | + 'ip' => $service->ip, | ||
| 100 | + 'title' => $service->title, | ||
| 101 | + 'belong_to' => $service->belong_to, | ||
| 102 | + 'sshpass' => $service->sshpass, | ||
| 103 | + 'ports' => $service->ports, | ||
| 104 | + 'other' => $service->other, | ||
| 105 | + 'delete' => $service->delete, | ||
| 106 | + ]; | ||
| 107 | + $diff = array_diff_assoc($original, $revised); | ||
| 108 | + unset($diff['create_at']); | ||
| 109 | + unset($diff['update_at']); | ||
| 110 | + unset($diff['deleted']); | ||
| 111 | + $remarks = ''; | ||
| 112 | + if ($diff) { | ||
| 113 | + $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:'; | ||
| 114 | + foreach ($diff as $key => $value) { | ||
| 115 | + $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; '; | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + // 添加日志 | ||
| 119 | + $this->server_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks); | ||
| 120 | + DB::commit(); | ||
| 121 | + return $this->success(); | ||
| 122 | + } | ||
| 123 | + DB::rollBack(); | ||
| 124 | + return $this->fail('服务器信息修改失败'); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 检查ip是否存在 | ||
| 129 | + * @param $ip | ||
| 130 | + * @return bool | ||
| 131 | + */ | ||
| 132 | + public function checkIp($ip) | ||
| 133 | + { | ||
| 134 | + $usIp = ServerInformation::query()->where('ip', $ip)->first(); | ||
| 135 | + if ($usIp) { | ||
| 136 | + return true; | ||
| 137 | + } else { | ||
| 138 | + return false; | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 详情 | ||
| 144 | + * @param int $deleted | ||
| 145 | + * @return array|Builder|Collection|Model | ||
| 146 | + * @throws AsideGlobalException | ||
| 147 | + * @throws BsideGlobalException | ||
| 148 | + */ | ||
| 149 | + public function serverInfo(int $deleted = ServerInformation::DELETED_NORMAL) | ||
| 150 | + { | ||
| 151 | + $id = \request()->input('id'); | ||
| 152 | + if (!$id) { | ||
| 153 | + return $this->fail('参数错误'); | ||
| 154 | + } | ||
| 155 | + $data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'sshpass', 'ports', 'create_at', 'update_at']); | ||
| 156 | + if (!$data) { | ||
| 157 | + return $this->fail('数据不存在!'); | ||
| 158 | + } | ||
| 159 | + return $data; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * 服务器操作日志 | ||
| 164 | + * @param int $action 1:添加 2:修改 3:删除 4:搜索 5:详情 6:列表 | ||
| 165 | + * @param array $original 原始数据 | ||
| 166 | + * @param array $revised 修改后数据 | ||
| 167 | + */ | ||
| 168 | + public function server_action_log(int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '') | ||
| 169 | + { | ||
| 170 | + // $action 1:添加 2:修改 3:删除 4:恢复 | ||
| 171 | + $actionArr = ServerInformationLog::actionArr(); | ||
| 172 | + $actionStr = $actionArr[$action]; | ||
| 173 | + $ip = request()->getClientIp(); | ||
| 174 | + $url = request()->getRequestUri(); | ||
| 175 | + $method = request()->getMethod(); | ||
| 176 | + $userId = $this->uid ?? 0; | ||
| 177 | + $log = new ServerInformationLog(); | ||
| 178 | + $log->user_id = $userId; | ||
| 179 | + $log->action = $actionStr; | ||
| 180 | + $log->original = json_encode($original); | ||
| 181 | + $log->revised = json_encode($revised); | ||
| 182 | + $log->ip = $ip; | ||
| 183 | + $log->url = $url; | ||
| 184 | + $log->method = $method; | ||
| 185 | + $log->remarks = $remarks; | ||
| 186 | + DB::beginTransaction(); | ||
| 187 | + try { | ||
| 188 | + $log->save(); | ||
| 189 | + DB::commit(); | ||
| 190 | + } catch (\Exception $e) { | ||
| 191 | + DB::rollBack(); | ||
| 192 | + Log::error('服务器信息日志添加失败'); | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + /** | ||
| 197 | + * @param array $request | ||
| 198 | + * @param $service | ||
| 199 | + * @return void | ||
| 200 | + */ | ||
| 201 | + public function extracted(array $request, $service) | ||
| 202 | + { | ||
| 203 | + $service->type = trim($request['type']); // 服务器类型 | ||
| 204 | + $service->ip = trim($request['ip']); // 服务器ip | ||
| 205 | + $service->title = trim($request['title']); // 服务器标题 | ||
| 206 | + $service->belong_to = trim($request['belong_to']); // 服务器归属 | ||
| 207 | + $service->sshpass = trim($request['sshpass']); // ssh密码 | ||
| 208 | + $service->ports = trim($request['ports']); // ssh端口 | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + /** | ||
| 212 | + * 批量获取数据删除 | ||
| 213 | + * @return array | ||
| 214 | + * @throws AsideGlobalException | ||
| 215 | + * @throws BsideGlobalException | ||
| 216 | + */ | ||
| 217 | + public function get_batch_update($action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL) | ||
| 218 | + { | ||
| 219 | + $id = request()->input('id'); | ||
| 220 | + if (!$id) { | ||
| 221 | + return $this->fail('参数错误'); | ||
| 222 | + } | ||
| 223 | + $ids = []; | ||
| 224 | + if (!is_array($id)) { | ||
| 225 | + $ids = explode(',', $id); | ||
| 226 | + } | ||
| 227 | + $ids = array_filter($ids, 'intval'); | ||
| 228 | + if (empty($ids)) { | ||
| 229 | + return $this->fail('参数错误'); | ||
| 230 | + } | ||
| 231 | + $data = ServerInformation::query()->whereIn('id', $ids)->where('deleted', $deleted)->get(); | ||
| 232 | + $restore_ids = $data->pluck('id')->toArray(); | ||
| 233 | + $actionArr = ServerInformationLog::actionArr(); | ||
| 234 | + $actionStr = $actionArr[$action]; | ||
| 235 | + if (empty($restore_ids)) { | ||
| 236 | + $this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR); | ||
| 237 | + } | ||
| 238 | + $original = $data->toArray(); | ||
| 239 | + DB::beginTransaction(); | ||
| 240 | + try { | ||
| 241 | + $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL; | ||
| 242 | + ServerInformation::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]); | ||
| 243 | + $this->server_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids)); | ||
| 244 | + DB::commit(); | ||
| 245 | + return $this->success(); | ||
| 246 | + } catch (\Exception $e) { | ||
| 247 | + DB::rollBack(); | ||
| 248 | + return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR); | ||
| 249 | + } | ||
| 250 | + } | ||
| 251 | +} |
| @@ -20,7 +20,7 @@ class DomainInfoLogic extends BaseLogic | @@ -20,7 +20,7 @@ class DomainInfoLogic extends BaseLogic | ||
| 20 | public function getDomainInfo($project_id) | 20 | public function getDomainInfo($project_id) |
| 21 | { | 21 | { |
| 22 | $project = app(ProjectLogic::class)->getInfo($project_id); | 22 | $project = app(ProjectLogic::class)->getInfo($project_id); |
| 23 | - $domain = $project['deploy_optimize']['domain']; | 23 | + $domain = $project['deploy_optimize']['domain'] ?? ''; |
| 24 | $info = $this->model->where('project_id', $project_id)->first(); | 24 | $info = $this->model->where('project_id', $project_id)->first(); |
| 25 | //不存在或时间过期了 重新获取信息 | 25 | //不存在或时间过期了 重新获取信息 |
| 26 | $expiration_date = $info['domain_info']['expiration_date'] ?? ''; | 26 | $expiration_date = $info['domain_info']['expiration_date'] ?? ''; |
| @@ -4,11 +4,14 @@ namespace App\Http\Logic\Aside\Project; | @@ -4,11 +4,14 @@ namespace App\Http\Logic\Aside\Project; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 7 | +use App\Helper\FormGlobalsoApi; | ||
| 7 | use App\Http\Logic\Aside\BaseLogic; | 8 | use App\Http\Logic\Aside\BaseLogic; |
| 9 | +use App\Models\InquirySet; | ||
| 8 | use App\Models\Project\DeployBuild; | 10 | use App\Models\Project\DeployBuild; |
| 9 | use App\Models\Project\DeployOptimize; | 11 | use App\Models\Project\DeployOptimize; |
| 10 | use App\Models\Project\Payment; | 12 | use App\Models\Project\Payment; |
| 11 | use App\Models\Project\Project; | 13 | use App\Models\Project\Project; |
| 14 | +use Illuminate\Database\Eloquent\Model; | ||
| 12 | use Illuminate\Support\Facades\DB; | 15 | use Illuminate\Support\Facades\DB; |
| 13 | 16 | ||
| 14 | /** | 17 | /** |
| @@ -39,15 +42,15 @@ class ProjectLogic extends BaseLogic | @@ -39,15 +42,15 @@ class ProjectLogic extends BaseLogic | ||
| 39 | } | 42 | } |
| 40 | 43 | ||
| 41 | public function save($param){ | 44 | public function save($param){ |
| 42 | - if(!empty($param['test_domain'])){ | ||
| 43 | - $param['test_domain'] = checkDomain($param['test_domain']); | ||
| 44 | - if(!$param['test_domain']){ | 45 | + if(!empty($param['deploy_build']['test_domain'])){ |
| 46 | + $param['deploy_build']['test_domain'] = checkDomain($param['deploy_build']['test_domain']); | ||
| 47 | + if(!$param['deploy_build']['test_domain']){ | ||
| 45 | $this->fail('测试域名格式不正确'); | 48 | $this->fail('测试域名格式不正确'); |
| 46 | } | 49 | } |
| 47 | } | 50 | } |
| 48 | - if(!empty($param['domain'])){ | ||
| 49 | - $param['domain'] = checkDomain($param['domain']); | ||
| 50 | - if(!$param['domain']){ | 51 | + if(!empty($param['deploy_optimize']['domain'])){ |
| 52 | + $param['deploy_optimize']['domain'] = checkDomain($param['deploy_optimize']['domain']); | ||
| 53 | + if(!$param['deploy_optimize']['domain']){ | ||
| 51 | $this->fail('正式域名格式不正确'); | 54 | $this->fail('正式域名格式不正确'); |
| 52 | } | 55 | } |
| 53 | } | 56 | } |
| @@ -122,4 +125,38 @@ class ProjectLogic extends BaseLogic | @@ -122,4 +125,38 @@ class ProjectLogic extends BaseLogic | ||
| 122 | parent::setWith(['payment', 'deploy_build', 'deploy_optimize']); | 125 | parent::setWith(['payment', 'deploy_build', 'deploy_optimize']); |
| 123 | parent::clearCache($id); | 126 | parent::clearCache($id); |
| 124 | } | 127 | } |
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * 保存询盘通知设置 | ||
| 131 | + * @author zbj | ||
| 132 | + * @date 2023/5/17 | ||
| 133 | + */ | ||
| 134 | + public function saveInquirySet($param) | ||
| 135 | + { | ||
| 136 | + $project = $this->getCacheInfo($param['project_id']); | ||
| 137 | + | ||
| 138 | + //同步到接口 | ||
| 139 | + $domain = parse_url($project['deploy_optimize']['domain'])['host']; | ||
| 140 | + $emails = Arr::arrToSet($param['emails']??'', 'trim'); | ||
| 141 | + $phones = Arr::arrToSet($param['phones']??'', 'trim'); | ||
| 142 | + $form_globalso_api = new FormGlobalsoApi(); | ||
| 143 | + $res = $form_globalso_api->setInquiry($domain, $emails, $phones); | ||
| 144 | + | ||
| 145 | + if (!$res) { | ||
| 146 | + $this->fail('保存失败'); | ||
| 147 | + } | ||
| 148 | + if ($res['status'] != 200) { | ||
| 149 | + $this->fail($res['message'] ?? '保存失败'); | ||
| 150 | + } | ||
| 151 | + //保存 | ||
| 152 | + $set = InquirySet::where('project_id', $param['project_id'])->first(); | ||
| 153 | + if (!$set) { | ||
| 154 | + $set = new InquirySet(); | ||
| 155 | + } | ||
| 156 | + $set->project_id = $param['project_id']; | ||
| 157 | + $set->emails = $emails; | ||
| 158 | + $set->phones = $phones; | ||
| 159 | + $set->save(); | ||
| 160 | + return $this->success(); | ||
| 161 | + } | ||
| 125 | } | 162 | } |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Logic\Aside\User; | ||
| 4 | - | ||
| 5 | -use App\Http\Logic\Aside\BaseLogic; | ||
| 6 | -use App\Models\User\ProjectMenu; | ||
| 7 | - | ||
| 8 | -class ProjectGroupLogic extends BaseLogic | ||
| 9 | -{ | ||
| 10 | - public function __construct() | ||
| 11 | - { | ||
| 12 | - parent::__construct(); | ||
| 13 | - | ||
| 14 | - $this->model = new ProjectMenu(); | ||
| 15 | - $this->param = $this->requestAll; | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - /** | ||
| 19 | - * @name :详情 | ||
| 20 | - * @return void | ||
| 21 | - * @author :liyuhang | ||
| 22 | - * @method | ||
| 23 | - */ | ||
| 24 | - public function group_info(){ | ||
| 25 | - $info = $this->info($this->param); | ||
| 26 | - return $this->success($info); | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | - * @name :添加 | ||
| 31 | - * @return void | ||
| 32 | - * @author :liyuhang | ||
| 33 | - * @method | ||
| 34 | - */ | ||
| 35 | - public function group_add(){ | ||
| 36 | - //查看当前用户组是否存在 | ||
| 37 | - $this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]); | ||
| 38 | - $rs = $this->model->add($this->param); | ||
| 39 | - if($rs === false){ | ||
| 40 | - $this->fail('error'); | ||
| 41 | - } | ||
| 42 | - return $this->success(); | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - /** | ||
| 46 | - * @name :编辑 | ||
| 47 | - * @return void | ||
| 48 | - * @author :liyuhang | ||
| 49 | - * @method | ||
| 50 | - */ | ||
| 51 | - public function group_edit(){ | ||
| 52 | - //查看当前用户组是否存在 | ||
| 53 | - $rs = $this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]); | ||
| 54 | - if($rs === false){ | ||
| 55 | - $this->fail('error'); | ||
| 56 | - } | ||
| 57 | - return $this->success(); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * @name :删除 | ||
| 62 | - * @return void | ||
| 63 | - * @author :liyuhang | ||
| 64 | - * @method | ||
| 65 | - */ | ||
| 66 | - public function group_del(){ | ||
| 67 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 68 | - $rs = $this->model->del($this->param); | ||
| 69 | - if($rs === false){ | ||
| 70 | - $this->fail('error'); | ||
| 71 | - } | ||
| 72 | - return $this->success(); | ||
| 73 | - } | ||
| 74 | -} |
| @@ -40,6 +40,8 @@ class AyrReleaseLogic extends BaseLogic | @@ -40,6 +40,8 @@ class AyrReleaseLogic extends BaseLogic | ||
| 40 | public function release_add(){ | 40 | public function release_add(){ |
| 41 | $this->param['project_id'] = $this->user['project_id']; | 41 | $this->param['project_id'] = $this->user['project_id']; |
| 42 | $this->param['operator_id'] = $this->user['id']; | 42 | $this->param['operator_id'] = $this->user['id']; |
| 43 | + $this->param['images'] = implode(',',$this->param['images']); | ||
| 44 | + $this->param['platforms'] = json_encode($this->param['platforms']); | ||
| 43 | $rs = $this->model->add($this->param); | 45 | $rs = $this->model->add($this->param); |
| 44 | if($rs === false){ | 46 | if($rs === false){ |
| 45 | $this->fail('error'); | 47 | $this->fail('error'); |
| @@ -61,17 +63,17 @@ class AyrReleaseLogic extends BaseLogic | @@ -61,17 +63,17 @@ class AyrReleaseLogic extends BaseLogic | ||
| 61 | $imageModel = new Image(); | 63 | $imageModel = new Image(); |
| 62 | $list = $imageModel->list(['hash'=>['in',$images]],'id'); | 64 | $list = $imageModel->list(['hash'=>['in',$images]],'id'); |
| 63 | foreach ($list as $v1){ | 65 | foreach ($list as $v1){ |
| 64 | - $arr[] = $v1['ayr_url']; | 66 | + $filename = basename($v1['path']); |
| 67 | + $arr[] = url('/upload/images/'.$filename); | ||
| 65 | } | 68 | } |
| 66 | }else{ | 69 | }else{ |
| 67 | - $arr[] = url('/b/file_hash/' . $v.rand(10000,99999).'mp4');; | 70 | + $fileModel = new File(); |
| 71 | + $info = $fileModel->read(['hash'=>$v]); | ||
| 72 | + $filename = basename($info['path']); | ||
| 73 | + $arr[] = url('/upload/files/'.$filename); | ||
| 68 | } | 74 | } |
| 69 | } | 75 | } |
| 70 | return $this->success($arr); | 76 | return $this->success($arr); |
| 71 | } | 77 | } |
| 72 | 78 | ||
| 73 | - | ||
| 74 | - public function platforms_request(){ | ||
| 75 | - | ||
| 76 | - } | ||
| 77 | } | 79 | } |
| @@ -52,7 +52,7 @@ class AyrShareLogic extends BaseLogic | @@ -52,7 +52,7 @@ class AyrShareLogic extends BaseLogic | ||
| 52 | 'title'=>$res['title'], | 52 | 'title'=>$res['title'], |
| 53 | 'ref_id'=>$res['refId'], | 53 | 'ref_id'=>$res['refId'], |
| 54 | 'profile_key'=>$res['profileKey'], | 54 | 'profile_key'=>$res['profileKey'], |
| 55 | - 'user_id'=>$this->user['id'], | 55 | + 'operator_id'=>$this->user['id'], |
| 56 | 'project_id'=>$this->user['project_id'], | 56 | 'project_id'=>$this->user['project_id'], |
| 57 | 'name'=>$this->param['name'], | 57 | 'name'=>$this->param['name'], |
| 58 | ]; | 58 | ]; |
| @@ -69,8 +69,11 @@ class AyrShareLogic extends BaseLogic | @@ -69,8 +69,11 @@ class AyrShareLogic extends BaseLogic | ||
| 69 | * @method :post | 69 | * @method :post |
| 70 | * @time :2023/5/6 10:16 | 70 | * @time :2023/5/6 10:16 |
| 71 | */ | 71 | */ |
| 72 | - public function ayr_share_info(){ | ||
| 73 | - $info = $this->model->read(['id'=>$this->param['share_id']]); | 72 | + public function ayr_share_info($share_id = ''){ |
| 73 | + if(isset($this->param['id'])){ | ||
| 74 | + $share_id = $this->param['id']; | ||
| 75 | + } | ||
| 76 | + $info = $this->model->read(['id'=>$share_id]); | ||
| 74 | if($info === false){ | 77 | if($info === false){ |
| 75 | $this->fail('当前数据不存在或已被删除'); | 78 | $this->fail('当前数据不存在或已被删除'); |
| 76 | } | 79 | } |
| @@ -97,7 +100,6 @@ class AyrShareLogic extends BaseLogic | @@ -97,7 +100,6 @@ class AyrShareLogic extends BaseLogic | ||
| 97 | * @time :2023/5/6 10:18 | 100 | * @time :2023/5/6 10:18 |
| 98 | */ | 101 | */ |
| 99 | public function ayr_share_del(){ | 102 | public function ayr_share_del(){ |
| 100 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 101 | $rs = $this->model->del($this->param); | 103 | $rs = $this->model->del($this->param); |
| 102 | if($rs === false){ | 104 | if($rs === false){ |
| 103 | $this->fail('删出失败'); | 105 | $this->fail('删出失败'); |
| @@ -207,16 +209,19 @@ class AyrShareLogic extends BaseLogic | @@ -207,16 +209,19 @@ class AyrShareLogic extends BaseLogic | ||
| 207 | if(!in_array($v,json_decode($info['bind_platforms']))){ | 209 | if(!in_array($v,json_decode($info['bind_platforms']))){ |
| 208 | $this->fail('未绑定平台'); | 210 | $this->fail('未绑定平台'); |
| 209 | } | 211 | } |
| 212 | + if($v == 'reddit' && isset($this->param['video'])){ | ||
| 213 | + $this->fail('不支持视频'); | ||
| 214 | + } | ||
| 210 | //验证图片数 | 215 | //验证图片数 |
| 211 | $img_num = count($this->param['images']); | 216 | $img_num = count($this->param['images']); |
| 212 | if($img_num > $this->send_num[$v]){ | 217 | if($img_num > $this->send_num[$v]){ |
| 213 | $this->fail('发布图片数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'张图'); | 218 | $this->fail('发布图片数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'张图'); |
| 214 | } | 219 | } |
| 215 | //验证图片数 | 220 | //验证图片数 |
| 216 | - $img_num = count($this->param['video']); | ||
| 217 | - if($img_num > 1){ | ||
| 218 | - $this->fail('发布视频数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'个视频'); | ||
| 219 | - } | 221 | +// $img_num = count($this->param['video']); |
| 222 | +// if($img_num > 1){ | ||
| 223 | +// $this->fail('发布视频数量超过最大限制,'.$v.'只允许'.$this->send_num[$v].'个视频'); | ||
| 224 | +// } | ||
| 220 | } | 225 | } |
| 221 | return $this->success(); | 226 | return $this->success(); |
| 222 | } | 227 | } |
| @@ -7,6 +7,7 @@ use App\Enums\Common\Code; | @@ -7,6 +7,7 @@ use App\Enums\Common\Code; | ||
| 7 | use App\Enums\Common\Common; | 7 | use App\Enums\Common\Common; |
| 8 | use App\Exceptions\BsideGlobalException; | 8 | use App\Exceptions\BsideGlobalException; |
| 9 | use App\Http\Controllers\File\ImageController; | 9 | use App\Http\Controllers\File\ImageController; |
| 10 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 10 | use App\Http\Logic\Logic; | 11 | use App\Http\Logic\Logic; |
| 11 | use App\Models\File\Image as ImageModel; | 12 | use App\Models\File\Image as ImageModel; |
| 12 | use Illuminate\Support\Facades\Cache; | 13 | use Illuminate\Support\Facades\Cache; |
| @@ -25,6 +26,8 @@ class BaseLogic extends Logic | @@ -25,6 +26,8 @@ class BaseLogic extends Logic | ||
| 25 | 26 | ||
| 26 | protected $user; | 27 | protected $user; |
| 27 | 28 | ||
| 29 | + protected $project; | ||
| 30 | + | ||
| 28 | protected $side = Common::B; | 31 | protected $side = Common::B; |
| 29 | 32 | ||
| 30 | public function __construct() | 33 | public function __construct() |
| @@ -32,6 +35,7 @@ class BaseLogic extends Logic | @@ -32,6 +35,7 @@ class BaseLogic extends Logic | ||
| 32 | $this->request = request(); | 35 | $this->request = request(); |
| 33 | $this->requestAll = request()->all(); | 36 | $this->requestAll = request()->all(); |
| 34 | $this->user = Cache::get(request()->header('token')); | 37 | $this->user = Cache::get(request()->header('token')); |
| 38 | + $this->project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 35 | } | 39 | } |
| 36 | 40 | ||
| 37 | 41 | ||
| @@ -152,4 +156,14 @@ class BaseLogic extends Logic | @@ -152,4 +156,14 @@ class BaseLogic extends Logic | ||
| 152 | } | 156 | } |
| 153 | return $rs; | 157 | return $rs; |
| 154 | } | 158 | } |
| 159 | + | ||
| 160 | + public function getProjectDomain(){ | ||
| 161 | + if(!empty($this->project['deploy_optimize']['domain'])){ | ||
| 162 | + return $this->project['deploy_optimize']['domain']; | ||
| 163 | + } | ||
| 164 | + if(!empty($this->project['deploy_build']['test_domain'])){ | ||
| 165 | + return $this->project['deploy_build']['test_domain']; | ||
| 166 | + } | ||
| 167 | + return ''; | ||
| 168 | + } | ||
| 155 | } | 169 | } |
| @@ -3,7 +3,10 @@ | @@ -3,7 +3,10 @@ | ||
| 3 | namespace App\Http\Logic\Bside; | 3 | namespace App\Http\Logic\Bside; |
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | -use App\Models\Inquiry; | 6 | +use App\Helper\FormGlobalsoApi; |
| 7 | +use App\Helper\Translate; | ||
| 8 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 9 | +use App\Models\InquirySet; | ||
| 7 | 10 | ||
| 8 | /** | 11 | /** |
| 9 | * Class InquiryLogic | 12 | * Class InquiryLogic |
| @@ -11,25 +14,72 @@ use App\Models\Inquiry; | @@ -11,25 +14,72 @@ use App\Models\Inquiry; | ||
| 11 | * @author zbj | 14 | * @author zbj |
| 12 | * @date 2023/5/4 | 15 | * @date 2023/5/4 |
| 13 | */ | 16 | */ |
| 14 | -class InquiryLogic extends BaseLogic | 17 | +class InquiryLogic extends BaseLogic |
| 15 | { | 18 | { |
| 19 | + protected $form_globalso_api; | ||
| 20 | + | ||
| 16 | public function __construct() | 21 | public function __construct() |
| 17 | { | 22 | { |
| 18 | parent::__construct(); | 23 | parent::__construct(); |
| 19 | 24 | ||
| 20 | - $this->model = new Inquiry(); | 25 | + $this->form_globalso_api = new FormGlobalsoApi(); |
| 26 | + } | ||
| 27 | + | ||
| 28 | + public function getApiList($export = false) | ||
| 29 | + { | ||
| 30 | + $page_size = $export ? 1000 : 20; | ||
| 31 | + $search = $this->request['search'] ?: ''; | ||
| 32 | + $page = $this->request['page'] ?: 1; | ||
| 33 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 34 | + $domain = $project['deploy_optimize']['domain'] ?? ''; | ||
| 35 | + $list = $this->form_globalso_api->getInquiryList($domain, $search, $page, $page_size); | ||
| 36 | + //处理格式 免得前端又改 | ||
| 37 | + $data = [ | ||
| 38 | + "list" => [], | ||
| 39 | + "total" => 0, | ||
| 40 | + "page" => $page, | ||
| 41 | + "total_page" => 1, | ||
| 42 | + "size" => $page_size | ||
| 43 | + ]; | ||
| 44 | + if (!empty($list['status']) && $list['status'] == 200) { | ||
| 45 | + foreach ($list['data']['data'] as $item) { | ||
| 46 | + $data['list'][] = $item; | ||
| 47 | + } | ||
| 48 | + $data['total'] = $list['data']['total']; | ||
| 49 | + $data['total_page'] = $list['data']['last_page']; | ||
| 50 | + } | ||
| 51 | + return $this->success($data); | ||
| 21 | } | 52 | } |
| 22 | 53 | ||
| 23 | public function getInfo($id) | 54 | public function getInfo($id) |
| 24 | { | 55 | { |
| 25 | - $info = $this->getCacheInfo($id); | ||
| 26 | - if(!$info){ | ||
| 27 | - $this->fail('数据不存在或者已经删除'); | 56 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); |
| 57 | + $domain = $project['deploy_optimize']['domain'] ?: ''; | ||
| 58 | + //修改状态为已读 | ||
| 59 | + if($this->request['read_status']){ | ||
| 60 | + $this->form_globalso_api->saveInquiryRead($domain, $id); | ||
| 28 | } | 61 | } |
| 29 | - //标记已读 | ||
| 30 | - if($info->status == Inquiry::STATUS_UNREAD){ | ||
| 31 | - parent::save(['id' => $info['id'], 'status' => Inquiry::STATUS_READ]); | 62 | + //翻译 |
| 63 | + $trans_message = ''; | ||
| 64 | + if($this->request['message']){ | ||
| 65 | + $trans_message = Translate::tran($this->request['message'], 'zh'); | ||
| 32 | } | 66 | } |
| 33 | - return $this->success($info->toArray()); | 67 | + return $this->success(['trans_message' => $trans_message]); |
| 34 | } | 68 | } |
| 69 | + | ||
| 70 | + public function delete($ids, $map = []) | ||
| 71 | + { | ||
| 72 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 73 | + $domain = $project['deploy_optimize']['domain'] ?: ''; | ||
| 74 | + $ids = array_filter(Arr::splitFilterToArray($ids), 'intval'); | ||
| 75 | + if(!$ids){ | ||
| 76 | + $this->fail('ID不能为空'); | ||
| 77 | + } | ||
| 78 | + $this->form_globalso_api->delInquiry($domain, $ids); | ||
| 79 | + return $this->success(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + | ||
| 35 | } | 85 | } |
| @@ -2,11 +2,15 @@ | @@ -2,11 +2,15 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside\Product; | 3 | namespace App\Http\Logic\Bside\Product; |
| 4 | 4 | ||
| 5 | +use App\Exceptions\BsideGlobalException; | ||
| 5 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Product\Category; | 8 | use App\Models\Product\Category; |
| 8 | use App\Models\Product\CategoryRelated; | 9 | use App\Models\Product\CategoryRelated; |
| 10 | +use App\Models\Product\KeywordRelated; | ||
| 9 | use App\Models\Product\Product; | 11 | use App\Models\Product\Product; |
| 12 | +use App\Models\RouteMap; | ||
| 13 | +use Illuminate\Support\Facades\DB; | ||
| 10 | 14 | ||
| 11 | /** | 15 | /** |
| 12 | * Class CategoryLogic | 16 | * Class CategoryLogic |
| @@ -23,6 +27,26 @@ class CategoryLogic extends BaseLogic | @@ -23,6 +27,26 @@ class CategoryLogic extends BaseLogic | ||
| 23 | $this->model = new Category(); | 27 | $this->model = new Category(); |
| 24 | } | 28 | } |
| 25 | 29 | ||
| 30 | + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 31 | + { | ||
| 32 | + $data = parent::getList($map, $sort, $columns, $limit); | ||
| 33 | + foreach ($data as &$v){ | ||
| 34 | + $v['url'] = $this->getProjectDomain() . $v['route'] ; | ||
| 35 | + $v['product_num'] = $this->getProductNum($v['id']); | ||
| 36 | + } | ||
| 37 | + if(!$map){ | ||
| 38 | + $data = Arr::listToTree($data); | ||
| 39 | + } | ||
| 40 | + return $this->success($data); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public function getInfo($id) | ||
| 44 | + { | ||
| 45 | + $info = parent::getInfo($id); | ||
| 46 | + $info['url'] = $this->getProjectDomain() . $info['route'] ; | ||
| 47 | + return $this->success($info); | ||
| 48 | + } | ||
| 49 | + | ||
| 26 | public function save($param){ | 50 | public function save($param){ |
| 27 | $param['pid'] = $param['pid'] ?? 0; | 51 | $param['pid'] = $param['pid'] ?? 0; |
| 28 | if(!empty($param['pid'])){ | 52 | if(!empty($param['pid'])){ |
| @@ -34,26 +58,53 @@ class CategoryLogic extends BaseLogic | @@ -34,26 +58,53 @@ class CategoryLogic extends BaseLogic | ||
| 34 | $this->fail('上级分类不存在'); | 58 | $this->fail('上级分类不存在'); |
| 35 | } | 59 | } |
| 36 | } | 60 | } |
| 37 | - return parent::save($param); | 61 | + DB::beginTransaction(); |
| 62 | + try { | ||
| 63 | + $res = parent::save($param); | ||
| 64 | + //路由映射 | ||
| 65 | + RouteMap::setRoute($param['title'], RouteMap::SOURCE_PRODUCT_CATE, $res['id'], $this->user['project_id']); | ||
| 66 | + DB::commit(); | ||
| 67 | + } catch (\Exception $e){ | ||
| 68 | + DB::rollBack(); | ||
| 69 | + errorLog('产品分类保存失败', $param, $e); | ||
| 70 | + $this->fail('保存失败'); | ||
| 71 | + } | ||
| 72 | + return $this->success(); | ||
| 38 | } | 73 | } |
| 39 | 74 | ||
| 40 | public function delete($ids, $map = []){ | 75 | public function delete($ids, $map = []){ |
| 41 | $ids= array_filter(Arr::splitFilterToArray($ids), 'intval'); | 76 | $ids= array_filter(Arr::splitFilterToArray($ids), 'intval'); |
| 42 | - foreach ($ids as $id){ | ||
| 43 | - $info = $this->getCacheInfo($id); | ||
| 44 | - if(!$info){ | ||
| 45 | - continue; | ||
| 46 | - } | ||
| 47 | - //是否有子分类 | ||
| 48 | - if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){ | ||
| 49 | - $this->fail("分类{$info['title']}存在子分类,不能删除"); | ||
| 50 | - } | ||
| 51 | - //是否有对应商品 | ||
| 52 | - if(CategoryRelated::where('cate_id', $id)->count()){ | ||
| 53 | - $this->fail("分类{$info['title']}存在产品,不能删除"); | 77 | + |
| 78 | + DB::beginTransaction(); | ||
| 79 | + try { | ||
| 80 | + foreach ($ids as $id){ | ||
| 81 | + $info = $this->getCacheInfo($id); | ||
| 82 | + if(!$info){ | ||
| 83 | + continue; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + //是否有子分类 | ||
| 87 | + if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){ | ||
| 88 | + $this->fail("分类{$info['title']}存在子分类,不能删除"); | ||
| 89 | + } | ||
| 90 | + //是否有对应商品 | ||
| 91 | + if(CategoryRelated::where('cate_id', $id)->count()){ | ||
| 92 | + $this->fail("分类{$info['title']}存在产品,不能删除"); | ||
| 93 | + } | ||
| 94 | + //删除路由映射 | ||
| 95 | + RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); | ||
| 54 | } | 96 | } |
| 97 | + parent::delete($ids); | ||
| 98 | + | ||
| 99 | + DB::commit(); | ||
| 100 | + } catch (BsideGlobalException $e){ | ||
| 101 | + DB::rollBack(); | ||
| 102 | + $this->fail($e->getMessage()); | ||
| 103 | + } catch (\Exception $e){ | ||
| 104 | + DB::rollBack(); | ||
| 105 | + $this->fail('删除失败'); | ||
| 55 | } | 106 | } |
| 56 | - return parent::delete($ids); | 107 | + return $this->success(); |
| 57 | } | 108 | } |
| 58 | 109 | ||
| 59 | /** | 110 | /** |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside\Product; | 3 | namespace App\Http\Logic\Bside\Product; |
| 4 | 4 | ||
| 5 | +use App\Exceptions\BsideGlobalException; | ||
| 5 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Product\KeywordRelated; | 8 | use App\Models\Product\KeywordRelated; |
| @@ -24,6 +25,24 @@ class KeywordLogic extends BaseLogic | @@ -24,6 +25,24 @@ class KeywordLogic extends BaseLogic | ||
| 24 | $this->model = new Keyword(); | 25 | $this->model = new Keyword(); |
| 25 | } | 26 | } |
| 26 | 27 | ||
| 28 | + public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 29 | + { | ||
| 30 | + $data = parent::getList($map, $sort, $columns, $limit); | ||
| 31 | + foreach ($data['list'] as &$v){ | ||
| 32 | + $v['product_num'] = $this->getProductNum($v['id']); | ||
| 33 | + $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']); | ||
| 34 | + $v['url'] = $this->getProjectDomain() . $v['route']; | ||
| 35 | + } | ||
| 36 | + return $this->success($data); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public function getInfo($id) | ||
| 40 | + { | ||
| 41 | + $info = parent::getInfo($id); | ||
| 42 | + $info['url'] = $this->getProjectDomain() . $info['route']; | ||
| 43 | + return $this->success($info); | ||
| 44 | + } | ||
| 45 | + | ||
| 27 | public function save($param){ | 46 | public function save($param){ |
| 28 | DB::beginTransaction(); | 47 | DB::beginTransaction(); |
| 29 | try { | 48 | try { |
| @@ -44,8 +63,6 @@ class KeywordLogic extends BaseLogic | @@ -44,8 +63,6 @@ class KeywordLogic extends BaseLogic | ||
| 44 | 63 | ||
| 45 | DB::beginTransaction(); | 64 | DB::beginTransaction(); |
| 46 | try { | 65 | try { |
| 47 | - parent::delete($ids); | ||
| 48 | - | ||
| 49 | foreach ($ids as $id){ | 66 | foreach ($ids as $id){ |
| 50 | $info = $this->getCacheInfo($id); | 67 | $info = $this->getCacheInfo($id); |
| 51 | if(!$info){ | 68 | if(!$info){ |
| @@ -60,8 +77,12 @@ class KeywordLogic extends BaseLogic | @@ -60,8 +77,12 @@ class KeywordLogic extends BaseLogic | ||
| 60 | //删除路由映射 | 77 | //删除路由映射 |
| 61 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 78 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 62 | } | 79 | } |
| 80 | + parent::delete($ids); | ||
| 63 | 81 | ||
| 64 | DB::commit(); | 82 | DB::commit(); |
| 83 | + } catch (BsideGlobalException $e){ | ||
| 84 | + DB::rollBack(); | ||
| 85 | + $this->fail($e->getMessage()); | ||
| 65 | }catch (\Exception $e){ | 86 | }catch (\Exception $e){ |
| 66 | DB::rollBack(); | 87 | DB::rollBack(); |
| 67 | $this->fail('删除失败'); | 88 | $this->fail('删除失败'); |
| @@ -53,6 +53,7 @@ class ProductLogic extends BaseLogic | @@ -53,6 +53,7 @@ class ProductLogic extends BaseLogic | ||
| 53 | $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim'); | 53 | $info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim'); |
| 54 | $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; | 54 | $info['status_text'] = Product::statusMap()[$info['status']] ?? ''; |
| 55 | $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? ''; | 55 | $info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? ''; |
| 56 | + $info['url'] = $this->getProjectDomain() . $info['route'] ; | ||
| 56 | return $info; | 57 | return $info; |
| 57 | } | 58 | } |
| 58 | 59 | ||
| @@ -85,8 +86,6 @@ class ProductLogic extends BaseLogic | @@ -85,8 +86,6 @@ class ProductLogic extends BaseLogic | ||
| 85 | 86 | ||
| 86 | DB::beginTransaction(); | 87 | DB::beginTransaction(); |
| 87 | try { | 88 | try { |
| 88 | - parent::delete($ids); | ||
| 89 | - | ||
| 90 | foreach ($ids as $id){ | 89 | foreach ($ids as $id){ |
| 91 | //删除路由映射 | 90 | //删除路由映射 |
| 92 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | 91 | RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); |
| @@ -97,6 +96,7 @@ class ProductLogic extends BaseLogic | @@ -97,6 +96,7 @@ class ProductLogic extends BaseLogic | ||
| 97 | //删除关键词关联 | 96 | //删除关键词关联 |
| 98 | KeywordRelated::where('product_id', $id)->delete(); | 97 | KeywordRelated::where('product_id', $id)->delete(); |
| 99 | } | 98 | } |
| 99 | + parent::delete($ids); | ||
| 100 | 100 | ||
| 101 | DB::commit(); | 101 | DB::commit(); |
| 102 | }catch (\Exception $e){ | 102 | }catch (\Exception $e){ |
| @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside; | @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 7 | +use App\Helper\QuanqiusouApi; | ||
| 7 | use App\Helper\Translate; | 8 | use App\Helper\Translate; |
| 8 | use App\Http\Logic\Aside\Project\DomainInfoLogic; | 9 | use App\Http\Logic\Aside\Project\DomainInfoLogic; |
| 9 | use App\Http\Logic\Aside\Project\ProjectLogic; | 10 | use App\Http\Logic\Aside\Project\ProjectLogic; |
| @@ -39,7 +40,7 @@ class RankDataLogic extends BaseLogic | @@ -39,7 +40,7 @@ class RankDataLogic extends BaseLogic | ||
| 39 | $external_links = ExternalLinks::where('project_id', $project_id)->first(); | 40 | $external_links = ExternalLinks::where('project_id', $project_id)->first(); |
| 40 | $indexed_pages = IndexedPages::where('project_id', $project_id)->first(); | 41 | $indexed_pages = IndexedPages::where('project_id', $project_id)->first(); |
| 41 | $speed = Speed::where('project_id', $project_id)->first(); | 42 | $speed = Speed::where('project_id', $project_id)->first(); |
| 42 | - | 43 | + $api_no = $project['deploy_optimize']['api_no'] ?? ''; |
| 43 | //排名数据 | 44 | //排名数据 |
| 44 | $data = [ | 45 | $data = [ |
| 45 | 'first_num' => $rank['first_num'] ?? 0, | 46 | 'first_num' => $rank['first_num'] ?? 0, |
| @@ -51,24 +52,36 @@ class RankDataLogic extends BaseLogic | @@ -51,24 +52,36 @@ class RankDataLogic extends BaseLogic | ||
| 51 | 'external_links_num' => $external_links['total'] ?? 0, | 52 | 'external_links_num' => $external_links['total'] ?? 0, |
| 52 | ]; | 53 | ]; |
| 53 | 54 | ||
| 54 | - //小语种列表 | ||
| 55 | - $langs = Arr::pluck($project['deploy_optimize']['minor_languages'], 'tl'); | ||
| 56 | - foreach ($langs as $lang) { | ||
| 57 | - $data['langs'][$lang] = Translate::getTls($lang); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | //项目信息 | 55 | //项目信息 |
| 61 | $data['project'] = [ | 56 | $data['project'] = [ |
| 62 | 'company' => $project['company'], | 57 | 'company' => $project['company'], |
| 63 | - 'domain' => $project['deploy_optimize']['domain'], | 58 | + 'domain' => $project['deploy_optimize']['domain'] ?? '', |
| 64 | 'domain_info' => ($domain_info['domain_info']['creation_date'] ?? '') . ' - ' . ($domain_info['domain_info']['expiration_date'] ?? ''), | 59 | 'domain_info' => ($domain_info['domain_info']['creation_date'] ?? '') . ' - ' . ($domain_info['domain_info']['expiration_date'] ?? ''), |
| 65 | 'cert_info' => ($domain_info['ssl']['start_time'] ?? '') . ' - ' . ($domain_info['ssl']['end_time'] ?? ''), | 60 | 'cert_info' => ($domain_info['ssl']['start_time'] ?? '') . ' - ' . ($domain_info['ssl']['end_time'] ?? ''), |
| 66 | - 'plan' => str_replace('营销大师-', '全球搜-', $project['deploy_build']['plan'][0]), | 61 | + 'plan' => str_replace('营销大师-', '全球搜-', $project['deploy_build']['plan'][0] ?? ''), |
| 67 | 'keyword_num' => $project['deploy_build']['keyword_num'], | 62 | 'keyword_num' => $project['deploy_build']['keyword_num'], |
| 68 | 'compliance_day' => $rank['compliance_day'] ?? 0, | 63 | 'compliance_day' => $rank['compliance_day'] ?? 0, |
| 69 | 'remain_day' => $project['deploy_build']['service_duration'] - ($rank['compliance_day'] ?? 0), | 64 | 'remain_day' => $project['deploy_build']['service_duration'] - ($rank['compliance_day'] ?? 0), |
| 70 | ]; | 65 | ]; |
| 71 | 66 | ||
| 67 | + //小语种列表 | ||
| 68 | + $quanqiusou_api = new QuanqiusouApi(); | ||
| 69 | + $lang_data = $quanqiusou_api->getLangRankData($api_no); | ||
| 70 | + $lang_data = Arr::setValueToKey($lang_data, 'language'); | ||
| 71 | + $data['langs'] = []; | ||
| 72 | + foreach($project['deploy_optimize']['minor_languages']??[] as $lang){ | ||
| 73 | + $remain_day = $lang_data[$lang['tl']]['dabiao_day'] ?? 0; | ||
| 74 | + $data['langs'][$lang['tl'] ?? ''] = [ | ||
| 75 | + 'lang_text' => Translate::getTls($lang['tl'] ?? ''), | ||
| 76 | + 'keyword_num' => $lang['keywords'] ?? 0, | ||
| 77 | + 'reach_day' => $lang_data[$lang['tl']]['dabiao_day'] ?? 0, | ||
| 78 | + 'home_cnt' => $lang_data[$lang['tl']]['home_cnt'] ?? 0, | ||
| 79 | + 'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day, | ||
| 80 | + 'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数 | ||
| 81 | + ]; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + | ||
| 72 | //测速 | 85 | //测速 |
| 73 | $data['speed'] = $speed['data'] ?? []; | 86 | $data['speed'] = $speed['data'] ?? []; |
| 74 | 87 | ||
| @@ -83,6 +96,7 @@ class RankDataLogic extends BaseLogic | @@ -83,6 +96,7 @@ class RankDataLogic extends BaseLogic | ||
| 83 | ]; | 96 | ]; |
| 84 | 97 | ||
| 85 | //外链引荐域名 | 98 | //外链引荐域名 |
| 99 | + $recomm_domain = $recomm_domain ? $recomm_domain->toArray() : []; | ||
| 86 | $data['external_links_domain_chat'] = [ | 100 | $data['external_links_domain_chat'] = [ |
| 87 | 'labels' => array_map(function ($item) { | 101 | 'labels' => array_map(function ($item) { |
| 88 | return Str::substrReplace($item, '***', 2, 3); | 102 | return Str::substrReplace($item, '***', 2, 3); |
| @@ -107,8 +121,8 @@ class RankDataLogic extends BaseLogic | @@ -107,8 +121,8 @@ class RankDataLogic extends BaseLogic | ||
| 107 | } | 121 | } |
| 108 | //关键词排名分析图 | 122 | //关键词排名分析图 |
| 109 | $data['rank_chat'] = [ | 123 | $data['rank_chat'] = [ |
| 110 | - 'data' => $rank_week['data'], | ||
| 111 | - 'labels' => $rank_week['date'], | 124 | + 'data' => $rank_week['data'] ?? [], |
| 125 | + 'labels' => $rank_week['date'] ?? [], | ||
| 112 | ]; | 126 | ]; |
| 113 | 127 | ||
| 114 | return $data; | 128 | return $data; |
| @@ -168,12 +182,24 @@ class RankDataLogic extends BaseLogic | @@ -168,12 +182,24 @@ class RankDataLogic extends BaseLogic | ||
| 168 | } | 182 | } |
| 169 | } | 183 | } |
| 170 | } | 184 | } |
| 185 | + $domain_arr = explode(':', $domain_text); | ||
| 171 | $v = [ | 186 | $v = [ |
| 172 | 'keyword' => $key, | 187 | 'keyword' => $key, |
| 173 | - 'domain' => $domain_text, | 188 | + 'domain_type' => $domain_arr[0], |
| 189 | + 'domain' => $domain_arr[1], | ||
| 190 | + 'domain_text' => $domain_text, | ||
| 174 | 'g' => $last['g'], //1核心关键词 | 191 | 'g' => $last['g'], //1核心关键词 |
| 175 | - 'position' => $data | 192 | + 'position' => $data, |
| 176 | ]; | 193 | ]; |
| 194 | + //图片排名 | ||
| 195 | + if(isset($last['p_img'])){ | ||
| 196 | + $v['img_position'] = $last['p_img']; | ||
| 197 | + } | ||
| 198 | + //视频排名 | ||
| 199 | + if(isset($last['p_vid'])){ | ||
| 200 | + $v['video_position'] = $last['p_vid']; | ||
| 201 | + } | ||
| 202 | + | ||
| 177 | if ($last['position'] == 0) { | 203 | if ($last['position'] == 0) { |
| 178 | $list0[] = $v; | 204 | $list0[] = $v; |
| 179 | } elseif ($last['position'] <= 30) { | 205 | } elseif ($last['position'] <= 30) { |
| @@ -4,7 +4,7 @@ namespace App\Http\Logic\Bside\User; | @@ -4,7 +4,7 @@ namespace App\Http\Logic\Bside\User; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | -use App\Models\ProjectDept; | 7 | +use App\Models\User\ProjectDept; |
| 8 | 8 | ||
| 9 | /** | 9 | /** |
| 10 | * Class DeptLogic | 10 | * Class DeptLogic |
app/Http/Logic/Bside/User/DeptUserLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside\User; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | +use App\Models\User\DeptUser; | ||
| 7 | +use App\Models\User\User as UserModel; | ||
| 8 | + | ||
| 9 | +class DeptUserLogic extends BaseLogic | ||
| 10 | +{ | ||
| 11 | + public function __construct() | ||
| 12 | + { | ||
| 13 | + parent::__construct(); | ||
| 14 | + | ||
| 15 | + $this->model = new DeptUser(); | ||
| 16 | + $this->param = $this->requestAll; | ||
| 17 | + } | ||
| 18 | + /** | ||
| 19 | + * @name :(部门用户)dept_user_add | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2023/5/18 10:21 | ||
| 23 | + */ | ||
| 24 | + public function dept_user_save(){ | ||
| 25 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 26 | + $rs = $this->dept_user_edit($this->param); | ||
| 27 | + }else{ | ||
| 28 | + $rs = $this->dept_user_add(); | ||
| 29 | + } | ||
| 30 | + if ($rs === false) { | ||
| 31 | + $this->fail('部门添加成员失败'); | ||
| 32 | + } | ||
| 33 | + return $this->success(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @name :(部门添加用户)dept_user_add | ||
| 38 | + * @author :lyh | ||
| 39 | + * @method :post | ||
| 40 | + * @time :2023/5/18 10:21 | ||
| 41 | + */ | ||
| 42 | + public function dept_user_add(){ | ||
| 43 | + $param = [ | ||
| 44 | + 'dept_id'=> $this->param['dept_id'], | ||
| 45 | + 'project_id'=>$this->user['project_id'], | ||
| 46 | + 'user_id'=>$this->param['user_id'], | ||
| 47 | + 'operator_id'=>$this->user['id'], | ||
| 48 | + 'create_id'=>$this->user['id'] | ||
| 49 | + ]; | ||
| 50 | + $rs = $this->model->add($param); | ||
| 51 | + if($rs === false){ | ||
| 52 | + $this->fail('部门添加成员失败'); | ||
| 53 | + } | ||
| 54 | + return $this->success(); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @name :(用户更改部门)dept_user_edit | ||
| 59 | + * @author :lyh | ||
| 60 | + * @method :post | ||
| 61 | + * @time :2023/5/17 17:54 | ||
| 62 | + */ | ||
| 63 | + public function dept_user_edit($param){ | ||
| 64 | + $rs = $this->model->edit($param,['id'=>$this->param['id']]); | ||
| 65 | + if($rs === false){ | ||
| 66 | + $this->fail('error'); | ||
| 67 | + } | ||
| 68 | + return $this->success(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * @name :(用户设置角色)user_edit_role | ||
| 73 | + * @author :lyh | ||
| 74 | + * @method :post | ||
| 75 | + * @time :2023/5/19 9:35 | ||
| 76 | + */ | ||
| 77 | + public function user_edit_role(){ | ||
| 78 | + $userModel = new UserModel(); | ||
| 79 | + $rs = $userModel->edit(['role_id'=>$this->param['role_id']],['id'=>$this->param['id']]); | ||
| 80 | + if($rs === false){ | ||
| 81 | + $this->fail('error'); | ||
| 82 | + } | ||
| 83 | + return $this->success(); | ||
| 84 | + } | ||
| 85 | +} |
| @@ -4,6 +4,8 @@ namespace App\Http\Logic\Bside\User; | @@ -4,6 +4,8 @@ namespace App\Http\Logic\Bside\User; | ||
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | use App\Models\User\ProjectGroup; | 6 | use App\Models\User\ProjectGroup; |
| 7 | +use App\Models\User\User as UserModel; | ||
| 8 | +use Illuminate\Support\Facades\DB; | ||
| 7 | 9 | ||
| 8 | class GroupLogic extends BaseLogic | 10 | class GroupLogic extends BaseLogic |
| 9 | { | 11 | { |
| @@ -15,17 +17,16 @@ class GroupLogic extends BaseLogic | @@ -15,17 +17,16 @@ class GroupLogic extends BaseLogic | ||
| 15 | $this->param = $this->requestAll; | 17 | $this->param = $this->requestAll; |
| 16 | } | 18 | } |
| 17 | /** | 19 | /** |
| 18 | - * @name :添加 | 20 | + * @name :添加用户组 |
| 19 | * @return void | 21 | * @return void |
| 20 | * @author :liyuhang | 22 | * @author :liyuhang |
| 21 | * @method | 23 | * @method |
| 22 | */ | 24 | */ |
| 23 | public function group_add(){ | 25 | public function group_add(){ |
| 24 | $this->param['project_id'] = $this->user['project_id']; | 26 | $this->param['project_id'] = $this->user['project_id']; |
| 25 | - $this->param['admin_id'] = $this->user['admin_id']; | ||
| 26 | - $this->param['create_id'] = $this->user['create_id']; | ||
| 27 | - $this->param['operator_id'] = $this->user['operator_id']; | ||
| 28 | - $this->param['user_list'] = ','.trim($this->param['user_list'],',').','; | 27 | + $this->param['admin_id'] = $this->user['id']; |
| 28 | + $this->param['create_id'] = $this->user['id']; | ||
| 29 | + $this->param['operator_id'] = $this->user['id']; | ||
| 29 | $rs = $this->model->add($this->param); | 30 | $rs = $this->model->add($this->param); |
| 30 | if($rs === false){ | 31 | if($rs === false){ |
| 31 | $this->fail('error'); | 32 | $this->fail('error'); |
| @@ -34,13 +35,37 @@ class GroupLogic extends BaseLogic | @@ -34,13 +35,37 @@ class GroupLogic extends BaseLogic | ||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | /** | 37 | /** |
| 38 | + * @name :(添加成员)group_add_user | ||
| 39 | + * @author :lyh | ||
| 40 | + * @method :post | ||
| 41 | + * @time :2023/5/17 15:58 | ||
| 42 | + */ | ||
| 43 | + public function group_add_user(){ | ||
| 44 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 45 | + //组装数据 | ||
| 46 | + $str = ltrim($info['user_list'],',').$this->param['user_list']; | ||
| 47 | + $arr = array_unique(explode(',',$str)); | ||
| 48 | + sort($arr); | ||
| 49 | + $str = ','.implode(',',$arr).','; | ||
| 50 | + DB::beginTransaction(); | ||
| 51 | + try { | ||
| 52 | + $this->model->edit(['user_list'=>$str],['id'=>$this->param['id']]); | ||
| 53 | + //更新父类 | ||
| 54 | + $this->update_parent($this->param,$info); | ||
| 55 | + DB::commit(); | ||
| 56 | + }catch (\Exception $e){ | ||
| 57 | + DB::rollBack(); | ||
| 58 | + $this->fail('添加成员失败'); | ||
| 59 | + } | ||
| 60 | + return $this->success(); | ||
| 61 | + } | ||
| 62 | + /** | ||
| 37 | * @name :编辑 | 63 | * @name :编辑 |
| 38 | * @return void | 64 | * @return void |
| 39 | * @author :liyuhang | 65 | * @author :liyuhang |
| 40 | * @method | 66 | * @method |
| 41 | */ | 67 | */ |
| 42 | public function group_edit(){ | 68 | public function group_edit(){ |
| 43 | - $this->param['user_list'] = ','.trim($this->param['user_list'],',').','; | ||
| 44 | $rs = $this->edit($this->param,['id'=>$this->param['id']]); | 69 | $rs = $this->edit($this->param,['id'=>$this->param['id']]); |
| 45 | if($rs === false){ | 70 | if($rs === false){ |
| 46 | $this->fail('error'); | 71 | $this->fail('error'); |
| @@ -49,13 +74,29 @@ class GroupLogic extends BaseLogic | @@ -49,13 +74,29 @@ class GroupLogic extends BaseLogic | ||
| 49 | } | 74 | } |
| 50 | 75 | ||
| 51 | /** | 76 | /** |
| 77 | + * @name :(获取成员列表)user_list | ||
| 78 | + * @author :lyh | ||
| 79 | + * @method :post | ||
| 80 | + * @time :2023/5/17 14:51 | ||
| 81 | + */ | ||
| 82 | + public function user_list($data = [],$order = 'id'){ | ||
| 83 | + unset($this->param['id']); | ||
| 84 | + $userModel = new UserModel(); | ||
| 85 | + $data = array_merge($data,$this->param); | ||
| 86 | + $lists = $userModel->list($data,$order,['id','name','mobile','created_at']); | ||
| 87 | + return $this->success($lists); | ||
| 88 | + } | ||
| 89 | + /** | ||
| 52 | * @name :详情 | 90 | * @name :详情 |
| 53 | * @return void | 91 | * @return void |
| 54 | * @author :liyuhang | 92 | * @author :liyuhang |
| 55 | * @method | 93 | * @method |
| 56 | */ | 94 | */ |
| 57 | - public function group_info(){ | ||
| 58 | - $info = $this->info($this->param); | 95 | + public function group_info($param = []){ |
| 96 | + if(empty($param)){ | ||
| 97 | + $param = $this->param; | ||
| 98 | + } | ||
| 99 | + $info = $this->model->read($this->param); | ||
| 59 | return $this->success($info); | 100 | return $this->success($info); |
| 60 | } | 101 | } |
| 61 | 102 | ||
| @@ -66,12 +107,69 @@ class GroupLogic extends BaseLogic | @@ -66,12 +107,69 @@ class GroupLogic extends BaseLogic | ||
| 66 | * @method | 107 | * @method |
| 67 | */ | 108 | */ |
| 68 | public function group_del(){ | 109 | public function group_del(){ |
| 69 | - $ids = $this->param['id']; | ||
| 70 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 71 | - $rs = $this->del($this->param,$ids); | 110 | + //查看当前是否拥有父类 |
| 111 | + $info = $this->model->read(['pid'=>$this->param['id']]); | ||
| 112 | + if($info !== false){ | ||
| 113 | + $this->fail('当前删除组织拥有下级组织,不允许删除'); | ||
| 114 | + } | ||
| 115 | + $rs = $this->del($this->param); | ||
| 72 | if($rs === false){ | 116 | if($rs === false){ |
| 73 | $this->fail('error'); | 117 | $this->fail('error'); |
| 74 | } | 118 | } |
| 75 | return $this->success(); | 119 | return $this->success(); |
| 76 | } | 120 | } |
| 121 | + | ||
| 122 | + /** | ||
| 123 | + * @name :(更新父类成员)update_parent | ||
| 124 | + * @author :lyh | ||
| 125 | + * @method :post | ||
| 126 | + * @time :2023/5/17 9:22 | ||
| 127 | + */ | ||
| 128 | + public function update_parent($param,$info){ | ||
| 129 | + //查询当前组是否拥有父类 | ||
| 130 | + if($info['pid'] != 0){ | ||
| 131 | + $parent_info = $this->model->read(['id'=>$info['pid']]); | ||
| 132 | + //把添加成员合并到上级 | ||
| 133 | + $str = trim(trim($param['user_list'],',').$parent_info['user_list'],','); | ||
| 134 | + $arr = array_unique(explode(',', $str)); | ||
| 135 | + sort($arr); | ||
| 136 | + $mergedString = ','.implode(',', $arr).','; | ||
| 137 | + $rs = $this->model->edit(['user_list'=>$mergedString],['id'=>$parent_info['id']]); | ||
| 138 | + if($rs === false){ | ||
| 139 | + $this->fail('更新父级失败'); | ||
| 140 | + } | ||
| 141 | + //查看当前父级是否还拥有父级 | ||
| 142 | + if($parent_info['pid'] != 0){ | ||
| 143 | + return $this->update_parent($param,$parent_info); | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + return $this->success(); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * @name :(更新子类,同时清空子集成员)edit_son | ||
| 151 | + * @author :lyh | ||
| 152 | + * @method :post | ||
| 153 | + * @time :2023/5/17 13:52 | ||
| 154 | + */ | ||
| 155 | + public function update_son($param,$id){ | ||
| 156 | + //当前数据详情 | ||
| 157 | + $info = $this->model->read(['id'=>$id]); | ||
| 158 | + //子集详情 | ||
| 159 | + $son_list = $this->model->list(['pid'=>$info['id']],'id'); | ||
| 160 | + if(!empty($son_list)){ | ||
| 161 | + //循环查询 | ||
| 162 | + foreach ($son_list as $k => $v){ | ||
| 163 | + $son_data = explode(',',trim($v['user_list'],',')); | ||
| 164 | + $son_str = ''; | ||
| 165 | + foreach ($son_data as $v1){ | ||
| 166 | + if(strpos($param['user_list'],','.$v1.',') > -1){ | ||
| 167 | + $son_str .= $v1.','; | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + $this->model->edit(['user_list'=>','.$son_str],['id'=>$v['id']]); | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + return true; | ||
| 174 | + } | ||
| 77 | } | 175 | } |
| @@ -22,7 +22,7 @@ class UserLogic extends BaseLogic | @@ -22,7 +22,7 @@ class UserLogic extends BaseLogic | ||
| 22 | * @method | 22 | * @method |
| 23 | */ | 23 | */ |
| 24 | public function user_info(){ | 24 | public function user_info(){ |
| 25 | - $info = $this->info($this->param); | 25 | + $info = $this->model->read($this->param); |
| 26 | return $this->success($info); | 26 | return $this->success($info); |
| 27 | } | 27 | } |
| 28 | /** | 28 | /** |
| @@ -97,9 +97,9 @@ class UserLogic extends BaseLogic | @@ -97,9 +97,9 @@ class UserLogic extends BaseLogic | ||
| 97 | * @method | 97 | * @method |
| 98 | */ | 98 | */ |
| 99 | public function user_del(){ | 99 | public function user_del(){ |
| 100 | - $ids = $this->param['id']; | ||
| 101 | $this->param['id'] = ['in',$this->param['id']]; | 100 | $this->param['id'] = ['in',$this->param['id']]; |
| 102 | - $this->del($this->param,$ids); | 101 | + $this->model->del($this->param); |
| 102 | + //对应删除组织架构 | ||
| 103 | return $this->success(); | 103 | return $this->success(); |
| 104 | } | 104 | } |
| 105 | 105 |
app/Http/Logic/Cside/BaseLogic.php
已删除
100644 → 0
| 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
已删除
100644 → 0
| 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,7 +4,6 @@ namespace App\Http\Logic; | @@ -4,7 +4,6 @@ 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; | ||
| 8 | use \App\Helper\Common as CommonHelper; | 7 | use \App\Helper\Common as CommonHelper; |
| 9 | use App\Exceptions\AsideGlobalException; | 8 | use App\Exceptions\AsideGlobalException; |
| 10 | use App\Exceptions\BsideGlobalException; | 9 | use App\Exceptions\BsideGlobalException; |
| @@ -46,9 +45,6 @@ class Logic | @@ -46,9 +45,6 @@ class Logic | ||
| 46 | if((request()->path()[0]) == Common::B){ | 45 | if((request()->path()[0]) == Common::B){ |
| 47 | throw new BsideGlobalException($code, $message); | 46 | throw new BsideGlobalException($code, $message); |
| 48 | } | 47 | } |
| 49 | - if((request()->path()[0]) == Common::C){ | ||
| 50 | - throw new CsideGlobalException($code, $message); | ||
| 51 | - } | ||
| 52 | throw new AsideGlobalException($code, $message); | 48 | throw new AsideGlobalException($code, $message); |
| 53 | } | 49 | } |
| 54 | 50 |
| 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 | -} |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | -namespace App\Http\Requests\Cside; | 3 | +namespace App\Http\Requests\Aside\Devops; |
| 4 | 4 | ||
| 5 | +use App\Models\Devops\ServerInformation; | ||
| 5 | use Illuminate\Foundation\Http\FormRequest; | 6 | use Illuminate\Foundation\Http\FormRequest; |
| 7 | +use Illuminate\Validation\Rule; | ||
| 6 | 8 | ||
| 7 | -/** | ||
| 8 | - * Class InquiryRequest | ||
| 9 | - * @package App\Http\Requests\Cside | ||
| 10 | - * @author zbj | ||
| 11 | - * @date 2023/5/4 | ||
| 12 | - */ | ||
| 13 | -class InquiryRequest extends FormRequest | 9 | +class ServerInformationRequest extends FormRequest |
| 14 | { | 10 | { |
| 15 | /** | 11 | /** |
| 16 | * Determine if the user is authorized to make this request. | 12 | * Determine if the user is authorized to make this request. |
| @@ -30,16 +26,37 @@ class InquiryRequest extends FormRequest | @@ -30,16 +26,37 @@ class InquiryRequest extends FormRequest | ||
| 30 | public function rules() | 26 | public function rules() |
| 31 | { | 27 | { |
| 32 | return [ | 28 | return [ |
| 33 | - 'name' => 'required|max:200', | ||
| 34 | - 'email' => 'required|email|max:200', | ||
| 35 | - 'phone' => 'max:200', | ||
| 36 | - 'content' => 'required', | 29 | + 'type' => [ 'required', Rule::in( array_keys( ( new ServerInformation )->ServiceArray() ) ) ], |
| 30 | + 'ip' => 'required|ip', | ||
| 31 | + 'title' => 'required|max:200', | ||
| 32 | + 'belong_to' => 'required|integer|in:1,2', // 1:公司 2:客户 | ||
| 33 | + 'sshpass' => 'required|max:100', | ||
| 34 | + 'ports' => 'required|integer|min:1|max:65535', | ||
| 37 | ]; | 35 | ]; |
| 38 | } | 36 | } |
| 39 | 37 | ||
| 40 | public function messages() | 38 | public function messages() |
| 41 | { | 39 | { |
| 42 | - return []; | 40 | + $service_array = ( new ServerInformation )->ServiceArray(); |
| 41 | + $serviceStr = implode( ', ', $service_array ); | ||
| 42 | + return [ | ||
| 43 | + 'type.required' => '服务器类型不能为空', | ||
| 44 | + 'type.integer' => '服务器类型格式不正确', | ||
| 45 | + 'type.between' => '服务器类型 ' . $serviceStr, | ||
| 46 | + 'ip.required' => 'ip不能为空', | ||
| 47 | + 'ip.ip' => 'ip格式不正确', | ||
| 48 | + 'title.required' => '服务器标题不能为空', | ||
| 49 | + 'title.max' => '服务器标题不能超过200个字符', | ||
| 50 | + 'belong_to.required' => '服务器归属不能为空', | ||
| 51 | + 'belong_to.integer' => '服务器归属格式不正确', | ||
| 52 | + 'belong_to.in' => '服务器归属只能是公司或者客户', | ||
| 53 | + 'sshpass.required' => 'ssh密码不能为空', | ||
| 54 | + 'sshpass.max' => 'ssh密码不能超过100个字符', | ||
| 55 | + 'ports.required' => 'ssh端口不能为空', | ||
| 56 | + 'ports.integer' => 'ssh端口格式不正确', | ||
| 57 | + 'ports.min' => 'ssh端口不能小于1', | ||
| 58 | + 'ports.max' => 'ssh端口不能大于65535', | ||
| 59 | + ]; | ||
| 43 | } | 60 | } |
| 44 | 61 | ||
| 45 | } | 62 | } |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | -namespace App\Http\Requests\Bside\AyrRelease; | 3 | +namespace App\Http\Requests\Bside\AyrShare; |
| 4 | 4 | ||
| 5 | use Illuminate\Foundation\Http\FormRequest; | 5 | use Illuminate\Foundation\Http\FormRequest; |
| 6 | 6 | ||
| @@ -24,12 +24,12 @@ class AyrReleaseRequest extends FormRequest | @@ -24,12 +24,12 @@ class AyrReleaseRequest extends FormRequest | ||
| 24 | { | 24 | { |
| 25 | return [ | 25 | return [ |
| 26 | 'title'=>'required', | 26 | 'title'=>'required', |
| 27 | - 'images'=>'required|array', | ||
| 28 | - 'video'=>'required', | 27 | +// 'images'=>'required|array', |
| 28 | +// 'video'=>'required', | ||
| 29 | 'content'=>'required', | 29 | 'content'=>'required', |
| 30 | 'share_id'=>'required', | 30 | 'share_id'=>'required', |
| 31 | 'platforms'=>'required|array', | 31 | 'platforms'=>'required|array', |
| 32 | - 'idempotency_key'=>'required', | 32 | +// 'schedule_date'=>'required', |
| 33 | ]; | 33 | ]; |
| 34 | } | 34 | } |
| 35 | 35 |
app/Models/Aside/TemplateHeaderFooter.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Aside; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 模板 头部底部 对所有 客户 | ||
| 9 | + * @author:dc | ||
| 10 | + * @time 2023/4/26 11:21 | ||
| 11 | + * Class TemplateHeaderFooter | ||
| 12 | + * @package App\Models\Aside | ||
| 13 | + */ | ||
| 14 | +class TemplateHeaderFooter extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_aside_template_header_footer'; | ||
| 17 | +} |
| @@ -84,7 +84,7 @@ class Base extends Model | @@ -84,7 +84,7 @@ class Base extends Model | ||
| 84 | * @author :liyuhang | 84 | * @author :liyuhang |
| 85 | * @method | 85 | * @method |
| 86 | */ | 86 | */ |
| 87 | - public function list($map,$order = 'sort',$fields = ['*']): array | 87 | + public function list($map = [],$order = 'id',$fields = ['*']): array |
| 88 | { | 88 | { |
| 89 | $query = $this->formatQuery($map); | 89 | $query = $this->formatQuery($map); |
| 90 | $lists = $query->select($fields)->orderBy($order)->get(); | 90 | $lists = $query->select($fields)->orderBy($order)->get(); |
| @@ -187,7 +187,7 @@ class Base extends Model | @@ -187,7 +187,7 @@ class Base extends Model | ||
| 187 | // in查询 ['id'=>['in',[1,2,3]]] | 187 | // in查询 ['id'=>['in',[1,2,3]]] |
| 188 | $query->orWhere($k, $v[1]); | 188 | $query->orWhere($k, $v[1]); |
| 189 | break; | 189 | break; |
| 190 | - case 'no in': | 190 | + case 'not in': |
| 191 | // in查询 ['id'=>['not in',[1,2,3]]] | 191 | // in查询 ['id'=>['not in',[1,2,3]]] |
| 192 | $query->whereNotIn($k, $v[1]); | 192 | $query->whereNotIn($k, $v[1]); |
| 193 | break; | 193 | break; |
app/Models/Bside/TemplateHeaderFooter.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Bside; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 模板 头部底部 客户自己的 | ||
| 9 | + * @author:dc | ||
| 10 | + * @time 2023/4/26 11:21 | ||
| 11 | + * Class TemplateHeaderFooter | ||
| 12 | + * @package App\Models\Bside | ||
| 13 | + */ | ||
| 14 | +class TemplateHeaderFooter extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_bside_template_header_footer'; | ||
| 17 | +} |
app/Models/Devops/ServerInformation.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Devops; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +class ServerInformation extends Model | ||
| 8 | +{ | ||
| 9 | + | ||
| 10 | + protected $table = 'gl_server_information'; | ||
| 11 | + const CREATED_AT = 'create_at'; | ||
| 12 | + const UPDATED_AT = 'update_at'; | ||
| 13 | + | ||
| 14 | + // 软删除 0:正常 1:删除 | ||
| 15 | + const DELETED_NORMAL = 0; | ||
| 16 | + const DELETED_DELETE = 1; | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @param $num | ||
| 21 | + * | ||
| 22 | + * @return string | ||
| 23 | + */ | ||
| 24 | + public function Service($num) | ||
| 25 | + { | ||
| 26 | + return $this->ServiceArray()[$num]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @return array | ||
| 31 | + */ | ||
| 32 | + public function ServiceArray() | ||
| 33 | + { | ||
| 34 | + return [ | ||
| 35 | + 1 => '阿里云', | ||
| 36 | + 2 => '腾讯云', | ||
| 37 | + 3 => 'linode', | ||
| 38 | + 4 => '尊云', | ||
| 39 | + 5 => '互联', | ||
| 40 | + 6 => '其他', | ||
| 41 | + 7 => 'Ramnode', | ||
| 42 | + 8 => 'CN2-SSD美国', | ||
| 43 | + 9 => '国内测试服务器', | ||
| 44 | + ]; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 字段信息 | ||
| 49 | + * @return array | ||
| 50 | + */ | ||
| 51 | + public function FieldsArray() | ||
| 52 | + { | ||
| 53 | + return [ | ||
| 54 | + 'type' => '服务器类型', | ||
| 55 | + 'ip' => '服务器IP', | ||
| 56 | + 'title' => '服务器标题', | ||
| 57 | + 'belong_to' => '服务器归属', | ||
| 58 | + 'sshpass' => 'SSH 密码', | ||
| 59 | + 'ports' => 'SSH 端口', | ||
| 60 | + 'other' => '其他信息 json格式', | ||
| 61 | + ]; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 服务器归属信息 | ||
| 66 | + * @return array | ||
| 67 | + */ | ||
| 68 | + public function BelongToArray() | ||
| 69 | + { | ||
| 70 | + return [ | ||
| 71 | + 1 => '公司', | ||
| 72 | + 2 => '客户', | ||
| 73 | + ]; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public function BelongTo($num) | ||
| 77 | + { | ||
| 78 | + return $this->BelongToArray()[$num]; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 返回服务器类型 | ||
| 83 | + * @param $value | ||
| 84 | + * | ||
| 85 | + * @return string | ||
| 86 | + */ | ||
| 87 | + public function getTypeAttribute($value) | ||
| 88 | + { | ||
| 89 | + return $this->Service($value); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 返回服务器归属 | ||
| 94 | + * @param $value | ||
| 95 | + * | ||
| 96 | + * @return string | ||
| 97 | + */ | ||
| 98 | + public function getBelongToAttribute($value) | ||
| 99 | + { | ||
| 100 | + return $this->BelongTo($value); | ||
| 101 | + } | ||
| 102 | +} |
app/Models/Devops/ServerInformationLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Devops; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +class ServerInformationLog extends Model | ||
| 8 | +{ | ||
| 9 | + protected $table = 'gl_server_information_log'; | ||
| 10 | + const CREATED_AT = 'create_at'; | ||
| 11 | + const UPDATED_AT = 'update_at'; | ||
| 12 | + | ||
| 13 | + public function getOriginalAttribute($value) | ||
| 14 | + { | ||
| 15 | + return json_decode($value, true); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + public function getRevisedAttribute($value) | ||
| 19 | + { | ||
| 20 | + return json_decode($value, true); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + /** @var int 日志添加 */ | ||
| 24 | + const ACTION_ADD = 1; | ||
| 25 | + /** @var int 日志修改 */ | ||
| 26 | + const ACTION_UPDATE = 2; | ||
| 27 | + /** @var int 日志删除 */ | ||
| 28 | + const ACTION_DELETE = 3; | ||
| 29 | + /** @var int 日志恢复 */ | ||
| 30 | + const ACTION_RECOVER = 4; | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @return string[] | ||
| 35 | + */ | ||
| 36 | + public static function actionArr() | ||
| 37 | + { | ||
| 38 | + return [ | ||
| 39 | + 1 => '添加', | ||
| 40 | + 2 => '修改', | ||
| 41 | + 3 => '删除', | ||
| 42 | + 4 => '恢复', | ||
| 43 | + ]; | ||
| 44 | + } | ||
| 45 | +} |
app/Models/Inquiry.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models; | ||
| 4 | - | ||
| 5 | -use App\Helper\Arr; | ||
| 6 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * Class Inquiry | ||
| 10 | - * @package App\Models | ||
| 11 | - * @author zbj | ||
| 12 | - * @date 2023/5/4 | ||
| 13 | - */ | ||
| 14 | -class Inquiry extends Base | ||
| 15 | -{ | ||
| 16 | - use SoftDeletes; | ||
| 17 | - | ||
| 18 | - //设置关联表名 | ||
| 19 | - protected $table = 'gl_inquiry'; | ||
| 20 | - | ||
| 21 | - const STATUS_UNREAD = 0; | ||
| 22 | - const STATUS_READ = 1; | ||
| 23 | - | ||
| 24 | - public function setIpInfoAttribute($value){ | ||
| 25 | - $this->attributes['ip_info'] = Arr::a2s($value); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - public function getIpInfoAttribute($value){ | ||
| 29 | - return Arr::s2a($value); | ||
| 30 | - } | ||
| 31 | -} |
app/Models/InquirySet.php
0 → 100644
| @@ -4,6 +4,7 @@ namespace App\Models\Product; | @@ -4,6 +4,7 @@ namespace App\Models\Product; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Models\Base; | 6 | use App\Models\Base; |
| 7 | +use App\Models\RouteMap; | ||
| 7 | use App\Services\Facades\Upload; | 8 | use App\Services\Facades\Upload; |
| 8 | use Illuminate\Database\Eloquent\SoftDeletes; | 9 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 9 | 10 | ||
| @@ -14,12 +15,21 @@ class Category extends Base | @@ -14,12 +15,21 @@ class Category extends Base | ||
| 14 | //设置关联表名 | 15 | //设置关联表名 |
| 15 | protected $table = 'gl_product_category'; | 16 | protected $table = 'gl_product_category'; |
| 16 | 17 | ||
| 18 | + const STATUS_ACTIVE = 1; | ||
| 19 | + | ||
| 17 | /** | 20 | /** |
| 18 | * 子分类 | 21 | * 子分类 |
| 19 | * @var array | 22 | * @var array |
| 20 | */ | 23 | */ |
| 21 | protected $child_ids_arr = []; | 24 | protected $child_ids_arr = []; |
| 22 | 25 | ||
| 26 | + | ||
| 27 | + protected $appends = ['route']; | ||
| 28 | + | ||
| 29 | + public function getRouteAttribute(){ | ||
| 30 | + return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_CATE, $this->id, $this->project_id); | ||
| 31 | + } | ||
| 32 | + | ||
| 23 | public function getImageAttribute($value) | 33 | public function getImageAttribute($value) |
| 24 | { | 34 | { |
| 25 | return Upload::path2url($value); | 35 | return Upload::path2url($value); |
| @@ -17,6 +17,14 @@ class RankData extends Base | @@ -17,6 +17,14 @@ class RankData extends Base | ||
| 17 | //设置关联表名 | 17 | //设置关联表名 |
| 18 | protected $table = 'gl_rank_data'; | 18 | protected $table = 'gl_rank_data'; |
| 19 | 19 | ||
| 20 | + public static function gMap(){ | ||
| 21 | + return [ | ||
| 22 | + 1 => '主关键词', | ||
| 23 | + 2 => '拓展关键词', | ||
| 24 | + 3 => '小语种关键词', | ||
| 25 | + ]; | ||
| 26 | + } | ||
| 27 | + | ||
| 20 | public function setDataAttribute($value) | 28 | public function setDataAttribute($value) |
| 21 | { | 29 | { |
| 22 | $this->attributes['data'] = Arr::a2s($value); | 30 | $this->attributes['data'] = Arr::a2s($value); |
| @@ -22,6 +22,7 @@ class RouteMap extends Model | @@ -22,6 +22,7 @@ class RouteMap extends Model | ||
| 22 | const SOURCE_PRODUCT = 'product'; | 22 | const SOURCE_PRODUCT = 'product'; |
| 23 | const SOURCE_PRODUCT_CATE = 'product_category'; | 23 | const SOURCE_PRODUCT_CATE = 'product_category'; |
| 24 | const SOURCE_PRODUCT_KEYWORD = 'product_keyword'; | 24 | const SOURCE_PRODUCT_KEYWORD = 'product_keyword'; |
| 25 | + const SOURCE_PAGE = 'page'; //单页面 | ||
| 25 | 26 | ||
| 26 | //路由类型 | 27 | //路由类型 |
| 27 | const SOURCE_BLOG = 'blog'; | 28 | const SOURCE_BLOG = 'blog'; |
| @@ -4,10 +4,7 @@ namespace App\Models\User; | @@ -4,10 +4,7 @@ namespace App\Models\User; | ||
| 4 | 4 | ||
| 5 | use App\Models\Base; | 5 | use App\Models\Base; |
| 6 | 6 | ||
| 7 | -class ProjectGroup extends Base | 7 | +class DeptUser extends Base |
| 8 | { | 8 | { |
| 9 | - //设置关联表名 | ||
| 10 | - protected $table = 'gl_project_group'; | ||
| 11 | - //自动维护create_at创建时间 updated_at修改时间 | ||
| 12 | - public $timestamps = true; | 9 | + protected $table = 'gl_project_dept_user'; |
| 13 | } | 10 | } |
app/Models/User/ViewDeptUser.php
0 → 100644
| @@ -40,7 +40,6 @@ class RouteServiceProvider extends ServiceProvider | @@ -40,7 +40,6 @@ class RouteServiceProvider extends ServiceProvider | ||
| 40 | //预定义两个端的API路由 | 40 | //预定义两个端的API路由 |
| 41 | $this->mapAsideRoute(); | 41 | $this->mapAsideRoute(); |
| 42 | $this->mapBsideRoute(); | 42 | $this->mapBsideRoute(); |
| 43 | - $this->mapCsideRoute(); | ||
| 44 | 43 | ||
| 45 | // 暂时无用 | 44 | // 暂时无用 |
| 46 | $this->routes(function () { | 45 | $this->routes(function () { |
| @@ -75,16 +74,6 @@ class RouteServiceProvider extends ServiceProvider | @@ -75,16 +74,6 @@ class RouteServiceProvider extends ServiceProvider | ||
| 75 | ->namespace($this->namespace . '\Bside') | 74 | ->namespace($this->namespace . '\Bside') |
| 76 | ->group(base_path('routes/bside.php')); | 75 | ->group(base_path('routes/bside.php')); |
| 77 | } | 76 | } |
| 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 | - } | ||
| 88 | 77 | ||
| 89 | /** | 78 | /** |
| 90 | * Configure the rate limiters for the application. | 79 | * Configure the rate limiters for the application. |
composer.lock
0 → 100644
此 diff 太大无法显示。
| @@ -60,12 +60,6 @@ return [ | @@ -60,12 +60,6 @@ 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 | - ], | ||
| 69 | 63 | ||
| 70 | 'stack' => [ | 64 | 'stack' => [ |
| 71 | 'driver' => 'stack', | 65 | 'driver' => 'stack', |
| @@ -19,14 +19,14 @@ return [ | @@ -19,14 +19,14 @@ return [ | ||
| 19 | 'size' => [ | 19 | 'size' => [ |
| 20 | 'max' => 1024*1024*2, // 2M | 20 | 'max' => 1024*1024*2, // 2M |
| 21 | ], | 21 | ], |
| 22 | - 'path' => '/image' | 22 | + 'path' => '/images' |
| 23 | ], | 23 | ], |
| 24 | //默认视频 | 24 | //默认视频 |
| 25 | 'default_file' =>[ | 25 | 'default_file' =>[ |
| 26 | 'size' => [ | 26 | 'size' => [ |
| 27 | 'max' => 1024*1024*20, // 2M | 27 | 'max' => 1024*1024*20, // 2M |
| 28 | ], | 28 | ], |
| 29 | - 'path' => '/file' | 29 | + 'path' => '/files' |
| 30 | ], | 30 | ], |
| 31 | //博客图 | 31 | //博客图 |
| 32 | 'blog' =>[ | 32 | 'blog' =>[ |
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | */ | 4 | */ |
| 5 | use \Illuminate\Support\Facades\Route; | 5 | use \Illuminate\Support\Facades\Route; |
| 6 | use \App\Http\Controllers\Aside; | 6 | use \App\Http\Controllers\Aside; |
| 7 | + | ||
| 7 | //必须登录验证的路由组 | 8 | //必须登录验证的路由组 |
| 8 | Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上web的中间件 | 9 | Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上web的中间件 |
| 9 | Route::middleware(['aloginauth'])->group(function () { | 10 | Route::middleware(['aloginauth'])->group(function () { |
| @@ -103,6 +104,7 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | @@ -103,6 +104,7 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | ||
| 103 | Route::get('/', [Aside\Project\ProjectController::class, 'list'])->name('admin.project'); | 104 | Route::get('/', [Aside\Project\ProjectController::class, 'list'])->name('admin.project'); |
| 104 | Route::get('/info', [Aside\Project\ProjectController::class, 'info'])->name('admin.project_info'); | 105 | Route::get('/info', [Aside\Project\ProjectController::class, 'info'])->name('admin.project_info'); |
| 105 | Route::post('/save', [Aside\Project\ProjectController::class, 'save'])->name('admin.project_save'); | 106 | Route::post('/save', [Aside\Project\ProjectController::class, 'save'])->name('admin.project_save'); |
| 107 | + Route::any('/inquiry_set', [Aside\Project\ProjectController::class, 'inquiry_set'])->name('admin.project_inquiry_set'); | ||
| 106 | }); | 108 | }); |
| 107 | 109 | ||
| 108 | //工单管理 | 110 | //工单管理 |
| @@ -122,6 +124,21 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | @@ -122,6 +124,21 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | ||
| 122 | Route::post('/update_database', [Aside\Devops\ServerConfigController::class, 'updateDatabase'])->name('admin.devops.server_config.update_database'); | 124 | Route::post('/update_database', [Aside\Devops\ServerConfigController::class, 'updateDatabase'])->name('admin.devops.server_config.update_database'); |
| 123 | Route::post('/update_code', [Aside\Devops\ServerConfigController::class, 'updateCode'])->name('admin.devops.server_config.update_code'); | 125 | Route::post('/update_code', [Aside\Devops\ServerConfigController::class, 'updateCode'])->name('admin.devops.server_config.update_code'); |
| 124 | }); | 126 | }); |
| 127 | + | ||
| 128 | + // 服务器添加|修改|删除 | ||
| 129 | + Route::prefix('server')->group(function () { | ||
| 130 | + Route::get('/', [Aside\Devops\ServerInformationController::class, 'lists'])->name('admin.devops.bt'); // 列表 | ||
| 131 | + Route::get('/info', [Aside\Devops\ServerInformationController::class, 'getServerInfo'])->name('admin.devops.bt_info'); // 获取信息 | ||
| 132 | + Route::get('/delete_info', [Aside\Devops\ServerInformationController::class, 'getDeleteServerInfo'])->name('admin.devops.bt_delete_info'); // 删除信息 | ||
| 133 | + Route::post('/add', [Aside\Devops\ServerInformationController::class, 'add'])->name('admin.devops.bt_add'); // 添加 | ||
| 134 | + Route::post('/edit', [Aside\Devops\ServerInformationController::class, 'edit'])->name('admin.devops.bt_edit'); // 修改 | ||
| 135 | + Route::get('/delete', [Aside\Devops\ServerInformationController::class, 'delete'])->name('admin.devops.bt_delete'); // 删除 | ||
| 136 | + Route::get('/delete_list', [Aside\Devops\ServerInformationController::class, 'delete_list'])->name('admin.devops.bt_delete_list'); // 删除列表 | ||
| 137 | + Route::get('/restore', [Aside\Devops\ServerInformationController::class, 'restore'])->name('admin.devops.bt_restore'); //恢复数据 | ||
| 138 | + Route::get('/search', [Aside\Devops\ServerInformationController::class, 'search'])->name('admin.devops.bt_search'); //搜索 | ||
| 139 | + Route::get('/log', [Aside\Devops\ServerInformationLogController::class, 'lists'])->name('admin.devops.bt_log_lists'); //日志列表 | ||
| 140 | + }); | ||
| 141 | + | ||
| 125 | }); | 142 | }); |
| 126 | 143 | ||
| 127 | // 自定义页面 模板,头部底部 | 144 | // 自定义页面 模板,头部底部 |
| @@ -21,6 +21,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -21,6 +21,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 21 | Route::any('/edit', [\App\Http\Controllers\Bside\User\UserController::class, 'edit'])->name('user_edit'); | 21 | Route::any('/edit', [\App\Http\Controllers\Bside\User\UserController::class, 'edit'])->name('user_edit'); |
| 22 | Route::any('/status', [\App\Http\Controllers\Bside\User\UserController::class, 'status'])->name('user_status'); | 22 | Route::any('/status', [\App\Http\Controllers\Bside\User\UserController::class, 'status'])->name('user_status'); |
| 23 | Route::any('/info', [\App\Http\Controllers\Bside\User\UserController::class, 'info'])->name('user_info'); | 23 | Route::any('/info', [\App\Http\Controllers\Bside\User\UserController::class, 'info'])->name('user_info'); |
| 24 | + Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list'); | ||
| 24 | Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del'); | 25 | Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del'); |
| 25 | }); | 26 | }); |
| 26 | 27 | ||
| @@ -42,16 +43,6 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -42,16 +43,6 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 42 | Route::any('/get_user_list', [\App\Http\Controllers\Bside\User\ProjectRoleController::class, 'get_user_list'])->name('project_role_get_user_list'); | 43 | Route::any('/get_user_list', [\App\Http\Controllers\Bside\User\ProjectRoleController::class, 'get_user_list'])->name('project_role_get_user_list'); |
| 43 | }); | 44 | }); |
| 44 | 45 | ||
| 45 | - //group相关路 | ||
| 46 | - Route::prefix('group')->group(function () { | ||
| 47 | - Route::any('/', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'lists'])->name('project_group_lists'); | ||
| 48 | - Route::any('/add', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'add'])->name('project_group_add'); | ||
| 49 | - Route::any('/edit', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'edit'])->name('project_group_edit'); | ||
| 50 | - Route::any('/info', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'info'])->name('project_group_info'); | ||
| 51 | - Route::any('/del', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'del'])->name('project_group_del'); | ||
| 52 | - Route::any('/get_user_lists', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists'); | ||
| 53 | - }); | ||
| 54 | - | ||
| 55 | //新闻相关路由 | 46 | //新闻相关路由 |
| 56 | Route::prefix('news')->group(function () { | 47 | Route::prefix('news')->group(function () { |
| 57 | //分类 | 48 | //分类 |
| @@ -106,7 +97,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -106,7 +97,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 106 | //公用ai自动生成 | 97 | //公用ai自动生成 |
| 107 | Route::any('/ai_http_post', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'ai_http_post'])->name('ai_http_post'); | 98 | Route::any('/ai_http_post', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'ai_http_post'])->name('ai_http_post'); |
| 108 | }); | 99 | }); |
| 109 | - //ai指令 | 100 | + //网站设置 |
| 110 | Route::prefix('setting')->group(function () { | 101 | Route::prefix('setting')->group(function () { |
| 111 | //首页设置 | 102 | //首页设置 |
| 112 | Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists'); | 103 | Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists'); |
| @@ -182,6 +173,15 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -182,6 +173,15 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 182 | Route::get('/info', [\App\Http\Controllers\Bside\User\DeptController::class, 'info'])->name('dept_info'); | 173 | Route::get('/info', [\App\Http\Controllers\Bside\User\DeptController::class, 'info'])->name('dept_info'); |
| 183 | Route::post('/save', [\App\Http\Controllers\Bside\User\DeptController::class, 'save'])->name('dept_save'); | 174 | Route::post('/save', [\App\Http\Controllers\Bside\User\DeptController::class, 'save'])->name('dept_save'); |
| 184 | Route::any('/delete', [\App\Http\Controllers\Bside\User\DeptController::class, 'delete'])->name('dept_delete'); | 175 | Route::any('/delete', [\App\Http\Controllers\Bside\User\DeptController::class, 'delete'])->name('dept_delete'); |
| 176 | + //成员管理 | ||
| 177 | + //组织架构 | ||
| 178 | + Route::prefix('user')->group(function () { | ||
| 179 | + Route::any('/', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'lists'])->name('dept_user'); | ||
| 180 | + Route::any('/save', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'save'])->name('dept_user_add'); | ||
| 181 | + Route::any('/info', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'info'])->name('dept_user_info'); | ||
| 182 | + Route::any('/set_admin', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'set_admin'])->name('dept_user_set_admin'); | ||
| 183 | + Route::any('/set_role', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'set_role'])->name('dept_user_set_role'); | ||
| 184 | + }); | ||
| 185 | }); | 185 | }); |
| 186 | 186 | ||
| 187 | //文件操作 | 187 | //文件操作 |
| @@ -259,6 +259,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -259,6 +259,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 259 | Route::any('/speed', [\App\Http\Controllers\Bside\RankDataController::class, 'speed'])->name('rank_data_speed'); | 259 | Route::any('/speed', [\App\Http\Controllers\Bside\RankDataController::class, 'speed'])->name('rank_data_speed'); |
| 260 | Route::any('/export', [\App\Http\Controllers\Bside\RankDataController::class, 'export'])->name('rank_data_export'); | 260 | Route::any('/export', [\App\Http\Controllers\Bside\RankDataController::class, 'export'])->name('rank_data_export'); |
| 261 | Route::any('/export_history', [\App\Http\Controllers\Bside\RankDataController::class, 'export_history'])->name('rank_data_export_history'); | 261 | Route::any('/export_history', [\App\Http\Controllers\Bside\RankDataController::class, 'export_history'])->name('rank_data_export_history'); |
| 262 | + Route::any('/get_google_rank', [\App\Http\Controllers\Bside\RankDataController::class, 'get_google_rank'])->name('rank_data_get_google_rank'); | ||
| 262 | }); | 263 | }); |
| 263 | 264 | ||
| 264 | 265 | ||
| @@ -266,8 +267,8 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -266,8 +267,8 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 266 | //无需登录验证的路由组 | 267 | //无需登录验证的路由组 |
| 267 | Route::group([], function () { | 268 | Route::group([], function () { |
| 268 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); | 269 | Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); |
| 269 | -// Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'get_country'])->name('get_country'); | 270 | + Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'ceShi'])->name('ce_shi'); |
| 270 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); | 271 | Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); |
| 271 | Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class,'index'])->name('image_show'); | 272 | Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class,'index'])->name('image_show'); |
| 272 | - Route::any('/file_hash/{hash}/', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show'); | 273 | + Route::any('/file_hash/{hash}', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show'); |
| 273 | }); | 274 | }); |
routes/cside.php
已删除
100644 → 0
-
请 注册 或 登录 后发表评论