如何调用resttemplate中的列表?

ncgqoxb0  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(229)

1-这是帐户的我的模型对象,我想为post方法返回一个json结果,我的问题是我的代码返回null=

  1. public class Account implements Serializable {
  2. private static final long serialVersionUID = 1L;
  3. private long id;
  4. private String accountType;
  5. private String title;
  6. private double lockedAmount;
  7. private String lastUpdate;
  8. private double balance;
  9. private String currency;
  10. private String rib;
  11. private String Agency;
  12. private String swiftcode;
  13. private String ribURI;
  14. private boolean canDebit;
  15. private boolean canCredit;
  16. private List<Operation> operation;
  17. private List<Documents> documents;

2-该类操作:

  1. public class Operation {
  2. private String Descript;
  3. private String ValueDate;
  4. private String bookDate;
  5. private String Reference;
  6. private Integer Debit;
  7. private Integer Credit;
  8. private Integer ClosingBalance;
  9. }

3-这是我在控制器中执行的操作:

  1. //get Operation list by account id
  2. @PostMapping("eAccount/Operations/Account/{id}")
  3. public List<Operation> getOperationsByAccountId(@PathVariable long id, String bookDate) {
  4. return operationService.getOperationsByAccountId(id, bookDate);
  5. }

4-4服务:

  1. //get Operation list by account id
  2. public List<Operation> getOperationsByAccountId(@PathVariable long id, String bookDate) {
  3. Account account = new Account();
  4. account.setId(id);
  5. String url = operationUrl;
  6. account = resttemplate.postForObject(url,account, Account.class);
  7. return account.getOperation();
  8. }

5-我需要返回此结果:

  1. { "account": { "id": "100000000137",
  2. "operation": [
  3. {
  4. "bookDate": "20160105 20160201" } ] } }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题