📜  过滤器进入特定范围的弹簧靴 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:43.337000             🧑  作者: Mango

代码示例2
@RequestMapping(value = AkApiUrl.fetchorderbydate, method = { RequestMethod.POST, RequestMethod.GET }, produces = {MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity fetchorderbydate(HttpServletRequest request, @RequestParam("startdate") String startdate, @RequestParam("enddate")  String enddate) {
    logger.info("Fetch order between start date: "+startdate+" and end date: "+enddate+" function is calling.. ");
    CustomResponse = ResponseFactory.getResponse(request);
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date orderdatefrom = sdf.parse(startdate);
        System.out.println("Order placed from date: "+orderdatefrom.toString());
        Date orderdateto = sdf.parse(enddate);
        System.out.println("Order placed to date: "+orderdateto.toString());
        List orderbydate = ordersdao.findByOrderdateGreaterThanEqualAndOrderdateLessThanEqualAndOrderstatusOrderByCreateddatetimeDesc(orderdatefrom, orderdateto,"refunded");
        System.out.println(orderdatefrom+" comes before"+orderdateto);
        System.out.println("Order data between two dates are : "+orderbydate.size());
        if (orderbydate != null) {
            CustomResponse.setResponse(orderbydate);
            CustomResponse.setStatus(CustomStatus.OK);
            CustomResponse.setStatusCode(CustomStatus.OK_CODE);
        }
    } catch (Exception e) {
        e.printStackTrace();
        CustomResponse.setResponse(null);
        CustomResponse.setStatus(CustomStatus.Error);
        CustomResponse.setStatusCode(CustomStatus.Error_CODE);
    }
    return new ResponseEntity(CustomResponse, HttpStatus.OK);
}