Skip to content

Commit

Permalink
Refactor: binlocation 엔티티에 photo 추가 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
pingowl authored Nov 24, 2024
1 parent 150b5dd commit 9710406
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/drugdrop/BE/domain/BinLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ public class BinLocation extends BaseEntity {
private String addrLvl2; // 시,군,구
private String name;
private String type; // 약국, 동사무소(주민센터,행정복지센터,면사무소), 우체국/통, 보건소(보건지소, 보건진료소)
private String locationPhoto;

public void setLocationPhoto(String photo){ this.locationPhoto = photo; }
}
8 changes: 7 additions & 1 deletion src/main/java/drugdrop/BE/service/MapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ public List<BinLocationResponse> getDivisionDrugBinLocations(String addrLvl1, St
}

private BinLocationResponse BinLocationToBinLocationResponse(BinLocation bin) {
String photo = bin.getLocationPhoto();
if(photo == null) {
photo = getLocationPhoto(bin.getName());
bin.setLocationPhoto(photo);
binLocationRepository.save(bin);
}
return BinLocationResponse.builder()
.id(bin.getId())
.address(bin.getAddress())
Expand All @@ -210,7 +216,7 @@ private BinLocationResponse BinLocationToBinLocationResponse(BinLocation bin) {
.type(bin.getType())
.addrLvl1(bin.getAddrLvl1())
.addrLvl2(bin.getAddrLvl2())
.locationPhoto(getLocationPhoto(bin.getName()))
.locationPhoto(photo)
.build();
}

Expand Down

0 comments on commit 9710406

Please sign in to comment.