Служба Spring Rest не возвращает полный объект - PullRequest
0 голосов
/ 08 октября 2019

У меня есть конечная точка счетов Spring, как показано ниже, которая возвращает массив объектов «Вещи» с некоторыми данными. По какой-то причине я получаю только часть объекта, когда выполняется вызов. Я пытаюсь получить массив вещей, включая полный объект, а не только странный подраздел, который я получаю ниже.

@GetMapping("/accounts")
    public List<Things> test3() throws JSONException {
        tester.clear();
        for (int i = 0; i < 4; i++) {
            Double db = (double) i;
            Things jo = new Things(String.valueOf(i), "c", "a", java.sql.Date.valueOf("2013-09-04"),db, java.sql.Date.valueOf("2013-09-04"),
                    "d", "e", "f", "g", ko, ko);

            tester.add(jo);
        }
        return tester;

Эта конечная точка содержится в restController и возвращает следующее:

[
    {
        "postBalance": 0.0,
        "intFromDate": "2013-09-04",
        "accType": "d",
        "accDestination": "e",
        "forexBch": "f",
        "forexAcc": "g",
        "maxLimit": 1111.0,
        "minLimit": 1111.0
    },
    {
        "postBalance": 1.0,
        "intFromDate": "2013-09-04",
        "accType": "d",
        "accDestination": "e",
        "forexBch": "f",
        "forexAcc": "g",
        "maxLimit": 1111.0,
        "minLimit": 1111.0
    },
    {
        "postBalance": 2.0,
        "intFromDate": "2013-09-04",
        "accType": "d",
        "accDestination": "e",
        "forexBch": "f",
        "forexAcc": "g",
        "maxLimit": 1111.0,
        "minLimit": 1111.0
    },
    {
        "postBalance": 3.0,
        "intFromDate": "2013-09-04",
        "accType": "d",
        "accDestination": "e",
        "forexBch": "f",
        "forexAcc": "g",
        "maxLimit": 1111.0,
        "minLimit": 1111.0
    }
]

Класс данных выглядит следующим образом.

package db2New.jdbc;

import java.sql.Date;

public class Things {
    private String customerKey;
    private String ccy;
    private String sfx;
    private Date dateLastAmended;
    private Double postBalance;
    private Date intFromDate;
    private String accType;
    private String accDestination;
    private String forexBch;
    private String forexAcc;
    private Double maxLimit;
    private Double minLimit;

    public Things(String customerKey, String ccy, String sfx, Date dateLastAmended, Double postBalance,
                  Date intFromDate, String accType, String accDestination, String forexBch, String forexAcc, Double maxLimit, Double minLimit) {
        setCustomerKey(customerKey);
        setCcy(ccy);
        setSfx(sfx);
        setDateLastAmended(dateLastAmended);
        setPostBalance(postBalance);
        setIntFromDate(intFromDate);
        setAccType(accType);
        setAccDestination(accDestination);
        setForexBch(forexBch);
        setForexAcc(forexAcc);
        setMaxLimit(maxLimit);
        setMinLimit(minLimit);

    }

    private String getCustomerKey() {
        return customerKey;
    }

    public void setCustomerKey(String customerKey) {
        this.customerKey = customerKey;
    }

    private String getCcy() {
        return ccy;
    }

    public void setCcy(String ccy) {
        this.ccy = ccy;
    }

    private String getSfx() {
        return sfx;
    }

    public void setSfx(String sfx) {
        this.sfx = sfx;
    }

    private Date getDateLastAmended() {
        return dateLastAmended;
    }

    public void setDateLastAmended(Date dateLastAmended) {
        this.dateLastAmended = dateLastAmended;
    }

    public Double getPostBalance() {
        return postBalance;
    }

    public void setPostBalance(Double postBalance) {
        this.postBalance = postBalance;
    }

    public Date getIntFromDate() {
        return intFromDate;
    }

    public void setIntFromDate(Date intFromDate) {
        this.intFromDate = intFromDate;
    }

    public String getAccType() {
        return accType;
    }

    public void setAccType(String accType) {
        this.accType = accType;
    }

    public String getAccDestination() {
        return accDestination;
    }

    public void setAccDestination(String accDestination) {
        this.accDestination = accDestination;
    }

    public String getForexBch() {
        return forexBch;
    }

    public void setForexBch(String forexBch) {
        this.forexBch = forexBch;
    }

    public String getForexAcc() {
        return forexAcc;
    }

    public void setForexAcc(String forexAcc) {
        this.forexAcc = forexAcc;
    }

    public Double getMaxLimit() {
        return maxLimit;
    }

    public void setMaxLimit(Double maxLimit) {
        this.maxLimit = maxLimit;
    }

    public Double getMinLimit() {
        return minLimit;
    }

    public void setMinLimit(Double minLimit) {
        this.minLimit = minLimit;
    }

}

1 Ответ

1 голос
/ 08 октября 2019

геттер для этого поля является частным, поэтому вам нужно изменить доступ к общедоступному

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...