com.formkiq.server.controller.IndexController Maven / Gradle / Ivy
package com.formkiq.server.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.formkiq.server.service.UserService;
/**
* Static Content Controller.
*
*/
@Controller
public class IndexController {
/** User Service. */
@Autowired
private UserService userservice;
/** User Count Cache. */
private int userCount = -1;
/**
* Handle static admin page.
* @return {@link String}
*/
@RequestMapping(value = "/admin", method = RequestMethod.GET)
public String admin() {
return "redirect:/admin/users";
}
/**
* Handle static Lost Password page.
* @return {@link String}
*/
@RequestMapping(value = "/403", method = RequestMethod.GET)
public String error403() {
return "403";
}
/**
* @return int
*/
private int getUserCount() {
if (this.userCount < 1) {
this.userCount = this.userservice.findUsers(null).getUsers().size();
}
return this.userCount;
}
/**
* Handle static home page.
* @return {@link String}
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String index() {
if (getUserCount() < 1) {
return "redirect:/setup";
}
return "redirect:/login";
}
/**
* Handle static login page.
* @return {@link String}
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login() {
return "login";
}
/**
* Handle static Lost Password page.
* @return {@link String}
*/
@RequestMapping(value = "/lostpassword", method = RequestMethod.GET)
public String lostpassword() {
return "lostpassword";
}
/**
* Handle static Register User page.
* @return {@link String}
*/
@RequestMapping(value = "/register", method = RequestMethod.GET)
public String register() {
return "register";
}
/**
* Handle static Reset Password page.
* @return {@link String}
*/
@RequestMapping(value = "/resetpassword", method = RequestMethod.GET)
public String resetpassword() {
return "resetpassword";
}
/**
* Handle static setup page.
* @return {@link String}
*/
@RequestMapping(value = "/setup", method = RequestMethod.GET)
public String setup() {
if (getUserCount() == 0) {
return "setup";
}
return "redirect:/";
}
}