all(); $list = Blacklist::where(function ($query) use ($all){ })->orderBy($all['sort_name']??'id',$all['sort_type']??'desc') ->paginate($all['page_size']??20); return $this->success($list); } /** * @OA\Get( * path="/api/admin/blacklist/show", * tags={"黑名单"}, * summary="详情", * description="", * @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", * description="暂无" * ) * ) */ public function show() { $all = \request()->all(); $messages = [ 'id.required' => 'Id必填', ]; $validator = Validator::make($all, [ 'id' => 'required' ],$messages); if($validator->fails()){ return $this->fail([ResponseCode::ERROR_PARAMETER,implode(',',$validator->errors()->all())]); } $detail = Blacklist::find($all['id']); return $this->success($detail); } /** * @OA\Post( * path="/api/admin/blacklist/save", * tags={"黑名单"}, * summary="更新", * description="", * @OA\Parameter(name="id", in="query", @OA\Schema(type="int"), required=true, description="Id(存在更新,不存在新增)"), * @OA\Parameter(name="admin_id", in="query", @OA\Schema(type="string"), required=false, description="不用填"), * @OA\Parameter(name="department_id", in="query", @OA\Schema(type="string"), required=false, description="不用填"), * @OA\Parameter(name="name", in="query", @OA\Schema(type="string"), required=false, description="名字"), * @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=false, description="手机号"), * @OA\Parameter(name="credent", in="query", @OA\Schema(type="string"), required=false, description="证件类型1身份证2护照"), * @OA\Parameter(name="idcard", in="query", @OA\Schema(type="string"), required=false, description="证件号"), * @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=false, description="开始时间"), * @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=false, description="结束时间"), * @OA\Parameter(name="status", in="query", @OA\Schema(type="string"), required=false, description="状态0禁用1启用"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Parameter(name="remark", in="query", @OA\Schema(type="string"), required=true, description="备注"), * @OA\Parameter(name="company_name", in="query", @OA\Schema(type="string"), required=true, description="单位名字"), * @OA\Parameter(name="file", in="query", @OA\Schema(type="string"), required=true, description="附件id数组"), * @OA\Response( * response="200", * description="暂无" * ) * ) */ public function save() { $all = \request()->all(); $messages = [ 'name.required' => '名称必填' ]; $validator = Validator::make($all, [ 'name' => 'required' ],$messages); if($validator->fails()){ return $this->fail([ResponseCode::ERROR_PARAMETER,implode(',',$validator->errors()->all())]); } DB::beginTransaction(); try { if(isset($all['id'])){ $model = Blacklist::find($all['id']); }else{ $model = new Blacklist(); $all['admin_id'] = $this->getUserId(); $all['department_id'] = $this->getUser()->department_id; } $model->fill($all); $model->save(); DB::commit(); return $this->success('更新成功'); }catch (\Exception $exception) { DB::rollBack(); return $this->fail([$exception->getCode(), $exception->getMessage()]); } } /** * @OA\Get( * path="/api/admin/blacklist/destroy", * tags={"黑名单"}, * summary="删除", * description="", * @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", * description="暂无" * ) * ) */ public function destroy() { $all = \request()->all(); $messages = [ 'id.required' => 'Id必填', ]; $validator = Validator::make($all, [ 'id' => 'required' ],$messages); if($validator->fails()){ return $this->fail([ResponseCode::ERROR_PARAMETER,implode(',',$validator->errors()->all())]); } Blacklist::where('id', $all['id'])->delete(); return $this->success('删除成功'); } }