lsg / auto-screen
筛选
Installs: 3 516
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
- dev-main
- 19.3
- 19.2
- 19.1
- 19.0
- 18.9
- 18.8
- 18.7
- 18.6
- 18.5
- 18.4
- 18.3
- 18.2
- 18.1
- 18.0
- 17.9
- 17.8
- 17.7
- 17.6
- 17.5
- 17.4
- 17.3
- 17.2
- 17.1
- 17.0
- 16.9
- 16.8
- 16.7
- 16.6
- 16.5
- 16.4
- 16.3
- 16.2
- 16.1
- 16.0
- 15.9
- 15.8
- 15.7
- 15.6
- 15.5
- 15.4
- 15.3
- 15.2
- 15.1
- 15.0
- 14.9
- 14.8
- 14.7
- 14.6
- 14.5
- 14.4
- 14.3
- 14.2
- 14.1
- 14.0
- 13.9
- 13.8
- 13.7
- 13.6
- 13.5
- 13.4
- 13.3
- 13.2
- 13.1
- 13.0
- 12.9
- 12.8
- 12.7
- 12.6
- 12.5
- 12.4
- 12.3
- 12.2
- 12.1
- 12.0
- 11.9
- 11.8
- 11.7
- 11.6
- 11.5
- 11.4
- 11.3
- 11.2
- 11.1
- 11.0
- 10.9
- 10.8
- 10.7
- 10.6
- 10.5
- 10.4
- 10.3
- 10.2
- 10.1
- 10.0
- 9.9
- 9.8
- 9.7
- 9.6
- 9.5
- 9.4
- 9.3
- 9.2
- 9.1
- 9.0
- 8.9
- 8.7
- 8.6
- 8.5
- 8.4
- 8.3
- 8.2
- 8.1
- 8.0
- 7.9
- 7.8
- 7.7
- 7.6
- 7.5
- 7.4
- 7.3
- 7.2
- 7.1
- 7.0
- 6.9
- 6.8
- 6.7
- 6.6
- 6.5
- 6.4
- 6.3
- 6.2
- 6.1
- 6.0
- 5.9
- 5.8
- 5.7
- 5.6
- 5.5
- 5.4
- 5.3
- 5.2
- 5.1
- 5.0
- 4.9
- 4.8
- 4.7
- 4.6
- 4.5
- 4.4
- 4.3
- 4.2
- 4.1
- 4.0
- 3.9
- 3.8
- 3.7
- 3.6
- 3.5
- 3.4
- 3.3
- 3.2
- 3.1
- 3.0
- 2.9
- 2.8
- 2.7
- 2.6
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1
- 2.0
- 1.9
- 1.8
- 1.7
- 1.6
- 1.5
- 1.4
- 1.3
- 1.2
- 1.1
This package is auto-updated.
Last update: 2025-03-01 00:39:26 UTC
README
English | 简体中文
GUPO AUTOMAKE SDK for PHP
实现了自动生成列表,验证器优化等功能
安装
Composer
composer require lsg/auto-screen php artisan vendor:publish --provider="Lsg\AutoScreen\AutoScreenServiceProvider" config/app.php 增加 //自动查询脚本 Lsg\AutoScreen\AutoScreenServiceProvider::class
列表使用说明
php artisan task:make_list AutoList //在app/Lists下面生成了自动列表代码 使用方法: * 0.声明一个列表路由(比如/api/patient/list) * 1.在controller层$service->list($itemCode), * 2.在service层use当前类
验证器使用说明
controller层需要引入MakeValidateRequest
<?php namespace App\Http\Controllers\Clinical; use Lsg\AutoScreen\Support\MakeValidateRequest; class PatientController extends BaseController { public function createPatients(MakeValidateRequest $request) { $user = request()->user; $card_no = $request->input('card_no', ''); $gender = get_idcard_sex($card_no); $birth_year = get_idcard_year($card_no); if (Patients::where('users_id', $user->id)->where('card_no', $card_no)->exists()) { throw new ApiException('患者已存在,请勿重复添加'); } $res = Patients::makeCreate(['users_id' => $user->id, 'gender' => $gender, 'birth_year' => $birth_year]); return success($res); }
config/makeValidate.php增加需要验证的类
<?php use App\Http\Controllers\TestController; use App\Http\Controllers\Clinical\PatientController; return [ 'name' => [ [TestController::class . '@index',PatientController::class . '@createPatients'], ['bail', 'required', 'string'], '用户姓名', ], 'phone' => [ [TestController::class . '@index'], ['bail', 'required', new Lsg\AutoScreen\Rules\PhoneRule], '手机号', ], 'card_no' => [ [TestController::class . '@index',PatientController::class . '@createPatients'], ['bail', 'required', new Lsg\AutoScreen\Rules\IdCardRule], '身份证号', ], ];
//更新自动验证缓存
php artisan task:make_validate
缓存中间件使用说明
App/Http/Kernel注册中间件 'validate.make' => \Lsg\AutoScreen\Middleware\ValidateMake::class,
<?php namespace App\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array<int, class-string|string> */ protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, // \App\Http\Middleware\TrustProxies::class, // \Fruitcake\Cors\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ]; /** * The application's route middleware groups. * * @var array<string, array<int, class-string|string>> */ protected $middlewareGroups = [ 'api' => [ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, // 'throttle:api', // \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ]; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array<string, class-string|string> */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, //缓存中间件 'cache.make' => \App\Http\Middleware\CacheMake::class, //入参验证器 'validate.make' => \Lsg\AutoScreen\Middleware\ValidateMake::class, ]; }
路由引入中间件 参数1是缓存时间 参数2是缓存key(在使用redis缓存的情况下仅仅对当前路由与入参作为缓存的key可能会导致redis缓存key重复)
<?php Route::group([ 'middleware' => ['cache.make:1,cancers'], ], function () { // 顶部六要素统计 Route::get('top_six_element', [WorkbenchController::class, 'topSixElement']); });
发行说明
每个版本的详细更改记录在发行说明中。
相关
许可证
Copyright (c) 2022-present, linsonggao All rights reserved