com.formkiq.server.controller.IndexController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of formkiq-server Show documentation
Show all versions of formkiq-server Show documentation
Server-side integration for the FormKiQ ios application
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;
/**
* @return int
*/
private int getUserCount() {
if (this.userCount < 1) {
this.userCount = this.userservice.findUsers().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 setup page.
* @return {@link String}
*/
@RequestMapping(value = "/setup", method = RequestMethod.GET)
public String setup() {
if (getUserCount() == 0) {
return "setup";
}
return "redirect:/";
}
}