【发布时间】:2017-06-30 15:08:29
【问题描述】:
我想将请求参数传递给返回 json 属性的方法。如何解决和产生这样的问题:
{
"project":{
"id": 1,
"cashflow":[{
date: "2014-09-27T18:30:49-0300",
value:-1000,
name:"telecomunication services"
},{
date: "2014-09-27T18:40:40-0200",
value:-2000,
name:"others cost services"
}
]
}
}
我的请求控制器如何将日期传递给方法
@JsonView({Views.PublicWithoutLazy.class})
@Transactional
@RequestMapping(value="/project", method=RequestMethod.GET)
public @ResponseBody Project findProject(Long id, Date dt) {
//my questions is here. how to pass date to filter cashflow?
return projectDAO.find(id);
}
实体
@Entity
Class project{
@JsonView(Views.PublicWithoutLazy.class)
@Id
Long id;
@MapKeyTemporal(TemporalType.DATE)
@OneToMany(mappedBy = "cashFlow", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.EXTRA)
private Map<Date, List<Cash>> cashflow= new HashMap<>();
@JsonView(Views.PublicWithoutLazy.class)
@Transient
public List<Cash> getCashFlow(Date dt){
return cashFlow.get(dt);
}
}
【问题讨论】: