Exemplo n.º 1
0
  @RequestMapping(value = "/index.html", method = RequestMethod.GET)
  public String index(
      org.springframework.ui.Model model,
      @RequestParam(value = "payroll", defaultValue = "TCH") String payroll,
      @RequestParam(value = "office", defaultValue = "All") String office) {

    if (Credential.getInstance().isEmpty()) return "redirect:/login.html";

    PeopleMissingTimeSheet timeSheet = PeopleMissingTimeSheet.getInstance();
    Employees employees = timeSheet.employeesOf(payroll);
    Date lastUpdateTime = timeSheet.lastUpdateTime();
    model.addAttribute("peoples", employees.atOffice(office));
    Set<String> offices = employees.availableOffices();
    System.out.print(offices);

    if (!stillValidOffice(office, offices)) {
      office = "All";
    }
    model.addAttribute("offices", offices);
    model.addAttribute("selectedPayroll", payroll);
    model.addAttribute("selectedOffice", office);
    List<Payroll> payrolls = payrollRepository.load().list();
    model.addAttribute("payrolls", payrolls);
    model.addAttribute("lastUpdateTime", lastUpdateTime);

    return "index";
  }
Exemplo n.º 2
0
  @RequestMapping(value = "/login.html", method = RequestMethod.POST)
  public String postCredential(HttpServletRequest request, Model model) {
    String username = StringUtils.trimToEmpty(request.getParameter("username"));
    String password = StringUtils.trimToEmpty(request.getParameter("password"));

    if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
      model.addAttribute("error", "User name and password required.");
      return "login";
    }

    Credential.getInstance().save(username, password);
    updateAsyn();
    return "redirect:/loading.html";
  }