当前位置: 首页>>代码示例>>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;未经允许,请勿转载。