Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : #1, #145, #146, #147, #148, #149, #150 #151

Merged
merged 8 commits into from
Mar 16, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Notice updateNotice(NoticeDto noticeDto, Admin admin, String fileName) {
if (finishDate != null)
this.finishDate = noticeDto.getFinishDate();
this.description = noticeDto.getDescription();
if (photoUrl != null)
if (fileName != null)
this.photoUrl = fileName;
this.admin = admin;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public class ParkingSpot extends BaseTimeEntity {

public ParkingSpot updateState(ParkingSpotType parkingSpotType) {
if (parkingSpotType != null)
{
if(parkingSpotType == ParkingSpotType.PARKINGSPOT_NO_CAR){
this.car = null;
}
this.type = parkingSpotType;
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public Long returnKey(Long kioskId) {
request = new HttpEntity<>(map, headers);

ResponseEntity<String> response2 = restTemplate.postForEntity(piBaseUrl + "/rfid-return", request, String.class);
System.out.println("response2: ");
System.out.println(response2);
String rfid = response2.getBody();
if (rfid == null) {
throw new RuntimeException("응답이 정상적이지 않습니다. 다시 시도해주세요");
Expand All @@ -134,7 +136,9 @@ public Long returnKey(Long kioskId) {
throw new RuntimeException("RFID가 태그되지 않았습니다.");
}

rfid = rfid.replaceAll("\"", "");

log.info("받은 rfid : "+ rfid);
// rfid로 차 키 조회
Key key = keyRepository.findByRfid(rfid)
.orElseThrow(() -> new RuntimeException("없는 차키입니다."));
Expand Down Expand Up @@ -163,7 +167,7 @@ public Long returnKey(Long kioskId) {

request = new HttpEntity<>(map, headers);

ResponseEntity<Boolean> response3 = restTemplate.postForEntity(piBaseUrl + "/receive-car-key", request, Boolean.class);
ResponseEntity<Boolean> response3 = restTemplate.postForEntity(piBaseUrl + "/return-car-key", request, Boolean.class);
if (!Boolean.TRUE.equals(response3.getBody())) {
throw new RuntimeException("응답이 정상적이지 않습니다. 다시 시도해주세요.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ public Boolean patchNotice(NoticePatchDto noticePatchDto, String adminUsername,

File lookupFile;
String projectPath;
String fileName = "";
String fileName = null;
// 사진이 변경된 경우
if (noticePatchDto.getIsModified()) {
log.info("사진이 변경되었습니다.");
// 기존의 사진이 있으면 지우기
if (!notice.getPhotoUrl().equals("")) {
log.info("기존의 이미지를 지웁니다.");
log.info(System.getProperty("user.dir") + "\\files\\" + URLDecoder.decode(notice.getPhotoUrl()));
log.info(System.getProperty("user.dir") + "\\files\\" + URLDecoder.decode(notice.getPhotoUrl(), "UTF-8"));
try {
lookupFile = new File(System.getProperty("user.dir") + "\\files\\" + URLDecoder.decode(notice.getPhotoUrl(), "UTF-8"));
lookupFile.delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ public Boolean postParkingSpots(ParkingSpotRequestList parkingSpotRequestList, S
return true;
}

@Transactional
public Point findCarLocationByCarNumber(String carNumber, String siDo, String branchName) {
return parkingSpotRepository.findCarLocationByCarNumber(carNumber, EnumValueConvertUtils.ofDesc(SiDoType.class, siDo), branchName);
}

@Transactional
public Boolean reportParkingStatus(ReportParkingSpotDto reportParkingSpotDto) {
ParkingSpot parkingSpot = parkingSpotRepository.findById(reportParkingSpotDto.getParkingSpotId())
.orElseThrow((() -> new RuntimeException("없는 주차장 자리입니다.")));
Expand All @@ -102,13 +103,13 @@ public Boolean reportParkingStatus(ReportParkingSpotDto reportParkingSpotDto) {
parkingSpotRepository.save(parkingSpot.updateState(reportParkingSpotDto.getIsParking() ? ParkingSpotType.PARKINGSPOT_CAR : ParkingSpotType.PARKINGSPOT_NO_CAR));
return true;
}

//주차봉 rfid 태그
@Transactional
public Boolean reportRfid(ReportRfidDto reportRfidDto) {
//rfid 내역 저장
if (!reportRfidDto.getIsRfidTagged())
if (!reportRfidDto.getIsRfidTagged()) {
log.info("rfid 미인식");

return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 true 반환이 맞나요....?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞습니다. 파이서버에서 저희가 주는 값을 사용하지 않기 때문입니다.

}
ParkingSpot parkingSpot = parkingSpotRepository.findById(reportRfidDto.getParkingSpotId())
.orElseThrow(() -> new RuntimeException("없는 주차장입니다."));
Key key = keyRepository.findByRfid(reportRfidDto.getRfid())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public class UsableCarResponseDto {
private Integer beforePrice;
private Integer afterPrice;
private Integer discountRatio;
private String imageUri;
private String photoUrl;

public UsableCarResponseDto(String carName, String carNumber, Integer totalDistance, Integer beforePrice, Integer discountRatio) {
public UsableCarResponseDto(String carName, String carNumber, Integer totalDistance, Integer beforePrice, Integer discountRatio, String photoUrl) {
this.carName = carName;
this.carNumber = carNumber;
this.totalDistance = totalDistance;
this.beforePrice = beforePrice;
this.afterPrice = (int) Math.ceil((beforePrice - (beforePrice * discountRatio * 0.01)));
this.discountRatio = discountRatio;
this.imageUri = "http://";
this.photoUrl = photoUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public List<UsableCarResponseDto> searchUsableCar(UsableCarSearchRequestDto requ
car.carNumber,
car.totalDistance,
car.carPrice,
car.discountRate
car.discountRate,
car.photoUrl
))
.from(car)
.innerJoin(car.carSpec, carSpec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,35 @@
import com.yu.yurentcar.global.BaseTimeEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;

@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "insurance_company")
@ToString
public class InsuranceCompany extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "company_id")
private Long companyId;

@NotNull
@Column(name = "company_name",length = 40)
@Column(name = "company_name", length = 40)
private String companyName;

@NotNull
@Column(name = "phone_number",length = 15)
@Column(name = "phone_number", length = 15)
private String phoneNumber;

@NotNull
@Column(name = "site_link",length = 100)
@Column(name = "site_link", length = 100)
private String siteLink;

@Builder
public InsuranceCompany(@NotNull String companyName, @NotNull String phoneNumber, @NotNull String siteLink) {
this.companyName = companyName;
this.phoneNumber = phoneNumber;
this.siteLink = siteLink;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
import com.yu.yurentcar.global.BaseTimeEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;

import java.time.LocalDateTime;

@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "insurance_contract")
@ToString
public class InsuranceContract extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -25,11 +23,13 @@ public class InsuranceContract extends BaseTimeEntity {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "insurance_company_id")
@ToString.Exclude
private InsuranceCompany insuranceCompany;

@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "reservation_id")
@ToString.Exclude
private Reservation reservation;
Comment on lines +26 to 33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetch가 필요한 코드는 Exclude 해둔 점 좋네요


@NotNull
Expand All @@ -39,4 +39,20 @@ public class InsuranceContract extends BaseTimeEntity {
@NotNull
@Column(name = "contraction_date")
private LocalDateTime contractionDate;

public void setReservation(Reservation reservation) {
this.reservation = reservation;
}

public void setInsuranceCompany(InsuranceCompany insuranceCompany) {
this.insuranceCompany = insuranceCompany;
}

@Builder
public InsuranceContract(@NotNull InsuranceCompany insuranceCompany, @NotNull Reservation reservation, @NotNull Integer contractionPrice, @NotNull LocalDateTime contractionDate) {
this.insuranceCompany = insuranceCompany;
this.reservation = reservation;
this.contractionPrice = contractionPrice;
this.contractionDate = contractionDate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.yu.yurentcar.domain.insurance.repository;

import com.yu.yurentcar.domain.insurance.entity.InsuranceCompany;
import org.springframework.data.jpa.repository.JpaRepository;

public interface InsuranceCompanyRepository extends JpaRepository<InsuranceCompany, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.yu.yurentcar.domain.insurance.repository;

import com.yu.yurentcar.domain.insurance.entity.InsuranceContract;
import org.springframework.data.jpa.repository.JpaRepository;

public interface InsuranceContractRepository extends JpaRepository<InsuranceContract, Long> {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.yu.yurentcar.domain.reservation.dto;

import lombok.*;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.time.LocalDateTime;
import java.util.List;
Expand All @@ -16,16 +19,18 @@ public class ReservationDetailDto {
private String carNumber;
private List<String> drivers;
private String photoUrl;
private Long reservationId;

@Builder
public ReservationDetailDto(LocalDateTime startDate, LocalDateTime endDate, String branchName, String carName, String carNumber) {
public ReservationDetailDto(LocalDateTime startDate, LocalDateTime endDate, String branchName, String carName, String carNumber, String photoUrl, Long reservationId) {
this.startDate = startDate;
this.endDate = endDate;
this.branchName = branchName;
this.carName = carName;
this.carNumber = carNumber;
this.drivers = null;
this.photoUrl = "http://";
this.photoUrl = photoUrl;
this.reservationId = reservationId;
}

public ReservationDetailDto updateDrivers(List<String> drivers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ReservationListResponseDto {
private String photoUrl;


public ReservationListResponseDto(Long reservationId, String carName, String carNumber, Integer totalDistance, LocalDateTime startDate, LocalDateTime endDate, String branchName, Integer price, Boolean isWritten) {
public ReservationListResponseDto(Long reservationId, String carName, String carNumber, Integer totalDistance, LocalDateTime startDate, LocalDateTime endDate, String branchName, Integer price, Boolean isWritten, String photoUrl) {
this.reservationId = reservationId;
this.carName = carName;
this.carNumber = carNumber;
Expand All @@ -48,6 +48,6 @@ else if (diff < 30)
else
this.reviewType = ReviewType.IMPOSSIBLE.getDbValue();

this.photoUrl="http://";
this.photoUrl = photoUrl;
}
}
15 changes: 11 additions & 4 deletions src/main/java/com/yu/yurentcar/domain/reservation/entity/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PastOrPresent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;
import org.hibernate.validator.constraints.Length;

import java.time.LocalDateTime;

@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "card")
@ToString
public class Card {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down Expand Up @@ -47,4 +45,13 @@ public class Card {
@PastOrPresent // 현재 또는 현재 이전
@Column(name = "register_date")
private LocalDateTime registerDate;

@Builder
public Card(@NotNull User user, @NotNull String cardNumber, @NotNull String CVC, @NotNull LocalDateTime expiredDate, @NotNull LocalDateTime registerDate) {
this.user = user;
this.cardNumber = cardNumber;
this.CVC = CVC;
this.expiredDate = expiredDate;
this.registerDate = registerDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public Point getBranchPointByUsername(String username) {
@Override
public ReservationDetailDto findNowReservationDetailByUsername(String username) {
return queryFactory
.select(Projections.constructor(ReservationDetailDto.class, reservation.startDate, reservation.endDate, branch.branchName, carSpecification.carName, car.carNumber))
.select(Projections.constructor(ReservationDetailDto.class, reservation.startDate, reservation.endDate, branch.branchName, carSpecification.carName, car.carNumber, car.photoUrl, reservation.reservationId))
.from(reservation)
.innerJoin(reservation.car, car)
.innerJoin(car.carSpec, carSpecification)
Expand Down Expand Up @@ -142,7 +142,8 @@ public List<ReservationListResponseDto> getReservationListByUsername(String user
reservation.endDate,
branch.branchName,
reservation.reservationPrice,
review.reviewId.isNotNull()))
review.reviewId.isNotNull(),
car.photoUrl))
.from(reservation)
.leftJoin(review).on(reservation.eq(review.reservation))
.innerJoin(reservation.car.branch, branch)
Expand Down Expand Up @@ -184,7 +185,7 @@ public List<ReservationBranchDto> getReservationListByBranchId(Long branchId, Bo
.from(reservation)
.where(reservation.car.branch.branchId.eq(branchId));
if (isDone != null) {
if(isDone)
if (isDone)
query = query.where(reservation.endDate.before(LocalDateTime.now()));
else
query = query.where(reservation.endDate.after(LocalDateTime.now()));
Expand All @@ -206,7 +207,7 @@ public ReservationBranchDto getReservationListByBranchIdAndNickname(Long branchI
.where(reservation.user.nickname.eq(nickname))
.where(reservation.car.branch.branchId.eq(branchId));
if (isDone != null) {
if(isDone)
if (isDone)
query = query.where(reservation.endDate.before(LocalDateTime.now()));
else
query = query.where(reservation.endDate.after(LocalDateTime.now()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public User saveSocialUser(String username, String name, Gender gender, LocalDat
.username(username)
.name(name)
.password(passwordEncoder.encode("1111"))
.nickname("hi")
.nickname(name)
.gender(gender)
.birthday(birthday)
.phoneNumber(phoneNumber)
Expand Down
Loading