Developer Cafe

DTO 설계하기 본문

JAVA

DTO 설계하기

개발자 카페 2021. 5. 11. 15:34
728x90

예시) object객체들을 담고있는 car, 리스트를 담고 있는 insurance, object객체들을 담고있는 agency

[
  {
    "car": {
      "modelCode": "xxxx",
      "erpCode": "xxx",
      "erpName": "xxxx",
      "possibleCnt": 0000,
      "seatCnt": 0000,
      "classCode": "xxxxx",
      "gearCode": "xxxx",
      "makerCode": "xxxx",
      "fuelCode": "xxxx",
      "yearsCode": "",
      "optionsCode": "xxxxxxxxxxxxxxx",
      "defaultFee": 00000,
      "saleFee": 00000,
      "specialAgency": "none",
      "imgUrlList": "https://xxxx.png",
      "imgUrlDetail": "https://xxxx.png",
      "unmanned": false,
      "foreign": false
    },
    "insurance": [
      {
        "code": "xxxx",
        "type": "xxxx",
        "fee": 00000,
        "saleFee": 00000,
        "originFee": 00000,
        "limitAge": 00,
        "limitCareer": 0
      }
    ],
    "agency": {
      "agencyCode": "xxxx",
      "agencyName": "xxxxx",
      "latitude": "xx.xx",
      "longitude": "xx.xx",
      "point": x.x,
      "ranking": 00,
      "mobileCheckIn": false,
      "guarantee": false
    }
  },
  {
    "car": {
      "modelCode": "xxxx",
      "erpCode": "xxx",
      "erpName": "xxxx",
      "possibleCnt": 0000,
      "seatCnt": 0000,
      "classCode": "xxxxx",
      "gearCode": "xxxx",
      "makerCode": "xxxx",
      "fuelCode": "xxxx",
      "yearsCode": "",
      "optionsCode": "xxxxxxxxxxxxxxx",
      "defaultFee": 00000,
      "saleFee": 00000,
      "specialAgency": "none",
      "imgUrlList": "https://xxxx.png",
      "imgUrlDetail": "https://xxxx.png",
      "unmanned": false,
      "foreign": false
    },
    "insurance": [
      {
        "code": "xxxx",
        "type": "xxxx",
        "fee": 00000,
        "saleFee": 00000,
        "originFee": 00000,
        "limitAge": 00,
        "limitCareer": 0
      }
    ],
    "agency": {
      "agencyCode": "xxxx",
      "agencyName": "xxxxx",
      "latitude": "xx.xx",
      "longitude": "xx.xx",
      "point": x.x,
      "ranking": 00,
      "mobileCheckIn": false,
      "guarantee": false
    }
  },
  {
    "car": {
      "modelCode": "xxxx",
      "erpCode": "xxx",
      "erpName": "xxxx",
      "possibleCnt": 0000,
      "seatCnt": 0000,
      "classCode": "xxxxx",
      "gearCode": "xxxx",
      "makerCode": "xxxx",
      "fuelCode": "xxxx",
      "yearsCode": "",
      "optionsCode": "xxxxxxxxxxxxxxx",
      "defaultFee": 00000,
      "saleFee": 00000,
      "specialAgency": "none",
      "imgUrlList": "https://xxxx.png",
      "imgUrlDetail": "https://xxxx.png",
      "unmanned": false,
      "foreign": false
    },
    "insurance": [
      {
        "code": "xxxx",
        "type": "xxxx",
        "fee": 00000,
        "saleFee": 00000,
        "originFee": 00000,
        "limitAge": 00,
        "limitCareer": 0
      }
    ],
    "agency": {
      "agencyCode": "xxxx",
      "agencyName": "xxxxx",
      "latitude": "xx.xx",
      "longitude": "xx.xx",
      "point": x.x,
      "ranking": 00,
      "mobileCheckIn": false,
      "guarantee": false
    }
  },
  {
    "car": {
      "modelCode": "xxxx",
      "erpCode": "xxx",
      "erpName": "xxxx",
      "possibleCnt": 0000,
      "seatCnt": 0000,
      "classCode": "xxxxx",
      "gearCode": "xxxx",
      "makerCode": "xxxx",
      "fuelCode": "xxxx",
      "yearsCode": "",
      "optionsCode": "xxxxxxxxxxxxxxx",
      "defaultFee": 00000,
      "saleFee": 00000,
      "specialAgency": "none",
      "imgUrlList": "https://xxxx.png",
      "imgUrlDetail": "https://xxxx.png",
      "unmanned": false,
      "foreign": false
    },
    "insurance": [
      {
        "code": "xxxx",
        "type": "xxxx",
        "fee": 00000,
        "saleFee": 00000,
        "originFee": 00000,
        "limitAge": 00,
        "limitCareer": 0
      }
    ],
    "agency": {
      "agencyCode": "xxxx",
      "agencyName": "xxxxx",
      "latitude": "xx.xx",
      "longitude": "xx.xx",
      "point": x.x,
      "ranking": 00,
      "mobileCheckIn": false,
      "guarantee": false
    }
  },
  {
    "car": {
      "modelCode": "xxxx",
      "erpCode": "xxx",
      "erpName": "xxxx",
      "possibleCnt": 0000,
      "seatCnt": 0000,
      "classCode": "xxxxx",
      "gearCode": "xxxx",
      "makerCode": "xxxx",
      "fuelCode": "xxxx",
      "yearsCode": "",
      "optionsCode": "xxxxxxxxxxxxxxx",
      "defaultFee": 00000,
      "saleFee": 00000,
      "specialAgency": "none",
      "imgUrlList": "https://xxxx.png",
      "imgUrlDetail": "https://xxxx.png",
      "unmanned": false,
      "foreign": false
    },
    "insurance": [
      {
        "code": "xxxx",
        "type": "xxxx",
        "fee": 00000,
        "saleFee": 00000,
        "originFee": 00000,
        "limitAge": 00,
        "limitCareer": 0
      }
    ],
    "agency": {
      "agencyCode": "xxxx",
      "agencyName": "xxxxx",
      "latitude": "xx.xx",
      "longitude": "xx.xx",
      "point": x.x,
      "ranking": 00,
      "mobileCheckIn": false,
      "guarantee": false
    }
  }
]

답) CarResDto를 담을 car, List<InsuranceResDto>를 담을 insurance, AgencyResDto를 담을 agency

@Data
public class ShowCarsResDto {
  private CarResDto car;
  private List<InsuranceResDto> insurance;
  private AgencyResDto agency;
}
@Data
public class CarResDto {
  private String modelCode;
  private String erpCode;
  private String erpName;
  private int possibleCnt;
  private int seatCnt;
  private String classCode;
  private String gearCode;
  private String makerCode;
  private String fuelCode;
  private String yearsCode;
  private String optionsCode;
  private int defaultFee;
  private int saleFee;
  private String specialAgency;
  private String imgUrlList;
  private String imgUrlDetail;
  private boolean unmanned;
  private boolean foreign;
}
@Data
public class InsuranceResDto {
  private String code;
  private String type;
  private int fee;
  private int saleFee;
  private int originFee;
  private int limitAge;
  private int limitCareer;
}
@Data
public class AgencyResDto {
  private String agencyCode;
  private String agencyName;
  private String latitude;
  private String longitude;
  private double point;
  private int ranking;
  private boolean mobileCheckIn;
  private boolean guarantee;
}

 

728x90
Comments