@Service
public interface LoginService{
boolean authUser(String userEmail, String authCode);
}
@Service
public class LoginServiceImpl implements LoginService{
public boolean authUser(String userEmail, String authCode){
//something checking
if(true){
return true;
}
return false;
}
}
@Controller
class LoginController {
@Autowired
private LoginService loginService;
@RequestMapping(value = "/login", method = RequestMapping.GET)
public String index() {
return "login";
}
@RequestMapping(value ="/login", method = RequestMapping.POST)
public String login(ModelMap model, @RequestParm ){
if(loginService.authUser(userEmail, authCode)){
return "home_page";
}
else{
model.put("hasError", true);
return "redirect:/login";
}
}
}