Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/koreatech/in/controller/BusController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import koreatech.in.domain.Bus.BusTimetable;
import koreatech.in.domain.Bus.SchoolBusCourse;
import koreatech.in.domain.Bus.SingleBusTime;
import koreatech.in.dto.normal.bus.BusTimetableResponse;
import koreatech.in.service.BusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -60,4 +61,13 @@ ResponseEntity<List<SingleBusTime>> getTimetable(@ApiParam(value = "yyyy-MM-dd",

return new ResponseEntity<>(busService.searchTimetable(date, time, depart, arrival), HttpStatus.OK);
}

@RequestMapping(value = "/timetable/v2", method = RequestMethod.GET)
public @ResponseBody
ResponseEntity<BusTimetableResponse> getTimetableV2(@ApiParam(value = "버스 종류(shuttle, commuting, express)", required = true) @RequestParam(value = "bus_type") String busType,
@ApiParam(value = "등/하교(to, from)", required = true) @RequestParam(value = "direction") String direction,
@ApiParam(value = "버스 노선 지역") @RequestParam(value = "region", required = false) String region) {

return new ResponseEntity<>(busService.getTimetableWithUpdatedAt(busType, direction, region), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ ResponseEntity<OwnerResponse> getOwner(@ApiParam(value = "owner_id", required =
@ApiResponse(code = 409, message = "- 조회한 회원의 신원이 사장님이 아닐 때 (code: 101018) \n" +
"- 중복된 닉네임일 때 (code: 101002)", response = ExceptionResponse.class),
@ApiResponse(code = 422, message = "- 유효한 성별이 아닐 때 (code: 101020) \n" +
"- 유효한 이메일이 아닐 때 (code: 101013) \n" +
"- 유효한 이메일이 아닐 때 (code: 101013) \n" +
"- 유효한 사업자 번호가 아닐 때(code: 101021)", response = ExceptionResponse.class)
})
@ParamValid
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package koreatech.in.dto.normal.bus;

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

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import koreatech.in.domain.Bus.BusTimetable;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
@JsonNaming(SnakeCaseStrategy.class)
public class BusTimetableResponse {
private List<? extends BusTimetable> busTimetables;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul")
private Date updatedAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public class OwnerRegisterRequest extends UserRegisterRequest {
)
private String companyNumber;

@Size(min = 3, max = 5, message = "이미지는 사업자등록증, 영업신고증, 통장사본을 포함하여 최소 3개 최대 5개까지 가능합니다.")
@Size(min = 1, max = 5, message = "이미지는 사업자등록증, 영업신고증, 통장사본을 포함하여 최소 1개 최대 5개까지 가능합니다.")
@ApiModelProperty(notes = "첨부 이미지들 \n"
+ "- required = false \n"
+ "- 이미지는 최소 3개 최대 5개까지 허용됨 \n"
+ "- 이미지는 최소 1개 최대 5개까지 허용됨 \n"
+ "- 모든 이미지들이 코인 이미지 형식이어야 함 \n"
, dataType = "[Lkoreatech.in.dto.global.AttachmentUrlRequest;"
, required = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
public class OwnerUpdateRequest // extends UserUpdateRequest // 사장님 Update에 대한 요청이 정확히 확인되지 않아, 필수적인 첨부파일만 넘기도록 함.
{

@Size(min = 3, max = 5, message = "이미지는 사업자등록증, 영업신고증, 통장사본을 포함하여 최소 3개 최대 5개까지 가능합니다.")
@Size(min = 1, max = 5, message = "이미지는 사업자등록증, 영업신고증, 통장사본을 포함하여 최소 1개 최대 5개까지 가능합니다.")
@ApiModelProperty(notes = "첨부 이미지들 \n"
+ "- not null \n"
+ "- 이미지는 최소 3개 최대 5개까지 허용됨 \n"
+ "- 이미지는 최소 1개 최대 5개까지 허용됨 \n"
+ "- 모든 이미지들이 코인 이미지 형식이어야 함 \n"
, dataType = "[Lkoreatech.in.dto.global.AttachmentUrlRequest;"
)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/koreatech/in/service/BusService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import koreatech.in.domain.Bus.BusRemainTime;
import koreatech.in.domain.Bus.SchoolBusCourse;
import koreatech.in.domain.Bus.SingleBusTime;
import koreatech.in.dto.normal.bus.BusTimetableResponse;

import java.util.List;

Expand All @@ -16,4 +17,6 @@ public interface BusService {
List<? extends BusTimetable> getTimetable(String busType, String direction, String region);

List<SingleBusTime> searchTimetable(String date, String time, String depart, String arrival);

BusTimetableResponse getTimetableWithUpdatedAt(String busType, String direction, String region);
}
27 changes: 27 additions & 0 deletions src/main/java/koreatech/in/service/BusServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

import koreatech.in.domain.Bus.*;
import koreatech.in.domain.ErrorMessage;
import koreatech.in.domain.Version.Version;
import koreatech.in.dto.normal.bus.BusTimetableResponse;
import koreatech.in.exception.BaseException;
import koreatech.in.exception.ExceptionInformation;
import koreatech.in.exception.PreconditionFailedException;
import koreatech.in.mapstruct.normal.bus.SchoolBusCourseConverter;
import koreatech.in.repository.BusRepository;
import koreatech.in.repository.VersionMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
Expand All @@ -16,13 +22,17 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

@Service
public class BusServiceImpl implements BusService {

@Autowired
private BusRepository busRepository;

@Autowired
private VersionMapper versionMapper;

@Override
public BusRemainTime getRemainTime(String busType, String depart, String arrival) {

Expand Down Expand Up @@ -81,4 +91,21 @@ public List<SingleBusTime> searchTimetable(String date, String time, String depa

return result;
}

@Override
public BusTimetableResponse getTimetableWithUpdatedAt(String busType, String direction, String region) {
List<? extends BusTimetable> busTimetables = getTimetable(busType, direction, region);

if (busType.equalsIgnoreCase("commuting")) {
busType = "shuttle";
}

Version version = Optional.ofNullable(versionMapper.getVersion(busType + "_bus_timetable"))
.orElseThrow(() -> new BaseException(ExceptionInformation.VERSION_NOT_FOUND));

return BusTimetableResponse.builder()
.busTimetables(busTimetables)
.updatedAt(version.getUpdated_at())
.build();
}
}