Skip to content

Commit

Permalink
[fix] 아카이빙 스크랩 안되는 오류 해결 (#77)
Browse files Browse the repository at this point in the history
* [fix] scrap validation 수정 #76

* [fix] enum value 대문자로 변경 #76
  • Loading branch information
wjdtkdgns authored Aug 1, 2023
1 parent ec87e9e commit a4ab7a6
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public void execute(Long archivingId, Boolean cancel) {
private void validateExecution(Long archivingId, Long userId, Boolean cancel) {
archivingValidator.validateExistById(archivingId);
archivingValidator.validateDeleteStatus(archivingId, userId);
if (!cancel) {
if (cancel) {
scrapValidator.validateExistScrap(userId, archivingId);
} else {
scrapValidator.validateNotExistScrap(userId, archivingId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Getter
public class CreateContentRequest {
@Schema(defaultValue = "image", description = "컨텐츠 타입")
@Schema(defaultValue = "IMAGE", description = "컨텐츠 타입")
@ValidEnum(target = ContentType.class)
private ContentType contentType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Getter
public class UpdateContentRequest {
@Schema(defaultValue = "image", description = "컨텐츠 타입")
@Schema(defaultValue = "IMAGE", description = "컨텐츠 타입")
@ValidEnum(target = ContentType.class)
private ContentType contentType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CreateReportRequest {
@Schema(defaultValue = "기타기타기타기타기타", description = "사유 ('기타'에만 해당)")
private String reason;

@Schema(defaultValue = "spam", description = "신고 종류")
@Schema(defaultValue = "SPAM", description = "신고 종류")
@ValidEnum(target = ReportedType.class)
private ReportedType reportedType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@Getter
@AllArgsConstructor
public enum ContentType {
IMAGE("image"),
LINK("link");
IMAGE("IMAGE"),
LINK("LINK");

@JsonValue private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@Getter
@AllArgsConstructor
public enum RecycleType {
CONTENT("content"),
ARCHIVING("archiving");
CONTENT("CONTENT"),
ARCHIVING("ARCHIVING");

@JsonValue private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@Getter
@AllArgsConstructor
public enum ReportObjectType {
CONTENT("content"),
ARCHIVING("archiving");
CONTENT("CONTENT"),
ARCHIVING("ARCHIVING");

@JsonValue private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
@Getter
@AllArgsConstructor
public enum ReportedType {
SPAM("spam"), // 스팸이에요
OBSCENE("obscene"), // 음란성 컨텐츠를 담고있어요
PERSONAL_INFO("personalInfo"), // 개인정보를 노출하고 있어요
INTELLECTUAL_PROPERTY("intellectualProperty"), // 지식재산권을 침해해요
VIOLENCE("violence"), // 혐오/폭력 컨텐츠를 담고 있어요
ILLEGAL_INFO("illegalInformation"), // 불법 정보를 포함하고 있어요
FRAUD("fraud"), // 사기 또는 피싱성 링크를 포함하고 있어요
ETC("etc"); // 기타
SPAM("SPAM"), // 스팸이에요
OBSCENE("OBSCENE"), // 음란성 컨텐츠를 담고있어요
PERSONAL_INFO("PERSONAL_INFO"), // 개인정보를 노출하고 있어요
INTELLECTUAL_PROPERTY("INTELLECTUAL_PROPERTY"), // 지식재산권을 침해해요
VIOLENCE("VIOLENCE"), // 혐오/폭력 컨텐츠를 담고 있어요
ILLEGAL_INFO("ILLEGAL_INFO"), // 불법 정보를 포함하고 있어요
FRAUD("FRAUD"), // 사기 또는 피싱성 링크를 포함하고 있어요
ETC("ETC"); // 기타

@JsonValue private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public void deleteAllByArchivingIdIn(List<Long> archivingIds) {
public void deleteAllByUser(User user) {
scrapRepository.deleteAllByUser(user);
}

public boolean existsByUserAndArchivingId(User user, Long archivingId) {
return scrapRepository.existsByUserAndArchivingId(user, archivingId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public interface ScrapRepository extends JpaRepository<Scrap, Long> {
void deleteAllByArchivingIdIn(List<Long> archivingId);

void deleteAllByUser(User user);

boolean existsByUserAndArchivingId(User user, Long archivingId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class ScrapValidator {

public void validateExistScrap(Long userId, Long archivingId) {
User user = userAdaptor.findById(userId);
if (isScrapExist(user, archivingId)) {
throw AlreadyExistScrapException.EXCEPTION;
}
scrapAdaptor.findByUserAndArchivingId(user, archivingId);
}

private Boolean isScrapExist(User user, Long archivingId) {
scrapAdaptor.findByUserAndArchivingId(user, archivingId);
return Boolean.TRUE;
public void validateNotExistScrap(Long userId, Long archivingId) {
User user = userAdaptor.findById(userId);
if (scrapAdaptor.existsByUserAndArchivingId(user, archivingId)) {
throw AlreadyExistScrapException.EXCEPTION;
}
}
}

0 comments on commit a4ab7a6

Please sign in to comment.