예제 #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     Logger::middlewareInfo('@ExampleMiddle begin, request:', ['headers' => $request->headers, 'url' => $request->fullUrl(), 'params' => $request->all()]);
     $response = $next($request);
     Logger::middlewareInfo('@ExampleMiddle end, response:', ['code' => $response->getStatusCode(), 'content' => $response->getContent()]);
     return $response;
 }
예제 #2
0
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * @api {post} /yzh/account/flush 彻底删除该商户下所有用户
  * @apiName PostToolFlush
  * @apiGroup Tool
  *
  * @apiParam {String} partner 商户编号
  *
  * @apiSuccessExample Success-Response:
  * HTTP/1.1 200 OK
  * {
  *   "ok": true
  * }
  *
  */
 public function flush(Request $request)
 {
     $input = $request->all();
     Logger::sysInfo('@YzhController flush, begin, clear', $input);
     $validator = Validator::make($input, ['partner' => 'required']);
     if ($validator->fails()) {
         $errors = $validator->errors()->toArray();
         return Response::error(FaultCode::PARAMS_ERROR, $errors);
     }
     if (!in_array($input['partner'], config('Flush'))) {
         return Response::error(FaultCode::ACCESS_DENIED);
     }
     $results = DB::connection('trial')->select('select I_USER_ID from dealer_user_relation where CH_DEALER_CODE = :code', ['code' => $input['partner']]);
     if (empty($results)) {
         return Response::result(['ok' => true]);
     }
     $log = [];
     foreach ($results as $row) {
         $id = $row->I_USER_ID;
         $log[] = DB::connection('trial')->delete('delete from users where I_USER_ID = :id', ['id' => $id]);
         $log[] = DB::connection('trial')->delete('delete from user_account where I_USER_ID = :id', ['id' => $id]);
         $log[] = DB::connection('trial')->delete('delete from user_bankcards where I_USER_ID = :id', ['id' => $id]);
         $log[] = DB::connection('trial')->delete('delete from dealer_user_relation where I_USER_ID = :id', ['id' => $id]);
     }
     Logger::sysInfo('@YzhController flush, end, log', $log);
     return Response::result(['ok' => true]);
 }