-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathMainMenuRouteController.java
More file actions
55 lines (45 loc) · 1.61 KB
/
MainMenuRouteController.java
File metadata and controls
55 lines (45 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package edu.uark.registerapp.controllers;
import java.util.Map;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import edu.uark.registerapp.controllers.enums.ViewModelNames;
import edu.uark.registerapp.controllers.enums.ViewNames;
import edu.uark.registerapp.models.entities.ActiveUserEntity;
import edu.uark.registerapp.models.enums.EmployeeClassification;
@Controller
@RequestMapping(value = "/mainMenu")
public class MainMenuRouteController extends BaseRouteController {
@RequestMapping(method = RequestMethod.GET)
public ModelAndView start(
@RequestParam final Map<String, String> queryParameters,
final HttpServletRequest request
) {
final Optional<ActiveUserEntity> activeUserEntity =
this.getCurrentUser(request);
if (!activeUserEntity.isPresent()) {
return this.buildInvalidSessionResponse();
}
ModelAndView modelAndView =
this.setErrorMessageFromQueryString(
new ModelAndView(ViewNames.MAIN_MENU.getViewName()),
queryParameters);
// Check if user is any kind of manager
if (EmployeeClassification.isElevatedUser(
activeUserEntity.get().getClassification()))
{
modelAndView.addObject(
ViewModelNames.IS_ELEVATED_USER.getValue(), true);
}
else
{
modelAndView.addObject(
ViewModelNames.IS_ELEVATED_USER.getValue(), false);
}
return modelAndView;
}
}