Exemplo n.º 1
0
  @RequestMapping(value = "/get/{type}", method = RequestMethod.GET)
  public String getPaymentsSpecific(
      ModelMap model,
      @PathVariable String type,
      @RequestParam(required = false, defaultValue = "") String dateFrom,
      @RequestParam(required = false, defaultValue = "") String dateTo,
      @RequestParam(required = false, defaultValue = "") String clientStr) {

    List<Payment> payments = new ArrayList<>();

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyy-MM-dd");
    Date d1 = new Date();
    Date d2 = new Date();

    model
        .addAttribute("dateFrom", dateFrom)
        .addAttribute("dateTo", dateTo)
        .addAttribute("clientStr", clientStr);

    if (type.equals("in")) {

      if (!dateFrom.equals("") && !dateTo.equals("")) {
        try {
          d1 = sdf.parse(dateFrom);
          d2 = sdf.parse(dateTo);
        } catch (ParseException e) {
          e.printStackTrace();
        }
        payments = paymentService.listPayments(clientStr, d1, d2);
      }

      if (dateFrom.equals("") && dateTo.equals("") && !clientStr.equals("")) {
        try {
          d1 = sdf.parse("1971-01-01");
          d2 = sdf.parse("2025-01-01");
        } catch (ParseException e) {
          e.printStackTrace();
        }
        payments = paymentService.listPayments(clientStr, d1, d2);
      }

      if (dateFrom.equals("") && dateTo.equals("") && clientStr.equals("")) {
        payments = paymentService.listPayments();
      }
      model.addAttribute("payments", payments);
      return "/auth/payment/paymentgetin";
    }

    // model.addAttribute("payments", paymentService.listPayments());
    return "/auth/payment/paymentget";
  }
Exemplo n.º 2
0
  @RequestMapping(value = "/get", method = RequestMethod.GET)
  public String getPaymentsAll(ModelMap model) {

    model.addAttribute("payments", paymentService.listPayments());
    return "/auth/payment/paymentget";
  }