作者 lyh

gx

... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Project\GscLogic;
use App\Http\Requests\Aside\User\GscRequest;
/**
* @remark :优化gsc账号
... ... @@ -48,4 +49,59 @@ class ProjectGscController extends BaseController
$lists = $gscLogic->DomainLists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取gsc账号详情
* @name :read
* @author :lyh
* @method :post
* @time :2023/6/19 16:55
*/
public function read(GscLogic $gscLogic){
$this->request->validate([
'gsc_id'=>'required'
],[
'gsc_id.required' => 'GSC账号ID不能为空'
]);
$info = $gscLogic->GscRead();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :添加/编辑gsc账号
* @name :add
* @author :lyh
* @method :post
* @time :2023/6/19 16:28
*/
public function save(GscRequest $gscRequest,GscLogic $gscLogic){
if(isset($this->param['id'])){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'GSC账号ID不能为空'
]);
}
$gscRequest->validated();
$gscLogic->GscSave();
$this->response('success');
}
/**
* @remark :逻辑删除gsc账号
* @name :del
* @author :lyh
* @method :post
* @time :2023/6/19 16:30
*/
public function del(GscLogic $gscLogic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'GSC账号ID不能为空'
]);
$gscLogic->GscDel();
$this->response('success');
}
}
... ...
... ... @@ -8,10 +8,12 @@ use App\Models\Project\Gsc;
class GscLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Gsc();
$this->param = $this->requestAll;
}
/**
... ... @@ -23,6 +25,14 @@ class GscLogic extends BaseLogic
*/
public function GscLists($map,$page,$row,$order = 'created_at',$files = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$files);
if(!empty($lists['list'])){
$domainInfoModel = new DomainInfo();
foreach ($lists['list'] as $k => $v){
$lists['list'][$k]['tal'] = $domainInfoModel->formatQuery(['gsc_id'=>$v['id']])->count();
$lists['list'][$k]['pub'] = $domainInfoModel->formatQuery(['gsc_id'=>$v['id']])->count();
$lists['list'][$k]['num'] = $lists['list'][$k]['tal'] - $lists['list'][$k]['pub'];
}
}
return $this->success($lists);
}
... ... @@ -34,8 +44,43 @@ class GscLogic extends BaseLogic
* @time :2023/6/19 15:56
*/
public function DomainLists($map,$page,$row,$order = 'created_at',$files = ['*']){
$domainModel = new DomainInfo();
$lists = $domainModel->lists($map,$page,$row,$order,$files);
$domainInfoModel = new DomainInfo();
$lists = $domainInfoModel->lists($map,$page,$row,$order,$files);
return $this->success($lists);
}
/**
* @remark :更新账号列表
* @name :save
* @author :lyh
* @method :post
* @time :2023/6/19 16:21
*/
public function GscSave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @remark :删除账号列表
* @name :del
* @author :lyh
* @method :post
* @time :2023/6/19 16:31
*/
public function GscDel(){
$this->param['id'] = ['in',$this->param['id']];
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}
... ...
<?php
namespace App\Http\Requests\Aside\User;
use Illuminate\Foundation\Http\FormRequest;
class GscRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'account'=>'required|string|regex:/^1[3-9]\d{9}$/',
'password'=>'required|string',
'mobile'=>'required|string',
'remark'=>'required|string',
];
}
public function messages()
{
return [
'account.required'=>'名称必须填写',
'account.regex'=>'请输入正确的手机号',
'password.required'=>'密码必须填写',
'mobile.required'=>'手机号码必须填写',
'remark.required'=>'备注必须填写',
];
}
}
... ...
... ... @@ -97,7 +97,10 @@ Route::middleware(['aloginauth'])->group(function () {
//优化gsc账号记录表
Route::prefix('gsc')->group(function () {
Route::any('/', [Aside\Project\ProjectGscController::class, 'lists'])->name('admin.lists');
Route::any('/read', [Aside\Project\ProjectGscController::class, 'domainLists'])->name('admin.domainLists');
Route::any('/domainLists', [Aside\Project\ProjectGscController::class, 'domainLists'])->name('admin.domainLists');
Route::any('/read', [Aside\Project\ProjectGscController::class, 'read'])->name('admin.read');
Route::any('/save', [Aside\Project\ProjectGscController::class, 'save'])->name('admin.save');
Route::any('/del', [Aside\Project\ProjectGscController::class, 'del'])->name('admin.del');
});
});
... ...