正在显示
67 个修改的文件
包含
2379 行增加
和
758 行删除
| @@ -43,46 +43,104 @@ class ShareUser extends Command | @@ -43,46 +43,104 @@ class ShareUser extends Command | ||
| 43 | protected function user_operator_record(){ | 43 | protected function user_operator_record(){ |
| 44 | //获取所有ayr_share用户 | 44 | //获取所有ayr_share用户 |
| 45 | $ayr_share_model = new AyrShareModel(); | 45 | $ayr_share_model = new AyrShareModel(); |
| 46 | - $ayr_share_list = $ayr_share_model->list(); | ||
| 47 | - foreach ($ayr_share_list as $k => $v){ | 46 | + $ayr_release = new AyrReleaseModel(); |
| 47 | + $ayr_share_list = $ayr_share_model->list(['profile_key'=>['!=','']]); | ||
| 48 | + foreach ($ayr_share_list as $v){ | ||
| 49 | + $time = Carbon::now()->modify('-7 days')->toDateString(); | ||
| 50 | + //创建时间小于7天前的当前时间 | ||
| 51 | + if($v['created_at'] > $time){ | ||
| 52 | + continue; | ||
| 53 | + } | ||
| 48 | //查询当前用户是否有未推送的博文 | 54 | //查询当前用户是否有未推送的博文 |
| 49 | - $ayr_release = new AyrReleaseModel(); | ||
| 50 | - $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]); | 55 | + $release_info = $this->release_info($ayr_release,$v); |
| 51 | //有推文时,直接跳出循环 | 56 | //有推文时,直接跳出循环 |
| 52 | if($release_info !== false){ | 57 | if($release_info !== false){ |
| 53 | continue; | 58 | continue; |
| 54 | } | 59 | } |
| 55 | - //查看用户是否在一周内有发送博客 | ||
| 56 | - $start_at = Carbon::now()->modify('-7 days')->toDateString(); | ||
| 57 | - $end_at = Carbon::now()->toDateString(); | ||
| 58 | - $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]); | 60 | + //查询7天是否发送博文 |
| 61 | + $release_info = $this->release_seven_info($ayr_release); | ||
| 59 | //有发送博文,则跳出循环 | 62 | //有发送博文,则跳出循环 |
| 60 | - if($release_info == false){ | 63 | + if($release_info !== false){ |
| 61 | continue; | 64 | continue; |
| 62 | } | 65 | } |
| 63 | //删除用户第三方配置 | 66 | //删除用户第三方配置 |
| 64 | - $ayr_share_helper = new AyrShareHelper(); | ||
| 65 | - $data_profiles = [ | ||
| 66 | - 'title'=>$v['title'], | ||
| 67 | - 'profileKey'=>$v['profile_key'] | ||
| 68 | - ]; | ||
| 69 | - $res = $ayr_share_helper->deleted_profiles($data_profiles); | ||
| 70 | - if($res['status'] == 'fail'){ | ||
| 71 | - $this->error++; | 67 | + if(!empty($v['profile_key'])){ |
| 68 | + $this->del_profiles($v); | ||
| 72 | continue; | 69 | continue; |
| 73 | } | 70 | } |
| 74 | //更新数据库 | 71 | //更新数据库 |
| 75 | - $data = [ | ||
| 76 | - 'title'=>null, | ||
| 77 | - 'bind_plat_from'=>null, | ||
| 78 | - 'profile_key'=>null, | ||
| 79 | - 'ref_id'=>null, | ||
| 80 | - ]; | ||
| 81 | - $res = $ayr_share_model->edit($data,['id'=>$v['id']]); | ||
| 82 | - if($res == false){ | ||
| 83 | - $this->error++; | ||
| 84 | - } | 72 | + $this->save_ayr_share($ayr_share_model,$v); |
| 85 | } | 73 | } |
| 86 | return $this->error; | 74 | return $this->error; |
| 87 | } | 75 | } |
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * @name :(删除第三方配置)del_profiles | ||
| 79 | + * @author :lyh | ||
| 80 | + * @method :post | ||
| 81 | + * @time :2023/6/14 16:10 | ||
| 82 | + */ | ||
| 83 | + public function del_profiles($v){ | ||
| 84 | + $ayr_share_helper = new AyrShareHelper(); | ||
| 85 | + $data_profiles = [ | ||
| 86 | + 'title'=>$v['title'], | ||
| 87 | + 'profileKey'=>$v['profile_key'] | ||
| 88 | + ]; | ||
| 89 | + $res = $ayr_share_helper->deleted_profiles($data_profiles); | ||
| 90 | + if($res['status'] == 'fail'){ | ||
| 91 | + echo '第三方删除失败'; | ||
| 92 | + return true; | ||
| 93 | + } | ||
| 94 | + return true; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * @name :(更新数据库)save_ayr_share | ||
| 99 | + * @author :lyh | ||
| 100 | + * @method :post | ||
| 101 | + * @time :2023/6/14 16:14 | ||
| 102 | + */ | ||
| 103 | + public function save_ayr_share(&$ayr_share_model,$v){ | ||
| 104 | + | ||
| 105 | + //更新数据库 | ||
| 106 | + $data = [ | ||
| 107 | + 'title'=>'', | ||
| 108 | + 'bind_platforms'=>'', | ||
| 109 | + 'profile_key'=>'', | ||
| 110 | + 'ref_id'=>'', | ||
| 111 | + ]; | ||
| 112 | + $res = $ayr_share_model->edit($data,['id'=>$v['id']]); | ||
| 113 | + if($res == false){ | ||
| 114 | + echo '更新数据库失败'; | ||
| 115 | + return true; | ||
| 116 | + } | ||
| 117 | + return true; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + /** | ||
| 121 | + * @name :(查询是否有定时发送报文)info | ||
| 122 | + * @author :lyh | ||
| 123 | + * @method :post | ||
| 124 | + * @time :2023/6/14 16:17 | ||
| 125 | + */ | ||
| 126 | + public function release_info(&$ayr_release,$v){ | ||
| 127 | + //查询当前用户是否有未推送的博文 | ||
| 128 | + $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]); | ||
| 129 | + return $release_info; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * @param $ayr_release | ||
| 134 | + * @name :(7天内无发送记录)release_seven_info | ||
| 135 | + * @author :lyh | ||
| 136 | + * @method :post | ||
| 137 | + * @time :2023/6/14 16:28 | ||
| 138 | + */ | ||
| 139 | + public function release_seven_info(&$ayr_release){ | ||
| 140 | + //查看用户是否在一周内有发送博客 | ||
| 141 | + $start_at = Carbon::now()->modify('-7 days')->toDateString(); | ||
| 142 | + $end_at = Carbon::now()->toDateString(); | ||
| 143 | + $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]); | ||
| 144 | + return $release_info; | ||
| 145 | + } | ||
| 88 | } | 146 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Bside\Statistics; | ||
| 4 | + | ||
| 5 | +use App\Models\Bside\Statistics\TrafficStatistics; | ||
| 6 | +use App\Models\CustomerVisit\CustomerVisit; | ||
| 7 | +use Illuminate\Console\Command; | ||
| 8 | +use Illuminate\Support\Facades\DB; | ||
| 9 | +use Throwable; | ||
| 10 | + | ||
| 11 | +class Logic | ||
| 12 | +{ | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * @param int $type 统计类型 | ||
| 16 | + * @return array | ||
| 17 | + */ | ||
| 18 | + public function getMonths(int $type = TrafficStatistics::TYPE_SOURCE) | ||
| 19 | + { | ||
| 20 | + $date = getPreviousMonthsDate(); | ||
| 21 | + $TrafficStatistics = new TrafficStatistics(); | ||
| 22 | + $lists = $TrafficStatistics->getMonthsLists($type, $date); | ||
| 23 | + if (!empty($lists)) { | ||
| 24 | + $dd = []; | ||
| 25 | + $lists->map(function ($item) use (&$dd) { | ||
| 26 | + $dd[] = $item->year . '-' . str_pad($item->month, 2, '0', STR_PAD_LEFT); | ||
| 27 | + }); | ||
| 28 | + $date = array_diff($date, $dd); | ||
| 29 | + } | ||
| 30 | + return $date; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @param array $column 统计数据 | ||
| 35 | + * @param int $type 统计类型 | ||
| 36 | + * @param string|null $date 日期 格式:Y-m | ||
| 37 | + * @param string $message | ||
| 38 | + * @return array | ||
| 39 | + * @throws Throwable | ||
| 40 | + */ | ||
| 41 | + public function save(array $column, int $type = TrafficStatistics::TYPE_SOURCE, string $date = null, $message = '统计当月访问来源数据') | ||
| 42 | + { | ||
| 43 | + DB::beginTransaction(); | ||
| 44 | + // 获取当天的IP|PV数量 | ||
| 45 | + $customerVisit = new CustomerVisit(); | ||
| 46 | + $ip_count = $customerVisit->getMonthIPCount($date); | ||
| 47 | + $pv_count = $customerVisit->getMonthPVCount($date); | ||
| 48 | + $column['pvnum'] = $pv_count; | ||
| 49 | + $column['ipnum'] = $ip_count; | ||
| 50 | + $date = $date ?? date('Y-m'); | ||
| 51 | + // 统计数据并插入到数据库 | ||
| 52 | + $dd = explode('-', $date); | ||
| 53 | + $year = $dd[0]; | ||
| 54 | + $month = $dd[1]; | ||
| 55 | + $column['year'] = $year; | ||
| 56 | + $column['month'] = $month; | ||
| 57 | + $trafficStatistics = new TrafficStatistics(); | ||
| 58 | + $isRes = $trafficStatistics->getMonth($type, $year, $month); | ||
| 59 | + if ($isRes) { | ||
| 60 | + $trafficStatistics = $isRes; | ||
| 61 | + } | ||
| 62 | + foreach ($column as $key => $value) { | ||
| 63 | + $trafficStatistics->$key = $value; | ||
| 64 | + } | ||
| 65 | + $res = $trafficStatistics->save(); | ||
| 66 | + if ($res) { | ||
| 67 | + DB::commit(); | ||
| 68 | + $meg = "{$date} - {$message}成功!"; | ||
| 69 | + } else { | ||
| 70 | + DB::rollBack(); | ||
| 71 | + $meg = "{$date} - {$message}失败!"; | ||
| 72 | + } | ||
| 73 | + return ['status' => $res, 'msg' => $meg]; | ||
| 74 | + } | ||
| 75 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Bside\Statistics; | ||
| 4 | + | ||
| 5 | +use App\Models\Bside\Statistics\TrafficTrends; | ||
| 6 | +use App\Models\CustomerVisit\CustomerVisit; | ||
| 7 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 8 | +use Illuminate\Console\Command; | ||
| 9 | +use Illuminate\Support\Facades\DB; | ||
| 10 | +use Throwable; | ||
| 11 | + | ||
| 12 | +class StatisticsDayTrend extends Command | ||
| 13 | +{ | ||
| 14 | + public $error = 0; | ||
| 15 | + /** | ||
| 16 | + * The name and signature of the console command. | ||
| 17 | + * | ||
| 18 | + * @var string | ||
| 19 | + */ | ||
| 20 | + protected $signature = 'statistics_day_trend'; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * The console command description. | ||
| 24 | + * | ||
| 25 | + * @var string | ||
| 26 | + */ | ||
| 27 | + protected $description = '统计当天流量趋势数据'; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @return void | ||
| 31 | + * @throws GuzzleException | ||
| 32 | + * @throws Throwable | ||
| 33 | + */ | ||
| 34 | + public function handle() | ||
| 35 | + { | ||
| 36 | + $date = getPreviousDaysDate(); | ||
| 37 | + $trafficTrends = new TrafficTrends(); | ||
| 38 | + $lists = $trafficTrends->getDaysLists($date); | ||
| 39 | + if (!empty($lists)) { | ||
| 40 | + $date = array_diff($date, $lists->pluck('day')->all()); | ||
| 41 | + } | ||
| 42 | + if (!empty($date)) { | ||
| 43 | + foreach ($date as $value) { | ||
| 44 | + echo $this->statistics_day_trend($value); | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + echo $this->statistics_day_trend(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 统计当天流量趋势数据PV|IP数量 | ||
| 52 | + * @return int|mixed | ||
| 53 | + * @throws GuzzleException|Throwable | ||
| 54 | + */ | ||
| 55 | + protected function statistics_day_trend($date = null) | ||
| 56 | + { | ||
| 57 | + DB::beginTransaction(); | ||
| 58 | + $date = $date ?? date('Y-m-d'); | ||
| 59 | + // 获取当天的IP|PV数量 | ||
| 60 | + $customerVisit = new CustomerVisit(); | ||
| 61 | + $ip_count = $customerVisit->getDayIPCount($date); | ||
| 62 | + $pv_count = $customerVisit->getDayPVCount($date); | ||
| 63 | + // 统计数据并插入到数据库 | ||
| 64 | + $trafficTrends = new TrafficTrends(); | ||
| 65 | + $isRes = $trafficTrends->getDay($date); | ||
| 66 | + if ($isRes) { | ||
| 67 | + $trafficTrends = $isRes; | ||
| 68 | + } | ||
| 69 | + $trafficTrends->day = $date; | ||
| 70 | + $trafficTrends->pvnum = $pv_count; | ||
| 71 | + $trafficTrends->ipnum = $ip_count; | ||
| 72 | + $res = $trafficTrends->save(); | ||
| 73 | + if ($res) { | ||
| 74 | + DB::commit(); | ||
| 75 | + $this->info($date . ' - 统计当天流量趋势数据PV|IP数量成功'); | ||
| 76 | + } else { | ||
| 77 | + DB::rollBack(); | ||
| 78 | + $this->error++; | ||
| 79 | + $this->info($date . ' - 统计当天流量趋势数据PV|IP数量失败'); | ||
| 80 | + } | ||
| 81 | + return $this->error; | ||
| 82 | + } | ||
| 83 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Bside\Statistics; | ||
| 4 | + | ||
| 5 | +use App\Models\Bside\Statistics\TrafficStatistics; | ||
| 6 | +use App\Models\CustomerVisit\CustomerVisit; | ||
| 7 | +use Illuminate\Console\Command; | ||
| 8 | +use Throwable; | ||
| 9 | + | ||
| 10 | +class StatisticsDistribution extends Command | ||
| 11 | +{ | ||
| 12 | + public $error = 0; | ||
| 13 | + /** | ||
| 14 | + * The name and signature of the console command. | ||
| 15 | + * | ||
| 16 | + * @var string | ||
| 17 | + */ | ||
| 18 | + protected $signature = 'statistics_distribution'; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * The console command description. | ||
| 22 | + * | ||
| 23 | + * @var string | ||
| 24 | + */ | ||
| 25 | + protected $description = '统计当月地域分布数据'; | ||
| 26 | + | ||
| 27 | + public $logic; | ||
| 28 | + | ||
| 29 | + public function __construct() | ||
| 30 | + { | ||
| 31 | + parent::__construct(); | ||
| 32 | + $this->logic = new Logic(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 定时执行 | ||
| 37 | + * @return void | ||
| 38 | + * @throws Throwable | ||
| 39 | + */ | ||
| 40 | + public function handle() | ||
| 41 | + { | ||
| 42 | + $date = $this->logic->getMonths(TrafficStatistics::TYPE_DISTRIBUTION); | ||
| 43 | + if (!empty($date)) { | ||
| 44 | + foreach ($date as $value) { | ||
| 45 | + echo $this->statistics_distribution($value); | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + echo $this->statistics_distribution(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 统计当天流量趋势数据PV|IP数量 | ||
| 53 | + * @param string|null $date | ||
| 54 | + * @return int|mixed | ||
| 55 | + * @throws Throwable | ||
| 56 | + */ | ||
| 57 | + protected function statistics_distribution(string $date = null) | ||
| 58 | + { | ||
| 59 | + $customerVisit = new CustomerVisit(); | ||
| 60 | + $type = TrafficStatistics::TYPE_DISTRIBUTION; | ||
| 61 | + $top = json_encode($customerVisit->getCountryCount($date) ?? []); | ||
| 62 | + $res = $this->logic->save(compact('top', 'type'), $type, $date, '统计当月地域分布数据'); | ||
| 63 | + if (!$res['status']) { | ||
| 64 | + $this->info($res['msg']); | ||
| 65 | + $this->error++; | ||
| 66 | + } | ||
| 67 | + $this->info($res['msg']); | ||
| 68 | + return $this->error; | ||
| 69 | + } | ||
| 70 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Bside\Statistics; | ||
| 4 | + | ||
| 5 | +use App\Models\Bside\Statistics\TrafficStatistics; | ||
| 6 | +use App\Models\CustomerVisit\CustomerVisit; | ||
| 7 | +use Illuminate\Console\Command; | ||
| 8 | +use Throwable; | ||
| 9 | + | ||
| 10 | +class StatisticsPage extends Command | ||
| 11 | +{ | ||
| 12 | + public $error = 0; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * The name and signature of the console command. | ||
| 16 | + * | ||
| 17 | + * @var string | ||
| 18 | + */ | ||
| 19 | + protected $signature = 'statistics_page'; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * The console command description. | ||
| 23 | + * | ||
| 24 | + * @var string | ||
| 25 | + */ | ||
| 26 | + protected $description = '统计当月受访页面数据'; | ||
| 27 | + | ||
| 28 | + public $logic; | ||
| 29 | + | ||
| 30 | + public function __construct() | ||
| 31 | + { | ||
| 32 | + parent::__construct(); | ||
| 33 | + $this->logic = new Logic(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 定时执行 | ||
| 38 | + * @return void | ||
| 39 | + */ | ||
| 40 | + public function handle() | ||
| 41 | + { | ||
| 42 | + $date = $this->logic->getMonths(TrafficStatistics::TYPE_PAGE); | ||
| 43 | + if (!empty($date)) { | ||
| 44 | + foreach ($date as $value) { | ||
| 45 | + echo $this->statistics_page($value); | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + echo $this->statistics_page(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 统计当月受访页面数据 | ||
| 53 | + * @param null $date | ||
| 54 | + * @return int|mixed | ||
| 55 | + * @throws Throwable | ||
| 56 | + */ | ||
| 57 | + protected function statistics_page($date = null) | ||
| 58 | + { | ||
| 59 | + $customerVisit = new CustomerVisit(); | ||
| 60 | + $top = json_encode($customerVisit->getPageCount($date) ?? []); | ||
| 61 | + $type = TrafficStatistics::TYPE_PAGE; | ||
| 62 | + $res = $this->logic->save(compact('top', 'type'), $type, $date, '统计当月受访页面数据'); | ||
| 63 | + if (!$res['status']) { | ||
| 64 | + $this->info($res['msg']); | ||
| 65 | + $this->error++; | ||
| 66 | + } | ||
| 67 | + $this->info($res['msg']); | ||
| 68 | + return $this->error; | ||
| 69 | + } | ||
| 70 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Bside\Statistics; | ||
| 4 | + | ||
| 5 | +use App\Models\Bside\Statistics\TrafficStatistics; | ||
| 6 | +use App\Models\CustomerVisit\CustomerVisit; | ||
| 7 | +use Illuminate\Console\Command; | ||
| 8 | +use Throwable; | ||
| 9 | + | ||
| 10 | +class StatisticsSource extends Command | ||
| 11 | +{ | ||
| 12 | + public $error = 0; | ||
| 13 | + /** | ||
| 14 | + * The name and signature of the console command. | ||
| 15 | + * | ||
| 16 | + * @var string | ||
| 17 | + */ | ||
| 18 | + protected $signature = 'statistics_source'; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * The console command description. | ||
| 22 | + * | ||
| 23 | + * @var string | ||
| 24 | + */ | ||
| 25 | + protected $description = '统计当月访问来源数据'; | ||
| 26 | + | ||
| 27 | + public $logic; | ||
| 28 | + | ||
| 29 | + public function __construct() | ||
| 30 | + { | ||
| 31 | + parent::__construct(); | ||
| 32 | + $this->logic = new Logic(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * @return void | ||
| 37 | + * @throws Throwable | ||
| 38 | + */ | ||
| 39 | + public function handle() | ||
| 40 | + { | ||
| 41 | + $date = $this->logic->getMonths(); | ||
| 42 | + if (!empty($date)) { | ||
| 43 | + foreach ($date as $value) { | ||
| 44 | + echo $this->statistics_source($value); | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + echo $this->statistics_source(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 统计当天流量趋势数据 | ||
| 52 | + * @param string|null $date | ||
| 53 | + * @return int|mixed | ||
| 54 | + * @throws Throwable | ||
| 55 | + */ | ||
| 56 | + protected function statistics_source(string $date = null) | ||
| 57 | + { | ||
| 58 | + // 获取当天的IP|PV数量 | ||
| 59 | + $customerVisit = new CustomerVisit(); | ||
| 60 | + $top = json_encode($customerVisit->getUrlCount($date) ?? []); | ||
| 61 | + $type = TrafficStatistics::TYPE_SOURCE; | ||
| 62 | + $res = $this->logic->save(compact('top', 'type'), $type, $date); | ||
| 63 | + if (!$res['status']) { | ||
| 64 | + $this->info($res['msg']); | ||
| 65 | + $this->error++; | ||
| 66 | + } | ||
| 67 | + $this->info($res['msg']); | ||
| 68 | + return $this->error; | ||
| 69 | + } | ||
| 70 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Bside\Statistics; | ||
| 4 | + | ||
| 5 | +use App\Models\Bside\Statistics\TrafficStatistics; | ||
| 6 | +use App\Models\CustomerVisit\CustomerVisit; | ||
| 7 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 8 | +use Illuminate\Console\Command; | ||
| 9 | +use Throwable; | ||
| 10 | + | ||
| 11 | +class StatisticsTerminal extends Command | ||
| 12 | +{ | ||
| 13 | + public $error = 0; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * The name and signature of the console command. | ||
| 17 | + * | ||
| 18 | + * @var string | ||
| 19 | + */ | ||
| 20 | + protected $signature = 'statistics_terminal'; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * The console command description. | ||
| 24 | + * | ||
| 25 | + * @var string | ||
| 26 | + */ | ||
| 27 | + protected $description = '统计当月访问终端数据'; | ||
| 28 | + | ||
| 29 | + public $logic; | ||
| 30 | + | ||
| 31 | + public function __construct() | ||
| 32 | + { | ||
| 33 | + parent::__construct(); | ||
| 34 | + $this->logic = new Logic(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @return void | ||
| 39 | + * @throws Throwable | ||
| 40 | + */ | ||
| 41 | + public function handle() | ||
| 42 | + { | ||
| 43 | + $date = $this->logic->getMonths(TrafficStatistics::TYPE_TERMINAL); | ||
| 44 | + if (!empty($date)) { | ||
| 45 | + foreach ($date as $value) { | ||
| 46 | + echo $this->statistics_terminal($value); | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + echo $this->statistics_terminal(); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 统计当月访问终端数据 | ||
| 54 | + * @param string|null $date | ||
| 55 | + * @return int|mixed | ||
| 56 | + * @throws Throwable | ||
| 57 | + */ | ||
| 58 | + protected function statistics_terminal(string $date = null) | ||
| 59 | + { | ||
| 60 | + $customerVisit = new CustomerVisit(); | ||
| 61 | + $pcnum = $customerVisit->getTerminalPcCount($date); | ||
| 62 | + $mbnum = $customerVisit->getTerminalMobileCount($date); | ||
| 63 | + $top = json_encode($customerVisit->getCountryCount($date) ?? []); | ||
| 64 | + $type = TrafficStatistics::TYPE_TERMINAL; | ||
| 65 | + $res = $this->logic->save(compact('top', 'type', 'pcnum', 'mbnum'), $type, $date, '统计当月访问终端数据'); | ||
| 66 | + if (!$res['status']) { | ||
| 67 | + $this->info($res['msg']); | ||
| 68 | + $this->error++; | ||
| 69 | + } | ||
| 70 | + $this->info($res['msg']); | ||
| 71 | + return $this->error; | ||
| 72 | + } | ||
| 73 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Bside\Statistics; | ||
| 4 | + | ||
| 5 | +use App\Models\Bside\Statistics\TrafficStatistics; | ||
| 6 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 7 | +use Illuminate\Console\Command; | ||
| 8 | +use Throwable; | ||
| 9 | + | ||
| 10 | +class StatisticsTrend extends Command | ||
| 11 | +{ | ||
| 12 | + public $error = 0; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * The name and signature of the console command. | ||
| 16 | + * | ||
| 17 | + * @var string | ||
| 18 | + */ | ||
| 19 | + protected $signature = 'statistics_trend'; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * The console command description. | ||
| 23 | + * | ||
| 24 | + * @var string | ||
| 25 | + */ | ||
| 26 | + protected $description = '统计当月流量趋势数据'; | ||
| 27 | + | ||
| 28 | + public $logic; | ||
| 29 | + | ||
| 30 | + public function __construct() | ||
| 31 | + { | ||
| 32 | + parent::__construct(); | ||
| 33 | + $this->logic = new Logic(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 定时执行 | ||
| 38 | + * @return void | ||
| 39 | + * @throws GuzzleException|Throwable | ||
| 40 | + */ | ||
| 41 | + public function handle() | ||
| 42 | + { | ||
| 43 | + $date = $this->logic->getMonths(TrafficStatistics::TYPE_TREND); | ||
| 44 | + if (!empty($date)) { | ||
| 45 | + foreach ($date as $value) { | ||
| 46 | + echo $this->statistics_trend($value); | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + echo $this->statistics_trend(); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 统计当天流量趋势数据 | ||
| 54 | + * @param string|null $date | ||
| 55 | + * @return int|mixed | ||
| 56 | + * @throws GuzzleException|Throwable | ||
| 57 | + */ | ||
| 58 | + protected function statistics_trend(string $date = null) | ||
| 59 | + { | ||
| 60 | + $domain = request()->getHttpHost(); //'www.wowstainless.com'; | ||
| 61 | + $sta_date = !is_null($date) ? $date . "-01" : date('Y-m-01'); | ||
| 62 | + $inquiry = getInquiryInformation($domain, $sta_date); | ||
| 63 | + $innum = $inquiry['count'] ?? 0; | ||
| 64 | + $top = json_encode($inquiry['lists'] ?? []); | ||
| 65 | + $type = TrafficStatistics::TYPE_TREND; | ||
| 66 | + $res = $this->logic->save(compact('top', 'type', 'innum'), $type, $date, '统计当月流量趋势数据'); | ||
| 67 | + if (!$res['status']) { | ||
| 68 | + $this->info($res['msg']); | ||
| 69 | + $this->error++; | ||
| 70 | + } | ||
| 71 | + $this->info($res['msg']); | ||
| 72 | + return $this->error; | ||
| 73 | + } | ||
| 74 | +} |
| @@ -4,11 +4,8 @@ namespace App\Console\Commands\Domain; | @@ -4,11 +4,8 @@ namespace App\Console\Commands\Domain; | ||
| 4 | 4 | ||
| 5 | use App\Exceptions\AsideGlobalException; | 5 | use App\Exceptions\AsideGlobalException; |
| 6 | use App\Exceptions\BsideGlobalException; | 6 | use App\Exceptions\BsideGlobalException; |
| 7 | -use App\Helper\AyrShare as AyrShareHelper; | ||
| 8 | use App\Http\Logic\Aside\Domain\DomainInfoLogic; | 7 | use App\Http\Logic\Aside\Domain\DomainInfoLogic; |
| 9 | -use App\Models\AyrShare\AyrRelease as AyrReleaseModel; | ||
| 10 | -use Carbon\Carbon; | ||
| 11 | -use App\Models\AyrShare\AyrShare as AyrShareModel; | 8 | +use GuzzleHttp\Exception\GuzzleException; |
| 12 | use Illuminate\Console\Command; | 9 | use Illuminate\Console\Command; |
| 13 | 10 | ||
| 14 | class DomainTime extends Command | 11 | class DomainTime extends Command |
| @@ -43,7 +40,7 @@ class DomainTime extends Command | @@ -43,7 +40,7 @@ class DomainTime extends Command | ||
| 43 | * 更新域名|证书到期时间 | 40 | * 更新域名|证书到期时间 |
| 44 | * @return int|mixed|void | 41 | * @return int|mixed|void |
| 45 | * @throws AsideGlobalException | 42 | * @throws AsideGlobalException |
| 46 | - * @throws BsideGlobalException | 43 | + * @throws BsideGlobalException|GuzzleException |
| 47 | */ | 44 | */ |
| 48 | protected function update_domain_time() | 45 | protected function update_domain_time() |
| 49 | { | 46 | { |
| @@ -54,7 +54,7 @@ class RankData extends BaseCommands | @@ -54,7 +54,7 @@ class RankData extends BaseCommands | ||
| 54 | continue; | 54 | continue; |
| 55 | } | 55 | } |
| 56 | //收录数 | 56 | //收录数 |
| 57 | - $indexed_pages_num = $site_res[$item['api_no']]; | 57 | + $indexed_pages_num = $site_res[$item['api_no']] ?? 0; |
| 58 | 58 | ||
| 59 | $this->save_rank($item['project_id'], $res, $indexed_pages_num); | 59 | $this->save_rank($item['project_id'], $res, $indexed_pages_num); |
| 60 | } | 60 | } |
| @@ -4,6 +4,7 @@ namespace App\Console\Commands\YesterdayCount; | @@ -4,6 +4,7 @@ namespace App\Console\Commands\YesterdayCount; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Common; | 5 | use App\Helper\Common; |
| 6 | use App\Helper\FormGlobalsoApi; | 6 | use App\Helper\FormGlobalsoApi; |
| 7 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 7 | use App\Models\CustomerVisit\CustomerVisitItem; | 8 | use App\Models\CustomerVisit\CustomerVisitItem; |
| 8 | use App\Models\Project\DeployBuild; | 9 | use App\Models\Project\DeployBuild; |
| 9 | use Carbon\Carbon; | 10 | use Carbon\Carbon; |
| @@ -41,28 +42,97 @@ class Yesterday extends Command | @@ -41,28 +42,97 @@ class Yesterday extends Command | ||
| 41 | $yesterday = Carbon::yesterday()->toDateString(); | 42 | $yesterday = Carbon::yesterday()->toDateString(); |
| 42 | foreach ($list as $v){ | 43 | foreach ($list as $v){ |
| 43 | $arr = []; | 44 | $arr = []; |
| 44 | - $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 45 | - $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 46 | - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($v['test_domain']); | ||
| 47 | - if($inquiry_list['status'] == self::STATUS_ERROR){ | ||
| 48 | - $arr['inquiry_num'] = 0; | ||
| 49 | - }else{ | ||
| 50 | - $arr['inquiry_num'] = count($inquiry_list['data']['total']); | ||
| 51 | - } | 45 | + //统计时间 |
| 52 | $arr['date'] = $yesterday; | 46 | $arr['date'] = $yesterday; |
| 53 | - $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first(); | ||
| 54 | - if(empty($rank_info)){ | ||
| 55 | - $arr['compliance_day'] = 0; | ||
| 56 | - }else{ | ||
| 57 | - $arr['compliance_day'] = $rank_info->compliance_day; | ||
| 58 | - } | 47 | + //pv统计 |
| 48 | + $arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']); | ||
| 49 | + //ip统计 | ||
| 50 | + $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']); | ||
| 51 | + //服务达标天数 | ||
| 52 | + $arr['compliance_day'] = $this->compliance_day($yesterday); | ||
| 53 | + //剩余服务时常 | ||
| 59 | $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']); | 54 | $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']); |
| 55 | + //项目id | ||
| 60 | $arr['project_id'] = $v['project_id']; | 56 | $arr['project_id'] = $v['project_id']; |
| 61 | $arr['created_at'] = date('Y-m-d H:i:s'); | 57 | $arr['created_at'] = date('Y-m-d H:i:s'); |
| 62 | $arr['updated_at'] = date('Y-m-d H:i:s'); | 58 | $arr['updated_at'] = date('Y-m-d H:i:s'); |
| 59 | + //询盘统计 | ||
| 60 | + $arr = $this->inquiry($arr,$v['test_domain']); | ||
| 63 | $data[] = $arr; | 61 | $data[] = $arr; |
| 64 | } | 62 | } |
| 63 | + //判断数据是否存在 | ||
| 65 | DB::table('gl_count')->insert($data); | 64 | DB::table('gl_count')->insert($data); |
| 66 | echo $this->error; | 65 | echo $this->error; |
| 67 | } | 66 | } |
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * @name :(统计pv)pv_num | ||
| 70 | + * @author :lyh | ||
| 71 | + * @method :post | ||
| 72 | + * @time :2023/6/14 15:40 | ||
| 73 | + */ | ||
| 74 | + public function pv_num($yesterday,$domain){ | ||
| 75 | + $pv = DB::table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); | ||
| 76 | + return $pv; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * @name :(统计pv)pv_num | ||
| 81 | + * @author :lyh | ||
| 82 | + * @method :post | ||
| 83 | + * @time :2023/6/14 15:40 | ||
| 84 | + */ | ||
| 85 | + public function ip_num($yesterday,$domain){ | ||
| 86 | + $ip = DB::table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); | ||
| 87 | + return $ip; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * @param $arr | ||
| 92 | + * @param $domain | ||
| 93 | + * @name :(询盘统计)inquiry | ||
| 94 | + * @author :lyh | ||
| 95 | + * @method :post | ||
| 96 | + * @time :2023/6/14 15:44 | ||
| 97 | + */ | ||
| 98 | + public function inquiry($arr,$domain){ | ||
| 99 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); | ||
| 100 | + if($inquiry_list['status'] == self::STATUS_ERROR){ | ||
| 101 | + $arr['inquiry_num'] = 0; | ||
| 102 | + }else{ | ||
| 103 | + $arr['inquiry_num'] = $inquiry_list['data']['total']; | ||
| 104 | + //询盘国家统计 | ||
| 105 | + $countryData = $inquiry_list['data']['data']; | ||
| 106 | + $countryArr = []; | ||
| 107 | + foreach ($countryData as $v1){ | ||
| 108 | + if(isset($countryArr[$v1['country']])){ | ||
| 109 | + $countryArr[$v1['country']]++; | ||
| 110 | + }else{ | ||
| 111 | + $countryArr[$v1['country']] = 0; | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + arsort($countryArr); | ||
| 115 | + $top20 = array_slice($countryArr, 0, 20, true); | ||
| 116 | + $arr['country'] = json_encode($top20); | ||
| 117 | + } | ||
| 118 | + return $arr; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + /** | ||
| 122 | + * @param $yesterday | ||
| 123 | + * @name :(服务达标天数)compliance_day | ||
| 124 | + * @author :lyh | ||
| 125 | + * @method :post | ||
| 126 | + * @time :2023/6/14 15:48 | ||
| 127 | + */ | ||
| 128 | + public function compliance_day($yesterday){ | ||
| 129 | + //服务达标天数 | ||
| 130 | + $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first(); | ||
| 131 | + if(empty($rank_info)){ | ||
| 132 | + $compliance_day = 0; | ||
| 133 | + }else{ | ||
| 134 | + $compliance_day = $rank_info->compliance_day; | ||
| 135 | + } | ||
| 136 | + return $compliance_day; | ||
| 137 | + } | ||
| 68 | } | 138 | } |
| @@ -27,7 +27,23 @@ class Kernel extends ConsoleKernel | @@ -27,7 +27,23 @@ class Kernel extends ConsoleKernel | ||
| 27 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | 27 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 |
| 28 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 | 28 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 |
| 29 | $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 | 29 | $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 |
| 30 | -// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1); // 更新域名|证书结束时间,每天凌晨1点执行一次 | 30 | +// // 更新域名|证书结束时间,每天凌晨1点执行一次 |
| 31 | +// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1); | ||
| 32 | +// // B站 - 网站数据统计 | ||
| 33 | +// // 获取当前月份最后一天 | ||
| 34 | +// $lastDay = date('Y-m-t'); | ||
| 35 | +// // 统计当月访问来源数据,每月最后一天23:59点执行一次 | ||
| 36 | +// $schedule->command('statistics_source')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1); | ||
| 37 | +// // 统计当月地域分布数据,每月最后一天23:59点执行一次 | ||
| 38 | +// $schedule->command('statistics_distribution')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1); | ||
| 39 | +// // 统计当月受访页面数据,每月最后一天23:59点执行一次 | ||
| 40 | +// $schedule->command('statistics_page')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1); | ||
| 41 | +// // 统计当月访问终端数据,每月最后一天23:59点执行一次 | ||
| 42 | +// $schedule->command('statistics_terminal')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1); | ||
| 43 | +// // 统计当月流量趋势数据,每月最后一天23:59点执行一次 | ||
| 44 | +// $schedule->command('statistics_trend')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1); | ||
| 45 | +// // 统计当天流量趋势数据,每天23:59点执行一次 | ||
| 46 | +// $schedule->command('statistics_day_trend')->dailyAt('23:59')->withoutOverlapping(1); | ||
| 31 | } | 47 | } |
| 32 | 48 | ||
| 33 | /** | 49 | /** |
app/Helper/AliSms.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Helper; | ||
| 4 | + | ||
| 5 | +class AliSms | ||
| 6 | +{ | ||
| 7 | + | ||
| 8 | + private $_msg = array( //状态对照 | ||
| 9 | + 1 => "发送成功", | ||
| 10 | + 0 => "其他系统错误", | ||
| 11 | + -1 => "短信余额不足", | ||
| 12 | + -2 => "资金账户被锁定", | ||
| 13 | + -3 => "用户被锁定", | ||
| 14 | + -4 => "号码在黑名单内", | ||
| 15 | + -5 => "用户名或密码不正确", | ||
| 16 | + -6 => "号码不正确", | ||
| 17 | + -7 => "接口连接失败", | ||
| 18 | + -8 => "号码格式错误", | ||
| 19 | + -9 => "通道编号错误", | ||
| 20 | + -10 => "定时发送时间不正确", | ||
| 21 | + -11 => "没有输入短信内容", | ||
| 22 | + -12 => "短信内容超出长度限制", | ||
| 23 | + -15 => "内容含非法关键字", | ||
| 24 | + -16 => "超出发送时间范围", | ||
| 25 | + -17 => "通道被关闭", | ||
| 26 | + -18 => "短信内容没有签名", | ||
| 27 | + -30 => "手机未认证", | ||
| 28 | + -31 => "身份未认证", | ||
| 29 | + -32 => "请勿重复发送", | ||
| 30 | + -33 => "验证码已过期,请重新获取", | ||
| 31 | + -34 => "手机号码格式不正确", | ||
| 32 | + -35 => "验证码不正确", | ||
| 33 | + ); | ||
| 34 | + // 保存错误信息 | ||
| 35 | + public $error; | ||
| 36 | + public $_code = ""; | ||
| 37 | + public $_name = ""; | ||
| 38 | + public $_key_str = ""; // cache full name. | ||
| 39 | + protected $_expire = 600; // 验证码过期时间(s) | ||
| 40 | + public $_key = [ | ||
| 41 | + ]; | ||
| 42 | + // Access Key ID | ||
| 43 | + private $accessKeyId = ''; | ||
| 44 | + // Access Key Secret | ||
| 45 | + private $accessKeySecret = ''; | ||
| 46 | + // 签名 | ||
| 47 | + private $signName = ''; | ||
| 48 | + // 模版ID | ||
| 49 | + public $templateCode = ''; | ||
| 50 | + | ||
| 51 | + public function __construct($config = array()) | ||
| 52 | + { | ||
| 53 | + $config = array( | ||
| 54 | + 'accessKeyId' => config('aliyunsms.access_key'), | ||
| 55 | + 'accessKeySecret' => config('aliyunsms.access_secret'), | ||
| 56 | + 'signName' => config('aliyunsms.sign_name'), | ||
| 57 | + 'templateCode' => config('aliyunsms.login_sms_temp'), | ||
| 58 | + ); | ||
| 59 | + // 配置参数 | ||
| 60 | + $this->accessKeyId = $config['accessKeyId']; | ||
| 61 | + $this->accessKeySecret = $config['accessKeySecret']; | ||
| 62 | + $this->signName = $config['signName']; | ||
| 63 | + $this->templateCode = $config['templateCode']; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 规范化字符串以符合阿里云短信接口 | ||
| 68 | + * @param $string | ||
| 69 | + * @return mixed|string | ||
| 70 | + */ | ||
| 71 | + private function percentEncode($string) | ||
| 72 | + { | ||
| 73 | + $string = urlencode($string); | ||
| 74 | + $string = preg_replace('/\+/', '%20', $string); | ||
| 75 | + $string = preg_replace('/\*/', '%2A', $string); | ||
| 76 | + $string = preg_replace('/%7E/', '~', $string); | ||
| 77 | + return $string; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 签名 | ||
| 82 | + * | ||
| 83 | + * @param unknown $parameters | ||
| 84 | + * @param unknown $accessKeySecret | ||
| 85 | + * @return string | ||
| 86 | + */ | ||
| 87 | + private function computeSignature($parameters, $accessKeySecret) | ||
| 88 | + { | ||
| 89 | + ksort($parameters); | ||
| 90 | + $canonicalizedQueryString = ''; | ||
| 91 | + foreach ($parameters as $key => $value) { | ||
| 92 | + $canonicalizedQueryString .= '&' . $this->percentEncode($key) . '=' . $this->percentEncode($value); | ||
| 93 | + } | ||
| 94 | + $stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); | ||
| 95 | + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $accessKeySecret . '&', true)); | ||
| 96 | + return $signature; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * 发送验证码 https://help.aliyun.com/document_detail/44364.html?spm=5176.doc44368.6.126.gSngXV | ||
| 101 | + * | ||
| 102 | + * @param unknown $mobile | ||
| 103 | + * @param unknown $verify_code | ||
| 104 | + * | ||
| 105 | + */ | ||
| 106 | + public function send_sms($mobile, $paramstring) | ||
| 107 | + { | ||
| 108 | + $params = array( | ||
| 109 | + // 公共参数 | ||
| 110 | + 'SignName' => $this->signName, | ||
| 111 | + 'Format' => 'JSON', | ||
| 112 | + 'Version' => '2016-09-27', | ||
| 113 | + 'AccessKeyId' => $this->accessKeyId, | ||
| 114 | + 'SignatureVersion' => '1.0', | ||
| 115 | + 'SignatureMethod' => 'HMAC-SHA1', | ||
| 116 | + 'SignatureNonce' => uniqid(), | ||
| 117 | + 'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'), | ||
| 118 | + // 接口参数 | ||
| 119 | + 'Action' => 'SingleSendSms', | ||
| 120 | + 'TemplateCode' => $this->templateCode, | ||
| 121 | + 'RecNum' => $mobile, | ||
| 122 | + 'ParamString' => $paramstring, | ||
| 123 | + ); | ||
| 124 | + // 计算签名并把签名结果加入请求参数 | ||
| 125 | + $params['Signature'] = $this->computeSignature($params, $this->accessKeySecret); | ||
| 126 | + | ||
| 127 | + // 发送请求 | ||
| 128 | + $url = 'https://sms.aliyuncs.com/?' . http_build_query($params); | ||
| 129 | + $result = http_get($url); //TODO:上线前打开 | ||
| 130 | + if (isset($result['Code'])) { | ||
| 131 | + $this->error = $this->getErrorMessage($result['Code']); | ||
| 132 | + return false; | ||
| 133 | + } | ||
| 134 | + return true; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * 发送验证码 https://help.aliyun.com/document_detail/44364.html?spm=5176.doc44368.6.126.gSngXV | ||
| 139 | + * | ||
| 140 | + * @param unknown $mobile | ||
| 141 | + * @param unknown $verify_code | ||
| 142 | + * | ||
| 143 | + */ | ||
| 144 | + public function send_verify($mobile) | ||
| 145 | + { | ||
| 146 | + if ($this->checkMobile($mobile) === false) { | ||
| 147 | + $this->error = $this->_msg[-34]; | ||
| 148 | + return -34; | ||
| 149 | + } | ||
| 150 | + $session = cache($this->_key_str . $mobile); | ||
| 151 | + if ($session && time() - $session['time'] < 60) { | ||
| 152 | + if ($session['code'] == null) { | ||
| 153 | + return true; | ||
| 154 | + } else { | ||
| 155 | + $this->error = $this->_msg[-32]; | ||
| 156 | + return -32; | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + $this->_code = rand(1000, 9999); | ||
| 160 | + $params = array( | ||
| 161 | + // 公共参数 | ||
| 162 | + 'SignName' => $this->signName, | ||
| 163 | + 'Format' => 'JSON', | ||
| 164 | + 'Version' => '2016-09-27', | ||
| 165 | + 'AccessKeyId' => $this->accessKeyId, | ||
| 166 | + 'SignatureVersion' => '1.0', | ||
| 167 | + 'SignatureMethod' => 'HMAC-SHA1', | ||
| 168 | + 'SignatureNonce' => uniqid(), | ||
| 169 | + 'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'), | ||
| 170 | + // 接口参数 | ||
| 171 | + 'Action' => 'SingleSendSms', | ||
| 172 | + 'TemplateCode' => $this->templateCode, | ||
| 173 | + 'RecNum' => $mobile, | ||
| 174 | + 'ParamString' => '{"msgcode":"' . $this->_code . '"}', | ||
| 175 | + ); | ||
| 176 | + // 计算签名并把签名结果加入请求参数 | ||
| 177 | + $params['Signature'] = $this->computeSignature($params, $this->accessKeySecret); | ||
| 178 | + // 发送请求 | ||
| 179 | + $url = 'https://sms.aliyuncs.com/?' . http_build_query($params); | ||
| 180 | + $result = http_get($url); //TODO:上线前打开 | ||
| 181 | + // $result =1; | ||
| 182 | + if ($result) { | ||
| 183 | + $session = array(); | ||
| 184 | + $session['code'] = $this->_code; // 把校验码保存到session | ||
| 185 | + $session['time'] = time(); // 验证码创建时间 | ||
| 186 | + cache($this->_key_str . $mobile, $session, $this->_expire); | ||
| 187 | + } else { | ||
| 188 | + return $this->error = $this->_msg[0]; | ||
| 189 | + } | ||
| 190 | + if (isset($result['Code'])) { | ||
| 191 | + $this->error = $this->getErrorMessage($result['Code']); | ||
| 192 | + return false; | ||
| 193 | + } | ||
| 194 | + return true; | ||
| 195 | + } | ||
| 196 | + /** | ||
| 197 | + * 验证手机号码 | ||
| 198 | + */ | ||
| 199 | + public function checkMobile($tel) | ||
| 200 | + { | ||
| 201 | + if (preg_match("/^1[3,4,6,5,8,7,9][0-9]{1}[0-9]{8}$/", $tel)) { | ||
| 202 | + //验证通过 | ||
| 203 | + return true; | ||
| 204 | + } else { | ||
| 205 | + $this->error = $this->_msg[-34]; | ||
| 206 | + //手机号码格式不对 | ||
| 207 | + return false; | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + /** | ||
| 212 | + * 验证码是否正确 | ||
| 213 | + * @param string $key 手机号码 | ||
| 214 | + * @param int|string $code 验证码 | ||
| 215 | + * @param int|string $type 类型 reg-注册时获取 sms-快速登录时 pwd-修改密码时 bind-绑定手机时 unbind-解绑时 | ||
| 216 | + * @return boolean 验证短信验证码是否正确 | ||
| 217 | + */ | ||
| 218 | + public function check($key, $code, $type = 'reg') | ||
| 219 | + { | ||
| 220 | + $this->_key_str = $type . '_' . $key; | ||
| 221 | + $session = cache($this->_key_str); | ||
| 222 | + if (empty($code) || empty($session)) { | ||
| 223 | + $this->error = $this->_msg[-33] . $this->_key_str; | ||
| 224 | + return false; | ||
| 225 | + } | ||
| 226 | + if (time() - $session['time'] > $this->_expire) { | ||
| 227 | + cache($this->_key_str, null); | ||
| 228 | + $this->error = $this->_msg[-33] . $this->_key_str; | ||
| 229 | + return false; | ||
| 230 | + } | ||
| 231 | + if ($code == $session['code']) { | ||
| 232 | + return true; | ||
| 233 | + } | ||
| 234 | + $this->error = $this->_msg[-35] . $this->_key_str; | ||
| 235 | + return false; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + /** | ||
| 239 | + * 验证成功后调用清空验证码 | ||
| 240 | + */ | ||
| 241 | + public function afterCheck() | ||
| 242 | + { | ||
| 243 | + cache($this->_key_str, null); | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + /** | ||
| 247 | + * 获取详细错误信息 | ||
| 248 | + * | ||
| 249 | + * @param unknown $status | ||
| 250 | + */ | ||
| 251 | + public function getErrorMessage($status) | ||
| 252 | + { | ||
| 253 | + | ||
| 254 | + $message = array( | ||
| 255 | + 'InvalidDayuStatus.Malformed' => '账户短信开通状态不正确', | ||
| 256 | + 'InvalidSignName.Malformed' => '短信签名不正确或签名状态不正确', | ||
| 257 | + 'InvalidTemplateCode.MalFormed' => '短信模板Code不正确或者模板状态不正确', | ||
| 258 | + 'InvalidRecNum.Malformed' => '目标手机号不正确,单次发送数量不能超过100', | ||
| 259 | + 'InvalidParamString.MalFormed' => '短信模板中变量不是json格式', | ||
| 260 | + 'InvalidParamStringTemplate.Malformed' => '短信模板中变量与模板内容不匹配', | ||
| 261 | + 'InvalidSendSms' => '1小时只能请求7次,谢谢', | ||
| 262 | + 'InvalidDayu.Malformed' => '变量不能是url,可以将变量固化在模板中', | ||
| 263 | + ); | ||
| 264 | + if (isset($message[$status])) { | ||
| 265 | + return $message[$status]; | ||
| 266 | + } | ||
| 267 | + return $status; | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + private function _addlog($name, $title) | ||
| 271 | + { | ||
| 272 | + $this->_keys["code"] = $this->_code; | ||
| 273 | +// addlog($this->_keys, $title, 1, $this->_url); | ||
| 274 | + } | ||
| 275 | +} |
| @@ -85,7 +85,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | @@ -85,7 +85,7 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K | ||
| 85 | 'domain'=>$domain, | 85 | 'domain'=>$domain, |
| 86 | 'privateKey'=>$this->private_key, | 86 | 'privateKey'=>$this->private_key, |
| 87 | 'profileKey'=>$data['profileKey'], | 87 | 'profileKey'=>$data['profileKey'], |
| 88 | -// 'logout'=>true | 88 | + 'logout'=>true |
| 89 | ]; | 89 | ]; |
| 90 | $url = $this->path.'/api/profiles/generateJWT'; | 90 | $url = $this->path.'/api/profiles/generateJWT'; |
| 91 | return $this->http_click('post',$url,$param); | 91 | return $this->http_click('post',$url,$param); |
| @@ -142,13 +142,13 @@ class Country | @@ -142,13 +142,13 @@ class Country | ||
| 142 | 'con_flag' => '', | 142 | 'con_flag' => '', |
| 143 | 143 | ||
| 144 | ], | 144 | ], |
| 145 | - 'zh-CN' => [ | 145 | + 'cn' => [ |
| 146 | 'text' => '中文(简体)', | 146 | 'text' => '中文(简体)', |
| 147 | 'lang_text' => '简体中文', | 147 | 'lang_text' => '简体中文', |
| 148 | 'con_flag' => 'con_flag/zh.jfif', | 148 | 'con_flag' => 'con_flag/zh.jfif', |
| 149 | 'shop_lang' => 'zh-cn', | 149 | 'shop_lang' => 'zh-cn', |
| 150 | ], | 150 | ], |
| 151 | - 'zh-TW' => [ | 151 | + 'tw' => [ |
| 152 | 'text' => '中文(繁体)', | 152 | 'text' => '中文(繁体)', |
| 153 | 'lang_text' => '繁体中文', | 153 | 'lang_text' => '繁体中文', |
| 154 | 'con_flag' => 'con_flag/zh.jfif', | 154 | 'con_flag' => 'con_flag/zh.jfif', |
| @@ -680,7 +680,7 @@ class Country | @@ -680,7 +680,7 @@ class Country | ||
| 680 | public function set_country(){ | 680 | public function set_country(){ |
| 681 | $data = []; | 681 | $data = []; |
| 682 | foreach ($this->tls_list as $k=>$v){ | 682 | foreach ($this->tls_list as $k=>$v){ |
| 683 | - $data[] = ['name'=>$v['text'],'alias'=>$k]; | 683 | + $data[] = ['name'=>$v['text'],'alias'=>$k,'image'=>$k.'.png','con_flag'=>$v['con_flag'],'lang_text'=>$v['lang_text']]; |
| 684 | } | 684 | } |
| 685 | $webCountry = new WebSettingCountry(); | 685 | $webCountry = new WebSettingCountry(); |
| 686 | $webCountry->insert($data); | 686 | $webCountry->insert($data); |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | use App\Utils\LogUtils; | 3 | use App\Utils\LogUtils; |
| 4 | +use GuzzleHttp\Client; | ||
| 5 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 4 | use Illuminate\Support\Carbon; | 6 | use Illuminate\Support\Carbon; |
| 5 | 7 | ||
| 6 | -define('HTTP_OPENAI_URL','http://openai.waimaoq.com/'); | 8 | +define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); |
| 7 | /** | 9 | /** |
| 8 | * 生成路由标识 | 10 | * 生成路由标识 |
| 9 | * @param $string | 11 | * @param $string |
| @@ -28,7 +30,8 @@ if (!function_exists('generateRoute')) { | @@ -28,7 +30,8 @@ if (!function_exists('generateRoute')) { | ||
| 28 | * @author zbj | 30 | * @author zbj |
| 29 | * @date 2023/4/27 | 31 | * @date 2023/4/27 |
| 30 | */ | 32 | */ |
| 31 | -function errorLog($title, $params, Throwable $exception){ | 33 | +function errorLog($title, $params, Throwable $exception) |
| 34 | +{ | ||
| 32 | $exceptionMessage = "错误CODE:" . $exception->getCode() . | 35 | $exceptionMessage = "错误CODE:" . $exception->getCode() . |
| 33 | "-----错误message:" . $exception->getMessage() . | 36 | "-----错误message:" . $exception->getMessage() . |
| 34 | '------错误文件:' . $exception->getFile() . | 37 | '------错误文件:' . $exception->getFile() . |
| @@ -37,15 +40,15 @@ function errorLog($title, $params, Throwable $exception){ | @@ -37,15 +40,15 @@ function errorLog($title, $params, Throwable $exception){ | ||
| 37 | LogUtils::error($title, $params, $exceptionMessage); | 40 | LogUtils::error($title, $params, $exceptionMessage); |
| 38 | } | 41 | } |
| 39 | 42 | ||
| 40 | -if(!function_exists('http_post')){ | 43 | +if (!function_exists('http_post')) { |
| 41 | /** | 44 | /** |
| 42 | * 发送http post请求 | 45 | * 发送http post请求 |
| 43 | * @param type $url | 46 | * @param type $url |
| 44 | * @param type $post_data | 47 | * @param type $post_data |
| 45 | */ | 48 | */ |
| 46 | - function http_post($url, $post_data,$header = []) | 49 | + function http_post($url, $post_data, $header = []) |
| 47 | { | 50 | { |
| 48 | - if(empty($header)){ | 51 | + if (empty($header)) { |
| 49 | $header = array( | 52 | $header = array( |
| 50 | "Accept: application/json", | 53 | "Accept: application/json", |
| 51 | "Content-Type:application/json;charset=utf-8", | 54 | "Content-Type:application/json;charset=utf-8", |
| @@ -64,22 +67,22 @@ if(!function_exists('http_post')){ | @@ -64,22 +67,22 @@ if(!function_exists('http_post')){ | ||
| 64 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | 67 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 65 | $res = curl_exec($ch); | 68 | $res = curl_exec($ch); |
| 66 | if (curl_errno($ch)) { | 69 | if (curl_errno($ch)) { |
| 67 | - \Illuminate\Support\Facades\Log::write(print_r(curl_errno($ch),1),'debug---1'); | 70 | + \Illuminate\Support\Facades\Log::info(print_r(curl_errno($ch), 1), 'debug---1'); |
| 68 | } | 71 | } |
| 69 | curl_close($ch); | 72 | curl_close($ch); |
| 70 | return json_decode($res, true); | 73 | return json_decode($res, true); |
| 71 | } | 74 | } |
| 72 | } | 75 | } |
| 73 | 76 | ||
| 74 | -if(!function_exists('http_get')){ | 77 | +if (!function_exists('http_get')) { |
| 75 | /** | 78 | /** |
| 76 | * 发送http get请求 | 79 | * 发送http get请求 |
| 77 | * @param type $url | 80 | * @param type $url |
| 78 | * @return type | 81 | * @return type |
| 79 | */ | 82 | */ |
| 80 | - function http_get($url,$header = []) | 83 | + function http_get($url, $header = []) |
| 81 | { | 84 | { |
| 82 | - if(empty($header)){ | 85 | + if (empty($header)) { |
| 83 | $header[] = "content-type: application/json; | 86 | $header[] = "content-type: application/json; |
| 84 | charset = UTF-8"; | 87 | charset = UTF-8"; |
| 85 | } | 88 | } |
| @@ -92,13 +95,14 @@ if(!function_exists('http_get')){ | @@ -92,13 +95,14 @@ if(!function_exists('http_get')){ | ||
| 92 | curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); | 95 | curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); |
| 93 | curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false); | 96 | curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false); |
| 94 | $access_txt = curl_exec($ch1); | 97 | $access_txt = curl_exec($ch1); |
| 98 | + \Illuminate\Support\Facades\Log::info($access_txt); | ||
| 95 | curl_close($ch1); | 99 | curl_close($ch1); |
| 96 | return json_decode($access_txt, true); | 100 | return json_decode($access_txt, true); |
| 97 | } | 101 | } |
| 98 | } | 102 | } |
| 99 | 103 | ||
| 100 | 104 | ||
| 101 | -if(!function_exists('_get_child')){ | 105 | +if (!function_exists('_get_child')) { |
| 102 | /** | 106 | /** |
| 103 | * 菜单权限->得到子级数组 | 107 | * 菜单权限->得到子级数组 |
| 104 | * @param int | 108 | * @param int |
| @@ -110,7 +114,7 @@ if(!function_exists('_get_child')){ | @@ -110,7 +114,7 @@ if(!function_exists('_get_child')){ | ||
| 110 | foreach ($arr as $k => $v) { | 114 | foreach ($arr as $k => $v) { |
| 111 | $v = (array)$v; | 115 | $v = (array)$v; |
| 112 | if ($v['pid'] == $my_id) { | 116 | if ($v['pid'] == $my_id) { |
| 113 | - $v['sub'] = _get_child($v['id'],$arr); | 117 | + $v['sub'] = _get_child($v['id'], $arr); |
| 114 | $new_arr[] = $v; | 118 | $new_arr[] = $v; |
| 115 | } | 119 | } |
| 116 | } | 120 | } |
| @@ -119,7 +123,6 @@ if(!function_exists('_get_child')){ | @@ -119,7 +123,6 @@ if(!function_exists('_get_child')){ | ||
| 119 | } | 123 | } |
| 120 | 124 | ||
| 121 | 125 | ||
| 122 | - | ||
| 123 | if (!function_exists('checkDomain')) { | 126 | if (!function_exists('checkDomain')) { |
| 124 | /** | 127 | /** |
| 125 | * 检查并补全域名协议 | 128 | * 检查并补全域名协议 |
| @@ -130,12 +133,12 @@ if (!function_exists('checkDomain')) { | @@ -130,12 +133,12 @@ if (!function_exists('checkDomain')) { | ||
| 130 | function checkDomain($value) | 133 | function checkDomain($value) |
| 131 | { | 134 | { |
| 132 | $urlParts = parse_url(strtolower($value)); | 135 | $urlParts = parse_url(strtolower($value)); |
| 133 | - if(empty($urlParts['host'])){ | 136 | + if (empty($urlParts['host'])) { |
| 134 | $urlParts = parse_url('https://' . $value); | 137 | $urlParts = parse_url('https://' . $value); |
| 135 | } | 138 | } |
| 136 | - $host = $urlParts['host'] ?? ''; | 139 | + $host = $urlParts['host'] ?? ''; |
| 137 | $scheme = $urlParts['scheme'] ?? 'https'; | 140 | $scheme = $urlParts['scheme'] ?? 'https'; |
| 138 | - if(!in_array($scheme, ['http', 'https'])){ | 141 | + if (!in_array($scheme, ['http', 'https'])) { |
| 139 | return false; | 142 | return false; |
| 140 | } | 143 | } |
| 141 | if (preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $host)) { | 144 | if (preg_match('/^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/', $host)) { |
| @@ -147,7 +150,6 @@ if (!function_exists('checkDomain')) { | @@ -147,7 +150,6 @@ if (!function_exists('checkDomain')) { | ||
| 147 | } | 150 | } |
| 148 | 151 | ||
| 149 | 152 | ||
| 150 | - | ||
| 151 | /** | 153 | /** |
| 152 | * 把返回的数据集转换成Tree | 154 | * 把返回的数据集转换成Tree |
| 153 | * @param $list array 数据列表 | 155 | * @param $list array 数据列表 |
| @@ -158,20 +160,21 @@ if (!function_exists('checkDomain')) { | @@ -158,20 +160,21 @@ if (!function_exists('checkDomain')) { | ||
| 158 | * @param bool $empty_child 当子数据不存在,是否要返回空子数据 | 160 | * @param bool $empty_child 当子数据不存在,是否要返回空子数据 |
| 159 | * @return array | 161 | * @return array |
| 160 | */ | 162 | */ |
| 161 | -function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0,$empty_child=true) { | 163 | +function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_child', $root = 0, $empty_child = true) |
| 164 | +{ | ||
| 162 | // 如果是数字,则是root | 165 | // 如果是数字,则是root |
| 163 | - if(is_numeric($pk)){ | ||
| 164 | - $root = $pk; | ||
| 165 | - $pk = 'id'; | 166 | + if (is_numeric($pk)) { |
| 167 | + $root = $pk; | ||
| 168 | + $pk = 'id'; | ||
| 166 | } | 169 | } |
| 167 | // 创建Tree | 170 | // 创建Tree |
| 168 | $tree = array(); | 171 | $tree = array(); |
| 169 | - if(is_array($list)) { | 172 | + if (is_array($list)) { |
| 170 | // 创建基于主键的数组引用 | 173 | // 创建基于主键的数组引用 |
| 171 | $refer = array(); | 174 | $refer = array(); |
| 172 | foreach ($list as $key => $data) { | 175 | foreach ($list as $key => $data) { |
| 173 | - if($empty_child){ | ||
| 174 | - $list[$key][$child] = []; | 176 | + if ($empty_child) { |
| 177 | + $list[$key][$child] = []; | ||
| 175 | } | 178 | } |
| 176 | $refer[$data[$pk]] =& $list[$key]; | 179 | $refer[$data[$pk]] =& $list[$key]; |
| 177 | } | 180 | } |
| @@ -180,9 +183,9 @@ function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0,$em | @@ -180,9 +183,9 @@ function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0,$em | ||
| 180 | $parentId = $data[$pid]; | 183 | $parentId = $data[$pid]; |
| 181 | if ($root == $parentId) { | 184 | if ($root == $parentId) { |
| 182 | $tree[] =& $list[$key]; | 185 | $tree[] =& $list[$key]; |
| 183 | - }else{ | 186 | + } else { |
| 184 | if (isset($refer[$parentId])) { | 187 | if (isset($refer[$parentId])) { |
| 185 | - $refer[$parentId][$child][] = & $list[$key]; | 188 | + $refer[$parentId][$child][] = &$list[$key]; |
| 186 | } | 189 | } |
| 187 | } | 190 | } |
| 188 | } | 191 | } |
| @@ -198,14 +201,15 @@ function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0,$em | @@ -198,14 +201,15 @@ function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0,$em | ||
| 198 | * @author:dc | 201 | * @author:dc |
| 199 | * @time 2022/1/11 10:13 | 202 | * @time 2022/1/11 10:13 |
| 200 | */ | 203 | */ |
| 201 | -function tree_to_list($tree, $child='_child'){ | ||
| 202 | - $lists = []; | ||
| 203 | - foreach ($tree as $item){ | ||
| 204 | - $c = $item[$child]??[]; | 204 | +function tree_to_list($tree, $child = '_child') |
| 205 | +{ | ||
| 206 | + $lists = []; | ||
| 207 | + foreach ($tree as $item) { | ||
| 208 | + $c = $item[$child] ?? []; | ||
| 205 | unset($item[$child]); | 209 | unset($item[$child]); |
| 206 | $lists[] = $item; | 210 | $lists[] = $item; |
| 207 | - if ($c){ | ||
| 208 | - $lists = array_merge($lists,tree_to_list($c, $child)); | 211 | + if ($c) { |
| 212 | + $lists = array_merge($lists, tree_to_list($c, $child)); | ||
| 209 | } | 213 | } |
| 210 | } | 214 | } |
| 211 | return $lists; | 215 | return $lists; |
| @@ -233,10 +237,10 @@ if (!function_exists('object_to_array')) { | @@ -233,10 +237,10 @@ if (!function_exists('object_to_array')) { | ||
| 233 | */ | 237 | */ |
| 234 | function object_to_array($data) | 238 | function object_to_array($data) |
| 235 | { | 239 | { |
| 236 | - if(is_object($data)){ | 240 | + if (is_object($data)) { |
| 237 | $data = (array)$data; | 241 | $data = (array)$data; |
| 238 | - }else{ | ||
| 239 | - foreach ($data as $k => $v){ | 242 | + } else { |
| 243 | + foreach ($data as $k => $v) { | ||
| 240 | $data[$k] = object_to_array($v); | 244 | $data[$k] = object_to_array($v); |
| 241 | } | 245 | } |
| 242 | } | 246 | } |
| @@ -244,3 +248,159 @@ if (!function_exists('object_to_array')) { | @@ -244,3 +248,159 @@ if (!function_exists('object_to_array')) { | ||
| 244 | } | 248 | } |
| 245 | } | 249 | } |
| 246 | 250 | ||
| 251 | +if (!function_exists('getPreviousDaysDate')) { | ||
| 252 | + /** | ||
| 253 | + * 获取当前指定前几天日期,默认获取前三天日期 | ||
| 254 | + * @param int $day | ||
| 255 | + * @return array | ||
| 256 | + */ | ||
| 257 | + function getPreviousDaysDate(int $day = 3) | ||
| 258 | + { | ||
| 259 | + $days = []; | ||
| 260 | + while ($day > 0) { | ||
| 261 | + $days[] = date("Y-m-d", strtotime("-{$day} days")); | ||
| 262 | + $day -= 1; | ||
| 263 | + } | ||
| 264 | + return $days; | ||
| 265 | + } | ||
| 266 | +} | ||
| 267 | + | ||
| 268 | +if (!function_exists('getPreviousMonthsDate')) { | ||
| 269 | + /** | ||
| 270 | + * 获取当前指定前几天日期,默认获取前三天日期 | ||
| 271 | + * @param int $month | ||
| 272 | + * @return array | ||
| 273 | + */ | ||
| 274 | + function getPreviousMonthsDate(int $month = 3) | ||
| 275 | + { | ||
| 276 | + $months = []; | ||
| 277 | + while ($month > 0) { | ||
| 278 | + $months[] = date("Y-m", strtotime("-{$month} months")); | ||
| 279 | + $month -= 1; | ||
| 280 | + } | ||
| 281 | + return $months; | ||
| 282 | + } | ||
| 283 | +} | ||
| 284 | + | ||
| 285 | +if (!function_exists('getInquiryInformation')) { | ||
| 286 | + /** | ||
| 287 | + * 获取第三方询盘信息 | ||
| 288 | + * @return array|string | ||
| 289 | + * @throws GuzzleException | ||
| 290 | + */ | ||
| 291 | + function getInquiryInformation($domain, $sta_date) | ||
| 292 | + { | ||
| 293 | + $token = md5($domain . date("Y-m-d")); | ||
| 294 | + $source = '1,3'; | ||
| 295 | + $url = "https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain={$domain}&token={$token}&source={$source}&sta_date={$sta_date}"; | ||
| 296 | + $client = new Client(['verify' => false]); | ||
| 297 | + $http = $client->get($url); | ||
| 298 | + $data = []; | ||
| 299 | + if ($http->getStatusCode() != 200) { | ||
| 300 | + return $data; | ||
| 301 | + } | ||
| 302 | + $content = $http->getBody()->getContents(); | ||
| 303 | + $json = json_decode($content, true); | ||
| 304 | + if ($json['status'] != 200) { | ||
| 305 | + return $content; | ||
| 306 | + } | ||
| 307 | + $data['count'] = $json['data']['count']; | ||
| 308 | + $data['lists'] = $json['data']['data']; | ||
| 309 | + return $data; | ||
| 310 | + } | ||
| 311 | +} | ||
| 312 | + | ||
| 313 | +if (!function_exists('stringUnderlineLowercase')) { | ||
| 314 | + /** | ||
| 315 | + * 正则 - 名字转为小写并将空格转为下划线 | ||
| 316 | + * @param $name | ||
| 317 | + * @return string | ||
| 318 | + */ | ||
| 319 | + function stringUnderlineLowercase($name) | ||
| 320 | + { | ||
| 321 | + return trim(strtolower(preg_replace('/[^a-zA-Z0-9]/', '_', $name))); | ||
| 322 | + } | ||
| 323 | +} | ||
| 324 | + | ||
| 325 | +if (!function_exists('checkIsGreaterMonth')) { | ||
| 326 | + /** | ||
| 327 | + * 判断传入日期是否大于当月 | ||
| 328 | + * @param $date | ||
| 329 | + * @return bool | ||
| 330 | + */ | ||
| 331 | + function checkIsGreaterMonth($date) | ||
| 332 | + { | ||
| 333 | + // 传入日期的时间戳 | ||
| 334 | + $timestamp = strtotime($date); | ||
| 335 | + // 当前月份的时间戳 | ||
| 336 | + $nowMonth = strtotime(date('Y-m')); | ||
| 337 | + // 判断传入日期是否大于当前月份 | ||
| 338 | + return $timestamp > $nowMonth; | ||
| 339 | + } | ||
| 340 | +} | ||
| 341 | + | ||
| 342 | +if (!function_exists('checkIsMonth')) { | ||
| 343 | + /** | ||
| 344 | + * 判断传入日期是否是当月 | ||
| 345 | + * @param $date | ||
| 346 | + * @return bool | ||
| 347 | + */ | ||
| 348 | + function checkIsMonth($date) | ||
| 349 | + { | ||
| 350 | + // 获取当前时间戳 | ||
| 351 | + $now = time(); | ||
| 352 | + // 获取当月的起始时间戳和结束时间戳 | ||
| 353 | + $firstDay = strtotime(date('Y-m-01', $now)); | ||
| 354 | + $lastDay = strtotime(date('Y-m-t', $now)); | ||
| 355 | + // 传入日期的时间戳 | ||
| 356 | + $timestamp = strtotime($date); | ||
| 357 | + // 判断传入日期是否在当月范围内 | ||
| 358 | + return $timestamp >= $firstDay && $timestamp <= $lastDay; | ||
| 359 | + } | ||
| 360 | +} | ||
| 361 | + | ||
| 362 | +if (!function_exists('getDateDays')) { | ||
| 363 | + /** | ||
| 364 | + * 返回当月到今天的天数 | ||
| 365 | + * @param string|null $date 日期,格式:Y-m | ||
| 366 | + * @return array | ||
| 367 | + */ | ||
| 368 | + function getDateDays(string $date = null) | ||
| 369 | + { | ||
| 370 | + list($year, $month, $day) = explode('-', date('Y-m-d')); | ||
| 371 | + // 获取当前月的第一天 | ||
| 372 | + $first_day_of_month = "{$year}-{$month}-01"; | ||
| 373 | + // 获取今天的日期 | ||
| 374 | + $today = "{$year}-{$month}-{$day}"; | ||
| 375 | + if (!is_null($date)) { | ||
| 376 | + $dd = explode('-', $date); | ||
| 377 | + if (!checkIsGreaterMonth($date) && !checkIsMonth($date)) { | ||
| 378 | + $year = $dd[0]; | ||
| 379 | + $month = $dd[1]; | ||
| 380 | + $first_day_of_month = "{$year}-{$month}-01"; | ||
| 381 | + return getDateArray("{$year}-{$month}-" . date("t", strtotime($first_day_of_month))); | ||
| 382 | + } | ||
| 383 | + } | ||
| 384 | + $day_timestamp = strtotime($today) - strtotime($first_day_of_month); | ||
| 385 | + return getDateArray("{$year}-{$month}-" . date('d', $day_timestamp)); | ||
| 386 | + } | ||
| 387 | +} | ||
| 388 | + | ||
| 389 | +if (!function_exists('getDateArray')) { | ||
| 390 | + /** | ||
| 391 | + * 获取当月获取日期 | ||
| 392 | + * @param string $date 日期,格式:Y-m-d | ||
| 393 | + * @return array | ||
| 394 | + */ | ||
| 395 | + function getDateArray(string $date) | ||
| 396 | + { | ||
| 397 | + list($year, $month, $day) = explode('-', date($date)); | ||
| 398 | + $i = 1; | ||
| 399 | + $days = []; | ||
| 400 | + while ($i <= $day) { | ||
| 401 | + $days[] = "{$year}-{$month}-" . str_pad($i, 2, "0", STR_PAD_LEFT); | ||
| 402 | + $i++; | ||
| 403 | + } | ||
| 404 | + return $days; | ||
| 405 | + } | ||
| 406 | +} |
| @@ -11,15 +11,19 @@ use Illuminate\Http\Request; | @@ -11,15 +11,19 @@ use Illuminate\Http\Request; | ||
| 11 | use function App\Helper\send_openai_msg; | 11 | use function App\Helper\send_openai_msg; |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | - * @name:ai指令 | 14 | + * @remark :ai指令 |
| 15 | + * @name :AiCommandController | ||
| 16 | + * @author :lyh | ||
| 17 | + * @time :2023/6/17 16:27 | ||
| 15 | */ | 18 | */ |
| 16 | class AiCommandController extends BaseController | 19 | class AiCommandController extends BaseController |
| 17 | { | 20 | { |
| 18 | /** | 21 | /** |
| 19 | - * @name :指令列表 | ||
| 20 | - * @return void | ||
| 21 | - * @author :liyuhang | ||
| 22 | - * @method | 22 | + * @param AiCommandModel $aiCommandModel |
| 23 | + * @name :lists | ||
| 24 | + * @author :lyh | ||
| 25 | + * @method :post | ||
| 26 | + * @time :2023/6/17 16:27 | ||
| 23 | */ | 27 | */ |
| 24 | public function lists(AiCommandModel $aiCommandModel){ | 28 | public function lists(AiCommandModel $aiCommandModel){ |
| 25 | $lists = $aiCommandModel->lists($this->map,$this->page,$this->row,$this->order); | 29 | $lists = $aiCommandModel->lists($this->map,$this->page,$this->row,$this->order); |
| @@ -27,10 +31,11 @@ class AiCommandController extends BaseController | @@ -27,10 +31,11 @@ class AiCommandController extends BaseController | ||
| 27 | } | 31 | } |
| 28 | 32 | ||
| 29 | /** | 33 | /** |
| 30 | - * @name :详情 | ||
| 31 | - * @return void | ||
| 32 | - * @author :liyuhang | ||
| 33 | - * @method | 34 | + * @param AiCommandLogic $aiCommandLogic |
| 35 | + * @name :info | ||
| 36 | + * @author :lyh | ||
| 37 | + * @method :post | ||
| 38 | + * @time :2023/6/17 16:27 | ||
| 34 | */ | 39 | */ |
| 35 | public function info(AiCommandLogic $aiCommandLogic){ | 40 | public function info(AiCommandLogic $aiCommandLogic){ |
| 36 | $this->request->validate([ | 41 | $this->request->validate([ |
| @@ -41,11 +46,14 @@ class AiCommandController extends BaseController | @@ -41,11 +46,14 @@ class AiCommandController extends BaseController | ||
| 41 | $aiCommandLogic->ai_info(); | 46 | $aiCommandLogic->ai_info(); |
| 42 | $this->response('success'); | 47 | $this->response('success'); |
| 43 | } | 48 | } |
| 49 | + | ||
| 44 | /** | 50 | /** |
| 45 | - * @name | ||
| 46 | - * @return void | ||
| 47 | - * @author :liyuhang | ||
| 48 | - * @method | 51 | + * @param AiCommandRequest $request |
| 52 | + * @param AiCommandLogic $aiCommandLogic | ||
| 53 | + * @name :add | ||
| 54 | + * @author :lyh | ||
| 55 | + * @method :post | ||
| 56 | + * @time :2023/6/17 16:27 | ||
| 49 | */ | 57 | */ |
| 50 | public function add(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){ | 58 | public function add(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){ |
| 51 | $request->validated(); | 59 | $request->validated(); |
| @@ -54,10 +62,12 @@ class AiCommandController extends BaseController | @@ -54,10 +62,12 @@ class AiCommandController extends BaseController | ||
| 54 | } | 62 | } |
| 55 | 63 | ||
| 56 | /** | 64 | /** |
| 57 | - * @name | ||
| 58 | - * @return void | ||
| 59 | - * @author :liyuhang | ||
| 60 | - * @method | 65 | + * @param AiCommandRequest $request |
| 66 | + * @param AiCommandLogic $aiCommandLogic | ||
| 67 | + * @name :edit | ||
| 68 | + * @author :lyh | ||
| 69 | + * @method :post | ||
| 70 | + * @time :2023/6/17 16:28 | ||
| 61 | */ | 71 | */ |
| 62 | public function edit(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){ | 72 | public function edit(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){ |
| 63 | $request->validate([ | 73 | $request->validate([ |
| @@ -70,10 +80,11 @@ class AiCommandController extends BaseController | @@ -70,10 +80,11 @@ class AiCommandController extends BaseController | ||
| 70 | } | 80 | } |
| 71 | 81 | ||
| 72 | /** | 82 | /** |
| 73 | - * @name | ||
| 74 | - * @return void | ||
| 75 | - * @author :liyuhang | ||
| 76 | - * @method | 83 | + * @param AiCommandLogic $aiCommandLogic |
| 84 | + * @name :del | ||
| 85 | + * @author :lyh | ||
| 86 | + * @method :post | ||
| 87 | + * @time :2023/6/17 16:27 | ||
| 77 | */ | 88 | */ |
| 78 | public function del(AiCommandLogic $aiCommandLogic){ | 89 | public function del(AiCommandLogic $aiCommandLogic){ |
| 79 | $this->request->validate([ | 90 | $this->request->validate([ |
| @@ -6,14 +6,20 @@ use App\Enums\Common\Code; | @@ -6,14 +6,20 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | use App\Models\Ai\AiLog as AiLogModel; | 7 | use App\Models\Ai\AiLog as AiLogModel; |
| 8 | 8 | ||
| 9 | - | 9 | +/** |
| 10 | + * @remark :ai发送记录 | ||
| 11 | + * @name :AiLogController | ||
| 12 | + * @author :lyh | ||
| 13 | + * @time :2023/6/17 16:26 | ||
| 14 | + */ | ||
| 10 | class AiLogController extends BaseController | 15 | class AiLogController extends BaseController |
| 11 | { | 16 | { |
| 12 | /** | 17 | /** |
| 13 | - * @name :ai日志列表 | ||
| 14 | - * @return void | ||
| 15 | - * @author :liyuhang | ||
| 16 | - * @method | 18 | + * @param AiLogModel $aiLogModel |
| 19 | + * @name :(ai发送日志列表)lists | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2023/6/17 16:25 | ||
| 17 | */ | 23 | */ |
| 18 | public function lists(AiLogModel $aiLogModel){ | 24 | public function lists(AiLogModel $aiLogModel){ |
| 19 | $lists = $aiLogModel->lists($this->map,$this->page,$this->row,$this->order); | 25 | $lists = $aiLogModel->lists($this->map,$this->page,$this->row,$this->order); |
| @@ -3,7 +3,9 @@ | @@ -3,7 +3,9 @@ | ||
| 3 | namespace App\Http\Controllers\Aside; | 3 | namespace App\Http\Controllers\Aside; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Enums\Common\Common; | ||
| 6 | use App\Http\Controllers\Controller; | 7 | use App\Http\Controllers\Controller; |
| 8 | +use App\Models\User\User as UserModel; | ||
| 7 | use Illuminate\Http\JsonResponse; | 9 | use Illuminate\Http\JsonResponse; |
| 8 | use Illuminate\Http\Request; | 10 | use Illuminate\Http\Request; |
| 9 | use Illuminate\Http\Exceptions\HttpResponseException; | 11 | use Illuminate\Http\Exceptions\HttpResponseException; |
| @@ -21,7 +23,7 @@ class BaseController extends Controller | @@ -21,7 +23,7 @@ class BaseController extends Controller | ||
| 21 | protected $order = 'id'; | 23 | protected $order = 'id'; |
| 22 | protected $map = [];//处理后的参数 | 24 | protected $map = [];//处理后的参数 |
| 23 | protected $uid = 0; | 25 | protected $uid = 0; |
| 24 | - protected $user = [];//当前登录用户详情 | 26 | + protected $manage = [];//当前登录用户详情 |
| 25 | /** | 27 | /** |
| 26 | * 获取所有参数 | 28 | * 获取所有参数 |
| 27 | */ | 29 | */ |
| @@ -30,14 +32,12 @@ class BaseController extends Controller | @@ -30,14 +32,12 @@ class BaseController extends Controller | ||
| 30 | $this->request = $request; | 32 | $this->request = $request; |
| 31 | $this->param = $this->request->all(); | 33 | $this->param = $this->request->all(); |
| 32 | $this->token = $this->request->header('token'); | 34 | $this->token = $this->request->header('token'); |
| 33 | - if(!empty($this->token) && !empty(Cache::get($this->token))){ | ||
| 34 | - $info = Cache::get($this->token); | ||
| 35 | - $this->user = $info; | 35 | + $this->get_param(); |
| 36 | + if(!empty($this->token) && !empty(Cache::get(Common::MANAGE_TOKEN . $this->token))){ | ||
| 37 | + $info = Cache::get(Common::MANAGE_TOKEN . $this->token); | ||
| 38 | + $this->manage = $info; | ||
| 36 | $this->uid = $info['id']; | 39 | $this->uid = $info['id']; |
| 37 | - //参数处理 | ||
| 38 | - $this->get_param(); | ||
| 39 | } | 40 | } |
| 40 | - | ||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | 43 | ||
| @@ -64,10 +64,13 @@ class BaseController extends Controller | @@ -64,10 +64,13 @@ class BaseController extends Controller | ||
| 64 | $this->header['token'] = $this->token; | 64 | $this->header['token'] = $this->token; |
| 65 | return response()->json($response,200,$this->header); | 65 | return response()->json($response,200,$this->header); |
| 66 | } | 66 | } |
| 67 | + | ||
| 67 | /** | 68 | /** |
| 68 | - * @name :参数过滤 | ||
| 69 | - * @author :liyuhang | ||
| 70 | - * @method | 69 | + * @remark :请求参数处理 |
| 70 | + * @name :get_param | ||
| 71 | + * @author :lyh | ||
| 72 | + * @method :post | ||
| 73 | + * @time :2023/6/17 16:34 | ||
| 71 | */ | 74 | */ |
| 72 | public function get_param(){ | 75 | public function get_param(){ |
| 73 | $param = $this->param; | 76 | $param = $this->param; |
| @@ -105,11 +108,18 @@ class BaseController extends Controller | @@ -105,11 +108,18 @@ class BaseController extends Controller | ||
| 105 | } | 108 | } |
| 106 | } | 109 | } |
| 107 | } | 110 | } |
| 111 | + | ||
| 108 | /** | 112 | /** |
| 109 | - * @name 统一返回参数 | ||
| 110 | - * @return JsonResponse | ||
| 111 | - * @author :liyuhang | ||
| 112 | - * @method | 113 | + * @param $msg |
| 114 | + * @param string $code | ||
| 115 | + * @param $data | ||
| 116 | + * @param $result_code | ||
| 117 | + * @param $type | ||
| 118 | + * @remark :统一返回 | ||
| 119 | + * @name :response | ||
| 120 | + * @author :lyh | ||
| 121 | + * @method :post | ||
| 122 | + * @time :2023/6/17 16:34 | ||
| 113 | */ | 123 | */ |
| 114 | public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse | 124 | public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse |
| 115 | { | 125 | { |
| @@ -128,10 +138,11 @@ class BaseController extends Controller | @@ -128,10 +138,11 @@ class BaseController extends Controller | ||
| 128 | 138 | ||
| 129 | /** | 139 | /** |
| 130 | * @param $data | 140 | * @param $data |
| 131 | - * @name :返回参数统一处理 | ||
| 132 | - * @return array|string | ||
| 133 | - * @author :liyuhang | ||
| 134 | - * @method | 141 | + * @remark :统一返回参数处理 |
| 142 | + * @name :_extents | ||
| 143 | + * @author :lyh | ||
| 144 | + * @method :post | ||
| 145 | + * @time :2023/6/17 16:34 | ||
| 135 | */ | 146 | */ |
| 136 | protected function _extents($data) { | 147 | protected function _extents($data) { |
| 137 | 148 | ||
| @@ -150,6 +161,12 @@ class BaseController extends Controller | @@ -150,6 +161,12 @@ class BaseController extends Controller | ||
| 150 | case 'image': | 161 | case 'image': |
| 151 | $v['image_link'] = url('/a/image/' . $v); | 162 | $v['image_link'] = url('/a/image/' . $v); |
| 152 | break; | 163 | break; |
| 164 | + case 'operator_id': | ||
| 165 | + if(!empty($v)){ | ||
| 166 | + $name = (new UserModel())->read(['id'=>$v],['id','name']); | ||
| 167 | + $data['operator_name'] = (isset($name['name']) && !empty($name['name'])) ? $name['name'] : '无名称'; | ||
| 168 | + } | ||
| 169 | + break; | ||
| 153 | } | 170 | } |
| 154 | } | 171 | } |
| 155 | } | 172 | } |
| @@ -159,6 +176,4 @@ class BaseController extends Controller | @@ -159,6 +176,4 @@ class BaseController extends Controller | ||
| 159 | 176 | ||
| 160 | 177 | ||
| 161 | 178 | ||
| 162 | - | ||
| 163 | - | ||
| 164 | } | 179 | } |
| @@ -73,6 +73,7 @@ class ServerInformationController extends BaseController | @@ -73,6 +73,7 @@ class ServerInformationController extends BaseController | ||
| 73 | */ | 73 | */ |
| 74 | public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic) | 74 | public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic) |
| 75 | { | 75 | { |
| 76 | + | ||
| 76 | $serverInformationRequest->validate([ | 77 | $serverInformationRequest->validate([ |
| 77 | 'id' => 'required|integer', | 78 | 'id' => 'required|integer', |
| 78 | ], [ | 79 | ], [ |
| @@ -3,18 +3,9 @@ | @@ -3,18 +3,9 @@ | ||
| 3 | namespace App\Http\Controllers\Aside\Devops; | 3 | namespace App\Http\Controllers\Aside\Devops; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | -use App\Exceptions\AsideGlobalException; | ||
| 7 | -use App\Exceptions\BsideGlobalException; | ||
| 8 | use App\Http\Controllers\Aside\BaseController; | 6 | 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; | 7 | use App\Models\Devops\ServerInformationLog; |
| 13 | -use Illuminate\Http\JsonResponse; | ||
| 14 | use Illuminate\Http\Request; | 8 | use Illuminate\Http\Request; |
| 15 | -use Illuminate\Support\Facades\DB; | ||
| 16 | -use Psr\Container\ContainerExceptionInterface; | ||
| 17 | -use Psr\Container\NotFoundExceptionInterface; | ||
| 18 | 9 | ||
| 19 | class ServerInformationLogController extends BaseController | 10 | class ServerInformationLogController extends BaseController |
| 20 | { | 11 | { |
| @@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Aside; | 3 | namespace App\Http\Controllers\Aside; |
| 4 | 4 | ||
| 5 | -use App\Http\Controllers\Controller; | ||
| 6 | -use Illuminate\Http\Request; | 5 | +use App\Http\Logic\Aside\Manage\MenuLogic; |
| 6 | +use App\Models\Manage\Manage; | ||
| 7 | 7 | ||
| 8 | /** | 8 | /** |
| 9 | * Class IndexController | 9 | * Class IndexController |
| @@ -11,16 +11,25 @@ use Illuminate\Http\Request; | @@ -11,16 +11,25 @@ use Illuminate\Http\Request; | ||
| 11 | * @author zbj | 11 | * @author zbj |
| 12 | * @date 2023/4/19 | 12 | * @date 2023/4/19 |
| 13 | */ | 13 | */ |
| 14 | -class IndexController extends Controller | 14 | +class IndexController extends BaseController |
| 15 | { | 15 | { |
| 16 | /** | 16 | /** |
| 17 | - * 首页 | ||
| 18 | - * @param Request $request | 17 | + * 用户菜单 |
| 18 | + * @param MenuLogic $logic | ||
| 19 | * @return \Illuminate\Http\JsonResponse | 19 | * @return \Illuminate\Http\JsonResponse |
| 20 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 21 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 22 | + * @author zbj | ||
| 23 | + * @date 2023/6/21 | ||
| 20 | */ | 24 | */ |
| 21 | - public function index(Request $request) | 25 | + public function get_menu(MenuLogic $logic) |
| 22 | { | 26 | { |
| 23 | - | 27 | + if($this->manage['id'] == Manage::ADMINISTRATOR_ID){ //超级管理员 |
| 28 | + $menus = $logic->getAllMenu(); | ||
| 29 | + }else{ | ||
| 30 | + $menus = $logic->getMenuByGroupId($this->manage['gid']); | ||
| 31 | + } | ||
| 32 | + return $this->success($menus); | ||
| 24 | } | 33 | } |
| 25 | 34 | ||
| 26 | } | 35 | } |
| @@ -18,27 +18,22 @@ class LoginController extends BaseController | @@ -18,27 +18,22 @@ class LoginController extends BaseController | ||
| 18 | 18 | ||
| 19 | function login(Request $request, LoginLogic $logic) | 19 | function login(Request $request, LoginLogic $logic) |
| 20 | { | 20 | { |
| 21 | - if ($request->isMethod('POST')) { | ||
| 22 | - $request->validate([ | ||
| 23 | - 'mobile' => ['required', new Mobile()], | ||
| 24 | - 'password' => 'required', | ||
| 25 | - ], [ | ||
| 26 | - 'mobile.required' => '请输入手机号', | ||
| 27 | - 'password.required' => '请输入密码', | ||
| 28 | - ]); | ||
| 29 | - | ||
| 30 | - $logic->login(); | ||
| 31 | - | ||
| 32 | - return $this->success(); | ||
| 33 | - } | ||
| 34 | - if($logic->manage()){ | ||
| 35 | - return redirect(route('admin.home.white')); | ||
| 36 | - } | ||
| 37 | - return view('admin.login'); | 21 | + $request->validate([ |
| 22 | + 'mobile' => ['required', new Mobile()], | ||
| 23 | + 'password' => 'required', | ||
| 24 | + ], [ | ||
| 25 | + 'mobile.required' => '请输入手机号', | ||
| 26 | + 'password.required' => '请输入密码', | ||
| 27 | + ]); | ||
| 28 | + | ||
| 29 | + $data = $logic->login(); | ||
| 30 | + | ||
| 31 | + return $this->success($data); | ||
| 38 | } | 32 | } |
| 39 | 33 | ||
| 40 | public function logout(LoginLogic $logic) | 34 | public function logout(LoginLogic $logic) |
| 41 | { | 35 | { |
| 42 | - return $logic->logout(); | 36 | + $logic->logout(); |
| 37 | + return $this->success(); | ||
| 43 | } | 38 | } |
| 44 | } | 39 | } |
| @@ -13,17 +13,20 @@ use App\Models\Mail\Mail as MailModel; | @@ -13,17 +13,20 @@ use App\Models\Mail\Mail as MailModel; | ||
| 13 | */ | 13 | */ |
| 14 | class MailController extends BaseController | 14 | class MailController extends BaseController |
| 15 | { | 15 | { |
| 16 | - public function lists(){ | ||
| 17 | - $mailModel = new MailModel(); | ||
| 18 | - $lists = $mailModel->lists($this->map,$this->page,$this->row,$this->order); | 16 | + public function lists(MailLogic $mailLogic){ |
| 17 | + if(isset($this->map['title']) && !empty($this->map['title'])){ | ||
| 18 | + $this->map['title'] = ['like','%'.$this->map['title'].'%']; | ||
| 19 | + } | ||
| 20 | + $lists = $mailLogic->mail_lists($this->map,$this->page,$this->row,$this->order); | ||
| 19 | $this->response('列表',Code::SUCCESS,$lists); | 21 | $this->response('列表',Code::SUCCESS,$lists); |
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | /** | 24 | /** |
| 23 | - * @name :详情 | ||
| 24 | - * @return void | ||
| 25 | - * @author :liyuhang | ||
| 26 | - * @method | 25 | + * @param MailLogic $mailLogic |
| 26 | + * @name :info | ||
| 27 | + * @author :lyh | ||
| 28 | + * @method :post | ||
| 29 | + * @time :2023/6/17 16:25 | ||
| 27 | */ | 30 | */ |
| 28 | public function info(MailLogic $mailLogic){ | 31 | public function info(MailLogic $mailLogic){ |
| 29 | $this->request->validate([ | 32 | $this->request->validate([ |
| @@ -37,10 +40,12 @@ class MailController extends BaseController | @@ -37,10 +40,12 @@ class MailController extends BaseController | ||
| 37 | 40 | ||
| 38 | 41 | ||
| 39 | /** | 42 | /** |
| 40 | - * @name :添加站内信 | ||
| 41 | - * @return void | ||
| 42 | - * @author :liyuhang | ||
| 43 | - * @method | 43 | + * @param MailRequest $mailRequest |
| 44 | + * @param MailLogic $mailLogic | ||
| 45 | + * @name :add | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2023/6/17 16:25 | ||
| 44 | */ | 49 | */ |
| 45 | public function add(MailRequest $mailRequest,MailLogic $mailLogic){ | 50 | public function add(MailRequest $mailRequest,MailLogic $mailLogic){ |
| 46 | $mailRequest->validated(); | 51 | $mailRequest->validated(); |
| @@ -49,10 +54,12 @@ class MailController extends BaseController | @@ -49,10 +54,12 @@ class MailController extends BaseController | ||
| 49 | } | 54 | } |
| 50 | 55 | ||
| 51 | /** | 56 | /** |
| 52 | - * @name :编辑站内信 | ||
| 53 | - * @return void | ||
| 54 | - * @author :liyuhang | ||
| 55 | - * @method | 57 | + * @param MailRequest $mailRequest |
| 58 | + * @param MailLogic $mailLogic | ||
| 59 | + * @name :edit | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2023/6/17 16:24 | ||
| 56 | */ | 63 | */ |
| 57 | public function edit(MailRequest $mailRequest,MailLogic $mailLogic){ | 64 | public function edit(MailRequest $mailRequest,MailLogic $mailLogic){ |
| 58 | $mailRequest->validate([ | 65 | $mailRequest->validate([ |
| @@ -65,16 +72,18 @@ class MailController extends BaseController | @@ -65,16 +72,18 @@ class MailController extends BaseController | ||
| 65 | } | 72 | } |
| 66 | 73 | ||
| 67 | /** | 74 | /** |
| 68 | - * @name :逻辑删除站内信 | ||
| 69 | - * @return void | ||
| 70 | - * @author :liyuhang | ||
| 71 | - * @method | 75 | + * @param MailLogic $mailLogic |
| 76 | + * @name :del | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2023/6/17 16:24 | ||
| 72 | */ | 80 | */ |
| 73 | public function del(MailLogic $mailLogic){ | 81 | public function del(MailLogic $mailLogic){ |
| 74 | $this->request->validate([ | 82 | $this->request->validate([ |
| 75 | - 'id'=>'required' | 83 | + 'id'=>['required','array'], |
| 76 | ],[ | 84 | ],[ |
| 77 | - 'id.required' => 'ID不能为空' | 85 | + 'id.required' => 'ID不能为空', |
| 86 | + 'id.array' => 'ID为数组', | ||
| 78 | ]); | 87 | ]); |
| 79 | $mailLogic->mail_del(); | 88 | $mailLogic->mail_del(); |
| 80 | $this->response('success'); | 89 | $this->response('success'); |
| @@ -27,7 +27,7 @@ class DeptController extends BaseController | @@ -27,7 +27,7 @@ class DeptController extends BaseController | ||
| 27 | $sort = ['id' => 'desc']; | 27 | $sort = ['id' => 'desc']; |
| 28 | $data = $logic->getList($map, $sort, ['id', 'pid', 'title'],0); | 28 | $data = $logic->getList($map, $sort, ['id', 'pid', 'title'],0); |
| 29 | 29 | ||
| 30 | - return view("admin.dept", ["list" => Arr::listToTree($data)]); | 30 | + return $this->success(Arr::listToTree($data)); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | public function info(Request $request, DeptLogic $logic){ | 33 | public function info(Request $request, DeptLogic $logic){ |
| @@ -22,7 +22,7 @@ class GroupController extends BaseController | @@ -22,7 +22,7 @@ class GroupController extends BaseController | ||
| 22 | public function list(Request $request, GroupLogic $logic) | 22 | public function list(Request $request, GroupLogic $logic) |
| 23 | { | 23 | { |
| 24 | $list = $logic->getList(); | 24 | $list = $logic->getList(); |
| 25 | - return view("admin.group", ["list" => $list]); | 25 | + return $this->success($list); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | public function info(Request $request, GroupLogic $logic){ | 28 | public function info(Request $request, GroupLogic $logic){ |
| @@ -21,8 +21,18 @@ class ManageController extends BaseController | @@ -21,8 +21,18 @@ class ManageController extends BaseController | ||
| 21 | 21 | ||
| 22 | public function list(Request $request, ManageLogic $logic) | 22 | public function list(Request $request, ManageLogic $logic) |
| 23 | { | 23 | { |
| 24 | - $list = $logic->getList(); | ||
| 25 | - return view("admin.manage", ["list" => $list]); | 24 | + $map = []; |
| 25 | + if(!empty($this->param['search'])){ | ||
| 26 | + $map[] = ['name|mobile', 'like', "%{$this->param['search']}%"]; | ||
| 27 | + } | ||
| 28 | + if(!empty($this->param['dept_id'])){ | ||
| 29 | + $map[] = ['dept_id', $this->param['dept_id']]; | ||
| 30 | + } | ||
| 31 | + if(!empty($this->param['gid'])){ | ||
| 32 | + $map[] = ['gid', $this->param['gid']]; | ||
| 33 | + } | ||
| 34 | + $list = $logic->getList($map); | ||
| 35 | + return $this->success($list); | ||
| 26 | } | 36 | } |
| 27 | 37 | ||
| 28 | public function info(Request $request, ManageLogic $logic){ | 38 | public function info(Request $request, ManageLogic $logic){ |
| @@ -6,8 +6,11 @@ use App\Helper\Arr; | @@ -6,8 +6,11 @@ use App\Helper\Arr; | ||
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | use App\Http\Logic\Aside\Manage\MenuLogic; | 7 | use App\Http\Logic\Aside\Manage\MenuLogic; |
| 8 | use App\Http\Requests\Aside\Manage\MenuRequest; | 8 | use App\Http\Requests\Aside\Manage\MenuRequest; |
| 9 | +use App\Models\Manage\Menu; | ||
| 9 | use App\Rules\Ids; | 10 | use App\Rules\Ids; |
| 10 | use Illuminate\Http\Request; | 11 | use Illuminate\Http\Request; |
| 12 | +use Illuminate\Support\Facades\Route; | ||
| 13 | +use Illuminate\Support\Str; | ||
| 11 | 14 | ||
| 12 | /** | 15 | /** |
| 13 | * 后台菜单 | 16 | * 后台菜单 |
| @@ -23,8 +26,22 @@ class MenuController extends BaseController | @@ -23,8 +26,22 @@ class MenuController extends BaseController | ||
| 23 | { | 26 | { |
| 24 | $map = []; | 27 | $map = []; |
| 25 | $sort = ['id' => 'desc']; | 28 | $sort = ['id' => 'desc']; |
| 26 | - $list = $logic->getList($map, $sort, ['*'],0); | ||
| 27 | - return view("admin.menu", ["list" => Arr::listToTree($list)]); | 29 | + $list = $logic->getList($map, $sort, ['id', 'pid', 'title', 'icon', 'type'],0); |
| 30 | + return $this->success(Arr::listToTree($list)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public function routes(Request $request){ | ||
| 34 | + //已绑定菜单的路由 | ||
| 35 | + $menu_route = array_filter(Menu::pluck('route_name')->toArray()); | ||
| 36 | + //路由 | ||
| 37 | + $list = []; | ||
| 38 | + $routes = Route::getRoutes()->getRoutesByName(); | ||
| 39 | + foreach ($routes as $name => $route) { | ||
| 40 | + if(Str::startsWith($name, 'admin.') && !Str::endsWith($name, '.white') && !in_array($name, $menu_route)){ | ||
| 41 | + $list[] = $name; | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + return $this->success($list); | ||
| 28 | } | 45 | } |
| 29 | 46 | ||
| 30 | public function info(Request $request, MenuLogic $logic){ | 47 | public function info(Request $request, MenuLogic $logic){ |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Project; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Aside\BaseController; | ||
| 6 | +use App\Http\Logic\Aside\Project\OptimizeLogic; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * @remark :优化方案设置 | ||
| 10 | + * @name :OptimizeController | ||
| 11 | + * @author :lyh | ||
| 12 | + * @time :2023/6/20 14:33 | ||
| 13 | + */ | ||
| 14 | +class OptimizeController extends BaseController | ||
| 15 | +{ | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * @remark :授权域名 | ||
| 19 | + * @name :empowerDomain | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2023/6/20 15:10 | ||
| 23 | + */ | ||
| 24 | + public function empowerDomain(OptimizeLogic $optimizeLogic){ | ||
| 25 | + $this->request->validate([ | ||
| 26 | + 'id'=>'required', | ||
| 27 | + 'gsc_id'=>'required' | ||
| 28 | + ],[ | ||
| 29 | + 'id.required' => '审核域名ID不能为空', | ||
| 30 | + 'gsc_id.required' => 'GSC账号ID不能为空' | ||
| 31 | + ]); | ||
| 32 | + $optimizeLogic->empowerDomain(); | ||
| 33 | + $this->response('success'); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @remark :优化设置 | ||
| 38 | + * @name :save | ||
| 39 | + * @author :lyh | ||
| 40 | + * @method :post | ||
| 41 | + * @time :2023/6/20 14:33 | ||
| 42 | + */ | ||
| 43 | + public function save(){ | ||
| 44 | + $this->response('success'); | ||
| 45 | + } | ||
| 46 | +} |
| @@ -4,7 +4,9 @@ namespace App\Http\Controllers\Aside\Project; | @@ -4,7 +4,9 @@ namespace App\Http\Controllers\Aside\Project; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | +use App\Http\Logic\Aside\Project\ProcessRecordsLogic; | ||
| 7 | use App\Http\Logic\Aside\Project\ProjectLogic; | 8 | use App\Http\Logic\Aside\Project\ProjectLogic; |
| 9 | +use App\Http\Requests\Aside\Project\ProcessRecordsRequest; | ||
| 8 | use App\Http\Requests\Aside\Project\ProjectRequest; | 10 | use App\Http\Requests\Aside\Project\ProjectRequest; |
| 9 | use App\Models\InquirySet; | 11 | use App\Models\InquirySet; |
| 10 | use App\Rules\Ids; | 12 | use App\Rules\Ids; |
| @@ -24,13 +26,16 @@ class ProjectController extends BaseController | @@ -24,13 +26,16 @@ class ProjectController extends BaseController | ||
| 24 | public function list(ProjectLogic $logic) | 26 | public function list(ProjectLogic $logic) |
| 25 | { | 27 | { |
| 26 | $map = []; | 28 | $map = []; |
| 29 | + if(!empty($this->param['type'])){ | ||
| 30 | + $map[] = ['type', $this->param['type']]; | ||
| 31 | + } | ||
| 27 | if(!empty($this->param['search'])){ | 32 | if(!empty($this->param['search'])){ |
| 28 | - $map[] = ['title', 'like', "%{$this->param['search']}%"]; | 33 | + $map[] = ['title|company', $this->param['search']]; |
| 29 | } | 34 | } |
| 30 | $sort = ['id' => 'desc']; | 35 | $sort = ['id' => 'desc']; |
| 31 | $data = $logic->getList($map, $sort); | 36 | $data = $logic->getList($map, $sort); |
| 32 | 37 | ||
| 33 | - return view("admin.project", ["list" => $data]); | 38 | + return $this->success($data); |
| 34 | } | 39 | } |
| 35 | 40 | ||
| 36 | public function info(Request $request, ProjectLogic $logic){ | 41 | public function info(Request $request, ProjectLogic $logic){ |
| @@ -78,4 +83,45 @@ class ProjectController extends BaseController | @@ -78,4 +83,45 @@ class ProjectController extends BaseController | ||
| 78 | $data = $logic->saveInquirySet($this->param); | 83 | $data = $logic->saveInquirySet($this->param); |
| 79 | return $this->success($data); | 84 | return $this->success($data); |
| 80 | } | 85 | } |
| 86 | + | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 数据源 | ||
| 90 | + * @param ProjectLogic $logic | ||
| 91 | + * @return \Illuminate\Http\JsonResponse | ||
| 92 | + * @throws \Psr\Container\ContainerExceptionInterface | ||
| 93 | + * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 94 | + * @author zbj | ||
| 95 | + * @date 2023/6/20 | ||
| 96 | + */ | ||
| 97 | + public function data_source(ProjectLogic $logic){ | ||
| 98 | + $data = $logic->dataSource(); | ||
| 99 | + return $this->success($data); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * 进程记录 | ||
| 104 | + * @author zbj | ||
| 105 | + * @date 2023/6/25 | ||
| 106 | + */ | ||
| 107 | + public function get_process_records(Request $request, ProcessRecordsLogic $logic){ | ||
| 108 | + $request->validate([ | ||
| 109 | + 'project_id'=>'required' | ||
| 110 | + ],[ | ||
| 111 | + 'project_id.required' => '项目ID不能为空' | ||
| 112 | + ]); | ||
| 113 | + $data = $logic->getInfo($this->param['project_id']); | ||
| 114 | + return $this->success($data); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * 保存进程记录 | ||
| 119 | + * @author zbj | ||
| 120 | + * @date 2023/6/25 | ||
| 121 | + */ | ||
| 122 | + public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic){ | ||
| 123 | + $this->param['operator_id'] = $this->manage['id']; | ||
| 124 | + $data = $logic->save($this->param); | ||
| 125 | + return $this->success($data); | ||
| 126 | + } | ||
| 81 | } | 127 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Project; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Aside\BaseController; | ||
| 7 | +use App\Http\Logic\Aside\Project\GscLogic; | ||
| 8 | +use App\Http\Requests\Aside\User\GscRequest; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @remark :优化gsc账号 | ||
| 12 | + * @name :ProjectGscController | ||
| 13 | + * @author :lyh | ||
| 14 | + * @time :2023/6/19 11:25 | ||
| 15 | + */ | ||
| 16 | +class ProjectGscController extends BaseController | ||
| 17 | +{ | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @remark :gsc账号列表 | ||
| 21 | + * @name :lists | ||
| 22 | + * @author :lyh | ||
| 23 | + * @method :post | ||
| 24 | + * @time :2023/6/19 11:25 | ||
| 25 | + */ | ||
| 26 | + public function lists(GscLogic $gscLogic){ | ||
| 27 | + $lists = $gscLogic->GscLists($this->map,$this->page,$this->row,$this->order); | ||
| 28 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @remark :根据gsc账号获取域名 | ||
| 33 | + * @name :lists | ||
| 34 | + * @author :lyh | ||
| 35 | + * @method :post | ||
| 36 | + * @time :2023/6/19 10:48 | ||
| 37 | + */ | ||
| 38 | + public function domainLists(GscLogic $gscLogic){ | ||
| 39 | + $this->request->validate([ | ||
| 40 | + 'gsc_id'=>'required' | ||
| 41 | + ],[ | ||
| 42 | + 'gsc_id.required' => 'GSC账号ID不能为空' | ||
| 43 | + ]); | ||
| 44 | + $lists = $gscLogic->DomainLists($this->map,$this->page,$this->row,$this->order); | ||
| 45 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * @remark :获取gsc账号详情 | ||
| 50 | + * @name :read | ||
| 51 | + * @author :lyh | ||
| 52 | + * @method :post | ||
| 53 | + * @time :2023/6/19 16:55 | ||
| 54 | + */ | ||
| 55 | + public function read(GscLogic $gscLogic){ | ||
| 56 | + $this->request->validate([ | ||
| 57 | + 'id'=>'required' | ||
| 58 | + ],[ | ||
| 59 | + 'id.required' => 'GSC账号ID不能为空' | ||
| 60 | + ]); | ||
| 61 | + $info = $gscLogic->GscRead(); | ||
| 62 | + $this->response('success',Code::SUCCESS,$info); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * @remark :添加/编辑gsc账号 | ||
| 67 | + * @name :add | ||
| 68 | + * @author :lyh | ||
| 69 | + * @method :post | ||
| 70 | + * @time :2023/6/19 16:28 | ||
| 71 | + */ | ||
| 72 | + public function save(GscRequest $gscRequest,GscLogic $gscLogic){ | ||
| 73 | + if(isset($this->param['id'])){ | ||
| 74 | + $gscRequest->validate([ | ||
| 75 | + 'id'=>'required' | ||
| 76 | + ],[ | ||
| 77 | + 'id.required' => 'GSC账号ID不能为空' | ||
| 78 | + ]); | ||
| 79 | + } | ||
| 80 | + $gscRequest->validated(); | ||
| 81 | + $gscLogic->GscSave(); | ||
| 82 | + $this->response('success'); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * @remark :逻辑删除gsc账号 | ||
| 87 | + * @name :del | ||
| 88 | + * @author :lyh | ||
| 89 | + * @method :post | ||
| 90 | + * @time :2023/6/19 16:30 | ||
| 91 | + */ | ||
| 92 | + public function del(GscLogic $gscLogic){ | ||
| 93 | + $this->request->validate([ | ||
| 94 | + 'id'=>'required' | ||
| 95 | + ],[ | ||
| 96 | + 'id.required' => 'GSC账号ID不能为空' | ||
| 97 | + ]); | ||
| 98 | + $gscLogic->GscDel(); | ||
| 99 | + $this->response('success'); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | +} |
| @@ -5,10 +5,12 @@ namespace App\Http\Controllers\Aside\Task; | @@ -5,10 +5,12 @@ namespace App\Http\Controllers\Aside\Task; | ||
| 5 | use App\Http\Controllers\Aside\BaseController; | 5 | use App\Http\Controllers\Aside\BaseController; |
| 6 | use App\Http\Logic\Aside\Task\TaskFollowLogic; | 6 | use App\Http\Logic\Aside\Task\TaskFollowLogic; |
| 7 | use App\Http\Logic\Aside\Task\TaskLogic; | 7 | use App\Http\Logic\Aside\Task\TaskLogic; |
| 8 | +use App\Http\Logic\Aside\Task\TaskOwnerLogic; | ||
| 8 | use App\Http\Requests\Aside\Task\TaskFollowRequest; | 9 | use App\Http\Requests\Aside\Task\TaskFollowRequest; |
| 9 | use App\Http\Requests\Aside\Task\TaskRequest; | 10 | use App\Http\Requests\Aside\Task\TaskRequest; |
| 10 | use App\Models\Task\Task; | 11 | use App\Models\Task\Task; |
| 11 | -use Illuminate\Support\Facades\Request; | 12 | +use App\Models\Task\TaskOwner; |
| 13 | +use Illuminate\Http\Request; | ||
| 12 | use Illuminate\Validation\Rule; | 14 | use Illuminate\Validation\Rule; |
| 13 | 15 | ||
| 14 | 16 | ||
| @@ -26,12 +28,19 @@ class TaskController extends BaseController | @@ -26,12 +28,19 @@ class TaskController extends BaseController | ||
| 26 | { | 28 | { |
| 27 | $map = []; | 29 | $map = []; |
| 28 | if(!empty($this->param['search'])){ | 30 | if(!empty($this->param['search'])){ |
| 29 | - $map[] = ['title', 'like', "%{$this->param['search']}%"]; | 31 | + $map[] = ['content', 'like', "%{$this->param['search']}%"]; |
| 30 | } | 32 | } |
| 33 | + if(!empty($this->param['created_manage_id'])){ | ||
| 34 | + $map[] = ['created_manage_id', $this->param['created_manage_id']]; | ||
| 35 | + } | ||
| 36 | + if(!empty($this->param['owner_manage_id'])){ | ||
| 37 | + $map[] = ['id', 'in', TaskOwner::where('manage_id', $this->param['owner_manage_id'])->pluck('task_id')]; | ||
| 38 | + } | ||
| 39 | + | ||
| 31 | $sort = ['id' => 'desc']; | 40 | $sort = ['id' => 'desc']; |
| 32 | - $data = $logic->getList($map, $sort); | 41 | + $data = $logic->getList($map, $sort, ['id', 'project_id', 'workload', 'priority', 'content', 'attachment', 'status', 'end_at', 'created_manage_id']); |
| 33 | 42 | ||
| 34 | - return view("admin.task", ["list" => $data]); | 43 | + return $this->success($data); |
| 35 | } | 44 | } |
| 36 | 45 | ||
| 37 | public function info(Request $request, TaskLogic $logic){ | 46 | public function info(Request $request, TaskLogic $logic){ |
| @@ -46,6 +55,7 @@ class TaskController extends BaseController | @@ -46,6 +55,7 @@ class TaskController extends BaseController | ||
| 46 | 55 | ||
| 47 | public function save(TaskRequest $request, TaskLogic $logic) | 56 | public function save(TaskRequest $request, TaskLogic $logic) |
| 48 | { | 57 | { |
| 58 | + $this->param['created_manage_id'] = $this->manage->id; | ||
| 49 | $data = $logic->save($this->param); | 59 | $data = $logic->save($this->param); |
| 50 | return $this->success($data); | 60 | return $this->success($data); |
| 51 | } | 61 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\User; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Aside\BaseController; | ||
| 7 | +use App\Http\Logic\Aside\User\DeptLogic; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @remark :b端用户组织架构 | ||
| 11 | + * @name :ProjectDeptController | ||
| 12 | + * @author :lyh | ||
| 13 | + * @time :2023/6/17 16:23 | ||
| 14 | + */ | ||
| 15 | +class ProjectDeptController extends BaseController | ||
| 16 | +{ | ||
| 17 | + /** | ||
| 18 | + * @name :(组织部门)lists | ||
| 19 | + * @author :lyh | ||
| 20 | + * @method :post | ||
| 21 | + * @time :2023/6/17 16:13 | ||
| 22 | + */ | ||
| 23 | + public function lists(DeptLogic $deptLogic){ | ||
| 24 | + if(isset($this->param['pid'])){ | ||
| 25 | + $this->map['pid'] = $this->param['pid']; | ||
| 26 | + } | ||
| 27 | + if(isset($this->map['title']) && !empty($this->map['title'])){ | ||
| 28 | + $this->map['title'] = ['like','%'.$this->map['title'].'%']; | ||
| 29 | + } | ||
| 30 | + $lists = $deptLogic->DeptLists($this->map,$this->page,$this->row,$this->order); | ||
| 31 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * @name :(部门详情)read | ||
| 36 | + * @author :lyh | ||
| 37 | + * @method :post | ||
| 38 | + * @time :2023/6/17 16:13 | ||
| 39 | + */ | ||
| 40 | + public function read(DeptLogic $deptLogic){ | ||
| 41 | + $this->request->validate([ | ||
| 42 | + 'id'=>'required' | ||
| 43 | + ],[ | ||
| 44 | + 'id.required' => 'ID不能为空' | ||
| 45 | + ]); | ||
| 46 | + $info = $deptLogic->DeptRead(); | ||
| 47 | + $this->response('success',Code::SUCCESS,$info); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | +} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Aside\User; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Http\Controllers\Aside\BaseController; | ||
| 7 | -use App\Http\Logic\Aside\User\ProjectGroupLogic; | ||
| 8 | -use App\Http\Requests\Aside\User\ProjectGroupRequest; | ||
| 9 | -use App\Models\ProjectGroup as ProjectGroupModel; | ||
| 10 | - | ||
| 11 | -class ProjectGroupController extends BaseController | ||
| 12 | -{ | ||
| 13 | - /** | ||
| 14 | - * @name:用户组列表 | ||
| 15 | - */ | ||
| 16 | - public function lists(ProjectGroupModel $projectGroupModel){ | ||
| 17 | - $lists = $projectGroupModel->lists($this->map,$this->page,$this->row,$this->order); | ||
| 18 | - $this->response('success',Code::SUCCESS,$lists); | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * @name :添加用户组 | ||
| 23 | - * @return void | ||
| 24 | - * @author :liyuhang | ||
| 25 | - * @method | ||
| 26 | - */ | ||
| 27 | - public function add(ProjectGroupRequest $request,ProjectGroupLogic $projectGroupLogic){ | ||
| 28 | - $request->validated(); | ||
| 29 | - $projectGroupLogic->group_add(); | ||
| 30 | - $this->response('success'); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * @name :编辑用户组 | ||
| 35 | - * @return void | ||
| 36 | - * @author :liyuhang | ||
| 37 | - * @method | ||
| 38 | - */ | ||
| 39 | - public function edit(ProjectGroupRequest $request,ProjectGroupLogic $projectGroupLogic){ | ||
| 40 | - $request->validate([ | ||
| 41 | - 'id'=>'required' | ||
| 42 | - ],[ | ||
| 43 | - 'id.required' => 'ID不能为空' | ||
| 44 | - ]); | ||
| 45 | - $projectGroupLogic->group_edit(); | ||
| 46 | - $this->response('success'); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - /** | ||
| 50 | - * @name :用户组详情 | ||
| 51 | - * @return void | ||
| 52 | - * @author :liyuhang | ||
| 53 | - * @method | ||
| 54 | - */ | ||
| 55 | - public function info(ProjectGroupLogic $projectGroupLogic){ | ||
| 56 | - $this->request->validate([ | ||
| 57 | - 'id'=>'required' | ||
| 58 | - ],[ | ||
| 59 | - 'id.required' => 'ID不能为空' | ||
| 60 | - ]); | ||
| 61 | - $projectGroupLogic->group_info(); | ||
| 62 | - $this->success('success'); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - /** | ||
| 66 | - * @name :删除用户组 | ||
| 67 | - * @return void | ||
| 68 | - * @author :liyuhang | ||
| 69 | - * @method | ||
| 70 | - */ | ||
| 71 | - public function del(ProjectGroupLogic $projectGroupLogic){ | ||
| 72 | - $this->request->validate([ | ||
| 73 | - 'id'=>'required' | ||
| 74 | - ],[ | ||
| 75 | - 'id.required' => 'ID不能为空' | ||
| 76 | - ]); | ||
| 77 | - $projectGroupLogic->group_del(); | ||
| 78 | - $this->success('success'); | ||
| 79 | - } | ||
| 80 | -} |
| @@ -10,25 +10,54 @@ use App\Models\User\ProjectMenu; | @@ -10,25 +10,54 @@ use App\Models\User\ProjectMenu; | ||
| 10 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 10 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 11 | use Illuminate\Http\Request; | 11 | use Illuminate\Http\Request; |
| 12 | 12 | ||
| 13 | +/** | ||
| 14 | + * @remark :b端菜单管理 | ||
| 15 | + * @name :ProjectMenuController | ||
| 16 | + * @author :lyh | ||
| 17 | + * @time :2023/6/17 16:23 | ||
| 18 | + */ | ||
| 13 | class ProjectMenuController extends BaseController | 19 | class ProjectMenuController extends BaseController |
| 14 | { | 20 | { |
| 21 | + | ||
| 15 | /** | 22 | /** |
| 16 | - * @name :用户菜单列表 | ||
| 17 | - * @return json | ||
| 18 | - * @author :liyuhang | ||
| 19 | - * @method | 23 | + * @remark :用户菜单列表 |
| 24 | + * @name :lists | ||
| 25 | + * @author :lyh | ||
| 26 | + * @method :post | ||
| 27 | + * @time :2023/6/21 17:24 | ||
| 20 | */ | 28 | */ |
| 21 | public function lists(){ | 29 | public function lists(){ |
| 22 | $menuModel = new ProjectMenuModel(); | 30 | $menuModel = new ProjectMenuModel(); |
| 31 | + if(isset($this->param['pid'])){ | ||
| 32 | + $this->map['pid'] = $this->param['pid']; | ||
| 33 | + } | ||
| 34 | + //是否为权限菜单 | ||
| 35 | + if(isset($this->param['is_role'])){ | ||
| 36 | + $this->map['is_role'] = $this->param['is_role']; | ||
| 37 | + } | ||
| 23 | $lists = $menuModel->lists($this->map,$this->page,$this->row,$this->order,['*']); | 38 | $lists = $menuModel->lists($this->map,$this->page,$this->row,$this->order,['*']); |
| 24 | $this->response('success',Code::SUCCESS,$lists); | 39 | $this->response('success',Code::SUCCESS,$lists); |
| 25 | } | 40 | } |
| 26 | 41 | ||
| 27 | /** | 42 | /** |
| 28 | - * @name :详情 | ||
| 29 | - * @return void | ||
| 30 | - * @author :liyuhang | ||
| 31 | - * @method | 43 | + * @remark :添加菜单时获取菜单列表 |
| 44 | + * @name :list | ||
| 45 | + * @author :lyh | ||
| 46 | + * @method :post | ||
| 47 | + * @time :2023/6/21 17:24 | ||
| 48 | + */ | ||
| 49 | + public function list(ProjectMenuLogic $projectMenuLogic){ | ||
| 50 | + $lists = $projectMenuLogic->MenuList(); | ||
| 51 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * @param ProjectMenuLogic $projectMenuLogic | ||
| 56 | + * @remark :详情 | ||
| 57 | + * @name :info | ||
| 58 | + * @author :lyh | ||
| 59 | + * @method :post | ||
| 60 | + * @time :2023/6/21 17:23 | ||
| 32 | */ | 61 | */ |
| 33 | public function info(ProjectMenuLogic $projectMenuLogic){ | 62 | public function info(ProjectMenuLogic $projectMenuLogic){ |
| 34 | $this->request->validate([ | 63 | $this->request->validate([ |
| @@ -41,10 +70,13 @@ class ProjectMenuController extends BaseController | @@ -41,10 +70,13 @@ class ProjectMenuController extends BaseController | ||
| 41 | } | 70 | } |
| 42 | 71 | ||
| 43 | /** | 72 | /** |
| 44 | - * @name :添加菜单 | ||
| 45 | - * @return void | ||
| 46 | - * @author :liyuhang | ||
| 47 | - * @method | 73 | + * @param ProjectRoleRequest $request |
| 74 | + * @param ProjectMenuLogic $projectMenuLogic | ||
| 75 | + * @remark :添加菜单 | ||
| 76 | + * @name :add | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2023/6/21 17:23 | ||
| 48 | */ | 80 | */ |
| 49 | public function add(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){ | 81 | public function add(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){ |
| 50 | $request->validated(); | 82 | $request->validated(); |
| @@ -53,10 +85,13 @@ class ProjectMenuController extends BaseController | @@ -53,10 +85,13 @@ class ProjectMenuController extends BaseController | ||
| 53 | } | 85 | } |
| 54 | 86 | ||
| 55 | /** | 87 | /** |
| 56 | - * @name :编辑菜单 | ||
| 57 | - * @return void | ||
| 58 | - * @author :liyuhang | ||
| 59 | - * @method | 88 | + * @param ProjectRoleRequest $request |
| 89 | + * @param ProjectMenuLogic $projectMenuLogic | ||
| 90 | + * @remark :编辑菜单 | ||
| 91 | + * @name :edit | ||
| 92 | + * @author :lyh | ||
| 93 | + * @method :post | ||
| 94 | + * @time :2023/6/21 17:22 | ||
| 60 | */ | 95 | */ |
| 61 | public function edit(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){ | 96 | public function edit(ProjectRoleRequest $request,ProjectMenuLogic $projectMenuLogic){ |
| 62 | $request->validate([ | 97 | $request->validate([ |
| @@ -69,10 +104,12 @@ class ProjectMenuController extends BaseController | @@ -69,10 +104,12 @@ class ProjectMenuController extends BaseController | ||
| 69 | } | 104 | } |
| 70 | 105 | ||
| 71 | /** | 106 | /** |
| 72 | - * @name :删除菜单 | ||
| 73 | - * @return void | ||
| 74 | - * @author :liyuhang | ||
| 75 | - * @method | 107 | + * @param ProjectMenuLogic $projectMenuLogic |
| 108 | + * @remark :删除菜单 | ||
| 109 | + * @name :del | ||
| 110 | + * @author :lyh | ||
| 111 | + * @method :post | ||
| 112 | + * @time :2023/6/21 17:22 | ||
| 76 | */ | 113 | */ |
| 77 | public function del(ProjectMenuLogic $projectMenuLogic){ | 114 | public function del(ProjectMenuLogic $projectMenuLogic){ |
| 78 | $this->request->validate([ | 115 | $this->request->validate([ |
| @@ -9,6 +9,12 @@ use App\Http\Requests\Aside\User\ProjectRoleRequest; | @@ -9,6 +9,12 @@ use App\Http\Requests\Aside\User\ProjectRoleRequest; | ||
| 9 | use App\Models\User\ProjectRole as ProjectRoleModel; | 9 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 10 | use Illuminate\Http\Request; | 10 | use Illuminate\Http\Request; |
| 11 | 11 | ||
| 12 | +/** | ||
| 13 | + * @remark :b端用户角色设置管理 | ||
| 14 | + * @name :ProjectRoleController | ||
| 15 | + * @author :lyh | ||
| 16 | + * @time :2023/6/17 16:22 | ||
| 17 | + */ | ||
| 12 | class ProjectRoleController extends BaseController | 18 | class ProjectRoleController extends BaseController |
| 13 | { | 19 | { |
| 14 | /** | 20 | /** |
| @@ -9,13 +9,21 @@ use App\Http\Requests\Aside\User\UserRequest; | @@ -9,13 +9,21 @@ use App\Http\Requests\Aside\User\UserRequest; | ||
| 9 | use App\Models\User\User as UserModel; | 9 | use App\Models\User\User as UserModel; |
| 10 | use Illuminate\Http\Request; | 10 | use Illuminate\Http\Request; |
| 11 | 11 | ||
| 12 | +/** | ||
| 13 | + * @remark :b端用户管理 | ||
| 14 | + * @name :ProjectUserController | ||
| 15 | + * @author :lyh | ||
| 16 | + * @time :2023/6/17 16:24 | ||
| 17 | + */ | ||
| 12 | class ProjectUserController extends BaseController | 18 | class ProjectUserController extends BaseController |
| 13 | { | 19 | { |
| 20 | + | ||
| 14 | /** | 21 | /** |
| 15 | - * @name :用户列表 | ||
| 16 | - * @return void | ||
| 17 | - * @author :liyuhang | ||
| 18 | - * @method | 22 | + * @remark :用户列表 |
| 23 | + * @name :lists | ||
| 24 | + * @author :lyh | ||
| 25 | + * @method :post | ||
| 26 | + * @time :2023/6/25 9:27 | ||
| 19 | */ | 27 | */ |
| 20 | public function lists(){ | 28 | public function lists(){ |
| 21 | $userModel = new UserModel(); | 29 | $userModel = new UserModel(); |
| @@ -25,10 +33,12 @@ class ProjectUserController extends BaseController | @@ -25,10 +33,12 @@ class ProjectUserController extends BaseController | ||
| 25 | } | 33 | } |
| 26 | 34 | ||
| 27 | /** | 35 | /** |
| 28 | - * @name :详情 | ||
| 29 | - * @return void | ||
| 30 | - * @author :liyuhang | ||
| 31 | - * @method | 36 | + * @param UserLogic $userLogic |
| 37 | + * @remark :用户详情 | ||
| 38 | + * @name :info | ||
| 39 | + * @author :lyh | ||
| 40 | + * @method :post | ||
| 41 | + * @time :2023/6/25 9:27 | ||
| 32 | */ | 42 | */ |
| 33 | public function info(UserLogic $userLogic){ | 43 | public function info(UserLogic $userLogic){ |
| 34 | $this->request->validate([ | 44 | $this->request->validate([ |
| @@ -36,14 +46,18 @@ class ProjectUserController extends BaseController | @@ -36,14 +46,18 @@ class ProjectUserController extends BaseController | ||
| 36 | ],[ | 46 | ],[ |
| 37 | 'id.required' => 'ID不能为空' | 47 | 'id.required' => 'ID不能为空' |
| 38 | ]); | 48 | ]); |
| 39 | - $userLogic->user_info(); | ||
| 40 | - $this->response('success'); | 49 | + $info = $userLogic->user_info(); |
| 50 | + $this->response('success',Code::SUCCESS,$info); | ||
| 41 | } | 51 | } |
| 52 | + | ||
| 42 | /** | 53 | /** |
| 43 | - * @name :添加用户 | ||
| 44 | - * @return void | ||
| 45 | - * @author :liyuhang | ||
| 46 | - * @method | 54 | + * @param UserRequest $request |
| 55 | + * @param UserLogic $userLogic | ||
| 56 | + * @remark :添加用户 | ||
| 57 | + * @name :add | ||
| 58 | + * @author :lyh | ||
| 59 | + * @method :post | ||
| 60 | + * @time :2023/6/25 9:27 | ||
| 47 | */ | 61 | */ |
| 48 | public function add(UserRequest $request,UserLogic $userLogic){ | 62 | public function add(UserRequest $request,UserLogic $userLogic){ |
| 49 | $request->validated(); | 63 | $request->validated(); |
| @@ -52,10 +66,13 @@ class ProjectUserController extends BaseController | @@ -52,10 +66,13 @@ class ProjectUserController extends BaseController | ||
| 52 | } | 66 | } |
| 53 | 67 | ||
| 54 | /** | 68 | /** |
| 55 | - * @name : 编辑 | ||
| 56 | - * @return void | ||
| 57 | - * @author :liyuhang | ||
| 58 | - * @method | 69 | + * @param UserRequest $request |
| 70 | + * @param UserLogic $userLogic | ||
| 71 | + * @remark :编辑用户 | ||
| 72 | + * @name :edit | ||
| 73 | + * @author :lyh | ||
| 74 | + * @method :post | ||
| 75 | + * @time :2023/6/25 9:28 | ||
| 59 | */ | 76 | */ |
| 60 | public function edit(UserRequest $request,UserLogic $userLogic){ | 77 | public function edit(UserRequest $request,UserLogic $userLogic){ |
| 61 | $request->validate([ | 78 | $request->validate([ |
| @@ -68,10 +85,12 @@ class ProjectUserController extends BaseController | @@ -68,10 +85,12 @@ class ProjectUserController extends BaseController | ||
| 68 | } | 85 | } |
| 69 | 86 | ||
| 70 | /** | 87 | /** |
| 71 | - * @name :批量删除 | ||
| 72 | - * @return void | ||
| 73 | - * @author :liyuhang | ||
| 74 | - * @method | 88 | + * @param UserLogic $userLogic |
| 89 | + * @remark :编辑用户 | ||
| 90 | + * @name :del | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2023/6/25 9:28 | ||
| 75 | */ | 94 | */ |
| 76 | public function del(UserLogic $userLogic){ | 95 | public function del(UserLogic $userLogic){ |
| 77 | $this->request->validate([ | 96 | $this->request->validate([ |
| @@ -14,7 +14,6 @@ class AiCommandController extends BaseController | @@ -14,7 +14,6 @@ class AiCommandController extends BaseController | ||
| 14 | public $chat_url = 'v2/openai_chat'; | 14 | public $chat_url = 'v2/openai_chat'; |
| 15 | /** | 15 | /** |
| 16 | * @name :ai生成 | 16 | * @name :ai生成 |
| 17 | - * @return void | ||
| 18 | * @author :liyuhang | 17 | * @author :liyuhang |
| 19 | * @method | 18 | * @method |
| 20 | */ | 19 | */ |
| @@ -38,8 +37,7 @@ class AiCommandController extends BaseController | @@ -38,8 +37,7 @@ class AiCommandController extends BaseController | ||
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | /** | 39 | /** |
| 41 | - * @name :写入日志 | ||
| 42 | - * @return void | 40 | + * @name :写入日志 |
| 43 | * @author :liyuhang | 41 | * @author :liyuhang |
| 44 | * @method | 42 | * @method |
| 45 | */ | 43 | */ |
| @@ -15,7 +15,7 @@ use App\Models\AyrShare\AyrShare as AyrShareModel; | @@ -15,7 +15,7 @@ use App\Models\AyrShare\AyrShare as AyrShareModel; | ||
| 15 | class AyrShareController extends BaseController | 15 | class AyrShareController extends BaseController |
| 16 | { | 16 | { |
| 17 | //生成名称前缀 | 17 | //生成名称前缀 |
| 18 | - const TITLE = 'global_so_'; | 18 | + const TITLE = 'globalso'; |
| 19 | /** | 19 | /** |
| 20 | * @name :(社交列表)lists | 20 | * @name :(社交列表)lists |
| 21 | * @author :lyh | 21 | * @author :lyh |
| @@ -24,7 +24,7 @@ class AyrShareController extends BaseController | @@ -24,7 +24,7 @@ class AyrShareController extends BaseController | ||
| 24 | */ | 24 | */ |
| 25 | public function lists(AyrShareModel $ayrShareModel,AyrShareLogic $ayrShareLogic){ | 25 | public function lists(AyrShareModel $ayrShareModel,AyrShareLogic $ayrShareLogic){ |
| 26 | //授权配置列表 | 26 | //授权配置列表 |
| 27 | - $share_list = $ayrShareModel->platforms; | 27 | + $share_list = $ayrShareModel->iconImage(); |
| 28 | $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['id','name','title','profile_key','bind_platforms','operator_id','created_at','updated_at']); | 28 | $lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['id','name','title','profile_key','bind_platforms','operator_id','created_at','updated_at']); |
| 29 | foreach ($lists['list'] as $k => $v){ | 29 | foreach ($lists['list'] as $k => $v){ |
| 30 | if(!empty($v['profile_key'])){ | 30 | if(!empty($v['profile_key'])){ |
| @@ -68,8 +68,11 @@ class AyrShareController extends BaseController | @@ -68,8 +68,11 @@ class AyrShareController extends BaseController | ||
| 68 | $res = false; | 68 | $res = false; |
| 69 | } | 69 | } |
| 70 | }else{ | 70 | }else{ |
| 71 | - $ayrShareLogic->ayr_share_edit(['bind_platforms'=>''],$this->param['id']); | ||
| 72 | - $res = true; | 71 | + if(!empty($info['bind_platforms'])){ |
| 72 | + $ayrShareLogic->ayr_share_edit(['bind_platforms'=>''],$this->param['id']); | ||
| 73 | + return true; | ||
| 74 | + } | ||
| 75 | + $res = false; | ||
| 73 | } | 76 | } |
| 74 | $this->response('success',Code::SUCCESS,['is_true'=>$res]); | 77 | $this->response('success',Code::SUCCESS,['is_true'=>$res]); |
| 75 | } | 78 | } |
| @@ -81,8 +84,10 @@ class AyrShareController extends BaseController | @@ -81,8 +84,10 @@ class AyrShareController extends BaseController | ||
| 81 | */ | 84 | */ |
| 82 | public function create_account(AyrShareRequest $ayrShareRequest,AyrShareLogic $ayrShareLogic){ | 85 | public function create_account(AyrShareRequest $ayrShareRequest,AyrShareLogic $ayrShareLogic){ |
| 83 | $ayrShareRequest->validated(); | 86 | $ayrShareRequest->validated(); |
| 87 | + //验证参数及 | ||
| 88 | + $ayrShareLogic->AyrVerify(); | ||
| 84 | $param = [ | 89 | $param = [ |
| 85 | - 'title'=>self::TITLE.$this->user['project_id'].':'.$this->param['name'], | 90 | + 'title'=>self::TITLE . ':' . $this->user['project_id'] . '-' . $this->param['name'], |
| 86 | ]; | 91 | ]; |
| 87 | //发送请求注册社交用户 | 92 | //发送请求注册社交用户 |
| 88 | $ayrShareHelper = new AyrShareHelper(); | 93 | $ayrShareHelper = new AyrShareHelper(); |
| @@ -91,7 +96,7 @@ class AyrShareController extends BaseController | @@ -91,7 +96,7 @@ class AyrShareController extends BaseController | ||
| 91 | $this->response('同步绑定失败'); | 96 | $this->response('同步绑定失败'); |
| 92 | } | 97 | } |
| 93 | //执行数据库操作 | 98 | //执行数据库操作 |
| 94 | - $ayrShareLogic->ayr_share_add($res); | 99 | + $ayrShareLogic->ayr_share_save($res); |
| 95 | $this->response('success'); | 100 | $this->response('success'); |
| 96 | } | 101 | } |
| 97 | 102 | ||
| @@ -108,15 +113,17 @@ class AyrShareController extends BaseController | @@ -108,15 +113,17 @@ class AyrShareController extends BaseController | ||
| 108 | 'id.required' => 'ID不能为空' | 113 | 'id.required' => 'ID不能为空' |
| 109 | ]); | 114 | ]); |
| 110 | $info = $ayrShareLogic->ayr_share_info(); | 115 | $info = $ayrShareLogic->ayr_share_info(); |
| 111 | - $data = [ | 116 | + if(!empty($info['title'])){ |
| 117 | + $data = [ | ||
| 112 | // 'title'=>$info['title'], | 118 | // 'title'=>$info['title'], |
| 113 | - 'profileKey'=>$info['profile_key'] | ||
| 114 | - ]; | ||
| 115 | - //发送请求删除社交用户 | ||
| 116 | - $ayrShareHelper = new AyrShareHelper(); | ||
| 117 | - $res = $ayrShareHelper->deleted_profiles($data); | ||
| 118 | - if($res['status'] == 'fail'){ | ||
| 119 | - $this->response('同步删除失败'); | 119 | + 'profileKey'=>$info['profile_key'] |
| 120 | + ]; | ||
| 121 | + //发送请求删除社交用户 | ||
| 122 | + $ayrShareHelper = new AyrShareHelper(); | ||
| 123 | + $res = $ayrShareHelper->deleted_profiles($data); | ||
| 124 | + if($res['status'] == 'fail'){ | ||
| 125 | + $this->response('同步删除失败'); | ||
| 126 | + } | ||
| 120 | } | 127 | } |
| 121 | $ayrShareLogic->ayr_share_del(); | 128 | $ayrShareLogic->ayr_share_del(); |
| 122 | $this->response('success'); | 129 | $this->response('success'); |
| @@ -5,14 +5,13 @@ namespace App\Http\Controllers\Bside; | @@ -5,14 +5,13 @@ namespace App\Http\Controllers\Bside; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Helper\Common; | 6 | use App\Helper\Common; |
| 7 | use App\Http\Controllers\Controller; | 7 | use App\Http\Controllers\Controller; |
| 8 | -use App\Http\Requests\Bside\Nav\NavRequest; | 8 | +use App\Http\Logic\Aside\Project\ProjectLogic; |
| 9 | use App\Http\Requests\Scene; | 9 | use App\Http\Requests\Scene; |
| 10 | use App\Models\User\User as UserModel; | 10 | use App\Models\User\User as UserModel; |
| 11 | use Illuminate\Http\JsonResponse; | 11 | use Illuminate\Http\JsonResponse; |
| 12 | use Illuminate\Http\Request; | 12 | use Illuminate\Http\Request; |
| 13 | use Illuminate\Http\Exceptions\HttpResponseException; | 13 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 14 | use Illuminate\Support\Facades\Cache; | 14 | use Illuminate\Support\Facades\Cache; |
| 15 | -use Illuminate\Support\Facades\Validator; | ||
| 16 | 15 | ||
| 17 | class BaseController extends Controller | 16 | class BaseController extends Controller |
| 18 | { | 17 | { |
| @@ -22,7 +21,7 @@ class BaseController extends Controller | @@ -22,7 +21,7 @@ class BaseController extends Controller | ||
| 22 | protected $page = 1;//当前页 | 21 | protected $page = 1;//当前页 |
| 23 | protected $row = 20;//每页条数 | 22 | protected $row = 20;//每页条数 |
| 24 | protected $header = [];//设置请求头参数 | 23 | protected $header = [];//设置请求头参数 |
| 25 | - protected $order = 'id'; | 24 | + protected $order = 'created_at'; |
| 26 | protected $map = [];//处理后的参数 | 25 | protected $map = [];//处理后的参数 |
| 27 | protected $uid = 0; | 26 | protected $uid = 0; |
| 28 | protected $user = [];//当前登录用户详情 | 27 | protected $user = [];//当前登录用户详情 |
| @@ -45,8 +44,7 @@ class BaseController extends Controller | @@ -45,8 +44,7 @@ class BaseController extends Controller | ||
| 45 | } | 44 | } |
| 46 | } | 45 | } |
| 47 | /** | 46 | /** |
| 48 | - * @name 参数过滤 | ||
| 49 | - * @return void | 47 | + * @name :参数过滤 |
| 50 | * @author :liyuhang | 48 | * @author :liyuhang |
| 51 | * @method | 49 | * @method |
| 52 | */ | 50 | */ |
| @@ -89,13 +87,12 @@ class BaseController extends Controller | @@ -89,13 +87,12 @@ class BaseController extends Controller | ||
| 89 | } | 87 | } |
| 90 | break; | 88 | break; |
| 91 | default: | 89 | default: |
| 92 | - if(!empty($v)){ | ||
| 93 | - $this->map[$k] = $v; | ||
| 94 | - } | 90 | + $this->map[$k] = $v; |
| 95 | break; | 91 | break; |
| 96 | } | 92 | } |
| 97 | } | 93 | } |
| 98 | } | 94 | } |
| 95 | + | ||
| 99 | /** | 96 | /** |
| 100 | * @name :统一返回参数 | 97 | * @name :统一返回参数 |
| 101 | * @return JsonResponse | 98 | * @return JsonResponse |
| @@ -172,8 +169,8 @@ class BaseController extends Controller | @@ -172,8 +169,8 @@ class BaseController extends Controller | ||
| 172 | break; | 169 | break; |
| 173 | case 'operator_id': | 170 | case 'operator_id': |
| 174 | if(!empty($v)){ | 171 | if(!empty($v)){ |
| 175 | - $name = (new UserModel())->read(['operator_id'=>$v],['id','name']); | ||
| 176 | - $data['operator_name'] = (isset($name['name']) && !empty($name['name'])) ? $name['name'] : '无名称'; | 172 | + $name = (new UserModel())->read(['id'=>$v],['id','name']); |
| 173 | + $data['operator_name'] = (isset($name['name']) && !empty($name['name'])) ? $name['name'] : '管理员'; | ||
| 177 | } | 174 | } |
| 178 | break; | 175 | break; |
| 179 | } | 176 | } |
| @@ -209,5 +206,30 @@ class BaseController extends Controller | @@ -209,5 +206,30 @@ class BaseController extends Controller | ||
| 209 | return \Illuminate\Support\Facades\Request::isMethod('post'); | 206 | return \Illuminate\Support\Facades\Request::isMethod('post'); |
| 210 | } | 207 | } |
| 211 | 208 | ||
| 209 | + /** | ||
| 210 | + * @name :(获取当前登录用户域名并通知更新)projectUrl | ||
| 211 | + * @author :lyh | ||
| 212 | + * @method :post | ||
| 213 | + * @time :2023/6/6 14:09 | ||
| 214 | + */ | ||
| 215 | + public function projectUrlNotify($str = ''){ | ||
| 216 | + $urlStr = 'api/updateHtmlNotify?model='.$str; | ||
| 217 | + $domain = $this->getProjectDomain(); | ||
| 218 | + if(!empty($domain)){ | ||
| 219 | + $url = $domain.$urlStr; | ||
| 220 | + return http_get($url); | ||
| 221 | + } | ||
| 222 | + return false; | ||
| 223 | + } | ||
| 212 | 224 | ||
| 225 | + public function getProjectDomain(){ | ||
| 226 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 227 | + if(!empty($project['deploy_optimize']['domain'])){ | ||
| 228 | + return $project['deploy_optimize']['domain']; | ||
| 229 | + } | ||
| 230 | + if(!empty($project['deploy_build']['test_domain'])){ | ||
| 231 | + return $project['deploy_build']['test_domain']; | ||
| 232 | + } | ||
| 233 | + return ''; | ||
| 234 | + } | ||
| 213 | } | 235 | } |
| @@ -8,12 +8,12 @@ use App\Http\Logic\Bside\Blog\BlogCategoryLogic; | @@ -8,12 +8,12 @@ use App\Http\Logic\Bside\Blog\BlogCategoryLogic; | ||
| 8 | use App\Http\Requests\Bside\Blog\BlogCategoryRequest; | 8 | use App\Http\Requests\Bside\Blog\BlogCategoryRequest; |
| 9 | use App\Models\Blog\Blog as BlogModel; | 9 | use App\Models\Blog\Blog as BlogModel; |
| 10 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 10 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 11 | +use App\Models\RouteMap; | ||
| 11 | 12 | ||
| 12 | class BlogCategoryController extends BaseController | 13 | class BlogCategoryController extends BaseController |
| 13 | { | 14 | { |
| 14 | /** | 15 | /** |
| 15 | * @name :博客分类列表 | 16 | * @name :博客分类列表 |
| 16 | - * @return json | ||
| 17 | * @author :liyuhang | 17 | * @author :liyuhang |
| 18 | * @method | 18 | * @method |
| 19 | */ | 19 | */ |
| @@ -26,6 +26,9 @@ class BlogCategoryController extends BaseController | @@ -26,6 +26,9 @@ class BlogCategoryController extends BaseController | ||
| 26 | $blogModel = new BlogModel(); | 26 | $blogModel = new BlogModel(); |
| 27 | foreach ($lists['list'] as $k => $v){ | 27 | foreach ($lists['list'] as $k => $v){ |
| 28 | $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); | 28 | $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); |
| 29 | + $v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $v['id'], $this->user['project_id']); | ||
| 30 | + $v['url'] = $this->getProjectDomain() . RouteMap::PATH_BLOG_CATE . '/' . $v['alias']; | ||
| 31 | + $v['hasChildren'] = (($blogCategoryModel->read(['pid'=>$v['id']])) != false) ? true : false; | ||
| 29 | $lists['list'][$k] = $v; | 32 | $lists['list'][$k] = $v; |
| 30 | } | 33 | } |
| 31 | } | 34 | } |
| @@ -33,8 +36,18 @@ class BlogCategoryController extends BaseController | @@ -33,8 +36,18 @@ class BlogCategoryController extends BaseController | ||
| 33 | } | 36 | } |
| 34 | 37 | ||
| 35 | /** | 38 | /** |
| 39 | + * @name :(添加/编辑时获取顶级分类)topList | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2023/6/13 9:03 | ||
| 43 | + */ | ||
| 44 | + public function categoryTopList(BlogCategoryLogic $blogCategoryLogic){ | ||
| 45 | + $list = $blogCategoryLogic->categoryTopList(); | ||
| 46 | + $this->response('success',Code::SUCCESS,$list); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 36 | * @name :获取当前分类详情 | 50 | * @name :获取当前分类详情 |
| 37 | - * @return void | ||
| 38 | * @author :liyuhang | 51 | * @author :liyuhang |
| 39 | * @method | 52 | * @method |
| 40 | */ | 53 | */ |
| @@ -45,11 +58,12 @@ class BlogCategoryController extends BaseController | @@ -45,11 +58,12 @@ class BlogCategoryController extends BaseController | ||
| 45 | 'id.required' => 'ID不能为空' | 58 | 'id.required' => 'ID不能为空' |
| 46 | ]); | 59 | ]); |
| 47 | $info = $blogCategoryLogic->info_blog_category(); | 60 | $info = $blogCategoryLogic->info_blog_category(); |
| 61 | + $info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $info['id'], $this->user['project_id']); | ||
| 62 | + $info['url'] = $this->getProjectDomain() . RouteMap::PATH_BLOG_CATE . '/' . $info['alias']; | ||
| 48 | $this->response('success',Code::SUCCESS,$info); | 63 | $this->response('success',Code::SUCCESS,$info); |
| 49 | } | 64 | } |
| 50 | /** | 65 | /** |
| 51 | * @name :添加分类 | 66 | * @name :添加分类 |
| 52 | - * @return json | ||
| 53 | * @author :liyuhang | 67 | * @author :liyuhang |
| 54 | * @method | 68 | * @method |
| 55 | */ | 69 | */ |
| @@ -62,7 +76,6 @@ class BlogCategoryController extends BaseController | @@ -62,7 +76,6 @@ class BlogCategoryController extends BaseController | ||
| 62 | 76 | ||
| 63 | /** | 77 | /** |
| 64 | * @name :编辑分类 | 78 | * @name :编辑分类 |
| 65 | - * @return void | ||
| 66 | * @author :liyuhang | 79 | * @author :liyuhang |
| 67 | * @method | 80 | * @method |
| 68 | */ | 81 | */ |
| @@ -79,7 +92,6 @@ class BlogCategoryController extends BaseController | @@ -79,7 +92,6 @@ class BlogCategoryController extends BaseController | ||
| 79 | 92 | ||
| 80 | /** | 93 | /** |
| 81 | * @name :编辑状态/与排序 | 94 | * @name :编辑状态/与排序 |
| 82 | - * @return void | ||
| 83 | * @author :liyuhang | 95 | * @author :liyuhang |
| 84 | * @method | 96 | * @method |
| 85 | */ | 97 | */ |
| @@ -95,7 +107,6 @@ class BlogCategoryController extends BaseController | @@ -95,7 +107,6 @@ class BlogCategoryController extends BaseController | ||
| 95 | 107 | ||
| 96 | /** | 108 | /** |
| 97 | * @name :删除分类 | 109 | * @name :删除分类 |
| 98 | - * @return void | ||
| 99 | * @author :liyuhang | 110 | * @author :liyuhang |
| 100 | * @method | 111 | * @method |
| 101 | */ | 112 | */ |
| @@ -9,12 +9,14 @@ use App\Http\Logic\Bside\Blog\BlogLabelLogic; | @@ -9,12 +9,14 @@ use App\Http\Logic\Bside\Blog\BlogLabelLogic; | ||
| 9 | use App\Http\Logic\Bside\Blog\BlogLogic; | 9 | use App\Http\Logic\Bside\Blog\BlogLogic; |
| 10 | use App\Http\Requests\Bside\Blog\BlogRequest; | 10 | use App\Http\Requests\Bside\Blog\BlogRequest; |
| 11 | use App\Models\Blog\Blog as BlogModel; | 11 | use App\Models\Blog\Blog as BlogModel; |
| 12 | +use App\Models\RouteMap; | ||
| 12 | 13 | ||
| 13 | class BlogController extends BaseController | 14 | class BlogController extends BaseController |
| 14 | { | 15 | { |
| 16 | + //通知别名 | ||
| 17 | + public $updateModelView = 'blog'; | ||
| 15 | /** | 18 | /** |
| 16 | * @name :博客列表 | 19 | * @name :博客列表 |
| 17 | - * @return json | ||
| 18 | * @author :liyuhang | 20 | * @author :liyuhang |
| 19 | * @method | 21 | * @method |
| 20 | */ | 22 | */ |
| @@ -29,15 +31,27 @@ class BlogController extends BaseController | @@ -29,15 +31,27 @@ class BlogController extends BaseController | ||
| 29 | $v = $blogCategoryLogic->get_category_name($v); | 31 | $v = $blogCategoryLogic->get_category_name($v); |
| 30 | //获取标签名称 | 32 | //获取标签名称 |
| 31 | $v = $blogLabelLogic->get_label_name($v); | 33 | $v = $blogLabelLogic->get_label_name($v); |
| 34 | + $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']); | ||
| 35 | + $v['url'] = $this->getProjectDomain() . $v['route']; | ||
| 32 | $lists['list'][$k] = $v; | 36 | $lists['list'][$k] = $v; |
| 33 | } | 37 | } |
| 34 | } | 38 | } |
| 35 | $this->response('success',Code::SUCCESS,$lists); | 39 | $this->response('success',Code::SUCCESS,$lists); |
| 36 | } | 40 | } |
| 41 | + /** | ||
| 42 | + * @remark :根据状态数量 | ||
| 43 | + * @name :getStatusNumber | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2023/6/19 9:39 | ||
| 47 | + */ | ||
| 48 | + public function getStatusNumber(BlogLogic $blogLogic){ | ||
| 49 | + $data = $blogLogic->getStatusNumber(); | ||
| 50 | + $this->response('success',Code::SUCCESS,$data); | ||
| 51 | + } | ||
| 37 | 52 | ||
| 38 | /** | 53 | /** |
| 39 | * @name :获取分页列表 | 54 | * @name :获取分页列表 |
| 40 | - * @return void | ||
| 41 | * @throws \App\Exceptions\BsideGlobalException | 55 | * @throws \App\Exceptions\BsideGlobalException |
| 42 | * @author :liyuhang | 56 | * @author :liyuhang |
| 43 | * @method | 57 | * @method |
| @@ -48,7 +62,6 @@ class BlogController extends BaseController | @@ -48,7 +62,6 @@ class BlogController extends BaseController | ||
| 48 | } | 62 | } |
| 49 | /** | 63 | /** |
| 50 | * @name :获取当前博客详情 | 64 | * @name :获取当前博客详情 |
| 51 | - * @return json | ||
| 52 | * @author :liyuhang | 65 | * @author :liyuhang |
| 53 | * @method | 66 | * @method |
| 54 | */ | 67 | */ |
| @@ -59,24 +72,25 @@ class BlogController extends BaseController | @@ -59,24 +72,25 @@ class BlogController extends BaseController | ||
| 59 | 'id.required' => 'ID不能为空' | 72 | 'id.required' => 'ID不能为空' |
| 60 | ]); | 73 | ]); |
| 61 | $info = $blogLogic->blog_info(); | 74 | $info = $blogLogic->blog_info(); |
| 75 | + $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']); | ||
| 76 | + $info['url'] = $this->getProjectDomain() . $info['route']; | ||
| 62 | $this->response('success',Code::SUCCESS,$info); | 77 | $this->response('success',Code::SUCCESS,$info); |
| 63 | } | 78 | } |
| 64 | /** | 79 | /** |
| 65 | * @name :添加博客 | 80 | * @name :添加博客 |
| 66 | - * @return void | ||
| 67 | * @author :liyuhang | 81 | * @author :liyuhang |
| 68 | * @method | 82 | * @method |
| 69 | */ | 83 | */ |
| 70 | public function add(BlogRequest $request,BlogLogic $blogLogic){ | 84 | public function add(BlogRequest $request,BlogLogic $blogLogic){ |
| 71 | $request->validated(); | 85 | $request->validated(); |
| 72 | $blogLogic->blog_add(); | 86 | $blogLogic->blog_add(); |
| 73 | - //TODO::写入日志 | 87 | + //TODO::通知网站更新 |
| 88 | + $this->projectUrlNotify($this->updateModelView); | ||
| 74 | $this->response('success'); | 89 | $this->response('success'); |
| 75 | } | 90 | } |
| 76 | 91 | ||
| 77 | /** | 92 | /** |
| 78 | * @name :编辑博客 | 93 | * @name :编辑博客 |
| 79 | - * @return void | ||
| 80 | * @author :liyuhang | 94 | * @author :liyuhang |
| 81 | * @method | 95 | * @method |
| 82 | */ | 96 | */ |
| @@ -87,13 +101,13 @@ class BlogController extends BaseController | @@ -87,13 +101,13 @@ class BlogController extends BaseController | ||
| 87 | 'id.required' => 'ID不能为空' | 101 | 'id.required' => 'ID不能为空' |
| 88 | ]); | 102 | ]); |
| 89 | $blogLogic->blog_edit(); | 103 | $blogLogic->blog_edit(); |
| 90 | - //TODO::写入日志 | 104 | + //TODO::通知网站更新 |
| 105 | + $this->projectUrlNotify($this->updateModelView); | ||
| 91 | $this->response('success'); | 106 | $this->response('success'); |
| 92 | } | 107 | } |
| 93 | 108 | ||
| 94 | /** | 109 | /** |
| 95 | * @name :编辑新闻seo | 110 | * @name :编辑新闻seo |
| 96 | - * @return void | ||
| 97 | * @author :liyuhang | 111 | * @author :liyuhang |
| 98 | * @method | 112 | * @method |
| 99 | */ | 113 | */ |
| @@ -114,7 +128,6 @@ class BlogController extends BaseController | @@ -114,7 +128,6 @@ class BlogController extends BaseController | ||
| 114 | } | 128 | } |
| 115 | /** | 129 | /** |
| 116 | * @name :编辑博客状态/排序 | 130 | * @name :编辑博客状态/排序 |
| 117 | - * @return void | ||
| 118 | * @author :liyuhang | 131 | * @author :liyuhang |
| 119 | * @method | 132 | * @method |
| 120 | */ | 133 | */ |
| @@ -132,7 +145,6 @@ class BlogController extends BaseController | @@ -132,7 +145,6 @@ class BlogController extends BaseController | ||
| 132 | 145 | ||
| 133 | /** | 146 | /** |
| 134 | * @name :删除博客(批量逻辑删除) | 147 | * @name :删除博客(批量逻辑删除) |
| 135 | - * @return void | ||
| 136 | * @author :liyuhang | 148 | * @author :liyuhang |
| 137 | * @method | 149 | * @method |
| 138 | */ | 150 | */ |
| @@ -13,7 +13,6 @@ class BlogLabelController extends BaseController | @@ -13,7 +13,6 @@ class BlogLabelController extends BaseController | ||
| 13 | { | 13 | { |
| 14 | /** | 14 | /** |
| 15 | * @name :博客标签列表 | 15 | * @name :博客标签列表 |
| 16 | - * @return json | ||
| 17 | * @author :liyuhang | 16 | * @author :liyuhang |
| 18 | * @method | 17 | * @method |
| 19 | */ | 18 | */ |
| @@ -32,13 +31,11 @@ class BlogLabelController extends BaseController | @@ -32,13 +31,11 @@ class BlogLabelController extends BaseController | ||
| 32 | public function add(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){ | 31 | public function add(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){ |
| 33 | $request->validated(); | 32 | $request->validated(); |
| 34 | $blogLabelLogic->add_blog_label(); | 33 | $blogLabelLogic->add_blog_label(); |
| 35 | - //TODO::写入日志 | ||
| 36 | $this->response('success'); | 34 | $this->response('success'); |
| 37 | } | 35 | } |
| 38 | 36 | ||
| 39 | /** | 37 | /** |
| 40 | * @name :编辑标签 | 38 | * @name :编辑标签 |
| 41 | - * @return void | ||
| 42 | * @author :liyuhang | 39 | * @author :liyuhang |
| 43 | * @method | 40 | * @method |
| 44 | */ | 41 | */ |
| @@ -49,13 +46,11 @@ class BlogLabelController extends BaseController | @@ -49,13 +46,11 @@ class BlogLabelController extends BaseController | ||
| 49 | 'id.required' => 'ID不能为空' | 46 | 'id.required' => 'ID不能为空' |
| 50 | ]); | 47 | ]); |
| 51 | $blogLabelLogic->edit_blog_label(); | 48 | $blogLabelLogic->edit_blog_label(); |
| 52 | - //TODO::写入日志 | ||
| 53 | $this->response('success'); | 49 | $this->response('success'); |
| 54 | } | 50 | } |
| 55 | 51 | ||
| 56 | /** | 52 | /** |
| 57 | * @name :编辑标签状态/排序 | 53 | * @name :编辑标签状态/排序 |
| 58 | - * @return void | ||
| 59 | * @author :liyuhang | 54 | * @author :liyuhang |
| 60 | * @method | 55 | * @method |
| 61 | */ | 56 | */ |
| @@ -66,13 +61,11 @@ class BlogLabelController extends BaseController | @@ -66,13 +61,11 @@ class BlogLabelController extends BaseController | ||
| 66 | 'id.required' => 'ID不能为空', | 61 | 'id.required' => 'ID不能为空', |
| 67 | ]); | 62 | ]); |
| 68 | $blogLabelLogic->status_blog_label(); | 63 | $blogLabelLogic->status_blog_label(); |
| 69 | - //TODO::写入日志 | ||
| 70 | $this->response('success'); | 64 | $this->response('success'); |
| 71 | } | 65 | } |
| 72 | 66 | ||
| 73 | /** | 67 | /** |
| 74 | * @name :删除标签(批量删除) | 68 | * @name :删除标签(批量删除) |
| 75 | - * @return void | ||
| 76 | * @author :liyuhang | 69 | * @author :liyuhang |
| 77 | * @method | 70 | * @method |
| 78 | */ | 71 | */ |
| @@ -3,18 +3,17 @@ | @@ -3,18 +3,17 @@ | ||
| 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; | ||
| 7 | -use App\Helper\Country; | ||
| 8 | -use App\Models\AyrShare\AyrRelease as AyrReleaseModel; | ||
| 9 | -use App\Models\AyrShare\AyrShare as AyrShareModel; | 6 | +use App\Http\Logic\Bside\User\UserLogic; |
| 7 | +use App\Http\Logic\Bside\User\UserLoginLogic; | ||
| 10 | use App\Models\Project\Project; | 8 | use App\Models\Project\Project; |
| 11 | use App\Models\Project\Project as ProjectModel; | 9 | use App\Models\Project\Project as ProjectModel; |
| 10 | +use App\Models\SmsLog; | ||
| 12 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 11 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 13 | use App\Models\User\ProjectRole as ProjectRoleModel; | 12 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 14 | use App\Models\User\User as UserModel; | 13 | use App\Models\User\User as UserModel; |
| 15 | -use Carbon\Carbon; | ||
| 16 | use Illuminate\Http\Request; | 14 | use Illuminate\Http\Request; |
| 17 | use Illuminate\Support\Facades\Cache; | 15 | use Illuminate\Support\Facades\Cache; |
| 16 | +use Mrgoon\AliSms\AliSms; | ||
| 18 | 17 | ||
| 19 | /*** | 18 | /*** |
| 20 | * 当前为公共类 所有方法均不需要验证登录token | 19 | * 当前为公共类 所有方法均不需要验证登录token |
| @@ -23,30 +22,25 @@ class ComController extends BaseController | @@ -23,30 +22,25 @@ class ComController extends BaseController | ||
| 23 | { | 22 | { |
| 24 | /** | 23 | /** |
| 25 | * @name :管理员登录 | 24 | * @name :管理员登录 |
| 26 | - * @return void | ||
| 27 | * @author :liyuhang | 25 | * @author :liyuhang |
| 28 | * @method | 26 | * @method |
| 29 | */ | 27 | */ |
| 30 | public function login(){ | 28 | public function login(){ |
| 31 | $this->request->validate([ | 29 | $this->request->validate([ |
| 32 | - 'mobile'=>['required'], | 30 | + 'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'], |
| 33 | 'password'=>['required'], | 31 | 'password'=>['required'], |
| 34 | ],[ | 32 | ],[ |
| 35 | 'mobile.required'=>'电话号码必须填写', | 33 | 'mobile.required'=>'电话号码必须填写', |
| 36 | 'password.required'=>'内容必须填写', | 34 | 'password.required'=>'内容必须填写', |
| 37 | - 'mobile.max' => 'mobile不大于12字符.', | 35 | + 'mobile.regex' => '请输入正确的手机号码', |
| 38 | ]); | 36 | ]); |
| 39 | - $userModel = new UserModel(); | ||
| 40 | - $res = $userModel->login($this->param); | ||
| 41 | - if($res === false){ | ||
| 42 | - $this->response('当前用户不存在或者被禁用,登录失败',Code::USER_ERROR,[]); | ||
| 43 | - } | 37 | + $userLogic = new UserLoginLogic(); |
| 38 | + $res = $userLogic->login(); | ||
| 44 | $this->response('请求成功',Code::SUCCESS,$res); | 39 | $this->response('请求成功',Code::SUCCESS,$res); |
| 45 | } | 40 | } |
| 46 | 41 | ||
| 47 | /** | 42 | /** |
| 48 | * @name :获取当前用户权限菜单列表 | 43 | * @name :获取当前用户权限菜单列表 |
| 49 | - * @return void | ||
| 50 | * @author :liyuhang | 44 | * @author :liyuhang |
| 51 | * @method | 45 | * @method |
| 52 | */ | 46 | */ |
| @@ -71,7 +65,6 @@ class ComController extends BaseController | @@ -71,7 +65,6 @@ class ComController extends BaseController | ||
| 71 | 65 | ||
| 72 | /** | 66 | /** |
| 73 | * @name :获取当前项目详情 | 67 | * @name :获取当前项目详情 |
| 74 | - * @return void | ||
| 75 | * @author :liyuhang | 68 | * @author :liyuhang |
| 76 | * @method | 69 | * @method |
| 77 | */ | 70 | */ |
| @@ -85,7 +78,6 @@ class ComController extends BaseController | @@ -85,7 +78,6 @@ class ComController extends BaseController | ||
| 85 | 78 | ||
| 86 | /** | 79 | /** |
| 87 | * @name :登录用户编辑资料/修改密码 | 80 | * @name :登录用户编辑资料/修改密码 |
| 88 | - * @return void | ||
| 89 | * @author :liyuhang | 81 | * @author :liyuhang |
| 90 | * @method | 82 | * @method |
| 91 | */ | 83 | */ |
| @@ -97,12 +89,9 @@ class ComController extends BaseController | @@ -97,12 +89,9 @@ class ComController extends BaseController | ||
| 97 | 'password.required'=>'密码必须填写', | 89 | 'password.required'=>'密码必须填写', |
| 98 | 'name.required'=>'名称必须填写', | 90 | 'name.required'=>'名称必须填写', |
| 99 | ]); | 91 | ]); |
| 100 | - $userModel = new UserModel(); | 92 | + $userLogic = new UserLogic(); |
| 101 | $this->param['id'] = $this->uid; | 93 | $this->param['id'] = $this->uid; |
| 102 | - $rs = $userModel->edits($this->param); | ||
| 103 | - if($rs === false){ | ||
| 104 | - $this->response('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR); | ||
| 105 | - } | 94 | + $userLogic->edits($this->param); |
| 106 | $this->response('编辑成功'); | 95 | $this->response('编辑成功'); |
| 107 | } | 96 | } |
| 108 | 97 | ||
| @@ -120,60 +109,40 @@ class ComController extends BaseController | @@ -120,60 +109,40 @@ class ComController extends BaseController | ||
| 120 | $this->response('success'); | 109 | $this->response('success'); |
| 121 | } | 110 | } |
| 122 | 111 | ||
| 123 | - | ||
| 124 | /** | 112 | /** |
| 125 | - * @name : (测试定时任务)检测用户是否无操作记录 | ||
| 126 | - * @author :lyh | ||
| 127 | - * @method :post | ||
| 128 | - * @time :2023/5/12 14:55 | 113 | + * 发送登录短信 |
| 114 | + * @param Request $request | ||
| 115 | + * @return \Illuminate\Http\JsonResponse | ||
| 129 | */ | 116 | */ |
| 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 | - } | 117 | + public function sendLoginSms(Request $request) |
| 118 | + { | ||
| 119 | + $this->request->validate([ | ||
| 120 | + 'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'], | ||
| 121 | + ],[ | ||
| 122 | + 'mobile.required' => '手机号码不能为空', | ||
| 123 | + 'mobile.regex' => '请输入正确的手机号码', | ||
| 124 | + ]); | ||
| 125 | + $mobile = $request->input('mobile'); | ||
| 126 | + $user = UserModel::where(['mobile' => $mobile])->first(); | ||
| 127 | + if (empty($user)) { | ||
| 128 | + $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE); | ||
| 175 | } | 129 | } |
| 176 | - return $this->error; | 130 | + $last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN); |
| 131 | + if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) { | ||
| 132 | + $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE); | ||
| 133 | + } | ||
| 134 | + $template = config('aliyunsms.login_sms_temp'); | ||
| 135 | + $code['code'] = rand(100000,999999); | ||
| 136 | + $ali_sms = new AliSms(); | ||
| 137 | + $send = $ali_sms->sendSms(strval($mobile), $template, $code); | ||
| 138 | + if (empty($send->Code) && $send->Code != 'OK') { | ||
| 139 | + $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE); | ||
| 140 | + } | ||
| 141 | + SmsLog::createLog($mobile, $code['code']); | ||
| 142 | + $this->response('success'); | ||
| 177 | } | 143 | } |
| 178 | 144 | ||
| 145 | + public function ceshi(){ | ||
| 146 | + return $this->request->route()->getAction(); | ||
| 147 | + } | ||
| 179 | } | 148 | } |
| @@ -30,9 +30,14 @@ class CustomController extends BaseController | @@ -30,9 +30,14 @@ class CustomController extends BaseController | ||
| 30 | // 每页数量 | 30 | // 每页数量 |
| 31 | $limit = intval($this->param['limit']??20); | 31 | $limit = intval($this->param['limit']??20); |
| 32 | 32 | ||
| 33 | + $name = request()->get('name'); | ||
| 34 | + $map = []; | ||
| 35 | + if($name){ | ||
| 36 | + $map[] = ['name','like','%'.htmlspecialchars($name).'%']; | ||
| 37 | + } | ||
| 33 | 38 | ||
| 34 | $lists = CustomLogic::instance()->getList( | 39 | $lists = CustomLogic::instance()->getList( |
| 35 | - [], | 40 | + $map, |
| 36 | [], | 41 | [], |
| 37 | ['id','name','title','status','url','keywords','description','created_at','updated_at'], | 42 | ['id','name','title','status','url','keywords','description','created_at','updated_at'], |
| 38 | $limit | 43 | $limit |
| @@ -35,7 +35,7 @@ class CountController extends BaseController | @@ -35,7 +35,7 @@ class CountController extends BaseController | ||
| 35 | //TODO::30天pv,ip统计 | 35 | //TODO::30天pv,ip统计 |
| 36 | $data['visit_data'] = $countLogic->visit_data_count(); | 36 | $data['visit_data'] = $countLogic->visit_data_count(); |
| 37 | //TODO::询盘国家统计 | 37 | //TODO::询盘国家统计 |
| 38 | - $data['country_data'] = $countLogic->inquiry_country_count(); | 38 | + $data['country_data'] = json_decode($data['yesterday']['country']); |
| 39 | //TODO::来源排名 | 39 | //TODO::来源排名 |
| 40 | $data['referrer_count'] = $countLogic->referrer_count(); | 40 | $data['referrer_count'] = $countLogic->referrer_count(); |
| 41 | //TODO::访问国家前10 | 41 | //TODO::访问国家前10 |
| @@ -44,42 +44,4 @@ class CountController extends BaseController | @@ -44,42 +44,4 @@ class CountController extends BaseController | ||
| 44 | $data['enterprise_service'] = $countLogic->enterprise_service(); | 44 | $data['enterprise_service'] = $countLogic->enterprise_service(); |
| 45 | return $this->response('success',Code::SUCCESS,$data); | 45 | return $this->response('success',Code::SUCCESS,$data); |
| 46 | } | 46 | } |
| 47 | - | ||
| 48 | - /*** | ||
| 49 | - * @name :(手动获取昨日数据统计)yesterday | ||
| 50 | - * @author :lyh | ||
| 51 | - * @method :post | ||
| 52 | - * @time :2023/5/24 9:13 | ||
| 53 | - */ | ||
| 54 | - public function yesterday(){ | ||
| 55 | - $deployModel = new DeployBuild(); | ||
| 56 | - $list = $deployModel->list(); | ||
| 57 | - $data = []; | ||
| 58 | - $yesterday = Carbon::yesterday()->toDateString(); | ||
| 59 | - foreach ($list as $v){ | ||
| 60 | - $arr = []; | ||
| 61 | - $arr['yesterday_pv_num'] = DB::table('gl_customer_visit_item')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 62 | - $arr['yesterday_ip_num'] = DB::table('gl_customer_visit')->whereDate('date', $yesterday)->where('domain',$v['test_domain'])->count(); | ||
| 63 | - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($v['test_domain']); | ||
| 64 | - if($inquiry_list['status'] == self::STATUS_ERROR){ | ||
| 65 | - $arr['inquiry_num'] = 0; | ||
| 66 | - }else{ | ||
| 67 | - $arr['inquiry_num'] = count($inquiry_list['data']['total']); | ||
| 68 | - } | ||
| 69 | - $arr['date'] = $yesterday; | ||
| 70 | - $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first(); | ||
| 71 | - if(empty($rank_info)){ | ||
| 72 | - $arr['compliance_day'] = 0; | ||
| 73 | - }else{ | ||
| 74 | - $arr['compliance_day'] = $rank_info->compliance_day; | ||
| 75 | - } | ||
| 76 | - $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']); | ||
| 77 | - $arr['project_id'] = $v['project_id']; | ||
| 78 | - $arr['created_at'] = date('Y-m-d H:i:s'); | ||
| 79 | - $arr['updated_at'] = date('Y-m-d H:i:s'); | ||
| 80 | - $data[] = $arr; | ||
| 81 | - } | ||
| 82 | - DB::table('gl_count')->insert($data); | ||
| 83 | - $this->response('success'); | ||
| 84 | - } | ||
| 85 | } | 47 | } |
| @@ -14,35 +14,62 @@ class MailController extends BaseController | @@ -14,35 +14,62 @@ class MailController extends BaseController | ||
| 14 | const STATUS_ONE = 1; //状态为已读状态 | 14 | const STATUS_ONE = 1; //状态为已读状态 |
| 15 | /** | 15 | /** |
| 16 | * @name :当前用户站内信列表 | 16 | * @name :当前用户站内信列表 |
| 17 | - * @return void | ||
| 18 | * @author :liyuhang | 17 | * @author :liyuhang |
| 19 | * @method | 18 | * @method |
| 20 | */ | 19 | */ |
| 21 | public function lists(){ | 20 | public function lists(){ |
| 22 | $mailModel = new MailModel(); | 21 | $mailModel = new MailModel(); |
| 23 | //获取当前用户下的所有站内信 | 22 | //获取当前用户下的所有站内信 |
| 24 | - $this->map['user_list'] = ['like','%,'.$this->uid.',%']; | ||
| 25 | - $this->map['user_list'] = ['or',null]; | ||
| 26 | - $lists = $mailModel->lists($this->map,$this->page,$this->row); | 23 | + $lists = $mailModel->where('status',0) |
| 24 | + ->where('user_list','like','%,'.$this->uid.',%')->orWhere('user_list', '')->select(['*'])->orderBy($this->order,'desc') | ||
| 25 | + ->paginate($this->row, ['*'], 'page', $this->page); | ||
| 26 | + if(!empty($lists)){ | ||
| 27 | + $lists = $lists->toArray(); | ||
| 28 | + } | ||
| 29 | + $mailUserModel = new MailUserModel(); | ||
| 30 | + $lists['unreadNum'] = $this->unreadNum($mailUserModel,$lists['total']); | ||
| 27 | if(!empty($lists['list'])){ | 31 | if(!empty($lists['list'])){ |
| 28 | - foreach ($lists['list'] as $k => $v){ | ||
| 29 | - $mailUserModel = new MailUserModel(); | ||
| 30 | - //获取用户已读还是未读 | ||
| 31 | - $info = $mailUserModel->read(['mail_id'=>$v['id'],'user_id'=>$this->uid]); | ||
| 32 | - if($info !== false){ | ||
| 33 | - $v['read_status'] = $this::STATUS_ONE;// | ||
| 34 | - }else{ | ||
| 35 | - $v['read_status'] = $this::STATUS_ZERO; | ||
| 36 | - } | ||
| 37 | - $lists['list'][$k] = $v; | ||
| 38 | - } | 32 | + //验证未读还是已读 |
| 33 | + $lists['list'] = $this->verifyRead($mailUserModel,$lists['list']); | ||
| 39 | } | 34 | } |
| 40 | $this->response('success',Code::SUCCESS,$lists); | 35 | $this->response('success',Code::SUCCESS,$lists); |
| 41 | } | 36 | } |
| 42 | 37 | ||
| 43 | /** | 38 | /** |
| 39 | + * @name :(验证已读还是未读)verifyRead | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2023/6/17 15:02 | ||
| 43 | + */ | ||
| 44 | + public function verifyRead(&$mailUserModel,$list){ | ||
| 45 | + foreach ($list as $k => $v){ | ||
| 46 | + //获取用户已读还是未读 | ||
| 47 | + $info = $mailUserModel->read(['mail_id'=>$v['id'],'user_id'=>$this->uid]); | ||
| 48 | + if($info !== false){ | ||
| 49 | + $v['read_status'] = $this::STATUS_ONE;// | ||
| 50 | + }else{ | ||
| 51 | + $v['read_status'] = $this::STATUS_ZERO; | ||
| 52 | + } | ||
| 53 | + $lists[$k] = $v; | ||
| 54 | + } | ||
| 55 | + return $lists; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @name :(未读数量)readNum | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2023/6/17 13:58 | ||
| 63 | + */ | ||
| 64 | + public function unreadNum(&$mailUserModel,$total){ | ||
| 65 | + //已读数量 | ||
| 66 | + $count = $mailUserModel->where(['user_id'=>$this->uid])->count(); | ||
| 67 | + $num = $total - $count; | ||
| 68 | + return $num; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 44 | * @name :获取站内信详情 | 72 | * @name :获取站内信详情 |
| 45 | - * @return void | ||
| 46 | * @author :liyuhang | 73 | * @author :liyuhang |
| 47 | * @method | 74 | * @method |
| 48 | */ | 75 | */ |
| @@ -79,21 +79,25 @@ class NavController extends BaseController | @@ -79,21 +79,25 @@ class NavController extends BaseController | ||
| 79 | // todo::需要配合 c端来 | 79 | // todo::需要配合 c端来 |
| 80 | return $this->success([ | 80 | return $this->success([ |
| 81 | [ | 81 | [ |
| 82 | - 'url' => '/', | 82 | + 'url' => '', |
| 83 | 'name' => '首页' | 83 | 'name' => '首页' |
| 84 | ], | 84 | ], |
| 85 | [ | 85 | [ |
| 86 | - 'url' => '/list', | ||
| 87 | - 'name' => '列表' | 86 | + 'url' => 'news', |
| 87 | + 'name' => '新闻' | ||
| 88 | ], | 88 | ], |
| 89 | [ | 89 | [ |
| 90 | - 'url' => '/page', | ||
| 91 | - 'name' => '单页' | 90 | + 'url' => 'products', |
| 91 | + 'name' => '产品' | ||
| 92 | ], | 92 | ], |
| 93 | [ | 93 | [ |
| 94 | - 'url' => '/goods', | ||
| 95 | - 'name' => '商品' | 94 | + 'url' => 'search', |
| 95 | + 'name' => '搜索页' | ||
| 96 | ], | 96 | ], |
| 97 | + [ | ||
| 98 | + 'url' => 'blog', | ||
| 99 | + 'name' => '博客' | ||
| 100 | + ] | ||
| 97 | ]); | 101 | ]); |
| 98 | } | 102 | } |
| 99 | 103 |
| @@ -8,12 +8,12 @@ use App\Http\Logic\Bside\News\NewsCategoryLogic; | @@ -8,12 +8,12 @@ use App\Http\Logic\Bside\News\NewsCategoryLogic; | ||
| 8 | use App\Http\Requests\Bside\News\NewsCategoryRequest; | 8 | use App\Http\Requests\Bside\News\NewsCategoryRequest; |
| 9 | use App\Models\News\News as NewsModel; | 9 | use App\Models\News\News as NewsModel; |
| 10 | use App\Models\News\NewsCategory as NewsCategoryModel; | 10 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 11 | +use App\Models\RouteMap; | ||
| 11 | 12 | ||
| 12 | class NewsCategoryController extends BaseController | 13 | class NewsCategoryController extends BaseController |
| 13 | { | 14 | { |
| 14 | /** | 15 | /** |
| 15 | * @name :新闻分类列表 | 16 | * @name :新闻分类列表 |
| 16 | - * @return json | ||
| 17 | * @author :liyuhang | 17 | * @author :liyuhang |
| 18 | * @method | 18 | * @method |
| 19 | */ | 19 | */ |
| @@ -26,6 +26,9 @@ class NewsCategoryController extends BaseController | @@ -26,6 +26,9 @@ class NewsCategoryController extends BaseController | ||
| 26 | $newsModel = new NewsModel(); | 26 | $newsModel = new NewsModel(); |
| 27 | foreach ($lists['list'] as $k => $v){ | 27 | foreach ($lists['list'] as $k => $v){ |
| 28 | $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); | 28 | $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); |
| 29 | + $v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $v['id'], $this->user['project_id']); | ||
| 30 | + $v['url'] = $this->getProjectDomain() . RouteMap::PATH_NEWS_CATE . '/' . $v['alias']; | ||
| 31 | + $v['hasChildren'] = (($newsCategory->read(['pid'=>$v['id']])) != false) ? true : false; | ||
| 29 | $lists['list'][$k] = $v; | 32 | $lists['list'][$k] = $v; |
| 30 | } | 33 | } |
| 31 | } | 34 | } |
| @@ -33,8 +36,18 @@ class NewsCategoryController extends BaseController | @@ -33,8 +36,18 @@ class NewsCategoryController extends BaseController | ||
| 33 | } | 36 | } |
| 34 | 37 | ||
| 35 | /** | 38 | /** |
| 39 | + * @name :(添加/编辑时获取顶级分类)topList | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2023/6/13 9:03 | ||
| 43 | + */ | ||
| 44 | + public function categoryTopList(NewsCategoryLogic $newsCategoryLogic){ | ||
| 45 | + $list = $newsCategoryLogic->categoryTopList(); | ||
| 46 | + $this->response('success',Code::SUCCESS,$list); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 36 | * @name :获取当前分类详情 | 50 | * @name :获取当前分类详情 |
| 37 | - * @return void | ||
| 38 | * @author :liyuhang | 51 | * @author :liyuhang |
| 39 | * @method | 52 | * @method |
| 40 | */ | 53 | */ |
| @@ -45,11 +58,12 @@ class NewsCategoryController extends BaseController | @@ -45,11 +58,12 @@ class NewsCategoryController extends BaseController | ||
| 45 | 'id.required' => 'ID不能为空' | 58 | 'id.required' => 'ID不能为空' |
| 46 | ]); | 59 | ]); |
| 47 | $info = $newsCategoryLogic->info_news_category(); | 60 | $info = $newsCategoryLogic->info_news_category(); |
| 61 | + $info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $info['id'], $this->user['project_id']); | ||
| 62 | + $info['url'] = $this->getProjectDomain() . RouteMap::PATH_NEWS_CATE . '/' . $info['alias']; | ||
| 48 | $this->response('success',Code::SUCCESS,$info); | 63 | $this->response('success',Code::SUCCESS,$info); |
| 49 | } | 64 | } |
| 50 | /** | 65 | /** |
| 51 | * @name :添加分类 | 66 | * @name :添加分类 |
| 52 | - * @return json | ||
| 53 | * @author :liyuhang | 67 | * @author :liyuhang |
| 54 | * @method | 68 | * @method |
| 55 | */ | 69 | */ |
| @@ -62,7 +76,6 @@ class NewsCategoryController extends BaseController | @@ -62,7 +76,6 @@ class NewsCategoryController extends BaseController | ||
| 62 | 76 | ||
| 63 | /** | 77 | /** |
| 64 | * @name :编辑分类 | 78 | * @name :编辑分类 |
| 65 | - * @return void | ||
| 66 | * @author :liyuhang | 79 | * @author :liyuhang |
| 67 | * @method | 80 | * @method |
| 68 | */ | 81 | */ |
| @@ -78,7 +91,6 @@ class NewsCategoryController extends BaseController | @@ -78,7 +91,6 @@ class NewsCategoryController extends BaseController | ||
| 78 | 91 | ||
| 79 | /** | 92 | /** |
| 80 | * @name :编辑状态/排序 | 93 | * @name :编辑状态/排序 |
| 81 | - * @return void | ||
| 82 | * @author :liyuhang | 94 | * @author :liyuhang |
| 83 | * @method | 95 | * @method |
| 84 | */ | 96 | */ |
| @@ -94,7 +106,6 @@ class NewsCategoryController extends BaseController | @@ -94,7 +106,6 @@ class NewsCategoryController extends BaseController | ||
| 94 | 106 | ||
| 95 | /** | 107 | /** |
| 96 | * @name :删除分类 | 108 | * @name :删除分类 |
| 97 | - * @return void | ||
| 98 | * @author :liyuhang | 109 | * @author :liyuhang |
| 99 | * @method | 110 | * @method |
| 100 | */ | 111 | */ |
| @@ -3,23 +3,23 @@ | @@ -3,23 +3,23 @@ | ||
| 3 | namespace App\Http\Controllers\Bside\News; | 3 | namespace App\Http\Controllers\Bside\News; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | -use App\Helper\Common; | ||
| 7 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Http\Logic\Bside\News\NewsCategoryLogic; | 7 | use App\Http\Logic\Bside\News\NewsCategoryLogic; |
| 9 | use App\Http\Logic\Bside\News\NewsLogic; | 8 | use App\Http\Logic\Bside\News\NewsLogic; |
| 10 | use App\Http\Requests\Bside\News\NewsRequest; | 9 | use App\Http\Requests\Bside\News\NewsRequest; |
| 11 | use App\Models\News\News as NewsModel; | 10 | use App\Models\News\News as NewsModel; |
| 11 | +use App\Models\RouteMap; | ||
| 12 | use Illuminate\Http\Request; | 12 | use Illuminate\Http\Request; |
| 13 | -use Illuminate\Support\Facades\DB; | 13 | + |
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 16 | * @name:新闻管理 | 16 | * @name:新闻管理 |
| 17 | */ | 17 | */ |
| 18 | class NewsController extends BaseController | 18 | class NewsController extends BaseController |
| 19 | { | 19 | { |
| 20 | + public $updateModelView = 'news'; | ||
| 20 | /** | 21 | /** |
| 21 | * @name :获取新闻列表 | 22 | * @name :获取新闻列表 |
| 22 | - * @return json | ||
| 23 | * @author :liyuhang | 23 | * @author :liyuhang |
| 24 | * @method | 24 | * @method |
| 25 | */ | 25 | */ |
| @@ -30,6 +30,8 @@ class NewsController extends BaseController | @@ -30,6 +30,8 @@ class NewsController extends BaseController | ||
| 30 | if(!empty($lists['list'])){ | 30 | if(!empty($lists['list'])){ |
| 31 | foreach ($lists['list'] as $k => $v){ | 31 | foreach ($lists['list'] as $k => $v){ |
| 32 | $v = $newsCategoryLogic->get_category_name($v); | 32 | $v = $newsCategoryLogic->get_category_name($v); |
| 33 | + $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']); | ||
| 34 | + $v['url'] = $this->getProjectDomain() . $v['route']; | ||
| 33 | $lists['list'][$k] = $v; | 35 | $lists['list'][$k] = $v; |
| 34 | } | 36 | } |
| 35 | } | 37 | } |
| @@ -37,8 +39,20 @@ class NewsController extends BaseController | @@ -37,8 +39,20 @@ class NewsController extends BaseController | ||
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | /** | 41 | /** |
| 42 | + * @remark :根据状态数量 | ||
| 43 | + * @name :getStatusNumber | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2023/6/19 9:39 | ||
| 47 | + */ | ||
| 48 | + public function getStatusNumber(NewsLogic $newsLogic){ | ||
| 49 | + $data = $newsLogic->getStatusNumber(); | ||
| 50 | + $this->response('success',Code::SUCCESS,$data); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + /** | ||
| 40 | * @name :添加新闻时获取分类列表 | 55 | * @name :添加新闻时获取分类列表 |
| 41 | - * @return void | ||
| 42 | * @author :liyuhang | 56 | * @author :liyuhang |
| 43 | * @method | 57 | * @method |
| 44 | */ | 58 | */ |
| @@ -48,7 +62,6 @@ class NewsController extends BaseController | @@ -48,7 +62,6 @@ class NewsController extends BaseController | ||
| 48 | } | 62 | } |
| 49 | /** | 63 | /** |
| 50 | * @name :获取详情 | 64 | * @name :获取详情 |
| 51 | - * @return void | ||
| 52 | * @author :liyuhang | 65 | * @author :liyuhang |
| 53 | * @method | 66 | * @method |
| 54 | */ | 67 | */ |
| @@ -59,6 +72,8 @@ class NewsController extends BaseController | @@ -59,6 +72,8 @@ class NewsController extends BaseController | ||
| 59 | 'id.required' => 'ID不能为空', | 72 | 'id.required' => 'ID不能为空', |
| 60 | ]); | 73 | ]); |
| 61 | $info = $newsLogic->news_info(); | 74 | $info = $newsLogic->news_info(); |
| 75 | + $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']); | ||
| 76 | + $info['url'] = $this->getProjectDomain() . $info['route']; | ||
| 62 | $this->response('success',Code::SUCCESS,$info); | 77 | $this->response('success',Code::SUCCESS,$info); |
| 63 | } | 78 | } |
| 64 | /** | 79 | /** |
| @@ -70,12 +85,13 @@ class NewsController extends BaseController | @@ -70,12 +85,13 @@ class NewsController extends BaseController | ||
| 70 | public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ | 85 | public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ |
| 71 | $newsRequest->validated(); | 86 | $newsRequest->validated(); |
| 72 | $newsLogic->news_add(); | 87 | $newsLogic->news_add(); |
| 73 | - $this->response('success'); | 88 | + //TODO::通知网站更新 |
| 89 | + $res = $this->projectUrlNotify($this->updateModelView); | ||
| 90 | + $this->response('success',Code::SUCCESS,$res); | ||
| 74 | } | 91 | } |
| 75 | 92 | ||
| 76 | /** | 93 | /** |
| 77 | * @name :编辑 | 94 | * @name :编辑 |
| 78 | - * @return void | ||
| 79 | * @author :liyuhang | 95 | * @author :liyuhang |
| 80 | * @method | 96 | * @method |
| 81 | */ | 97 | */ |
| @@ -86,12 +102,13 @@ class NewsController extends BaseController | @@ -86,12 +102,13 @@ class NewsController extends BaseController | ||
| 86 | 'id.required' => 'ID不能为空', | 102 | 'id.required' => 'ID不能为空', |
| 87 | ]); | 103 | ]); |
| 88 | $newsLogic->news_edit(); | 104 | $newsLogic->news_edit(); |
| 89 | - $this->response('success'); | 105 | + //TODO::通知网站更新 |
| 106 | + $res = $this->projectUrlNotify($this->updateModelView); | ||
| 107 | + $this->response('success',Code::SUCCESS,$res); | ||
| 90 | } | 108 | } |
| 91 | 109 | ||
| 92 | /** | 110 | /** |
| 93 | * @name :编辑新闻seo | 111 | * @name :编辑新闻seo |
| 94 | - * @return void | ||
| 95 | * @author :liyuhang | 112 | * @author :liyuhang |
| 96 | * @method | 113 | * @method |
| 97 | */ | 114 | */ |
| @@ -113,7 +130,6 @@ class NewsController extends BaseController | @@ -113,7 +130,6 @@ class NewsController extends BaseController | ||
| 113 | 130 | ||
| 114 | /** | 131 | /** |
| 115 | * @name :编辑状态/与排序 | 132 | * @name :编辑状态/与排序 |
| 116 | - * @return void | ||
| 117 | * @author :liyuhang | 133 | * @author :liyuhang |
| 118 | * @method | 134 | * @method |
| 119 | */ | 135 | */ |
| @@ -130,7 +146,6 @@ class NewsController extends BaseController | @@ -130,7 +146,6 @@ class NewsController extends BaseController | ||
| 130 | } | 146 | } |
| 131 | /** | 147 | /** |
| 132 | * @name :删除新闻(逻辑删除) | 148 | * @name :删除新闻(逻辑删除) |
| 133 | - * @return void | ||
| 134 | * @author :liyuhang | 149 | * @author :liyuhang |
| 135 | * @method | 150 | * @method |
| 136 | */ | 151 | */ |
| @@ -73,6 +73,8 @@ class ProductController extends BaseController | @@ -73,6 +73,8 @@ class ProductController extends BaseController | ||
| 73 | public function save(ProductRequest $request, ProductLogic $logic) | 73 | public function save(ProductRequest $request, ProductLogic $logic) |
| 74 | { | 74 | { |
| 75 | $data = $logic->save($this->param); | 75 | $data = $logic->save($this->param); |
| 76 | + //通知更新界面 | ||
| 77 | + $this->projectUrlNotify('product'); | ||
| 76 | return $this->success($data); | 78 | return $this->success($data); |
| 77 | } | 79 | } |
| 78 | 80 | ||
| @@ -88,4 +90,9 @@ class ProductController extends BaseController | @@ -88,4 +90,9 @@ class ProductController extends BaseController | ||
| 88 | return $this->success($data); | 90 | return $this->success($data); |
| 89 | } | 91 | } |
| 90 | 92 | ||
| 93 | + | ||
| 94 | + public function getStatusNumber(ProductLogic $logic){ | ||
| 95 | + $data = $logic->getStatusNumber(); | ||
| 96 | + $this->response('success',Code::SUCCESS,$data); | ||
| 97 | + } | ||
| 91 | } | 98 | } |
| @@ -188,7 +188,7 @@ class RankDataController extends BaseController | @@ -188,7 +188,7 @@ class RankDataController extends BaseController | ||
| 188 | 'video_position' => 0, | 188 | 'video_position' => 0, |
| 189 | ]; | 189 | ]; |
| 190 | $client = new Client([ | 190 | $client = new Client([ |
| 191 | - 'base_uri' => 'http://45.136.131.71:8000', | 191 | + 'base_uri' => 'http://rank.waimaoq.com', |
| 192 | 'timeout' => '20' | 192 | 'timeout' => '20' |
| 193 | ]); | 193 | ]); |
| 194 | 194 | ||
| @@ -208,7 +208,7 @@ class RankDataController extends BaseController | @@ -208,7 +208,7 @@ class RankDataController extends BaseController | ||
| 208 | $data = [ | 208 | $data = [ |
| 209 | 'position' => 0, | 209 | 'position' => 0, |
| 210 | ]; | 210 | ]; |
| 211 | - $res = HttpUtils::get('http://45.136.131.71:8000/luminati_rank', $param); | 211 | + $res = HttpUtils::get('http://rank.waimaoq.com/luminati_rank', $param); |
| 212 | if ($res) { | 212 | if ($res) { |
| 213 | $res = Arr::s2a($res); | 213 | $res = Arr::s2a($res); |
| 214 | $data['position'] = $res['position']; | 214 | $data['position'] = $res['position']; |
| @@ -28,8 +28,8 @@ class ProjectCountryController extends BaseController | @@ -28,8 +28,8 @@ class ProjectCountryController extends BaseController | ||
| 28 | * @method :post | 28 | * @method :post |
| 29 | * @time :2023/4/28 17:53 | 29 | * @time :2023/4/28 17:53 |
| 30 | */ | 30 | */ |
| 31 | - public function edit(ProjectCountryLogic $projectCountryLogic){ | ||
| 32 | - $projectCountryLogic->country_edit(); | 31 | + public function save(ProjectCountryLogic $projectCountryLogic){ |
| 32 | + $projectCountryLogic->country_save(); | ||
| 33 | $this->response('success'); | 33 | $this->response('success'); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Setting; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Bside\BaseController; | ||
| 7 | +use App\Http\Logic\Bside\Setting\ProofreadingLogic; | ||
| 8 | + | ||
| 9 | +class ProofreadingController extends BaseController | ||
| 10 | +{ | ||
| 11 | + const LANGUAGE_ID = 1;//默认语言英语 | ||
| 12 | + const TYPE_IMAGE = 2;//校队图片 | ||
| 13 | + /** | ||
| 14 | + * @name :lists | ||
| 15 | + * @author :lyh | ||
| 16 | + * @method :post | ||
| 17 | + * @time :2023/6/12 10:52 | ||
| 18 | + */ | ||
| 19 | + public function lists(ProofreadingLogic $proofreadingLogic){ | ||
| 20 | + //默认显示语言为英语 | ||
| 21 | + if(!isset($this->map['language_id']) || empty($this->map['language_id'])){ | ||
| 22 | + $this->map['language_id'] = $this::LANGUAGE_ID; | ||
| 23 | + } | ||
| 24 | + $lists = $proofreadingLogic->proofreadingList($this->map,$this->page,$this->row); | ||
| 25 | + if(!empty($lists['list']) && ($this->param['type'] == $this::TYPE_IMAGE)){ | ||
| 26 | + foreach ($lists['list'] as $k => $v){ | ||
| 27 | + $lists['list'][$k]['image_link'] = url('/b/image/' . $v['translate']); | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @name :(新增/更新多语言)save | ||
| 35 | + * @author :lyh | ||
| 36 | + * @method :post | ||
| 37 | + * @time :2023/6/12 10:52 | ||
| 38 | + */ | ||
| 39 | + public function save(ProofreadingLogic $proofreadingLogic){ | ||
| 40 | + $proofreadingLogic->proofreadingSave(); | ||
| 41 | + $this->response('success'); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @name :(当前项目选中的语言列表)languageList | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2023/6/12 15:52 | ||
| 49 | + */ | ||
| 50 | + public function languageList(ProofreadingLogic $proofreadingLogic){ | ||
| 51 | + $list = $proofreadingLogic->countryLanguageList($this->map,$this->order); | ||
| 52 | + $this->response('success',Code::SUCCESS,$list); | ||
| 53 | + } | ||
| 54 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Http\Logic\Bside\Statistics\StatisticsLogic; | ||
| 7 | +use App\Models\Bside\Statistics\TrafficStatistics; | ||
| 8 | +use Illuminate\Http\JsonResponse; | ||
| 9 | +use Psr\Container\ContainerExceptionInterface; | ||
| 10 | +use Psr\Container\NotFoundExceptionInterface; | ||
| 11 | +use Throwable; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 流量统计 | ||
| 15 | + * Class StatisticsController | ||
| 16 | + * @package App\Http\Controllers\Bside | ||
| 17 | + */ | ||
| 18 | +class StatisticsController extends BaseController | ||
| 19 | +{ | ||
| 20 | + public $statisticsLogic; | ||
| 21 | + | ||
| 22 | + public $trafficStatistics; | ||
| 23 | + | ||
| 24 | + public function __construct() | ||
| 25 | + { | ||
| 26 | + $this->statisticsLogic = new StatisticsLogic(); | ||
| 27 | + $this->trafficStatistics = new TrafficStatistics(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 访问来源 | ||
| 32 | + * @return JsonResponse | ||
| 33 | + * @throws ContainerExceptionInterface | ||
| 34 | + * @throws NotFoundExceptionInterface|Throwable | ||
| 35 | + */ | ||
| 36 | + public function source() | ||
| 37 | + { | ||
| 38 | + $type = $this->trafficStatistics::TYPE_SOURCE; | ||
| 39 | + $response = $this->statisticsLogic->getStatisticsData($type); | ||
| 40 | + return $this->success($response); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 地域分布 | ||
| 45 | + * @return JsonResponse | ||
| 46 | + * @throws ContainerExceptionInterface | ||
| 47 | + * @throws NotFoundExceptionInterface|Throwable | ||
| 48 | + */ | ||
| 49 | + public function distribution() | ||
| 50 | + { | ||
| 51 | + $type = $this->trafficStatistics::TYPE_DISTRIBUTION; | ||
| 52 | + $response = $this->statisticsLogic->getStatisticsData($type); | ||
| 53 | + return $this->success($response); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 受访页面 | ||
| 58 | + * @return JsonResponse | ||
| 59 | + * @throws ContainerExceptionInterface | ||
| 60 | + * @throws NotFoundExceptionInterface|Throwable | ||
| 61 | + */ | ||
| 62 | + public function page() | ||
| 63 | + { | ||
| 64 | + $type = $this->trafficStatistics::TYPE_PAGE; | ||
| 65 | + $response = $this->statisticsLogic->getStatisticsData($type); | ||
| 66 | + return $this->success($response); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 访问终端 | ||
| 71 | + * @return JsonResponse | ||
| 72 | + * @throws ContainerExceptionInterface | ||
| 73 | + * @throws NotFoundExceptionInterface|Throwable | ||
| 74 | + */ | ||
| 75 | + public function terminal() | ||
| 76 | + { | ||
| 77 | + $type = $this->trafficStatistics::TYPE_TERMINAL; | ||
| 78 | + $response = $this->statisticsLogic->getStatisticsData($type); | ||
| 79 | + return $this->success($response); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 流量趋势 | ||
| 84 | + * @return JsonResponse | ||
| 85 | + * @throws ContainerExceptionInterface | ||
| 86 | + * @throws NotFoundExceptionInterface|Throwable | ||
| 87 | + */ | ||
| 88 | + public function trend() | ||
| 89 | + { | ||
| 90 | + $type = $this->trafficStatistics::TYPE_TREND; | ||
| 91 | + $response = $this->statisticsLogic->getStatisticsData($type); | ||
| 92 | + $response['days'] = $this->statisticsLogic->getDaysTrend(); | ||
| 93 | + return $this->success($response); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | +} |
| @@ -123,7 +123,8 @@ class TemplateController extends BaseController | @@ -123,7 +123,8 @@ class TemplateController extends BaseController | ||
| 123 | $data = TemplateLogic::instance()->first($source,$source_id); | 123 | $data = TemplateLogic::instance()->first($source,$source_id); |
| 124 | $res = [ | 124 | $res = [ |
| 125 | 'html' => $data['html']??'', | 125 | 'html' => $data['html']??'', |
| 126 | - 'name' => 'example' | 126 | + 'section_list_id' => $data['section_list_id']??'', |
| 127 | + 'name' => 'example', | ||
| 127 | ]; | 128 | ]; |
| 128 | return $this->response('',Code::SUCCESS,$res); | 129 | return $this->response('',Code::SUCCESS,$res); |
| 129 | 130 | ||
| @@ -139,10 +140,6 @@ class TemplateController extends BaseController | @@ -139,10 +140,6 @@ class TemplateController extends BaseController | ||
| 139 | $data = $request->validated(); | 140 | $data = $request->validated(); |
| 140 | $data['data_source'] = $data['source']; | 141 | $data['data_source'] = $data['source']; |
| 141 | $data['data_source_id'] = $data['source_id']; | 142 | $data['data_source_id'] = $data['source_id']; |
| 142 | - unset($data['source']); | ||
| 143 | - unset($data['source_id']); | ||
| 144 | - TemplateLogic::instance()->save($data); | ||
| 145 | - return $this->response('保存成功'); | ||
| 146 | 143 | ||
| 147 | // 不需要数据id | 144 | // 不需要数据id |
| 148 | if(in_array($data['data_source'],['index'])){ | 145 | if(in_array($data['data_source'],['index'])){ |
| @@ -198,8 +195,7 @@ class TemplateController extends BaseController | @@ -198,8 +195,7 @@ class TemplateController extends BaseController | ||
| 198 | */ | 195 | */ |
| 199 | public function chunk(){ | 196 | public function chunk(){ |
| 200 | 197 | ||
| 201 | - $lists = TemplateChunkLogic::instance()->getList([['status','=',1]],['sort'=>'asc'],['*'],false)->toArray(); | ||
| 202 | - | 198 | + $lists = TemplateChunkLogic::instance()->getList([['status','=',1]],['sort'=>'asc'],['*'],false); |
| 203 | foreach ($lists as &$list){ | 199 | foreach ($lists as &$list){ |
| 204 | unset($list['created_at']); | 200 | unset($list['created_at']); |
| 205 | unset($list['updated_at']); | 201 | unset($list['updated_at']); |
| @@ -6,34 +6,82 @@ use App\Enums\Common\Code; | @@ -6,34 +6,82 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | use App\Http\Logic\Bside\User\DeptUserLogic; | 7 | use App\Http\Logic\Bside\User\DeptUserLogic; |
| 8 | use App\Models\User\ViewDeptUser; | 8 | use App\Models\User\ViewDeptUser; |
| 9 | +use Illuminate\Support\Facades\DB; | ||
| 9 | 10 | ||
| 10 | class DeptUserController extends BaseController | 11 | class DeptUserController extends BaseController |
| 11 | { | 12 | { |
| 12 | /** | 13 | /** |
| 13 | * @name :name | 14 | * @name :name |
| 14 | - * @return void | ||
| 15 | * @author :liyuhang | 15 | * @author :liyuhang |
| 16 | * @method | 16 | * @method |
| 17 | */ | 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'); | 18 | + public function lists(){ |
| 19 | + $query = DB::table('gl_project_user') | ||
| 20 | + ->leftJoin('gl_project_dept_user', 'gl_project_user.id', '=', 'gl_project_dept_user.user_id') | ||
| 21 | + ->leftJoin('gl_project_dept', 'gl_project_dept_user.dept_id', '=', 'gl_project_dept.id') | ||
| 22 | + ->join('gl_project_role', 'gl_project_user.role_id', '=', 'gl_project_role.id') | ||
| 23 | + ->orderBy('gl_project_dept_user.id','desc'); | ||
| 24 | + $query = $this->searchParam($query); | ||
| 25 | + $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page); | ||
| 21 | $this->response('success',Code::SUCCESS,$lists); | 26 | $this->response('success',Code::SUCCESS,$lists); |
| 22 | } | 27 | } |
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @name :(查询参数设置)selectParam | ||
| 31 | + * @author :lyh | ||
| 32 | + * @method :post | ||
| 33 | + * @time :2023/6/14 15:00 | ||
| 34 | + */ | ||
| 35 | + public function selectParam(){ | ||
| 36 | + $select = [ | ||
| 37 | + 'gl_project_dept_user.dept_id AS dept_id', | ||
| 38 | + 'gl_project_user.name AS name', | ||
| 39 | + 'gl_project_user.project_id AS project_id', | ||
| 40 | + 'gl_project_user.mobile AS mobile', | ||
| 41 | + 'gl_project_user.email AS email', | ||
| 42 | + 'gl_project_user.status AS status', | ||
| 43 | + 'gl_project_user.role_id AS role_id', | ||
| 44 | + 'gl_project_user.operator_id AS operator_id', | ||
| 45 | + 'gl_project_dept_user.is_admin AS is_admin', | ||
| 46 | + 'gl_project_dept.title AS title', | ||
| 47 | + 'gl_project_dept.pid AS pid', | ||
| 48 | + 'gl_project_dept.remark AS remark', | ||
| 49 | + 'gl_project_user.id AS user_id', | ||
| 50 | + 'gl_project_dept_user.id AS id', | ||
| 51 | + 'gl_project_role.name AS role_name' | ||
| 52 | + ]; | ||
| 53 | + return $select; | ||
| 54 | + } | ||
| 55 | + /** | ||
| 56 | + * @name :(搜索参数处理)searchParam | ||
| 57 | + * @author :lyh | ||
| 58 | + * @method :post | ||
| 59 | + * @time :2023/6/14 14:58 | ||
| 60 | + */ | ||
| 61 | + public function searchParam(&$query){ | ||
| 62 | + //搜索条件处理 | ||
| 63 | + if(isset($this->map['name'])){ | ||
| 64 | + $query = $query->where('gl_project_user.name',$this->map['name'][0],'%'.$this->map['name'][1].'%'); | ||
| 65 | + } | ||
| 66 | + if(isset($this->map['dept_id'])){ | ||
| 67 | + $query = $query->where('gl_project_dept_user.dept_id',$this->map['dept_id']); | ||
| 68 | + } | ||
| 69 | + $query = $query->where('gl_project_user.project_id',$this->user['project_id']); | ||
| 70 | + return $query; | ||
| 71 | + } | ||
| 23 | /** | 72 | /** |
| 24 | - * @param ViewDeptUser $viewDeptUser | ||
| 25 | * @name :(详情)info | 73 | * @name :(详情)info |
| 26 | * @author :lyh | 74 | * @author :lyh |
| 27 | * @method :post | 75 | * @method :post |
| 28 | * @time :2023/5/18 9:32 | 76 | * @time :2023/5/18 9:32 |
| 29 | */ | 77 | */ |
| 30 | - public function info(ViewDeptUser $viewDeptUser){ | 78 | + public function info(DeptUserLogic $deptUserLogic){ |
| 31 | $this->request->validate([ | 79 | $this->request->validate([ |
| 32 | 'id'=>['required'] | 80 | 'id'=>['required'] |
| 33 | ],[ | 81 | ],[ |
| 34 | 'id.required' => 'id不能为空' | 82 | 'id.required' => 'id不能为空' |
| 35 | ]); | 83 | ]); |
| 36 | - $info = $viewDeptUser->read($this->param); | 84 | + $info = $deptUserLogic->dept_user_info(); |
| 37 | $this->response('success',Code::SUCCESS,$info); | 85 | $this->response('success',Code::SUCCESS,$info); |
| 38 | } | 86 | } |
| 39 | 87 |
| @@ -14,7 +14,6 @@ class ProjectRoleController extends BaseController | @@ -14,7 +14,6 @@ class ProjectRoleController extends BaseController | ||
| 14 | { | 14 | { |
| 15 | /** | 15 | /** |
| 16 | * @name :用户角色列表() | 16 | * @name :用户角色列表() |
| 17 | - * @return json | ||
| 18 | * @author :liyuhang | 17 | * @author :liyuhang |
| 19 | * @method | 18 | * @method |
| 20 | */ | 19 | */ |
| @@ -30,7 +29,6 @@ class ProjectRoleController extends BaseController | @@ -30,7 +29,6 @@ class ProjectRoleController extends BaseController | ||
| 30 | 29 | ||
| 31 | /** | 30 | /** |
| 32 | * @name :根据角色获取会员列表 | 31 | * @name :根据角色获取会员列表 |
| 33 | - * @return void | ||
| 34 | * @author :liyuhang | 32 | * @author :liyuhang |
| 35 | * @method | 33 | * @method |
| 36 | */ | 34 | */ |
| @@ -41,7 +39,6 @@ class ProjectRoleController extends BaseController | @@ -41,7 +39,6 @@ class ProjectRoleController extends BaseController | ||
| 41 | } | 39 | } |
| 42 | /** | 40 | /** |
| 43 | * @name :详情 | 41 | * @name :详情 |
| 44 | - * @return json | ||
| 45 | * @author :liyuhang | 42 | * @author :liyuhang |
| 46 | * @method | 43 | * @method |
| 47 | */ | 44 | */ |
| @@ -56,7 +53,6 @@ class ProjectRoleController extends BaseController | @@ -56,7 +53,6 @@ class ProjectRoleController extends BaseController | ||
| 56 | } | 53 | } |
| 57 | /** | 54 | /** |
| 58 | * @name :添加/编辑角色时获取菜单列表 | 55 | * @name :添加/编辑角色时获取菜单列表 |
| 59 | - * @return void | ||
| 60 | * @author :liyuhang | 56 | * @author :liyuhang |
| 61 | * @method | 57 | * @method |
| 62 | */ | 58 | */ |
| @@ -66,7 +62,6 @@ class ProjectRoleController extends BaseController | @@ -66,7 +62,6 @@ class ProjectRoleController extends BaseController | ||
| 66 | } | 62 | } |
| 67 | /** | 63 | /** |
| 68 | * @name :添加角色 | 64 | * @name :添加角色 |
| 69 | - * @return void | ||
| 70 | * @author :liyuhang | 65 | * @author :liyuhang |
| 71 | * @method | 66 | * @method |
| 72 | */ | 67 | */ |
| @@ -78,7 +73,6 @@ class ProjectRoleController extends BaseController | @@ -78,7 +73,6 @@ class ProjectRoleController extends BaseController | ||
| 78 | 73 | ||
| 79 | /** | 74 | /** |
| 80 | * @name :编辑角色 | 75 | * @name :编辑角色 |
| 81 | - * @return void | ||
| 82 | * @author :liyuhang | 76 | * @author :liyuhang |
| 83 | * @method | 77 | * @method |
| 84 | */ | 78 | */ |
| @@ -94,7 +88,6 @@ class ProjectRoleController extends BaseController | @@ -94,7 +88,6 @@ class ProjectRoleController extends BaseController | ||
| 94 | 88 | ||
| 95 | /** | 89 | /** |
| 96 | * @name :修改用户状态 | 90 | * @name :修改用户状态 |
| 97 | - * @return void | ||
| 98 | * @author :liyuhang | 91 | * @author :liyuhang |
| 99 | * @method | 92 | * @method |
| 100 | */ | 93 | */ |
| @@ -110,7 +103,6 @@ class ProjectRoleController extends BaseController | @@ -110,7 +103,6 @@ class ProjectRoleController extends BaseController | ||
| 110 | 103 | ||
| 111 | /** | 104 | /** |
| 112 | * @name :删除角色 | 105 | * @name :删除角色 |
| 113 | - * @return void | ||
| 114 | * @author :liyuhang | 106 | * @author :liyuhang |
| 115 | * @method | 107 | * @method |
| 116 | */ | 108 | */ |
| @@ -17,7 +17,6 @@ class UserController extends BaseController | @@ -17,7 +17,6 @@ class UserController extends BaseController | ||
| 17 | { | 17 | { |
| 18 | /** | 18 | /** |
| 19 | * @name :name | 19 | * @name :name |
| 20 | - * @return void | ||
| 21 | * @author :liyuhang | 20 | * @author :liyuhang |
| 22 | * @method | 21 | * @method |
| 23 | */ | 22 | */ |
| @@ -41,7 +40,6 @@ class UserController extends BaseController | @@ -41,7 +40,6 @@ class UserController extends BaseController | ||
| 41 | 40 | ||
| 42 | /** | 41 | /** |
| 43 | * @name :添加管理员 | 42 | * @name :添加管理员 |
| 44 | - * @return void | ||
| 45 | * @author :liyuhang | 43 | * @author :liyuhang |
| 46 | * @method | 44 | * @method |
| 47 | */ | 45 | */ |
| @@ -53,7 +51,6 @@ class UserController extends BaseController | @@ -53,7 +51,6 @@ class UserController extends BaseController | ||
| 53 | 51 | ||
| 54 | /** | 52 | /** |
| 55 | * @name : 编辑管理员 | 53 | * @name : 编辑管理员 |
| 56 | - * @return void | ||
| 57 | * @author :liyuhang | 54 | * @author :liyuhang |
| 58 | * @method | 55 | * @method |
| 59 | */ | 56 | */ |
| @@ -69,7 +66,6 @@ class UserController extends BaseController | @@ -69,7 +66,6 @@ class UserController extends BaseController | ||
| 69 | 66 | ||
| 70 | /** | 67 | /** |
| 71 | * @name :修改当前用户状态 | 68 | * @name :修改当前用户状态 |
| 72 | - * @return void | ||
| 73 | * @author :liyuhang | 69 | * @author :liyuhang |
| 74 | * @method | 70 | * @method |
| 75 | */ | 71 | */ |
| @@ -85,7 +81,6 @@ class UserController extends BaseController | @@ -85,7 +81,6 @@ class UserController extends BaseController | ||
| 85 | 81 | ||
| 86 | /** | 82 | /** |
| 87 | * @name :详情 | 83 | * @name :详情 |
| 88 | - * @return json | ||
| 89 | * @author :liyuhang | 84 | * @author :liyuhang |
| 90 | * @method | 85 | * @method |
| 91 | */ | 86 | */ |
| @@ -100,7 +95,6 @@ class UserController extends BaseController | @@ -100,7 +95,6 @@ class UserController extends BaseController | ||
| 100 | } | 95 | } |
| 101 | /** | 96 | /** |
| 102 | * @name :删除管理员 | 97 | * @name :删除管理员 |
| 103 | - * @return json | ||
| 104 | * @author :liyuhang | 98 | * @author :liyuhang |
| 105 | * @method | 99 | * @method |
| 106 | */ | 100 | */ |
| @@ -108,8 +108,13 @@ class FileController | @@ -108,8 +108,13 @@ class FileController | ||
| 108 | echo $content; | 108 | echo $content; |
| 109 | exit; | 109 | exit; |
| 110 | } | 110 | } |
| 111 | + | ||
| 111 | /** | 112 | /** |
| 112 | - * 图片上传 | 113 | + * @remark :上传文件 |
| 114 | + * @name :upload | ||
| 115 | + * @author :lyh | ||
| 116 | + * @method :post | ||
| 117 | + * @time :2023/6/17 16:32 | ||
| 113 | */ | 118 | */ |
| 114 | public function upload() { | 119 | public function upload() { |
| 115 | $this->request->validate([ | 120 | $this->request->validate([ |
| @@ -129,11 +134,14 @@ class FileController | @@ -129,11 +134,14 @@ class FileController | ||
| 129 | return $this->single($files); | 134 | return $this->single($files); |
| 130 | } | 135 | } |
| 131 | } | 136 | } |
| 137 | + | ||
| 132 | /** | 138 | /** |
| 133 | - * @name :上传 | ||
| 134 | - * @return void | ||
| 135 | - * @author :liyuhang | ||
| 136 | - * @method | 139 | + * @param $files |
| 140 | + * @remark :单文件上传 | ||
| 141 | + * @name :single | ||
| 142 | + * @author :lyh | ||
| 143 | + * @method :post | ||
| 144 | + * @time :2023/6/17 16:32 | ||
| 137 | */ | 145 | */ |
| 138 | public function single($files){ | 146 | public function single($files){ |
| 139 | $hash = hash_file('md5', $files->getPathname()); | 147 | $hash = hash_file('md5', $files->getPathname()); |
| @@ -162,10 +170,14 @@ class FileController | @@ -162,10 +170,14 @@ class FileController | ||
| 162 | } | 170 | } |
| 163 | return $this->response('资源',Code::SUCCESS,['file'=>$hash]); | 171 | return $this->response('资源',Code::SUCCESS,['file'=>$hash]); |
| 164 | } | 172 | } |
| 173 | + | ||
| 165 | /** | 174 | /** |
| 166 | - * 多文件上传 | ||
| 167 | - * @param type $files file对象集合 | ||
| 168 | - * @return type | 175 | + * @param $files |
| 176 | + * @remark :多文件上传 | ||
| 177 | + * @name :multi | ||
| 178 | + * @author :lyh | ||
| 179 | + * @method :post | ||
| 180 | + * @time :2023/6/17 16:32 | ||
| 169 | */ | 181 | */ |
| 170 | private function multi($files) { | 182 | private function multi($files) { |
| 171 | if (!is_array($files)) { | 183 | if (!is_array($files)) { |
| @@ -199,11 +211,18 @@ class FileController | @@ -199,11 +211,18 @@ class FileController | ||
| 199 | $fileModel->insert($save_data); | 211 | $fileModel->insert($save_data); |
| 200 | return $this->response('资源',Code::SUCCESS,['file'=>$data]); | 212 | return $this->response('资源',Code::SUCCESS,['file'=>$data]); |
| 201 | } | 213 | } |
| 214 | + | ||
| 202 | /** | 215 | /** |
| 203 | - * @name 统一返回参数 | ||
| 204 | - * @return JsonResponse | ||
| 205 | - * @author :liyuhang | ||
| 206 | - * @method | 216 | + * @param $msg |
| 217 | + * @param string $code | ||
| 218 | + * @param $data | ||
| 219 | + * @param $result_code | ||
| 220 | + * @param $type | ||
| 221 | + * @remark :统一返回接口 | ||
| 222 | + * @name :response | ||
| 223 | + * @author :lyh | ||
| 224 | + * @method :post | ||
| 225 | + * @time :2023/6/17 16:33 | ||
| 207 | */ | 226 | */ |
| 208 | public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse | 227 | public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse |
| 209 | { | 228 | { |
| @@ -220,10 +239,11 @@ class FileController | @@ -220,10 +239,11 @@ class FileController | ||
| 220 | 239 | ||
| 221 | /** | 240 | /** |
| 222 | * @param $data | 241 | * @param $data |
| 223 | - * @name :返回参数处理 | ||
| 224 | - * @return array|string | ||
| 225 | - * @author :liyuhang | ||
| 226 | - * @method | 242 | + * @remark :参数处理 |
| 243 | + * @name :_extents | ||
| 244 | + * @author :lyh | ||
| 245 | + * @method :post | ||
| 246 | + * @time :2023/6/17 16:32 | ||
| 227 | */ | 247 | */ |
| 228 | protected function _extents($data) { | 248 | protected function _extents($data) { |
| 229 | 249 | ||
| @@ -240,13 +260,7 @@ class FileController | @@ -240,13 +260,7 @@ class FileController | ||
| 240 | } | 260 | } |
| 241 | switch ((string) $k) { | 261 | switch ((string) $k) { |
| 242 | case 'file': | 262 | case 'file': |
| 243 | - $data['file_link'] = url('/b/file_hash/' . $v .'/'.rand(100,999)); | ||
| 244 | - break; | ||
| 245 | - case 'files': | ||
| 246 | - $v = explode(',',$v); | ||
| 247 | - foreach ($v as $k1=>$v1){ | ||
| 248 | - $data['files_link'][$k1] = url('/b/file_hash/' . $v1 . '/'.rand(100,999)); | ||
| 249 | - } | 263 | + $data['file_link'] = url('/b/file_hash/'.$v); |
| 250 | break; | 264 | break; |
| 251 | } | 265 | } |
| 252 | } | 266 | } |
| @@ -91,7 +91,10 @@ class ImageController | @@ -91,7 +91,10 @@ class ImageController | ||
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | /** | 93 | /** |
| 94 | - * 图片上传 | 94 | + * @name :(图片上传)upload |
| 95 | + * @author :lyh | ||
| 96 | + * @method :post | ||
| 97 | + * @time :2023/6/17 16:28 | ||
| 95 | */ | 98 | */ |
| 96 | public function upload() { | 99 | public function upload() { |
| 97 | $this->request->validate([ | 100 | $this->request->validate([ |
| @@ -112,10 +115,12 @@ class ImageController | @@ -112,10 +115,12 @@ class ImageController | ||
| 112 | } | 115 | } |
| 113 | 116 | ||
| 114 | /** | 117 | /** |
| 115 | - * @name :上传图片 | ||
| 116 | - * @return void | ||
| 117 | - * @author :liyuhang | ||
| 118 | - * @method | 118 | + * @param $files |
| 119 | + * @remark :单图片上传 | ||
| 120 | + * @name :single | ||
| 121 | + * @author :lyh | ||
| 122 | + * @method :post | ||
| 123 | + * @time :2023/6/17 16:30 | ||
| 119 | */ | 124 | */ |
| 120 | public function single($files){ | 125 | public function single($files){ |
| 121 | $hash = hash_file('md5', $files->getPathname()); | 126 | $hash = hash_file('md5', $files->getPathname()); |
| @@ -144,12 +149,16 @@ class ImageController | @@ -144,12 +149,16 @@ class ImageController | ||
| 144 | } | 149 | } |
| 145 | return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]); | 150 | return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]); |
| 146 | } | 151 | } |
| 152 | + | ||
| 147 | /** | 153 | /** |
| 148 | - * 生成缩略图缓存 | ||
| 149 | - * @param type $info | ||
| 150 | - * @param type $w | ||
| 151 | - * @param type $h | ||
| 152 | - * @return string | 154 | + * @param $info |
| 155 | + * @param $w | ||
| 156 | + * @param $h | ||
| 157 | + * @remark :生成缩略图 | ||
| 158 | + * @name :cacheImage | ||
| 159 | + * @author :lyh | ||
| 160 | + * @method :post | ||
| 161 | + * @time :2023/6/17 16:31 | ||
| 153 | */ | 162 | */ |
| 154 | private function cacheImage($info, $w, $h) { | 163 | private function cacheImage($info, $w, $h) { |
| 155 | $path = $info['path']; | 164 | $path = $info['path']; |
| @@ -159,9 +168,12 @@ class ImageController | @@ -159,9 +168,12 @@ class ImageController | ||
| 159 | } | 168 | } |
| 160 | 169 | ||
| 161 | /** | 170 | /** |
| 162 | - * 多图片上传 | ||
| 163 | - * @param type $files file对象集合 | ||
| 164 | - * @return type | 171 | + * @param $files |
| 172 | + * @remark :多图片上传 | ||
| 173 | + * @name :multi | ||
| 174 | + * @author :lyh | ||
| 175 | + * @method :post | ||
| 176 | + * @time :2023/6/17 16:31 | ||
| 165 | */ | 177 | */ |
| 166 | private function multi($files) { | 178 | private function multi($files) { |
| 167 | 179 |
| @@ -5,7 +5,7 @@ namespace App\Http\Logic\Aside; | @@ -5,7 +5,7 @@ namespace App\Http\Logic\Aside; | ||
| 5 | 5 | ||
| 6 | use App\Enums\Common\Common; | 6 | use App\Enums\Common\Common; |
| 7 | use App\Http\Logic\Logic; | 7 | use App\Http\Logic\Logic; |
| 8 | -use Illuminate\Support\Facades\Session; | 8 | +use Illuminate\Support\Facades\Cache; |
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 | 11 | * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 |
| @@ -18,12 +18,9 @@ class BaseLogic extends Logic | @@ -18,12 +18,9 @@ class BaseLogic extends Logic | ||
| 18 | 18 | ||
| 19 | protected $side = Common::A; | 19 | protected $side = Common::A; |
| 20 | 20 | ||
| 21 | - protected $user = []; | ||
| 22 | - | ||
| 23 | public function __construct() | 21 | public function __construct() |
| 24 | { | 22 | { |
| 25 | $this->requestAll = request()->all(); | 23 | $this->requestAll = request()->all(); |
| 26 | - $this->user = Session::get('manage'); | ||
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | 26 |
| @@ -25,8 +25,6 @@ class ServerInformationLogic extends BaseLogic | @@ -25,8 +25,6 @@ class ServerInformationLogic extends BaseLogic | ||
| 25 | { | 25 | { |
| 26 | parent::__construct(); | 26 | parent::__construct(); |
| 27 | 27 | ||
| 28 | - $this->model = new ServerInformation(); | ||
| 29 | - | ||
| 30 | $this->param = $this->requestAll; | 28 | $this->param = $this->requestAll; |
| 31 | 29 | ||
| 32 | } | 30 | } |
| @@ -41,23 +39,22 @@ class ServerInformationLogic extends BaseLogic | @@ -41,23 +39,22 @@ class ServerInformationLogic extends BaseLogic | ||
| 41 | { | 39 | { |
| 42 | $request = $this->param ?? []; | 40 | $request = $this->param ?? []; |
| 43 | $service = new ServerInformation(); | 41 | $service = new ServerInformation(); |
| 44 | - $this->extracted( $request, $service ); | ||
| 45 | - if ( $this->checkIp( $service->ip ) ) { | ||
| 46 | - return $this->fail( '服务器信息添加失败,ip已存在' ); | 42 | + $this->extracted($request, $service, $service->FieldsArray()); |
| 43 | + if ($this->checkIp($request['ip'])) { | ||
| 44 | + return $this->fail('服务器信息添加失败,ip已存在'); | ||
| 47 | } | 45 | } |
| 48 | DB::beginTransaction(); | 46 | DB::beginTransaction(); |
| 49 | - | ||
| 50 | - if ( $service->save() ) { | ||
| 51 | - $original = $service->getOriginal(); | ||
| 52 | - $original['type'] = $request['type']; | 47 | + if ($service->save()) { |
| 48 | + $original = $service->getOriginal(); | ||
| 49 | + $original['type'] = $request['type']; | ||
| 53 | $original['belong_to'] = $request['belong_to']; | 50 | $original['belong_to'] = $request['belong_to']; |
| 54 | // 添加日志 | 51 | // 添加日志 |
| 55 | - $this->server_action_log( ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id ); | 52 | + $this->server_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id); |
| 56 | DB::commit(); | 53 | DB::commit(); |
| 57 | return $this->success(); | 54 | return $this->success(); |
| 58 | } | 55 | } |
| 59 | DB::rollBack(); | 56 | DB::rollBack(); |
| 60 | - return $this->fail( '服务器信息添加失败' ); | 57 | + return $this->fail('服务器信息添加失败'); |
| 61 | 58 | ||
| 62 | } | 59 | } |
| 63 | 60 | ||
| @@ -69,53 +66,53 @@ class ServerInformationLogic extends BaseLogic | @@ -69,53 +66,53 @@ class ServerInformationLogic extends BaseLogic | ||
| 69 | */ | 66 | */ |
| 70 | public function update() | 67 | public function update() |
| 71 | { | 68 | { |
| 72 | - $service = $this->getService(); | ||
| 73 | - $fields_array = $service->FieldsArray(); | ||
| 74 | - $request = $this->param ?? []; | ||
| 75 | - $original = $service->getOriginal(); | ||
| 76 | - $original['type'] = $service->ServiceStr( $original['type'] ); | ||
| 77 | - $original['belong_to'] = $service->BelongToStr( $original['belong_to'] ); | ||
| 78 | - $this->extracted( $request, $service, $original ); | 69 | + $service = $this->getService(); |
| 70 | + $fields_array = $service->FieldsArray(); | ||
| 71 | + $request = $this->param ?? []; | ||
| 72 | + $original = $service->getOriginal(); | ||
| 73 | + $original['type'] = $service->ServiceStr($original['type']); | ||
| 74 | + $original['belong_to'] = $service->BelongToStr($original['belong_to']); | ||
| 75 | + $this->extracted($request, $service, $original); | ||
| 79 | // 检查ip是否存在 | 76 | // 检查ip是否存在 |
| 80 | - if ( $service->ip != $request['ip'] ) { | ||
| 81 | - if ( $this->checkIp( $request['ip'] ) ) { | ||
| 82 | - $this->fail( '服务器信息修改失败,ip已存在', Code::USER_ERROR ); | 77 | + if ($service->ip != $request['ip']) { |
| 78 | + if ($this->checkIp($request['ip'])) { | ||
| 79 | + $this->fail('服务器信息修改失败,ip已存在', Code::USER_ERROR); | ||
| 83 | } | 80 | } |
| 84 | } | 81 | } |
| 85 | DB::beginTransaction(); | 82 | DB::beginTransaction(); |
| 86 | - if ( $service->save() ) { | 83 | + if ($service->save()) { |
| 87 | $revised = $service->getAttributes(); | 84 | $revised = $service->getAttributes(); |
| 88 | - $diff = array_diff_assoc( $original, $revised ); | ||
| 89 | - unset( $diff['created_at'] ); | ||
| 90 | - unset( $diff['updated_at'] ); | ||
| 91 | - unset( $diff['deleted'] ); | 85 | + $diff = array_diff_assoc($original, $revised); |
| 86 | + unset($diff['created_at']); | ||
| 87 | + unset($diff['updated_at']); | ||
| 88 | + unset($diff['deleted']); | ||
| 92 | $remarks = ''; | 89 | $remarks = ''; |
| 93 | - if ( $diff ) { | 90 | + if ($diff) { |
| 94 | $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:'; | 91 | $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:'; |
| 95 | - foreach ( $diff as $key => $value ) { | 92 | + foreach ($diff as $key => $value) { |
| 96 | $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; '; | 93 | $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; '; |
| 97 | } | 94 | } |
| 98 | } else { | 95 | } else { |
| 99 | $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,无修改'; | 96 | $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,无修改'; |
| 100 | } | 97 | } |
| 101 | // 添加日志 | 98 | // 添加日志 |
| 102 | - $this->server_action_log( ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks ); | 99 | + $this->server_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks); |
| 103 | DB::commit(); | 100 | DB::commit(); |
| 104 | return $this->success(); | 101 | return $this->success(); |
| 105 | } | 102 | } |
| 106 | DB::rollBack(); | 103 | DB::rollBack(); |
| 107 | - return $this->fail( '服务器信息修改失败' ); | 104 | + return $this->fail('服务器信息修改失败'); |
| 108 | } | 105 | } |
| 109 | 106 | ||
| 110 | - public function getService( int $deleted = ServerInformation::DELETED_NORMAL ) | 107 | + public function getService(int $deleted = ServerInformation::DELETED_NORMAL) |
| 111 | { | 108 | { |
| 112 | $id = $this->param['id'] ?? 0; | 109 | $id = $this->param['id'] ?? 0; |
| 113 | - if ( !$id ) { | ||
| 114 | - return $this->fail( 'ID不能为空' ); | 110 | + if (!$id) { |
| 111 | + return $this->fail('ID不能为空'); | ||
| 115 | } | 112 | } |
| 116 | - $data = ServerInformation::query()->where( 'deleted', $deleted )->find( $id ); | ||
| 117 | - if ( !$data ) { | ||
| 118 | - return $this->fail( '数据不存在!' ); | 113 | + $data = ServerInformation::query()->where('deleted', $deleted)->find($id); |
| 114 | + if (!$data) { | ||
| 115 | + return $this->fail('数据不存在!'); | ||
| 119 | } | 116 | } |
| 120 | return $data; | 117 | return $data; |
| 121 | } | 118 | } |
| @@ -125,10 +122,10 @@ class ServerInformationLogic extends BaseLogic | @@ -125,10 +122,10 @@ class ServerInformationLogic extends BaseLogic | ||
| 125 | * @param $ip | 122 | * @param $ip |
| 126 | * @return bool | 123 | * @return bool |
| 127 | */ | 124 | */ |
| 128 | - public function checkIp( $ip ) | 125 | + public function checkIp($ip) |
| 129 | { | 126 | { |
| 130 | - $usIp = ServerInformation::query()->where( 'ip', $ip )->first(); | ||
| 131 | - if ( $usIp ) { | 127 | + $usIp = ServerInformation::query()->where('ip', $ip)->first(); |
| 128 | + if ($usIp) { | ||
| 132 | return true; | 129 | return true; |
| 133 | } else { | 130 | } else { |
| 134 | return false; | 131 | return false; |
| @@ -142,15 +139,15 @@ class ServerInformationLogic extends BaseLogic | @@ -142,15 +139,15 @@ class ServerInformationLogic extends BaseLogic | ||
| 142 | * @throws AsideGlobalException | 139 | * @throws AsideGlobalException |
| 143 | * @throws BsideGlobalException | 140 | * @throws BsideGlobalException |
| 144 | */ | 141 | */ |
| 145 | - public function serverInfo( int $deleted = ServerInformation::DELETED_NORMAL ) | 142 | + public function serverInfo(int $deleted = ServerInformation::DELETED_NORMAL) |
| 146 | { | 143 | { |
| 147 | $id = $this->param['id'] ?? 0; | 144 | $id = $this->param['id'] ?? 0; |
| 148 | - if ( !$id ) { | ||
| 149 | - return $this->fail( 'ID不能为空' ); | 145 | + if (!$id) { |
| 146 | + return $this->fail('ID不能为空'); | ||
| 150 | } | 147 | } |
| 151 | - $data = ServerInformation::query()->where( 'deleted', $deleted )->find( $id, [ 'type', 'ip', 'title', 'belong_to', 'ports', 'created_at', 'updated_at' ] ); | ||
| 152 | - if ( !$data ) { | ||
| 153 | - return $this->fail( '数据不存在!' ); | 148 | + $data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'ports', 'created_at', 'updated_at']); |
| 149 | + if (!$data) { | ||
| 150 | + return $this->fail('数据不存在!'); | ||
| 154 | } | 151 | } |
| 155 | return $data; | 152 | return $data; |
| 156 | } | 153 | } |
| @@ -161,25 +158,25 @@ class ServerInformationLogic extends BaseLogic | @@ -161,25 +158,25 @@ class ServerInformationLogic extends BaseLogic | ||
| 161 | * @param array $original 原始数据 | 158 | * @param array $original 原始数据 |
| 162 | * @param array $revised 修改后数据 | 159 | * @param array $revised 修改后数据 |
| 163 | */ | 160 | */ |
| 164 | - public function server_action_log( int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '' ) | 161 | + public function server_action_log(int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '') |
| 165 | { | 162 | { |
| 166 | $log = new ServerInformationLog(); | 163 | $log = new ServerInformationLog(); |
| 167 | - $this->log( $log, $action, $original, $revised, $remarks ); | 164 | + $this->log($log, $action, $original, $revised, $remarks); |
| 168 | } | 165 | } |
| 169 | 166 | ||
| 170 | /** | 167 | /** |
| 168 | + * 提取数据 | ||
| 171 | * @param array $request | 169 | * @param array $request |
| 172 | - * @param $service | 170 | + * @param $service |
| 171 | + * @param array $original | ||
| 173 | * @return void | 172 | * @return void |
| 174 | */ | 173 | */ |
| 175 | - public function extracted( array $request, $service, array $original = [] ) | 174 | + public function extracted(array $request, $service, array $original) |
| 176 | { | 175 | { |
| 177 | - $service->type = trim( $request['type'] ) ?? $original['type']; // 服务器类型 | ||
| 178 | - $service->ip = trim( $request['ip'] ) ?? $original['ip']; // 服务器ip | ||
| 179 | - $service->title = trim( $request['title'] ) ?? $original['title']; // 服务器标题 | ||
| 180 | - $service->belong_to = trim( $request['belong_to'] ) ?? $original['belong_to']; // 服务器归属 | ||
| 181 | - $service->sshpass = trim( $request['sshpass'] ) ?? $original['sshpass']; // ssh密码 | ||
| 182 | - $service->ports = trim( $request['ports'] ) ?? $original['ports']; // ssh端口 | 176 | + $request = array_intersect_key($request, $original); |
| 177 | + foreach ($request as $key => $value) { | ||
| 178 | + $service->$key = trim($value) ?? $original[$key]; | ||
| 179 | + } | ||
| 183 | } | 180 | } |
| 184 | 181 | ||
| 185 | /** | 182 | /** |
| @@ -188,27 +185,27 @@ class ServerInformationLogic extends BaseLogic | @@ -188,27 +185,27 @@ class ServerInformationLogic extends BaseLogic | ||
| 188 | * @throws AsideGlobalException | 185 | * @throws AsideGlobalException |
| 189 | * @throws BsideGlobalException | 186 | * @throws BsideGlobalException |
| 190 | */ | 187 | */ |
| 191 | - public function get_batch_update( $action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL ) | 188 | + public function get_batch_update($action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL) |
| 192 | { | 189 | { |
| 193 | - $ids = $this->getIds(); | ||
| 194 | - $data = ServerInformation::query()->whereIn( 'id', $ids )->where( 'deleted', $deleted )->get(); | ||
| 195 | - $restore_ids = $data->pluck( 'id' )->toArray(); | ||
| 196 | - $actionArr = ServerInformationLog::actionArr(); | ||
| 197 | - $actionStr = $actionArr[$action]; | ||
| 198 | - if ( empty( $restore_ids ) ) { | ||
| 199 | - $this->fail( $actionStr . '服务器信息不存在!', Code::USER_ERROR ); | 190 | + $ids = $this->getIds(); |
| 191 | + $data = ServerInformation::query()->whereIn('id', $ids)->where('deleted', $deleted)->get(); | ||
| 192 | + $restore_ids = $data->pluck('id')->toArray(); | ||
| 193 | + $actionArr = ServerInformationLog::actionArr(); | ||
| 194 | + $actionStr = $actionArr[$action]; | ||
| 195 | + if (empty($restore_ids)) { | ||
| 196 | + $this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR); | ||
| 200 | } | 197 | } |
| 201 | $original = $data->toArray(); | 198 | $original = $data->toArray(); |
| 202 | DB::beginTransaction(); | 199 | DB::beginTransaction(); |
| 203 | try { | 200 | try { |
| 204 | $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL; | 201 | $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL; |
| 205 | - ServerInformation::query()->whereIn( 'id', $restore_ids )->update( [ 'deleted' => $update ] ); | ||
| 206 | - $this->server_action_log( $action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode( ', ', $restore_ids ) ); | 202 | + ServerInformation::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]); |
| 203 | + $this->server_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids)); | ||
| 207 | DB::commit(); | 204 | DB::commit(); |
| 208 | return $this->success(); | 205 | return $this->success(); |
| 209 | - } catch ( \Exception $e ) { | 206 | + } catch (\Exception $e) { |
| 210 | DB::rollBack(); | 207 | DB::rollBack(); |
| 211 | - return $this->fail( '服务器信息' . $actionStr . '失败', Code::USER_ERROR ); | 208 | + return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR); |
| 212 | } | 209 | } |
| 213 | } | 210 | } |
| 214 | 211 | ||
| @@ -221,16 +218,16 @@ class ServerInformationLogic extends BaseLogic | @@ -221,16 +218,16 @@ class ServerInformationLogic extends BaseLogic | ||
| 221 | public function getIds() | 218 | public function getIds() |
| 222 | { | 219 | { |
| 223 | $id = $this->param['id'] ?? 0; | 220 | $id = $this->param['id'] ?? 0; |
| 224 | - if ( !$id ) { | ||
| 225 | - return $this->fail( '参数错误' ); | 221 | + if (!$id) { |
| 222 | + return $this->fail('参数错误'); | ||
| 226 | } | 223 | } |
| 227 | $ids = []; | 224 | $ids = []; |
| 228 | - if ( !is_array( $id ) ) { | ||
| 229 | - $ids = explode( ',', $id ); | 225 | + if (!is_array($id)) { |
| 226 | + $ids = explode(',', $id); | ||
| 230 | } | 227 | } |
| 231 | - $ids = array_filter( $ids, 'intval' ); | ||
| 232 | - if ( empty( $ids ) ) { | ||
| 233 | - return $this->fail( '参数错误' ); | 228 | + $ids = array_filter($ids, 'intval'); |
| 229 | + if (empty($ids)) { | ||
| 230 | + return $this->fail('参数错误'); | ||
| 234 | } | 231 | } |
| 235 | return $ids; | 232 | return $ids; |
| 236 | } | 233 | } |
| @@ -10,7 +10,8 @@ use App\Http\Logic\Aside\BaseLogic; | @@ -10,7 +10,8 @@ use App\Http\Logic\Aside\BaseLogic; | ||
| 10 | use App\Http\Logic\Aside\Devops\ServerInformationLogic; | 10 | use App\Http\Logic\Aside\Devops\ServerInformationLogic; |
| 11 | use App\Models\Aside\Domain\DomainInfo; | 11 | use App\Models\Aside\Domain\DomainInfo; |
| 12 | use App\Models\Aside\Domain\DomainInfoLog; | 12 | use App\Models\Aside\Domain\DomainInfoLog; |
| 13 | -use App\Models\Devops\ServerInformation; | 13 | +use GuzzleHttp\Client; |
| 14 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 14 | use Illuminate\Database\Eloquent\Builder; | 15 | use Illuminate\Database\Eloquent\Builder; |
| 15 | use Illuminate\Database\Eloquent\Collection; | 16 | use Illuminate\Database\Eloquent\Collection; |
| 16 | use Illuminate\Database\Eloquent\Model; | 17 | use Illuminate\Database\Eloquent\Model; |
| @@ -27,8 +28,6 @@ class DomainInfoLogic extends BaseLogic | @@ -27,8 +28,6 @@ class DomainInfoLogic extends BaseLogic | ||
| 27 | { | 28 | { |
| 28 | parent::__construct(); | 29 | parent::__construct(); |
| 29 | 30 | ||
| 30 | - $this->model = new ServerInformation(); | ||
| 31 | - | ||
| 32 | $this->param = $this->requestAll; | 31 | $this->param = $this->requestAll; |
| 33 | 32 | ||
| 34 | } | 33 | } |
| @@ -46,12 +45,12 @@ class DomainInfoLogic extends BaseLogic | @@ -46,12 +45,12 @@ class DomainInfoLogic extends BaseLogic | ||
| 46 | return $this->fail('域名已存在!'); | 45 | return $this->fail('域名已存在!'); |
| 47 | } | 46 | } |
| 48 | $domain = new DomainInfo(); | 47 | $domain = new DomainInfo(); |
| 49 | - $this->extracted($request, $domain); | 48 | + $this->extracted($request, $domain, $domain->FieldsArray()); |
| 50 | DB::beginTransaction(); | 49 | DB::beginTransaction(); |
| 51 | if ($domain->save()) { | 50 | if ($domain->save()) { |
| 52 | - $original = $domain->getOriginal(); | 51 | + $original = $domain->getOriginal(); |
| 53 | $original['belong_to'] = $request['belong_to']; | 52 | $original['belong_to'] = $request['belong_to']; |
| 54 | - $original['status'] = $request['status']; | 53 | + $original['status'] = $request['status']; |
| 55 | // 添加日志 | 54 | // 添加日志 |
| 56 | $this->domain_action_log(DomainInfoLog::ACTION_ADD, $original, $original, '添加域名信息成功 - ID : ' . $domain->id); | 55 | $this->domain_action_log(DomainInfoLog::ACTION_ADD, $original, $original, '添加域名信息成功 - ID : ' . $domain->id); |
| 57 | DB::commit(); | 56 | DB::commit(); |
| @@ -70,23 +69,25 @@ class DomainInfoLogic extends BaseLogic | @@ -70,23 +69,25 @@ class DomainInfoLogic extends BaseLogic | ||
| 70 | */ | 69 | */ |
| 71 | public function update() | 70 | public function update() |
| 72 | { | 71 | { |
| 73 | - $domain = $this->getDomain(); | ||
| 74 | - $original = $domain->getOriginal(); | 72 | + $domain = $this->getDomain(); |
| 73 | + $original = $domain->getOriginal(); | ||
| 75 | $original['belong_to'] = $domain->BelongToStr($original['belong_to']); | 74 | $original['belong_to'] = $domain->BelongToStr($original['belong_to']); |
| 76 | - $original['status'] = $domain->StatusToStr($original['status']); | ||
| 77 | - $request = $this->param; | 75 | + $original['status'] = $domain->StatusToStr($original['status']); |
| 76 | + $request = $this->param; | ||
| 78 | $this->extracted($request, $domain, $original); | 77 | $this->extracted($request, $domain, $original); |
| 79 | // 检查ip是否存在 | 78 | // 检查ip是否存在 |
| 80 | - if ($domain->domain != $request['domain']) { | ||
| 81 | - if ($this->checkDomain($request['domain'])) { | ||
| 82 | - $this->fail('域名信息修改失败,域名已存在', Code::USER_ERROR); | 79 | + if (array_key_exists('domain', $request)) { |
| 80 | + if ($domain->domain != $request['domain']) { | ||
| 81 | + if ($this->checkDomain($request['domain'])) { | ||
| 82 | + $this->fail('域名信息修改失败,域名已存在', Code::USER_ERROR); | ||
| 83 | + } | ||
| 83 | } | 84 | } |
| 84 | } | 85 | } |
| 85 | DB::beginTransaction(); | 86 | DB::beginTransaction(); |
| 86 | if ($domain->save()) { | 87 | if ($domain->save()) { |
| 87 | $fields_array = $domain->FieldsArray(); | 88 | $fields_array = $domain->FieldsArray(); |
| 88 | - $revised = $domain->getAttributes(); | ||
| 89 | - $diff = array_diff_assoc($original, $revised); | 89 | + $revised = $domain->getAttributes(); |
| 90 | + $diff = array_diff_assoc($original, $revised); | ||
| 90 | unset($diff['created_at']); | 91 | unset($diff['created_at']); |
| 91 | unset($diff['updated_at']); | 92 | unset($diff['updated_at']); |
| 92 | unset($diff['deleted']); | 93 | unset($diff['deleted']); |
| @@ -179,21 +180,13 @@ class DomainInfoLogic extends BaseLogic | @@ -179,21 +180,13 @@ class DomainInfoLogic extends BaseLogic | ||
| 179 | * @param $domain | 180 | * @param $domain |
| 180 | * @param array $original | 181 | * @param array $original |
| 181 | * @return void | 182 | * @return void |
| 182 | - * @throws AsideGlobalException | ||
| 183 | - * @throws BsideGlobalException | ||
| 184 | */ | 183 | */ |
| 185 | - public function extracted( array $request, $domain, array $original = []) | 184 | + public function extracted(array $request, $domain, array $original) |
| 186 | { | 185 | { |
| 187 | - $domain->domain = trim($request['domain']) ?? $original['domain']; | ||
| 188 | - if (!$this->validateDomain($domain->domain)) { | ||
| 189 | - $this->fail('域名格式错误'); | 186 | + $request = array_intersect_key($request, $original); |
| 187 | + foreach ($request as $key => $value) { | ||
| 188 | + $domain->$key = trim($value) ?? $original[$key]; | ||
| 190 | } | 189 | } |
| 191 | - $domain->belong_to = trim($request['belong_to']) ?? $original['belong_to']; // 域名归属 1 - 公司 2 - 客户 | ||
| 192 | - $domain->status = trim($request['status']) ?? $original['status']; // 域名状态 0 - 正常 1 - 关闭 | ||
| 193 | - $domain->domain_start_time = trim($request['domain_start_time']) ?? $original['domain_start_time']; // 域名开始时间 | ||
| 194 | - $domain->domain_end_time = trim($request['domain_end_time']) ?? $original['domain_end_time']; | ||
| 195 | - $domain->certificate_start_time = trim($request['certificate_start_time']) ?? $original['certificate_start_time']; // 证书开始时间 | ||
| 196 | - $domain->certificate_end_time = trim($request['certificate_end_time']) ?? $original['certificate_end_time']; // 证书结束时间 | ||
| 197 | } | 190 | } |
| 198 | 191 | ||
| 199 | /** | 192 | /** |
| @@ -204,11 +197,11 @@ class DomainInfoLogic extends BaseLogic | @@ -204,11 +197,11 @@ class DomainInfoLogic extends BaseLogic | ||
| 204 | */ | 197 | */ |
| 205 | public function get_batch_update($action = DomainInfoLog::ACTION_DELETE, $deleted = DomainInfo::DELETED_NORMAL) | 198 | public function get_batch_update($action = DomainInfoLog::ACTION_DELETE, $deleted = DomainInfo::DELETED_NORMAL) |
| 206 | { | 199 | { |
| 207 | - $ids = (new ServerInformationLogic())->getIds(); | ||
| 208 | - $data = DomainInfo::query()->whereIn('id', $ids)->where('deleted', $deleted)->get(); | 200 | + $ids = (new ServerInformationLogic())->getIds(); |
| 201 | + $data = DomainInfo::query()->whereIn('id', $ids)->where('deleted', $deleted)->get(); | ||
| 209 | $restore_ids = $data->pluck('id')->toArray(); | 202 | $restore_ids = $data->pluck('id')->toArray(); |
| 210 | - $actionArr = DomainInfoLog::actionArr(); | ||
| 211 | - $actionStr = $actionArr[$action]; | 203 | + $actionArr = DomainInfoLog::actionArr(); |
| 204 | + $actionStr = $actionArr[$action]; | ||
| 212 | if (empty($restore_ids)) { | 205 | if (empty($restore_ids)) { |
| 213 | $this->fail($actionStr . '域名信息不存在!', Code::USER_ERROR); | 206 | $this->fail($actionStr . '域名信息不存在!', Code::USER_ERROR); |
| 214 | } | 207 | } |
| @@ -232,18 +225,18 @@ class DomainInfoLogic extends BaseLogic | @@ -232,18 +225,18 @@ class DomainInfoLogic extends BaseLogic | ||
| 232 | */ | 225 | */ |
| 233 | public function getDomainCertificateTime($domain) | 226 | public function getDomainCertificateTime($domain) |
| 234 | { | 227 | { |
| 235 | - $domain = trim($domain); | ||
| 236 | - $data = []; | 228 | + $domain = trim($domain); |
| 229 | + $data = []; | ||
| 237 | $context = stream_context_create(['ssl' => ['capture_peer_cert' => true]]); // Notice: only 7.0.7+ supports this | 230 | $context = stream_context_create(['ssl' => ['capture_peer_cert' => true]]); // Notice: only 7.0.7+ supports this |
| 238 | - $stream = stream_socket_client("ssl://$domain:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); | 231 | + $stream = stream_socket_client("ssl://$domain:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); |
| 239 | if ($stream) { | 232 | if ($stream) { |
| 240 | - $params = stream_context_get_params($stream); | 233 | + $params = stream_context_get_params($stream); |
| 241 | $peerCertificate = openssl_x509_parse($params['options']['ssl']['peer_certificate']); | 234 | $peerCertificate = openssl_x509_parse($params['options']['ssl']['peer_certificate']); |
| 242 | if ($peerCertificate) { | 235 | if ($peerCertificate) { |
| 243 | - $validFrom = date_create_from_format('U', $peerCertificate['validFrom_time_t']); // 有效期开始时间 | ||
| 244 | - $validTo = date_create_from_format('U', $peerCertificate['validTo_time_t']); // 有效期结束时间 | 236 | + $validFrom = date_create_from_format('U', $peerCertificate['validFrom_time_t']); // 有效期开始时间 |
| 237 | + $validTo = date_create_from_format('U', $peerCertificate['validTo_time_t']); // 有效期结束时间 | ||
| 245 | $data['validFrom'] = $validFrom->format('Y-m-d H:i:s'); | 238 | $data['validFrom'] = $validFrom->format('Y-m-d H:i:s'); |
| 246 | - $data['validTo'] = $validTo->format('Y-m-d H:i:s'); | 239 | + $data['validTo'] = $validTo->format('Y-m-d H:i:s'); |
| 247 | } | 240 | } |
| 248 | } | 241 | } |
| 249 | return $data; | 242 | return $data; |
| @@ -256,60 +249,38 @@ class DomainInfoLogic extends BaseLogic | @@ -256,60 +249,38 @@ class DomainInfoLogic extends BaseLogic | ||
| 256 | public function getAllDomain() | 249 | public function getAllDomain() |
| 257 | { | 250 | { |
| 258 | return DomainInfo::query()->where('status', 1) | 251 | return DomainInfo::query()->where('status', 1) |
| 259 | - ->where('deleted', DomainInfo::DELETED_NORMAL) | ||
| 260 | - ->orderBy('updated_at', 'desc') | ||
| 261 | - ->get(); | 252 | + ->where('deleted', DomainInfo::DELETED_NORMAL) |
| 253 | + ->orderBy('updated_at', 'desc') | ||
| 254 | + ->get(); | ||
| 262 | } | 255 | } |
| 263 | 256 | ||
| 264 | /** | 257 | /** |
| 265 | * 域名到期时间 | 258 | * 域名到期时间 |
| 259 | + * @param $domain | ||
| 266 | * @return array | 260 | * @return array |
| 261 | + * @throws GuzzleException | ||
| 267 | */ | 262 | */ |
| 268 | public function getDomainTime($domain) | 263 | public function getDomainTime($domain) |
| 269 | { | 264 | { |
| 270 | - $conJson = file_get_contents("http://openai.waimaoq.com/v1/whois_api?domain={$domain}"); | ||
| 271 | - $conArr = json_decode($conJson, true); | ||
| 272 | - $data = []; | ||
| 273 | - if ($conArr['code'] == 200) { | ||
| 274 | - $con = $conArr['text']; | ||
| 275 | - $data['domain'] = $domain; | 265 | + $url = "http://openai.waimaoq.com/v1/whois_api?domain={$domain}"; |
| 266 | + $client = new Client(['verify' => false]); | ||
| 267 | + $http = $client->get($url); | ||
| 268 | + $data = []; | ||
| 269 | + if ($http->getStatusCode() != 200) { | ||
| 270 | + return $data; | ||
| 271 | + } | ||
| 272 | + $content = $http->getBody()->getContents(); | ||
| 273 | + $json = json_decode($content, true); | ||
| 274 | + if ($json['code'] == 200) { | ||
| 275 | + $con = $json['text']; | ||
| 276 | + $data['domain'] = $domain; | ||
| 276 | $data['validFrom'] = $con['creation_date']; | 277 | $data['validFrom'] = $con['creation_date']; |
| 277 | - $data['validTo'] = $con['expiration_date']; | 278 | + $data['validTo'] = $con['expiration_date']; |
| 278 | } | 279 | } |
| 279 | return $data; | 280 | return $data; |
| 280 | } | 281 | } |
| 281 | 282 | ||
| 282 | /** | 283 | /** |
| 283 | - * 验证给定的值是否是有效的域名。 | ||
| 284 | - * | ||
| 285 | - * @param mixed $value | ||
| 286 | - * @return bool | ||
| 287 | - */ | ||
| 288 | - public function validateDomain($value) | ||
| 289 | - { | ||
| 290 | - // 从域中删除任何空间或路径。 | ||
| 291 | - $domain = preg_replace('/\s|\/.*$/', '', $value); | ||
| 292 | - // 验证域是否至少包含一个句点。 | ||
| 293 | - if (strpos($domain, '.') === false) { | ||
| 294 | - return false; | ||
| 295 | - } | ||
| 296 | - // 验证域是否以句点开始或结束。 | ||
| 297 | - if (strpos($domain, '.') === 0 || strrpos($domain, '.') === strlen($domain) - 1) { | ||
| 298 | - return false; | ||
| 299 | - } | ||
| 300 | - // 验证域是否不包含无效字符。 | ||
| 301 | - if (!preg_match('/^[a-zA-Z0-9\-\.]+$/', $domain)) { | ||
| 302 | - return false; | ||
| 303 | - } | ||
| 304 | - // 验证域是否具有有效的顶级域。 | ||
| 305 | - $tld = substr($domain, strrpos($domain, '.') + 1); | ||
| 306 | - if (!in_array($tld, ['com', 'net', 'org'])) { // 如有必要,添加更多TLD。 | ||
| 307 | - return false; | ||
| 308 | - } | ||
| 309 | - return true; | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - /** | ||
| 313 | * 根据域名更新证书到期时间 | 284 | * 根据域名更新证书到期时间 |
| 314 | * @param $id | 285 | * @param $id |
| 315 | * @param $updata | 286 | * @param $updata |
| @@ -2,10 +2,11 @@ | @@ -2,10 +2,11 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Aside; | 3 | namespace App\Http\Logic\Aside; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Common; | ||
| 5 | use App\Models\Manage\Manage; | 6 | use App\Models\Manage\Manage; |
| 6 | use App\Models\Manage\LoginLog; | 7 | use App\Models\Manage\LoginLog; |
| 8 | +use Illuminate\Support\Facades\Cache; | ||
| 7 | use Illuminate\Support\Facades\Hash; | 9 | use Illuminate\Support\Facades\Hash; |
| 8 | -use Illuminate\Support\Facades\Session; | ||
| 9 | 10 | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| @@ -26,8 +27,7 @@ class LoginLogic extends BaseLogic | @@ -26,8 +27,7 @@ class LoginLogic extends BaseLogic | ||
| 26 | 27 | ||
| 27 | public function login() | 28 | public function login() |
| 28 | { | 29 | { |
| 29 | - $manage = $this->model->where('mobile', $this->requestAll['mobile'])->first(); | ||
| 30 | - | 30 | + $manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id')->where('mobile', $this->requestAll['mobile'])->first(); |
| 31 | if (!$manage){ | 31 | if (!$manage){ |
| 32 | $this->fail('登录用户名不存在'); | 32 | $this->fail('登录用户名不存在'); |
| 33 | } | 33 | } |
| @@ -37,21 +37,33 @@ class LoginLogic extends BaseLogic | @@ -37,21 +37,33 @@ class LoginLogic extends BaseLogic | ||
| 37 | if (!Hash::check($this->requestAll['password'], $manage->password)) { | 37 | if (!Hash::check($this->requestAll['password'], $manage->password)) { |
| 38 | $this->fail('登录密码不正确'); | 38 | $this->fail('登录密码不正确'); |
| 39 | } | 39 | } |
| 40 | - Session::put('manage', $manage->toArray()); | ||
| 41 | - | 40 | + if(!empty($manage['token'])){ |
| 41 | + //清除上一次用户缓存 | ||
| 42 | + Cache::pull(Common::MANAGE_TOKEN . $manage['token']); | ||
| 43 | + } | ||
| 44 | + //生成新token | ||
| 45 | + $token = md5(uniqid().$manage['id']); | ||
| 46 | + //存储缓存 | ||
| 47 | + $manage['token'] = $token; | ||
| 48 | + Cache::add(Common::MANAGE_TOKEN . $token,$manage); | ||
| 49 | + //更新用户信息 | ||
| 50 | + $manage->token = $token; | ||
| 51 | + $res = $manage->save(); | ||
| 52 | + if(!$res){ | ||
| 53 | + $this->fail('系统错误,请联系管理员'); | ||
| 54 | + } | ||
| 42 | LoginLog::addLog($manage->id); | 55 | LoginLog::addLog($manage->id); |
| 43 | - | ||
| 44 | - return $this->success(); | 56 | + return $this->success($manage->makeVisible('token')->toArray()); |
| 45 | } | 57 | } |
| 46 | 58 | ||
| 47 | public function logout(){ | 59 | public function logout(){ |
| 48 | - Session::forget('manage'); | ||
| 49 | - return redirect(route('admin.login')); | 60 | + Cache::pull(request()->header('token')); |
| 61 | + return $this->success(); | ||
| 50 | } | 62 | } |
| 51 | 63 | ||
| 52 | public static function manage($field = ''){ | 64 | public static function manage($field = ''){ |
| 53 | - $manage = Session::get('manage'); | ||
| 54 | - $manage = Manage::find(1)->toArray(); | 65 | + $manage = Cache::get(Common::MANAGE_TOKEN . request()->header('token')); |
| 66 | + $manage = Manage::find($manage['id'] ?? 0); | ||
| 55 | if($field){ | 67 | if($field){ |
| 56 | return $manage[$field] ?? ''; | 68 | return $manage[$field] ?? ''; |
| 57 | } | 69 | } |
-
请 注册 或 登录 后发表评论