0
リクエストパラメータをjsonのプロパティを返すメソッドに渡したいとします。私はその後、設定したフィルタを作成し解決するためにSpring jsonview getParameterリクエストパラメータ付き
{
"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"
}
]
}
}
私requestcontroller方法に日付を渡す方法
@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);
}
}