-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feat : 소셜링 수정 #44
The head ref may contain hidden characters: "13-be-\uC18C\uC15C\uB9C1-\uC218\uC815"
Feat : 소셜링 수정 #44
Changes from 16 commits
5804a39
f93dcf4
3f4ceb8
7cf6b7d
eb891a7
b5daf27
440fac8
1385a19
a09633d
508d3b3
763b0b9
c2ff0fa
9c48265
5a58207
c943065
1ecfa79
78e971f
21c75fd
5de88fe
8d1e887
2ce4cd6
981c31d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.likelion12.common.exception; | ||
|
||
import com.example.likelion12.common.response.status.ResponseStatus; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MemberSocialringException extends RuntimeException{ | ||
private final ResponseStatus exceptionStatus; | ||
|
||
public MemberSocialringException(ResponseStatus exceptionStatus) { | ||
super(exceptionStatus.getMessage()); | ||
this.exceptionStatus = exceptionStatus; | ||
} | ||
|
||
public MemberSocialringException(ResponseStatus exceptionStatus, String message) { | ||
super(message); | ||
this.exceptionStatus = exceptionStatus; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.example.likelion12.common.exception_handler; | ||
|
||
import com.example.likelion12.common.exception.MemberSocialringException; | ||
import com.example.likelion12.common.response.BaseErrorResponse; | ||
import jakarta.annotation.Priority; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@Priority(0) | ||
@RestControllerAdvice | ||
public class MemberSocialringExceptionControllerAdvice { | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
@ExceptionHandler(MemberSocialringException.class) | ||
public BaseErrorResponse handle_MemberSocialringException(MemberSocialringException e) { | ||
log.error("[handle_MemberSocialringException]", e); | ||
return new BaseErrorResponse(e.getExceptionStatus(), e.getMessage()); | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주석 달아주신거 너무 좋습니다~ |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 이거 명진님이랑만 말한거 같은데 저기서 activityRegionId 랑 facilityId, exerciseId 로 넘겨주지 말고 (저 3개는 id 로 요청할 일이 거의 없으니까요!) 차라리 그냥 프론트에서 바로 사용할 수 있도록 String 인 이름값으로 넘겨주면 어떨까요??? activityRegionId -> activityRegionName / facilityId -> facilityName / exerciseId -> exerciseName 이렇게요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 감사합니다! 참고하여 수정하겠습니다!! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.likelion12.dto; | ||
|
||
import com.example.likelion12.domain.base.BaseGender; | ||
import com.example.likelion12.domain.base.BaseLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class PatchSocialringModifyRequest { | ||
private String socialringName; | ||
private String socialringImg; | ||
private Long activityRegionId; | ||
private Long facilityId; | ||
private Long exerciseId; | ||
private Integer totalRecruits; | ||
private LocalDate socialringDate; | ||
private Integer socialringCost; | ||
private String comment; | ||
private String commentSimple; | ||
private BaseGender gender; | ||
private BaseLevel level; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package com.example.likelion12.repository; | ||
|
||
import com.example.likelion12.domain.MemberSocialring; | ||
import com.example.likelion12.domain.base.BaseStatus; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface MemberSocialringRepository extends JpaRepository<MemberSocialring, Long> { | ||
//Optional<MemberSocialring> findByMemberIdAndSocialringIdAndStatus(Long memberId, Long socialringId, BaseStatus status); | ||
Optional<MemberSocialring> findByMember_MemberIdAndSocialring_SocialringIdAndStatus(Long memberId, Long socialringId, BaseStatus status); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.example.likelion12.service; | ||
|
||
import com.example.likelion12.common.exception.MemberSocialringException; | ||
import com.example.likelion12.domain.*; | ||
import com.example.likelion12.domain.base.BaseRole; | ||
import com.example.likelion12.domain.base.BaseStatus; | ||
|
@@ -9,6 +10,8 @@ | |
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import static com.example.likelion12.common.response.status.BaseExceptionResponseStatus.CANNOT_MEMBERSOCIALRING_CAPTAIN; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
|
@@ -26,4 +29,17 @@ public void createMemberSocialring(Member member, Socialring socialring){ | |
MemberSocialring memberSocialring = new MemberSocialring(BaseRole.CAPTAIN,socialring,member,BaseStatus.ACTIVE); | ||
memberSocialringRepository.save(memberSocialring); | ||
} | ||
|
||
/** | ||
* 소셜링 수정,삭제 시 접근하는 member가 CAPTAIN 인지 확인 | ||
*/ | ||
@Transactional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기 메소드 단순히 CAPTAIN 인지 아닌지 조회하는 부분 맞나요?? 맞다면 단순 조회고 데이터베이스에는 아무런 영향을 주지 않기 때문에 트랜잭션 어노테이션은 사용하지 않으셔도 무방합니다~ |
||
public void ConfirmCaptainMemberSocialring(MemberSocialring memberSocialring){ | ||
log.info("[MemberSocialringService.ConfirmCaptainMemberSocialring]"); | ||
|
||
if (!BaseRole.CAPTAIN.equals(memberSocialring.getRole())) { | ||
throw new MemberSocialringException(CANNOT_MEMBERSOCIALRING_CAPTAIN); | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 잘 넣으셨네요!! 👍