正在显示
4 个修改的文件
包含
151 行增加
和
3 行删除
| @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Project; | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Project; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | use App\Http\Logic\Aside\Project\GscLogic; | 7 | use App\Http\Logic\Aside\Project\GscLogic; |
| 8 | +use App\Http\Requests\Aside\User\GscRequest; | ||
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| 10 | * @remark :优化gsc账号 | 11 | * @remark :优化gsc账号 |
| @@ -48,4 +49,59 @@ class ProjectGscController extends BaseController | @@ -48,4 +49,59 @@ class ProjectGscController extends BaseController | ||
| 48 | $lists = $gscLogic->DomainLists($this->map,$this->page,$this->row,$this->order); | 49 | $lists = $gscLogic->DomainLists($this->map,$this->page,$this->row,$this->order); |
| 49 | $this->response('success',Code::SUCCESS,$lists); | 50 | $this->response('success',Code::SUCCESS,$lists); |
| 50 | } | 51 | } |
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * @remark :获取gsc账号详情 | ||
| 55 | + * @name :read | ||
| 56 | + * @author :lyh | ||
| 57 | + * @method :post | ||
| 58 | + * @time :2023/6/19 16:55 | ||
| 59 | + */ | ||
| 60 | + public function read(GscLogic $gscLogic){ | ||
| 61 | + $this->request->validate([ | ||
| 62 | + 'gsc_id'=>'required' | ||
| 63 | + ],[ | ||
| 64 | + 'gsc_id.required' => 'GSC账号ID不能为空' | ||
| 65 | + ]); | ||
| 66 | + $info = $gscLogic->GscRead(); | ||
| 67 | + $this->response('success',Code::SUCCESS,$info); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @remark :添加/编辑gsc账号 | ||
| 72 | + * @name :add | ||
| 73 | + * @author :lyh | ||
| 74 | + * @method :post | ||
| 75 | + * @time :2023/6/19 16:28 | ||
| 76 | + */ | ||
| 77 | + public function save(GscRequest $gscRequest,GscLogic $gscLogic){ | ||
| 78 | + if(isset($this->param['id'])){ | ||
| 79 | + $this->request->validate([ | ||
| 80 | + 'id'=>'required' | ||
| 81 | + ],[ | ||
| 82 | + 'id.required' => 'GSC账号ID不能为空' | ||
| 83 | + ]); | ||
| 84 | + } | ||
| 85 | + $gscRequest->validated(); | ||
| 86 | + $gscLogic->GscSave(); | ||
| 87 | + $this->response('success'); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * @remark :逻辑删除gsc账号 | ||
| 92 | + * @name :del | ||
| 93 | + * @author :lyh | ||
| 94 | + * @method :post | ||
| 95 | + * @time :2023/6/19 16:30 | ||
| 96 | + */ | ||
| 97 | + public function del(GscLogic $gscLogic){ | ||
| 98 | + $this->request->validate([ | ||
| 99 | + 'id'=>'required' | ||
| 100 | + ],[ | ||
| 101 | + 'id.required' => 'GSC账号ID不能为空' | ||
| 102 | + ]); | ||
| 103 | + $gscLogic->GscDel(); | ||
| 104 | + $this->response('success'); | ||
| 105 | + } | ||
| 106 | + | ||
| 51 | } | 107 | } |
| @@ -8,10 +8,12 @@ use App\Models\Project\Gsc; | @@ -8,10 +8,12 @@ use App\Models\Project\Gsc; | ||
| 8 | 8 | ||
| 9 | class GscLogic extends BaseLogic | 9 | class GscLogic extends BaseLogic |
| 10 | { | 10 | { |
| 11 | + | ||
| 11 | public function __construct() | 12 | public function __construct() |
| 12 | { | 13 | { |
| 13 | parent::__construct(); | 14 | parent::__construct(); |
| 14 | $this->model = new Gsc(); | 15 | $this->model = new Gsc(); |
| 16 | + $this->param = $this->requestAll; | ||
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | /** | 19 | /** |
| @@ -23,6 +25,14 @@ class GscLogic extends BaseLogic | @@ -23,6 +25,14 @@ class GscLogic extends BaseLogic | ||
| 23 | */ | 25 | */ |
| 24 | public function GscLists($map,$page,$row,$order = 'created_at',$files = ['*']){ | 26 | public function GscLists($map,$page,$row,$order = 'created_at',$files = ['*']){ |
| 25 | $lists = $this->model->lists($map,$page,$row,$order,$files); | 27 | $lists = $this->model->lists($map,$page,$row,$order,$files); |
| 28 | + if(!empty($lists['list'])){ | ||
| 29 | + $domainInfoModel = new DomainInfo(); | ||
| 30 | + foreach ($lists['list'] as $k => $v){ | ||
| 31 | + $lists['list'][$k]['tal'] = $domainInfoModel->formatQuery(['gsc_id'=>$v['id']])->count(); | ||
| 32 | + $lists['list'][$k]['pub'] = $domainInfoModel->formatQuery(['gsc_id'=>$v['id']])->count(); | ||
| 33 | + $lists['list'][$k]['num'] = $lists['list'][$k]['tal'] - $lists['list'][$k]['pub']; | ||
| 34 | + } | ||
| 35 | + } | ||
| 26 | return $this->success($lists); | 36 | return $this->success($lists); |
| 27 | } | 37 | } |
| 28 | 38 | ||
| @@ -34,8 +44,43 @@ class GscLogic extends BaseLogic | @@ -34,8 +44,43 @@ class GscLogic extends BaseLogic | ||
| 34 | * @time :2023/6/19 15:56 | 44 | * @time :2023/6/19 15:56 |
| 35 | */ | 45 | */ |
| 36 | public function DomainLists($map,$page,$row,$order = 'created_at',$files = ['*']){ | 46 | public function DomainLists($map,$page,$row,$order = 'created_at',$files = ['*']){ |
| 37 | - $domainModel = new DomainInfo(); | ||
| 38 | - $lists = $domainModel->lists($map,$page,$row,$order,$files); | 47 | + $domainInfoModel = new DomainInfo(); |
| 48 | + $lists = $domainInfoModel->lists($map,$page,$row,$order,$files); | ||
| 39 | return $this->success($lists); | 49 | return $this->success($lists); |
| 40 | } | 50 | } |
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * @remark :更新账号列表 | ||
| 54 | + * @name :save | ||
| 55 | + * @author :lyh | ||
| 56 | + * @method :post | ||
| 57 | + * @time :2023/6/19 16:21 | ||
| 58 | + */ | ||
| 59 | + public function GscSave(){ | ||
| 60 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 61 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 62 | + }else{ | ||
| 63 | + $rs = $this->model->add($this->param); | ||
| 64 | + } | ||
| 65 | + if($rs === false){ | ||
| 66 | + $this->fail('error'); | ||
| 67 | + } | ||
| 68 | + return $this->success(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * @remark :删除账号列表 | ||
| 73 | + * @name :del | ||
| 74 | + * @author :lyh | ||
| 75 | + * @method :post | ||
| 76 | + * @time :2023/6/19 16:31 | ||
| 77 | + */ | ||
| 78 | + public function GscDel(){ | ||
| 79 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 80 | + $rs = $this->model->del($this->param); | ||
| 81 | + if($rs === false){ | ||
| 82 | + $this->fail('error'); | ||
| 83 | + } | ||
| 84 | + return $this->success(); | ||
| 85 | + } | ||
| 41 | } | 86 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\User; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class GscRequest extends FormRequest | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * Determine if the user is authorized to make this request. | ||
| 11 | + * | ||
| 12 | + * @return bool | ||
| 13 | + */ | ||
| 14 | + public function authorize() | ||
| 15 | + { | ||
| 16 | + return true; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * Get the validation rules that apply to the request. | ||
| 21 | + * | ||
| 22 | + * @return array | ||
| 23 | + */ | ||
| 24 | + public function rules() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + 'account'=>'required|string|regex:/^1[3-9]\d{9}$/', | ||
| 28 | + 'password'=>'required|string', | ||
| 29 | + 'mobile'=>'required|string', | ||
| 30 | + 'remark'=>'required|string', | ||
| 31 | + ]; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public function messages() | ||
| 35 | + { | ||
| 36 | + return [ | ||
| 37 | + 'account.required'=>'名称必须填写', | ||
| 38 | + 'account.regex'=>'请输入正确的手机号', | ||
| 39 | + 'password.required'=>'密码必须填写', | ||
| 40 | + 'mobile.required'=>'手机号码必须填写', | ||
| 41 | + 'remark.required'=>'备注必须填写', | ||
| 42 | + ]; | ||
| 43 | + } | ||
| 44 | +} |
| @@ -97,7 +97,10 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -97,7 +97,10 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 97 | //优化gsc账号记录表 | 97 | //优化gsc账号记录表 |
| 98 | Route::prefix('gsc')->group(function () { | 98 | Route::prefix('gsc')->group(function () { |
| 99 | Route::any('/', [Aside\Project\ProjectGscController::class, 'lists'])->name('admin.lists'); | 99 | Route::any('/', [Aside\Project\ProjectGscController::class, 'lists'])->name('admin.lists'); |
| 100 | - Route::any('/read', [Aside\Project\ProjectGscController::class, 'domainLists'])->name('admin.domainLists'); | 100 | + Route::any('/domainLists', [Aside\Project\ProjectGscController::class, 'domainLists'])->name('admin.domainLists'); |
| 101 | + Route::any('/read', [Aside\Project\ProjectGscController::class, 'read'])->name('admin.read'); | ||
| 102 | + Route::any('/save', [Aside\Project\ProjectGscController::class, 'save'])->name('admin.save'); | ||
| 103 | + Route::any('/del', [Aside\Project\ProjectGscController::class, 'del'])->name('admin.del'); | ||
| 101 | }); | 104 | }); |
| 102 | }); | 105 | }); |
| 103 | 106 |
-
请 注册 或 登录 后发表评论