use of com.alibaba.fastjson.support.spring.annotation.FastJsonView in project fastjson by alibaba.
the class FastJsonViewControllerTest method test6.
@RequestMapping("test6")
@FastJsonView(include = { @FastJsonFilter(clazz = Company.class, props = { "id" }) }, exclude = { @FastJsonFilter(clazz = Company.class, props = { "name" }) })
@ResponseBody
public Company test6() {
Company company = new Company();
company.setId(100L);
company.setName("测试");
company.setDescription("fastjsonview注解测试");
company.setStock("haha");
return company;
}
use of com.alibaba.fastjson.support.spring.annotation.FastJsonView in project fastjson by alibaba.
the class FastJsonViewControllerTest method test4.
@RequestMapping("test4")
@FastJsonView(include = { @FastJsonFilter(clazz = Company.class, props = { "id", "name", "rootDepartment" }) }, exclude = { @FastJsonFilter(clazz = Department.class, props = { "description" }) })
@ResponseBody
public Company test4() {
Company company = new Company();
company.setId(100L);
company.setName("测试");
company.setDescription("fastjsonview注解测试");
company.setStock("haha");
Department department = new Department();
department.setName("部门1");
department.setDescription("部门1描述");
department.setId(1L);
company.setRootDepartment(department);
return company;
}
use of com.alibaba.fastjson.support.spring.annotation.FastJsonView in project fastjson by alibaba.
the class FastJsonViewControllerTest method test2.
@RequestMapping("test2")
@FastJsonView(exclude = { @FastJsonFilter(clazz = Company.class, props = { "id", "name" }) })
@ResponseBody
public Company test2() {
Company company = new Company();
company.setId(100L);
company.setName("测试");
company.setDescription("fastjsonview注解测试");
company.setStock("haha");
return company;
}
use of com.alibaba.fastjson.support.spring.annotation.FastJsonView in project fastjson by alibaba.
the class FastJsonViewResponseBodyAdvice method beforeBodyWriteInternal.
protected void beforeBodyWriteInternal(FastJsonContainer container, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
FastJsonView annotation = returnType.getMethodAnnotation(FastJsonView.class);
FastJsonFilter[] include = annotation.include();
FastJsonFilter[] exclude = annotation.exclude();
PropertyPreFilters filters = new PropertyPreFilters();
for (FastJsonFilter item : include) {
filters.addFilter(item.clazz(), item.props());
}
for (FastJsonFilter item : exclude) {
filters.addFilter(item.clazz()).addExcludes(item.props());
}
container.setFilters(filters);
}
use of com.alibaba.fastjson.support.spring.annotation.FastJsonView in project uavstack by uavorg.
the class FastJsonViewResponseBodyAdvice method beforeBodyWriteInternal.
protected void beforeBodyWriteInternal(FastJsonContainer container, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
FastJsonView annotation = returnType.getMethodAnnotation(FastJsonView.class);
FastJsonFilter[] include = annotation.include();
FastJsonFilter[] exclude = annotation.exclude();
PropertyPreFilters filters = new PropertyPreFilters();
for (FastJsonFilter item : include) {
filters.addFilter(item.clazz(), item.props());
}
for (FastJsonFilter item : exclude) {
filters.addFilter(item.clazz()).addExcludes(item.props());
}
container.setFilters(filters);
}
Aggregations