Search in sources :

Example 46 with GetMapping

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";
}
Also used : UserEntity(ua.springweb.security.entity.UserEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 47 with GetMapping

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";
}
Also used : EditUserRequest(com.zavada.domain.EditUserRequest) UserEntity(com.zavada.entity.UserEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 48 with GetMapping

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";
}
Also used : CreateAdvRequest(com.zavada.domain.CreateAdvRequest) UserEntity(com.zavada.entity.UserEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 49 with GetMapping

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";
}
Also used : UserModel(ua.model.UserModel) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 50 with GetMapping

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";
}
Also used : UserModel(ua.model.UserModel) ArrayList(java.util.ArrayList) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

GetMapping (org.springframework.web.bind.annotation.GetMapping)756 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)114 ResponseEntity (org.springframework.http.ResponseEntity)80 ArrayList (java.util.ArrayList)52 List (java.util.List)49 ModelAndView (org.springframework.web.servlet.ModelAndView)48 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)45 HttpHeaders (org.springframework.http.HttpHeaders)41 Map (java.util.Map)40 HashMap (java.util.HashMap)38 lombok.val (lombok.val)38 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)36 Grid (org.hisp.dhis.common.Grid)35 IOException (java.io.IOException)34 RequestParam (org.springframework.web.bind.annotation.RequestParam)34 ApiOperation (io.swagger.annotations.ApiOperation)31 RootNode (org.hisp.dhis.node.types.RootNode)31 PathVariable (org.springframework.web.bind.annotation.PathVariable)31 HttpServletRequest (javax.servlet.http.HttpServletRequest)30 FieldFilterParams (org.hisp.dhis.fieldfilter.FieldFilterParams)28