當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonView類代碼示例

本文整理匯總了Java中com.fasterxml.jackson.annotation.JsonView的典型用法代碼示例。如果您正苦於以下問題:Java JsonView類的具體用法?Java JsonView怎麽用?Java JsonView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JsonView類屬於com.fasterxml.jackson.annotation包,在下文中一共展示了JsonView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showProjectsDetails

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(JsonViews.Project.class)
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/api/project/details", method = {RequestMethod.GET, RequestMethod.POST}, produces = "application/json")
public List<Project> showProjectsDetails()
{
    LOGGER.debug("ApiController - showProjectsDetails");
    return projectService.findAllWithAll();
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:9,代碼來源:ApiProjectController.java

示例2: propertyField

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@Override
public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) {
    field.annotate(JsonProperty.class).param("value", propertyName);
    if (field.type().erasure().equals(field.type().owner().ref(Set.class))) {
        field.annotate(JsonDeserialize.class).param("as", LinkedHashSet.class);
    }

    if (propertyNode.has("javaJsonView")) {
        field.annotate(JsonView.class).param(
                "value", field.type().owner().ref(propertyNode.get("javaJsonView").asText()));
    }

    if (propertyNode.has("description")) {
        field.annotate(JsonPropertyDescription.class).param("value", propertyNode.get("description").asText());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:Jackson2Annotator.java

示例3: getAllPosts

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@GetMapping()
//    @ApiOperation(nickname = "get-all-posts", value = "Get all posts")
//    @ApiResponses(
//        value = {
//            @ApiResponse(code = 200, message = "return all posts by page")
//        }
//    )
    @JsonView(View.Summary.class)
    public ResponseEntity<Page<Post>> getAllPosts(
        @RequestParam(value = "q", required = false) String keyword, //
        @RequestParam(value = "status", required = false) Post.Status status, //
        @PageableDefault(page = 0, size = 10, sort = "createdDate", direction = Direction.DESC) Pageable page) {

        log.debug("get all posts of [email protected]" + keyword + ", status @" + status + ", [email protected]" + page);

        Page<Post> posts = this.postRepository.findAll(PostSpecifications.filterByKeywordAndStatus(keyword, status), page);

        return new ResponseEntity<>(posts, HttpStatus.OK);
    }
 
開發者ID:hantsy,項目名稱:spring-microservice-sample,代碼行數:20,代碼來源:PostController.java

示例4: getPost

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@GetMapping(value = "/{slug}")
@JsonView(View.Public.class)
public ResponseEntity<Post> getPost(@PathVariable("slug") String slug) {

    log.debug("get postsinfo by slug @" + slug);

    Post post = this.postRepository.findBySlug(slug).orElseThrow(
        () -> {
            return new PostNotFoundException(slug);
        }
    );

    log.debug("get post @" + post);

    return new ResponseEntity<>(post, HttpStatus.OK);
}
 
開發者ID:hantsy,項目名稱:spring-microservice-sample,代碼行數:17,代碼來源:PostController.java

示例5: deleteSprint

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(JsonViews.Basique.class)
@RequestMapping(value = "/api/sprint/delete/{id}", method = RequestMethod.DELETE, produces = "application/json")
public ResponseEntity<Sprint> deleteSprint(@PathVariable("id") Long id)
{
    LOGGER.debug("ApiController - deleteSprint");

    Sprint sprint = null;
    if(sprintService.exists(id))
    {
        sprint = sprintService.findOneById(id);

        sprintService.deleteOneById(sprint.getId());

        return new ResponseEntity<Sprint>(sprint, HttpStatus.ACCEPTED);
    }
    return new ResponseEntity<Sprint>(sprint, HttpStatus.NOT_FOUND);
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:18,代碼來源:ApiSprintController.java

示例6: linkSprintIdWithStoryId

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(JsonViews.Basique.class)
@RequestMapping(value = "/api/sprint/{idSprint}/story/{idStory}", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<Sprint> linkSprintIdWithStoryId(@PathVariable Long idSprint, @PathVariable Long idStory)
{
    LOGGER.debug("ApiController - linkSprintIdWithStoryId");

    Story story = storyService.findOneByIdWithAll(idStory);
    Sprint sprint = sprintService.findOneByIdWithAll(idSprint);

    if(null==sprint ||null ==story)
    {
        return new ResponseEntity<Sprint>(sprint, HttpStatus.NOT_FOUND);
    }

    story.setStorySprint(sprint);
    story = storyService.save(story);
    sprint = sprintService.findOneByIdWithAll(idSprint);
    return new ResponseEntity<Sprint>(sprint, HttpStatus.CREATED);
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:20,代碼來源:ApiSprintController.java

示例7: sendUser

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(JsonViews.Basique.class)
@RequestMapping(value = "/api/user/add", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<User> sendUser(@RequestBody User user)
{
    LOGGER.debug("ApiController - sendUser");
    if(!userService.exists(user.getEmail()))
    {
        userService.save(user);

        LOGGER.debug("ApiController - sendUser - User créé");
        return new ResponseEntity<User>(user, HttpStatus.CREATED);
    }
    else
    {
        LOGGER.debug("ApiController - sendUser - User déjà existant");
        return new ResponseEntity<User>(user, HttpStatus.CONFLICT);
    }
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:19,代碼來源:ApiUserController.java

示例8: updateStory

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(JsonViews.Basique.class)
@RequestMapping(value = "/api/story/update/{idStory}", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<Story> updateStory(@PathVariable Long idStory, @RequestBody Story story, @RequestParam Long idSprint)
{
    LOGGER.debug("ApiController - updateStory");
    if(idSprint != null)
    {
        Sprint sprint = sprintService.findOneById(idSprint);
        if(null==sprint) {
            LOGGER.debug("ApiController - updateStory - Sprint inexistant");
            return new ResponseEntity<Story>(story, HttpStatus.NOT_FOUND);
        }
        story.setStorySprint(sprint);
    }
    storyService.updateStory(idStory, story);
    LOGGER.debug("ApiController - updateStory - Story maj");
    return new ResponseEntity<Story>(story, HttpStatus.ACCEPTED);
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:19,代碼來源:ApiStoryController.java

示例9: sendStoryWithSprintId

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(JsonViews.Basique.class)
@RequestMapping(value = "/api/story/add/sprint/{idSprint}", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<Story> sendStoryWithSprintId(@PathVariable Long idSprint, @RequestBody Story story)
{
    LOGGER.debug("ApiController - sendStoryWithSprintId");
    Sprint sprint = sprintService.findOneById(idSprint);
    if(null==sprint)
    {
        LOGGER.debug("ApiController - sendStoryWithSprintId - Sprint inexistant");
        return new ResponseEntity<Story>(story, HttpStatus.NOT_FOUND);
    }
    if(story.getStatus()==null)
        story.setStatus(StoryStatus.TODO);

    story = storyService.save(story);
    story.setStorySprint(sprint);
    story = storyService.save(story);

    LOGGER.debug("ApiController - sendStoryWithSprintId - Story créé");
    return new ResponseEntity<Story>(story, HttpStatus.CREATED);
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:22,代碼來源:ApiStoryController.java

示例10: deleteTask

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(JsonViews.Basique.class)
@RequestMapping(value = "/api/task/delete/{id}", method = RequestMethod.DELETE, produces = "application/json")
public ResponseEntity<Task> deleteTask(@PathVariable("id") Long id)
{
    LOGGER.debug("ApiController - deleteTask");

    Task task = null;
    if(taskService.exists(id))
    {
        task = taskService.findOneById(id);
        taskService.deleteOneById(task.getId());

        return new ResponseEntity<Task>(task, HttpStatus.ACCEPTED);
    }
    return new ResponseEntity<Task>(task, HttpStatus.NOT_FOUND);
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:17,代碼來源:ApiTaskController.java

示例11: getAnswersByUser

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(Views.Public.class)
@RequestMapping(value = "/answer/user/{name}", method = RequestMethod.GET)
public ResponseEntity<?> getAnswersByUser(@PathVariable("name") String name) {

    User user = userService.getByUsername(name);

    if (user == null) {
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }

    List<Answer> answers = answerService.getByUser(user);
    if (answers.isEmpty()) {
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }
    return new ResponseEntity<List<Answer>>(answers, HttpStatus.OK);
}
 
開發者ID:noveogroup-amorgunov,項目名稱:spring-mvc-react,代碼行數:17,代碼來源:AnswerController.java

示例12: getQuestionsByUser

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(Views.Public.class)
@RequestMapping(value = "/questions/user/{name}", method = RequestMethod.GET)
public ResponseEntity<?> getQuestionsByUser(@PathVariable("name") String name) {

    User user = userService.getByUsername(name);

    if (user == null) {
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }

    List<Question> questions = questionService.getByUser(user);
    if (questions.isEmpty()) {
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }
    return new ResponseEntity<List<Question>>(questions, HttpStatus.OK);
}
 
開發者ID:noveogroup-amorgunov,項目名稱:spring-mvc-react,代碼行數:17,代碼來源:QuestionController.java

示例13: getQuestionsByTag

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(Views.Public.class)
@RequestMapping(value = "/questions/tag/{name}", method = RequestMethod.GET)
public ResponseEntity<?> getQuestionsByTag(@PathVariable("name") String name) {

    Tag tag = tagService.getByName(name);

    if (tag == null) {
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }

    List<Question> questions = questionService.getByTag(tag);
    if (questions.isEmpty()) {
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }
    return new ResponseEntity<List<Question>>(questions, HttpStatus.OK);
}
 
開發者ID:noveogroup-amorgunov,項目名稱:spring-mvc-react,代碼行數:17,代碼來源:QuestionController.java

示例14: login

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(Views.Public.class)
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ResponseEntity<?> login(@RequestBody LoginModel data) {
    User user = userService.getByUsername(data.getUsername());

    if (user == null) {
        return new ResponseEntity(new LoginResponseBody(false, null, "User with that name isn't exist"),
                HttpStatus.OK);
    }

    if (!Objects.equals(user.getPassword(), MD5.getHash(data.getPassword()))) {
        return new ResponseEntity(new LoginResponseBody(false, null, "wrong_password"),
                HttpStatus.OK);
    }

    String token = Jwts.builder()
            .setSubject(data.getUsername())
            .signWith(SignatureAlgorithm.HS512, key)
            .compact();

    return new ResponseEntity(new LoginResponseBody(true, token), HttpStatus.OK);
}
 
開發者ID:noveogroup-amorgunov,項目名稱:spring-mvc-react,代碼行數:23,代碼來源:AuthorizationController.java

示例15: register

import com.fasterxml.jackson.annotation.JsonView; //導入依賴的package包/類
@JsonView(Views.Public.class)
@RequestMapping(value = "/register", method = RequestMethod.POST)
public ResponseEntity<?> register(@RequestBody LoginModel data) {

    User user = userService.getByUsername(data.getUsername());

    if (user != null) {
        return new ResponseEntity(new LoginResponseBody(false, null, "User with that name has already existed"),
                HttpStatus.OK);
    }

    User newUser = new User(data.getUsername(), MD5.getHash(data.getPassword()), new Date(), "active", 0);
    userService.addUser(newUser);

    String token = Jwts.builder()
            .setSubject(newUser.getUsername())
            .signWith(SignatureAlgorithm.HS512, key)
            .compact();

    return new ResponseEntity(new LoginResponseBody(true, token), HttpStatus.OK);
}
 
開發者ID:noveogroup-amorgunov,項目名稱:spring-mvc-react,代碼行數:22,代碼來源:AuthorizationController.java


注:本文中的com.fasterxml.jackson.annotation.JsonView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。