Skip to content

Commit

Permalink
πŸ› [Bug] party penalty μ—¬λŸ¬λ²ˆ 받은 μœ μ €λŠ” μ˜μ›νžˆ μ‚¬μš©ν•  수 μ—†λŠ” 버그 μˆ˜μ • 및 (νŒ¨λ„ν‹° μˆ˜μ •) 버그 μˆ˜μ • (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AreSain authored Mar 28, 2024
1 parent 4094d62 commit d2117ee
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class PartyPenaltyAdminReqDto {
String message;

@NotNull(message = "penaltyTime이 λΉ„μ–΄μžˆμŠ΅λ‹ˆλ‹€")
@Min(value = 1, message = "μ˜¬λ°”λ₯Έ penaltyTime을 λ„£μ–΄μ£Όμ„Έμš”")
@Min(value = 0, message = "μ˜¬λ°”λ₯Έ penaltyTime을 λ„£μ–΄μ£Όμ„Έμš”")
int penaltyTime;

@NotBlank(message = "IntraIdκ°€ λΉ„μ–΄μžˆμŠ΅λ‹ˆλ‹€")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CategoryService {
@Transactional(readOnly = true)
public CategoryListResDto findCategoryList(UserDto userDto) {
User user = userRepository.findById(userDto.getId()).get();
PartyPenalty partyPenalty = partyPenaltyRepository.findByUserId(user.getId());
PartyPenalty partyPenalty = partyPenaltyRepository.findLatestByUserId(user.getId());
if (PartyPenalty.isOnPenalty(partyPenalty)) {
throw new OnPenaltyException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void addCreateComment(Long roomId, CommentCreateReqDto reqDto, Long userI
throw new RoomNotOpenException();
}

PartyPenalty partyPenalty = partyPenaltyRepository.findByUserId(userId);
PartyPenalty partyPenalty = partyPenaltyRepository.findLatestByUserId(userId);
if (PartyPenalty.isOnPenalty(partyPenalty)) {
throw new OnPenaltyException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void addReportUser(Long roomId, ReportReqDto reportReqDto, String userInt
@Transactional
public void partyGivePenalty(String intraId, Integer penaltyTime, String penaltyType) {
User user = userRepository.findByIntraId(intraId).get();
PartyPenalty pPenalty = partyPenaltyRepository.findByUserId(user.getId());
PartyPenalty pPenalty = partyPenaltyRepository.findLatestByUserId(user.getId());

if (pPenalty != null && LocalDateTime.now().isBefore(pPenalty.getStartTime()
.plusMinutes(pPenalty.getPenaltyTime()))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class RoomManagementService {
@Transactional
public RoomCreateResDto addCreateRoom(RoomCreateReqDto roomCreateReqDto, UserDto userDto) {
User user = userRepository.findById(userDto.getId()).get();
PartyPenalty partyPenalty = partyPenaltyRepository.findByUserId(user.getId());
PartyPenalty partyPenalty = partyPenaltyRepository.findLatestByUserId(user.getId());
if (PartyPenalty.isOnPenalty(partyPenalty)) {
throw new OnPenaltyException();
}
Expand Down Expand Up @@ -176,7 +176,7 @@ public RoomStartResDto modifyStartRoom(Long roomId, UserDto user) {
public RoomJoinResDto addJoinRoom(Long roomId, UserDto userDto) {
User user = userRepository.findById(userDto.getId()).get();
Room room = roomRepository.findById(roomId).orElseThrow(RoomNotFoundException::new);
PartyPenalty partyPenalty = partyPenaltyRepository.findByUserId(user.getId());
PartyPenalty partyPenalty = partyPenaltyRepository.findLatestByUserId(user.getId());
if (PartyPenalty.isOnPenalty(partyPenalty)) {
throw new OnPenaltyException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import gg.data.party.PartyPenalty;

public interface PartyPenaltyRepository extends JpaRepository<PartyPenalty, Long> {
PartyPenalty findByUserId(Long id);
@Query("SELECT p FROM PartyPenalty p WHERE p.user.id = :userId ORDER BY p.startTime DESC")
PartyPenalty findLatestByUserId(@Param("userId") Long userId);

List<PartyPenalty> findAllByUserId(Long userId);

Expand Down

0 comments on commit d2117ee

Please sign in to comment.