Skip to content

Commit

Permalink
Merge pull request #2 from DebbieIsFree/feature/airplane
Browse files Browse the repository at this point in the history
Feature/airplane PR 하겠습니다.
  • Loading branch information
DebbieIsFree authored May 21, 2024
2 parents f899385 + 3063ab4 commit 117f3e4
Show file tree
Hide file tree
Showing 21 changed files with 509 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.EnjoyTripBackend.controller;

import com.example.EnjoyTripBackend.dto.NonPagingResponseResult;
import com.example.EnjoyTripBackend.dto.ResponseResult;
import com.example.EnjoyTripBackend.dto.house.HouseRequestDto;
import com.example.EnjoyTripBackend.dto.house.HouseResponseDto;
import com.example.EnjoyTripBackend.service.HouseService;
import com.example.EnjoyTripBackend.util.argumentresolver.LimitedSizePagination;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class HouseController {

private final HouseService houseService;

@GetMapping("/houses")
public ResponseEntity<ResponseResult<List<HouseResponseDto>>> houseList(@PageableDefault(size = 20) Pageable pageable){
return ResponseEntity.ok().body(houseService.houseList(pageable));
}

@GetMapping("/houses/{id}")
public ResponseEntity<NonPagingResponseResult<HouseResponseDto>> houseDetail(@PathVariable("id")String id){
return ResponseEntity.ok().body(houseService.findById(id));
}

@PostMapping("/houses/search")
@LimitedSizePagination(maxSize = 20)
public ResponseEntity<ResponseResult<List<HouseResponseDto>>> houseSearchList(@PageableDefault(size = 20) Pageable pageable, @RequestBody HouseRequestDto requestDto){
return ResponseEntity.ok().body(houseService.houseSearchList(pageable, requestDto));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.EnjoyTripBackend.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class House {
private String addr1;
private String addr2;
private String areacode;
private String contentid;
private String firstimage;
private String mapx;
private String mapy;
private String mlevel;
private String tel;
private String title;
private String sigungucode;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.EnjoyTripBackend.dto.airplane;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AirplaneBody {
private AirplaneItems items;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.EnjoyTripBackend.dto.airplane;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AirplaneDto {

private AirplaneResponse response;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.EnjoyTripBackend.dto.airplane;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

@Getter
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AirplaneItem {
private String airlineNm;
private String arrAirportNm;
private String arrPlandTime;
private String depAirportNm;
private String depPlandTime;
private String economyCharge;
private String prestigeCharge;
private String vihicleId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.EnjoyTripBackend.dto.airplane;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AirplaneItems {
private List<AirplaneItem> item;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.EnjoyTripBackend.dto.airplane;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AirplaneResponse {
private AirplaneBody body;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.EnjoyTripBackend.dto.house;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class HouseBody {
private HouseItems items;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.EnjoyTripBackend.dto.house;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class HouseDto {

private HouseResponse response;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.EnjoyTripBackend.dto.house;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

@Getter
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class HouseItem {
private String addr1;
private String addr2;
private String areacode;
private String benikia;
private String cat1;
private String cat2;
private String cat3;
private String contentid;
private String contenttypeid;
private String createdtime;
private String firstimage;
private String firstimage2;
private String cpyrhtDivCd;
private String goodstay;
private String hanok;
private String mapx;
private String mapy;
private String mlevel;
private String modifiedtime;
private String tel;
private String title;
private String booktour;
private String sigungucode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.EnjoyTripBackend.dto.house;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class HouseItems {
private List<HouseItem> item;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.EnjoyTripBackend.dto.house;

import lombok.*;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class HouseRequestDto {
private String areacode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.EnjoyTripBackend.dto.house;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class HouseResponse {
private HouseBody body;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.EnjoyTripBackend.dto.house;

import lombok.*;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HouseResponseDto {
private Long id;
private String addr1;
private String addr2;
private String areacode;
private String contentid;
private String firstimage;
private String mapx;
private String mapy;
private String mlevel;
private String tel;
private String title;
private String sigungucode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.EnjoyTripBackend.repository;

import com.example.EnjoyTripBackend.domain.House;
import com.example.EnjoyTripBackend.dto.PageRequestList;
import com.example.EnjoyTripBackend.dto.house.HouseResponseDto;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Optional;

@Mapper
public interface HouseRepository {
Long save(House house);
List<HouseResponseDto> findAll(PageRequestList<?> requestList);
Optional<HouseResponseDto> findById(String id);
List<HouseResponseDto> findAllBySearch(PageRequestList<?> requestList);
Long findTotalCount();
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.example.EnjoyTripBackend.service;

import com.example.EnjoyTripBackend.domain.Airplane;
import com.example.EnjoyTripBackend.dto.airplane.AirplaneItem;
import com.example.EnjoyTripBackend.dto.NonPagingResponseResult;
import com.example.EnjoyTripBackend.dto.PageRequestList;
import com.example.EnjoyTripBackend.dto.ResponseResult;
import com.example.EnjoyTripBackend.dto.airplane.AirplaneRequestDto;
import com.example.EnjoyTripBackend.dto.airplane.AirplaneResponseDto;
import com.example.EnjoyTripBackend.dto.golf.GolfRequestDto;
import com.example.EnjoyTripBackend.dto.golf.GolfResponseDto;
import com.example.EnjoyTripBackend.dto.place.PlaceResponseDto;
import com.example.EnjoyTripBackend.exception.EnjoyTripException;
import com.example.EnjoyTripBackend.exception.ErrorCode;
import com.example.EnjoyTripBackend.repository.AirplaneRepository;
Expand All @@ -18,8 +16,6 @@
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Date;
import java.util.Optional;

@Service
@RequiredArgsConstructor
Expand All @@ -29,16 +25,16 @@ public class AirplaneService {
private final AirplaneRepository airplaneRepository;

@Transactional
public void save(AirplaneResponseDto airplaneResponseDto) {
public void save(AirplaneItem item) {
Airplane airplane = Airplane.builder()
.airlineNm(airplaneResponseDto.getAirlineNm())
.arrAirportNm(airplaneResponseDto.getArrAirportNm())
.depAirportNm(airplaneResponseDto.getDepAirportNm())
.arrPlandTime(airplaneResponseDto.getArrPlandTime())
.depPlandTime(airplaneResponseDto.getDepPlandTime())
.economyCharge(airplaneResponseDto.getEconomyCharge())
.prestigeCharge(airplaneResponseDto.getPrestigeCharge())
.vihicleId(airplaneResponseDto.getVihicleId())
.airlineNm(item.getAirlineNm())
.arrAirportNm(item.getArrAirportNm())
.depAirportNm(item.getDepAirportNm())
.arrPlandTime(item.getArrPlandTime())
.depPlandTime(item.getDepPlandTime())
.economyCharge(item.getEconomyCharge())
.prestigeCharge(item.getPrestigeCharge())
.vihicleId(item.getVihicleId())
.build();

airplaneRepository.save(airplane);
Expand Down
Loading

0 comments on commit 117f3e4

Please sign in to comment.