如何调用resttemplate中的列表?

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

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

public class Account implements Serializable {

    private static final long serialVersionUID = 1L;

    private long id;
    private String accountType;
    private String title;
    private double lockedAmount;
    private String lastUpdate;
    private double balance;
    private String currency;
    private String rib;
    private String Agency;
    private String swiftcode;
    private String ribURI;
    private boolean canDebit;
    private boolean canCredit;
    private List<Operation> operation;
    private List<Documents> documents;

2-该类操作:

public class Operation {

    private String Descript;
    private String ValueDate;
    private String bookDate;
    private String Reference;
    private Integer Debit;
    private Integer Credit;
    private Integer ClosingBalance;

}

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

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

4-4服务:

//get Operation list by account id 
    public List<Operation> getOperationsByAccountId(@PathVariable long id, String bookDate) {
        Account account = new Account();

        account.setId(id);
        String url = operationUrl;
        account = resttemplate.postForObject(url,account, Account.class);

        return account.getOperation();
    }

5-我需要返回此结果:

{   "account": {     "id": "100000000137",     
"operation": [       
{        
 "bookDate": "20160105 20160201"       }     ]   } }

暂无答案!

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

相关问题