master
cody 11 months ago
parent aabd8c4573
commit b6bbd25203

@ -25,6 +25,25 @@ class GateController extends Controller
{ {
use ApiResponse; use ApiResponse;
/**
* @OA\Get(
* path="/api/admin/gate/user-list",
* tags={"门岗端接口"},
* summary="门岗用户列表",
* description="",
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function uerList()
{
$admin = Admin::whereHas('role', function ($query) {
$query->where('name', 'like', '%门岗%');
})->get();
return $this->success($admin);
}
/** /**
* @OA\Get( * @OA\Get(
@ -35,7 +54,7 @@ class GateController extends Controller
* @OA\Parameter(name="date", in="query", @OA\Schema(type="string"), required=false, description="查询日期格式Y-m-d默认今天"), * @OA\Parameter(name="date", in="query", @OA\Schema(type="string"), required=false, description="查询日期格式Y-m-d默认今天"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="string"), required=false, description="状态筛选1通过(待进厂)3已进厂4已离厂"), * @OA\Parameter(name="status", in="query", @OA\Schema(type="string"), required=false, description="状态筛选1通过(待进厂)3已进厂4已离厂"),
* @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=false, description="类型筛选1访客2访客车辆3物流车辆"), * @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=false, description="类型筛选1访客2访客车辆3物流车辆"),
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="关键词搜索(姓名、手机号、车牌号"), * @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="关键词搜索(人牌,身份证,核销码"),
* @OA\Parameter(name="page", in="query", @OA\Schema(type="integer"), required=false, description="页码默认1"), * @OA\Parameter(name="page", in="query", @OA\Schema(type="integer"), required=false, description="页码默认1"),
* @OA\Parameter(name="page_size", in="query", @OA\Schema(type="integer"), required=false, description="每页数量默认20"), * @OA\Parameter(name="page_size", in="query", @OA\Schema(type="integer"), required=false, description="每页数量默认20"),
* @OA\Response( * @OA\Response(
@ -88,10 +107,9 @@ class GateController extends Controller
// 关键词搜索 // 关键词搜索
if ($keyword) { if ($keyword) {
$query->where(function ($q) use ($keyword) { $query->where(function ($q) use ($keyword) {
$q->where('name', 'like', "%{$keyword}%") $q->where('person_no', "{$keyword}")
->orWhere('mobile', 'like', "%{$keyword}%") ->orWhere('idcard', "{$keyword}")
->orWhere('plate', 'like', "%{$keyword}%") ->orWhere('code', "{$keyword}");
->orWhere('code', 'like', "%{$keyword}%");
}); });
} }
@ -106,12 +124,17 @@ class GateController extends Controller
} }
/** /**
* @OA\Get( * @OA\Post(
* path="/api/gate/visits/{id}", * path="/api/gate/visits/detail",
* tags={"门岗端接口"}, * tags={"门岗端接口"},
* summary="拜访详情信息", * summary="拜访详情信息",
* description="获取指定拜访的详细信息", * description="获取指定拜访的详细信息",
* @OA\Parameter(name="id", in="path", @OA\Schema(type="integer"), required=true, description="拜访ID"), * @OA\RequestBody(
* required=true,
* @OA\JsonContent(
* @OA\Property(property="id", type="integer", description="拜访ID")
* )
* ),
* @OA\Response( * @OA\Response(
* response="200", * response="200",
* description="成功获取拜访详情", * description="成功获取拜访详情",
@ -123,9 +146,15 @@ class GateController extends Controller
* ) * )
* ) * )
*/ */
public function visitDetail($id) public function visitDetail(Request $request)
{ {
try { try {
$id = $request->input('id');
if (!$id) {
return $this->fail([ResponseCode::ERROR_PARAMETER, __('gate.visit_id_required')]);
}
$visit = Visit::with([ $visit = Visit::with([
'visitArea', 'visitArea',
'visitTime', 'visitTime',
@ -151,14 +180,14 @@ class GateController extends Controller
/** /**
* @OA\Post( * @OA\Post(
* path="/api/gate/visits/{id}/update", * path="/api/gate/visits/update",
* tags={"门岗端接口"}, * tags={"门岗端接口"},
* summary="更新拜访信息", * summary="更新拜访信息",
* description="门岗端更新拜访信息绑定ID卡、修改状态、上传货车图片等", * description="门岗端更新拜访信息绑定ID卡、修改状态、上传货车图片等",
* @OA\Parameter(name="id", in="path", @OA\Schema(type="integer"), required=true, description="拜访ID"),
* @OA\RequestBody( * @OA\RequestBody(
* required=true, * required=true,
* @OA\JsonContent( * @OA\JsonContent(
* @OA\Property(property="id", type="integer", description="拜访ID"),
* @OA\Property(property="action", type="string", description="操作类型bind_card绑定ID卡enter进厂leave离厂upload_vehicle上传货车图片"), * @OA\Property(property="action", type="string", description="操作类型bind_card绑定ID卡enter进厂leave离厂upload_vehicle上传货车图片"),
* @OA\Property(property="person_no", type="string", description="人牌号绑定ID卡时必填"), * @OA\Property(property="person_no", type="string", description="人牌号绑定ID卡时必填"),
* @OA\Property(property="car_no", type="string", description="停车牌号绑定ID卡时必填"), * @OA\Property(property="car_no", type="string", description="停车牌号绑定ID卡时必填"),
@ -177,9 +206,15 @@ class GateController extends Controller
* ) * )
* ) * )
*/ */
public function updateVisit(Request $request, $id) public function updateVisit(Request $request)
{ {
try { try {
$id = $request->input('id');
if (!$id) {
return $this->fail([ResponseCode::ERROR_PARAMETER, __('gate.visit_id_required')]);
}
$visit = Visit::find($id); $visit = Visit::find($id);
if (!$visit) { if (!$visit) {
return $this->fail([ResponseCode::ERROR_BUSINESS, __('gate.visit_not_found')]); return $this->fail([ResponseCode::ERROR_BUSINESS, __('gate.visit_not_found')]);
@ -318,10 +353,7 @@ class GateController extends Controller
* summary="核销", * summary="核销",
* description="", * description="",
* @OA\Parameter(name="admin_id", in="query", @OA\Schema(type="string"), required=false, description="管理员id"), * @OA\Parameter(name="admin_id", in="query", @OA\Schema(type="string"), required=false, description="管理员id"),
* @OA\Parameter(name="code", in="query", @OA\Schema(type="string"), required=false, description="编码(二选一)"), * @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="关键词(人牌,身份证,核销码)"),
* @OA\Parameter(name="idcard", in="query", @OA\Schema(type="string"), required=false, description="身份证(二选一)"),
* @OA\Parameter(name="car_no", in="query", @OA\Schema(type="string"), required=false, description="停车牌"),
* @OA\Parameter(name="person_no", in="query", @OA\Schema(type="string"), required=false, description="人牌"),
* @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=false, description="1进厂2离厂"), * @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=false, description="1进厂2离厂"),
* @OA\Response( * @OA\Response(
* response="200", * response="200",
@ -333,10 +365,12 @@ class GateController extends Controller
{ {
$all = \request()->all(); $all = \request()->all();
$messages = [ $messages = [
'keyword.required' => __('关键词'),
'type.required' => __('gate.validation.type_required'), 'type.required' => __('gate.validation.type_required'),
'admin_id.required' => __('gate.validation.admin_id_required') 'admin_id.required' => __('gate.validation.admin_id_required')
]; ];
$validator = Validator::make($all, [ $validator = Validator::make($all, [
'keyword' => 'required',
'type' => 'required', 'type' => 'required',
'admin_id' => 'required' 'admin_id' => 'required'
], $messages); ], $messages);
@ -348,13 +382,10 @@ class GateController extends Controller
if (empty($idcard) && empty($code)) { if (empty($idcard) && empty($code)) {
return $this->fail([ResponseCode::ERROR_PARAMETER, __('gate.validation.code_or_idcard_required')]); return $this->fail([ResponseCode::ERROR_PARAMETER, __('gate.validation.code_or_idcard_required')]);
} }
$check = Visit::where(function ($query) use ($idcard, $code) { $check = Visit::where(function ($query) use ($all) {
if (!empty($idcard)) { $query->where('person_no', "{$all['keyword']}")
$query->where('idcard', $idcard); ->orWhere('idcard', "{$all['keyword']}")
} ->orWhere('code', "{$all['keyword']}");
if (!empty($code)) {
$query->where('code', $code);
}
})->first(); })->first();
if (empty($check)) { if (empty($check)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, __('gate.business.visit_not_found')]); return $this->fail([ResponseCode::ERROR_BUSINESS, __('gate.business.visit_not_found')]);

@ -15,6 +15,7 @@ return [
], ],
// Direct keys (for compatibility with existing code) // Direct keys (for compatibility with existing code)
'visit_not_found' => 'Visit record not found', 'visit_not_found' => 'Visit record not found',
'visit_id_required' => 'Visit ID is required',
'get_visit_list_failed' => 'Failed to get visit list', 'get_visit_list_failed' => 'Failed to get visit list',
'get_visit_detail_failed' => 'Failed to get visit detail', 'get_visit_detail_failed' => 'Failed to get visit detail',
'person_no_required' => 'Person number is required', 'person_no_required' => 'Person number is required',

@ -15,6 +15,7 @@ return [
], ],
// 直接键名(为了兼容现有代码) // 直接键名(为了兼容现有代码)
'visit_not_found' => '拜访记录不存在', 'visit_not_found' => '拜访记录不存在',
'visit_id_required' => '拜访ID必填',
'get_visit_list_failed' => '获取拜访列表失败', 'get_visit_list_failed' => '获取拜访列表失败',
'get_visit_detail_failed' => '获取拜访详情失败', 'get_visit_detail_failed' => '获取拜访详情失败',
'person_no_required' => '人牌号必填', 'person_no_required' => '人牌号必填',

@ -23,11 +23,12 @@ Route::any('test', [\App\Http\Controllers\Admin\OtherController::class, "test"])
// 门岗端接口路由组(无需鉴权,但支持多语言) // 门岗端接口路由组(无需鉴权,但支持多语言)
Route::prefix('gate')->middleware(['set.locale'])->group(function () { Route::prefix('gate')->middleware(['set.locale'])->group(function () {
Route::get("user-list", [\App\Http\Controllers\GateController::class, "uerList"]);
Route::get('visits', [\App\Http\Controllers\GateController::class, 'visits']); Route::get('visits', [\App\Http\Controllers\GateController::class, 'visits']);
Route::get('visits/{id}', [\App\Http\Controllers\GateController::class, 'visitDetail']); Route::post('visits/detail', [\App\Http\Controllers\GateController::class, 'visitDetail']);
Route::get("visits/use-code", [\App\Http\Controllers\GateController::class, "useCode"]); Route::get("visits/use-code", [\App\Http\Controllers\GateController::class, "useCode"]);
Route::post('visits/{id}/update', [\App\Http\Controllers\GateController::class, 'updateVisit']); Route::post('visits/update', [\App\Http\Controllers\GateController::class, 'updateVisit']);
}); });
// 后台管理接口路由组(支持多语言) // 后台管理接口路由组(支持多语言)

Loading…
Cancel
Save