本文整理汇总了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();
}
示例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());
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}