Skip to content

Commit

Permalink
refactor: 인증 경로 추가 (#noisssue)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelSuho committed Aug 13, 2024
1 parent 7fa4cf4 commit a30d367
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
public class ScrapRequest {
@JsonProperty("town-code")
private Long townCode;
@JsonProperty("industry-name")
private String industryName;
@JsonProperty("quarter")
private Long quarter;
private String email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ public class ScrapResponse {

private Long townCode;
private String townName;
private String industryName;
private Long quarter;

public ScrapResponse(Long townCode, String townName, String industryName, Long quarter) {
public ScrapResponse(Long townCode, String townName, Long quarter) {
this.townCode = townCode;
this.townName = townName;
this.industryName = industryName;
this.quarter = quarter;
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/dduckddak/domain/member/model/Scrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class Scrap {
private Long id;

private Long townCode;
private String industryName;
private Long quarter;

@ManyToOne(fetch = FetchType.LAZY)
Expand All @@ -24,7 +23,6 @@ public class Scrap {

public Scrap(ScrapRequest scrapRequest, Member member) {
this.townCode = scrapRequest.getTownCode();
this.industryName = scrapRequest.getIndustryName();
this.quarter = scrapRequest.getQuarter();
this.member = member;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

public interface ScrapRepository extends JpaRepository<Scrap, Long> {
Optional<Scrap> findByTownCode(Long code);
boolean existsByTownCodeAndIndustryNameAndQuarter(Long townCode, String industryName, Long quarter);
boolean existsByTownCodeAndQuarter(Long townCode, Long quarter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void saveScrap(ScrapRequest scrapRequest) {

log.info("ScrapRequest: {}", scrapRequest);
Scrap scrap = new Scrap(scrapRequest, member);
if (scrapRepository.existsByTownCodeAndIndustryNameAndQuarter(scrap.getTownCode(), scrap.getIndustryName(), scrap.getQuarter())) {
if (scrapRepository.existsByTownCodeAndQuarter(scrap.getTownCode(), scrap.getQuarter())) {
throw new RuntimeException("이미 스크랩한 지역입니다.");
}

Expand All @@ -55,7 +55,7 @@ public List<ScrapResponse> getScrapList(String email) {
.map(scrap -> {
Town town = townRepository.findByCodeAndQuarter(String.valueOf(scrap.getTownCode()), scrap.getQuarter())
.orElseThrow(() -> new RuntimeException("해당 지역이 존재하지 않습니다."));
return new ScrapResponse(Long.parseLong(town.getCode()), town.getName(), scrap.getIndustryName(), scrap.getQuarter());
return new ScrapResponse(Long.parseLong(town.getCode()), town.getName(), scrap.getQuarter());
})
.toList();
}
Expand Down

0 comments on commit a30d367

Please sign in to comment.