use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class BaseController method showProfile.
@GetMapping("/profile")
// @PreAuthorize("hasRole('ROLE_USER') OR hasRole('ROLE_ADMIN')")
@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER')")
public String showProfile(Principal principal, Model model) {
UserEntity entity = userService.findUserByEmail(principal.getName());
model.addAttribute("user", entity);
return "profile";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class UserController method editUserProfile.
@GetMapping("/edit/{userId}")
public String editUserProfile(@PathVariable("userId") int userId, Model model, Principal principal) {
UserEntity entity = userService.findUserByEmail(principal.getName());
if (userId != entity.getId())
return "redirect:/user";
EditUserRequest request = UserMapper.entityToEditUser(entity);
model.addAttribute("editModel", request);
return "user/edit";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class UserController method createAdvertisement.
// --- Advertisement
@GetMapping("/{userId}/create")
public String createAdvertisement(@PathVariable("userId") int userId, Model model, Principal principal) {
UserEntity entity = userService.findUserByEmail(principal.getName());
CreateAdvRequest advRequest = new CreateAdvRequest();
advRequest.setEntity(entity);
model.addAttribute("title", "Create Advertisement");
// model.addAttribute("userId", userId);
model.addAttribute("advModel", advRequest);
model.addAttribute("colors", Color.values());
model.addAttribute("fuelTypes", FuelType.values());
model.addAttribute("bodyTypes", BodyType.values());
return "user/create-adv";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class BaseController method showUserDetail.
@GetMapping("/user/{userId}/detail")
public String showUserDetail(Model model, @PathVariable("userId") int userId, @RequestParam("name") String name, @RequestParam("age") int age, @RequestParam("email") String email) {
UserModel userModel = new UserModel(userId, name, age, email);
model.addAttribute("user", userModel);
return "detail";
}
use of org.springframework.web.bind.annotation.GetMapping in project Logos_Materials_October_2017 by VolodymyrZavada.
the class BaseController method showUsersPage.
@GetMapping("/users")
public String showUsersPage(Model model) {
List<UserModel> userModels = new ArrayList<>();
userModels.add(new UserModel(1, "Abram", 45, "abram@mail.com"));
userModels.add(new UserModel(2, "John", 35, "john@mail.com"));
userModels.add(new UserModel(3, "Tim", 34, "tim@mail.com"));
userModels.add(new UserModel(4, "Tom", 25, "tom@mail.com"));
userModels.add(new UserModel(5, "Adam", 89, "adam@mail.com"));
userModels.add(new UserModel(6, "R", 37, "r@mail.com"));
model.addAttribute("userList", userModels);
return "users";
}
Aggregations