-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 노선 검색 API - 노선 등록 service - 정류장 검색 service - 정류장 등록 service - 노선별 경유 정류장 검색 service - 노선별 경유 정류장 등록 service
- Loading branch information
Showing
19 changed files
with
649 additions
and
11 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
server/src/main/java/com/talkka/server/bus/controller/BusRouteController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.talkka.server.bus.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.talkka.server.bus.dto.BusRouteRespDto; | ||
import com.talkka.server.bus.service.BusRouteService; | ||
import com.talkka.server.common.dto.ApiRespDto; | ||
import com.talkka.server.common.enums.StatusCode; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/bus/route") | ||
public class BusRouteController { | ||
private final BusRouteService busRouteService; | ||
|
||
@GetMapping("") | ||
public ResponseEntity<ApiRespDto<List<BusRouteRespDto>>> findByRouteName(@RequestParam("search") String routeName) { | ||
return ResponseEntity.ok( | ||
ApiRespDto.<List<BusRouteRespDto>>builder() | ||
.statusCode(StatusCode.OK.getCode()) | ||
.message(StatusCode.OK.getMessage()) | ||
.data(busRouteService.findByRouteName(routeName)) | ||
.build() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
server/src/main/java/com/talkka/server/bus/dao/BusRouteRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
package com.talkka.server.bus.dao; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface BusRouteRepository extends JpaRepository<BusRouteEntity, Long> { | ||
|
||
boolean existsByApiRouteId(String apiRouteId); | ||
|
||
Optional<BusRouteEntity> findByApiRouteId(String apiRouteId); | ||
|
||
List<BusRouteEntity> findByRouteNameLikeOrderByRouteNameAsc(String routeName); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
server/src/main/java/com/talkka/server/bus/dao/BusRouteStationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
package com.talkka.server.bus.dao; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface BusRouteStationRepository extends JpaRepository<BusRouteStationEntity, Long> { | ||
List<BusRouteStationEntity> findByRouteId(Long routeId); | ||
|
||
List<BusRouteStationEntity> findByStationId(Long stationId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
server/src/main/java/com/talkka/server/bus/dao/BusStationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
package com.talkka.server.bus.dao; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface BusStationRepository extends JpaRepository<BusStationEntity, Long> { | ||
Optional<BusStationEntity> findByApiStationId(String apiStationId); | ||
|
||
List<BusStationEntity> findByStationNameLikeOrderByStationNameAsc(String stationName); | ||
|
||
boolean existsByApiStationId(String apiStationId); | ||
} |
70 changes: 70 additions & 0 deletions
70
server/src/main/java/com/talkka/server/bus/dto/BusRouteCreateDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.talkka.server.bus.dto; | ||
|
||
import com.talkka.server.bus.dao.BusRouteEntity; | ||
import com.talkka.server.bus.enums.BusRouteType; | ||
import com.talkka.server.bus.enums.DistrictCode; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Builder | ||
@ToString | ||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class BusRouteCreateDto { | ||
|
||
private String apiRouteId; // 공공 api 에서 제공해주는 식별자 | ||
private String routeName; // 노선 번호 | ||
private BusRouteType routeTypeCd; // 노선 유형 코드 | ||
private String routeTypeName; // 노선 유형명 | ||
private String companyId; // 운수업체 아이디 | ||
private String companyName; // 운수업체명 | ||
private String companyTel; // 운수업체 전화번호 | ||
private DistrictCode districtCd; // 관할 지역 코드 | ||
private String upFirstTime; // 평일 기점 첫차 시간 | ||
private String upLastTime; // 평일 기점 막차 시간 | ||
private String downFirstTime; // 평일 종점 첫차 시간 | ||
private String downLastTime; // 평일 종점 막차 시간 | ||
private String startMobileNo; // 기점 정류소 번호 | ||
private Long startStationId; // 기점 정류소 아이디 | ||
private String startStationName; // 기점 정류소명 | ||
private Long endStationId; // 종점 정류소 아이디 | ||
private String endMobileNo; // 종점 정류소 번호 | ||
private String endStationName; // 종점 정류소명 | ||
private String regionName; // 지역명 | ||
private Integer peekAlloc; // 평일 최소 배차 시간 | ||
private Integer nPeekAlloc; // 평일 최대 배차 시간 | ||
|
||
public BusRouteEntity toEntity() { | ||
return BusRouteEntity.builder() | ||
.apiRouteId(apiRouteId) | ||
.routeName(routeName) | ||
.routeTypeCd(routeTypeCd) | ||
.routeTypeName(routeTypeName) | ||
.companyId(companyId) | ||
.companyName(companyName) | ||
.companyTel(companyTel) | ||
.districtCd(districtCd) | ||
.upFirstTime(upFirstTime) | ||
.upLastTime(upLastTime) | ||
.downFirstTime(downFirstTime) | ||
.downLastTime(downLastTime) | ||
.startMobileNo(startMobileNo) | ||
.startStationId(startStationId) | ||
.startStationName(startStationName) | ||
.endStationId(endStationId) | ||
.endMobileNo(endMobileNo) | ||
.endStationName(endStationName) | ||
.regionName(regionName) | ||
.peekAlloc(peekAlloc) | ||
.nPeekAlloc(nPeekAlloc) | ||
.build(); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
server/src/main/java/com/talkka/server/bus/dto/BusRouteRespDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.talkka.server.bus.dto; | ||
|
||
import com.talkka.server.bus.dao.BusRouteEntity; | ||
import com.talkka.server.bus.enums.BusRouteType; | ||
import com.talkka.server.bus.enums.DistrictCode; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Builder | ||
@ToString | ||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class BusRouteRespDto { | ||
|
||
private Long routeId; | ||
private String routeName; // 노선 번호 | ||
private BusRouteType routeTypeCd; // 노선 유형 코드 | ||
private String routeTypeName; // 노선 유형명 | ||
private DistrictCode districtCd; // 관할 지역 코드 | ||
private String upFirstTime; // 평일 기점 첫차 시간 | ||
private String upLastTime; // 평일 기점 막차 시간 | ||
private String downFirstTime; // 평일 종점 첫차 시간 | ||
private String downLastTime; // 평일 종점 막차 시간 | ||
private String startMobileNo; // 기점 정류소 번호 | ||
private Long startStationId; // 기점 정류소 아이디 | ||
private String startStationName; // 기점 정류소명 | ||
private Long endStationId; // 종점 정류소 아이디 | ||
private String endMobileNo; // 종점 정류소 번호 | ||
private String endStationName; // 종점 정류소명 | ||
private String regionName; // 지역명 | ||
private Integer peekAlloc; // 평일 최소 배차 시간 | ||
private Integer nPeekAlloc; // 평일 최대 배차 시간 | ||
|
||
public static BusRouteRespDto of(BusRouteEntity busRouteEntity) { | ||
return BusRouteRespDto.builder() | ||
.routeId(busRouteEntity.getId()) | ||
.routeName(busRouteEntity.getRouteName()) | ||
.routeTypeCd(busRouteEntity.getRouteTypeCd()) | ||
.routeTypeName(busRouteEntity.getRouteTypeName()) | ||
.districtCd(busRouteEntity.getDistrictCd()) | ||
.upFirstTime(busRouteEntity.getUpFirstTime()) | ||
.upLastTime(busRouteEntity.getUpLastTime()) | ||
.downFirstTime(busRouteEntity.getDownFirstTime()) | ||
.downLastTime(busRouteEntity.getDownLastTime()) | ||
.startMobileNo(busRouteEntity.getStartMobileNo()) | ||
.startStationId(busRouteEntity.getStartStationId()) | ||
.startStationName(busRouteEntity.getStartStationName()) | ||
.endStationId(busRouteEntity.getEndStationId()) | ||
.endMobileNo(busRouteEntity.getEndMobileNo()) | ||
.endStationName(busRouteEntity.getEndStationName()) | ||
.regionName(busRouteEntity.getRegionName()) | ||
.peekAlloc(busRouteEntity.getPeekAlloc()) | ||
.nPeekAlloc(busRouteEntity.getNPeekAlloc()) | ||
.build(); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
server/src/main/java/com/talkka/server/bus/dto/BusRouteStationCreateDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.talkka.server.bus.dto; | ||
|
||
import com.talkka.server.bus.dao.BusStationEntity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Builder | ||
@ToString | ||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class BusRouteStationCreateDto { | ||
|
||
private String apiRouteId; | ||
private String apiStationId; | ||
private BusStationEntity station; | ||
private Short stationSeq; | ||
private String stationName; | ||
} |
40 changes: 40 additions & 0 deletions
40
server/src/main/java/com/talkka/server/bus/dto/BusRouteStationRespDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.talkka.server.bus.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import com.talkka.server.bus.dao.BusRouteStationEntity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@Builder | ||
@ToString | ||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class BusRouteStationRespDto { | ||
|
||
private Long busRouteStationId; | ||
private BusRouteRespDto route; | ||
private BusStationRespDto station; | ||
private Short stationSeq; | ||
private String stationName; | ||
private LocalDateTime createdAt; | ||
|
||
public static BusRouteStationRespDto of(BusRouteStationEntity busRouteStationEntity) { | ||
return BusRouteStationRespDto.builder() | ||
.busRouteStationId(busRouteStationEntity.getId()) | ||
.route(BusRouteRespDto.of(busRouteStationEntity.getRoute())) | ||
.station(BusStationRespDto.of(busRouteStationEntity.getStation())) | ||
.stationSeq(busRouteStationEntity.getStationSeq()) | ||
.stationName(busRouteStationEntity.getStationName()) | ||
.createdAt(busRouteStationEntity.getCreatedAt()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.