Skip to content

Commit

Permalink
[fix] 기타 로직 수정 (#55)
Browse files Browse the repository at this point in the history
* [fix] #54 add Transactional in service

* [fix] #54 edit dto method name (from/of)

* [fix] #54 add final in arguments

* [fix] #54 delete unnecessary service class

* [fix] #54 change return value to void

* [fix] #54 edit dto method name (from/of)

* [fix] #54 fix mismatched field type
  • Loading branch information
chaewonni authored Jul 14, 2024
1 parent 678d0ae commit 1dbbe78
Show file tree
Hide file tree
Showing 33 changed files with 230 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class LocationController {

@GetMapping("/locations")
public ResponseEntity<List<LocationsDto>> getLocations(
@RequestParam(name="q") String query
@RequestParam(name="q") final String query
) {
return ResponseEntity.ok(naverService.getLocations(query));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class MeetingController {

@PostMapping("/meetings")
public ResponseEntity<CreatedMeetingDto> createMeeting(
@UserId Long userId,
@Valid @RequestBody MeetingCreateDto meetingCreateDto
@UserId final Long userId,
@Valid @RequestBody final MeetingCreateDto meetingCreateDto
) {
CreatedMeetingDto createdMeetingDto = meetingService.createMeeting(userId, meetingCreateDto);
return ResponseEntity
Expand All @@ -36,32 +36,32 @@ public ResponseEntity<CreatedMeetingDto> createMeeting(

@PostMapping("/meetings/register")
public ResponseEntity<Void> registerMeeting(
@UserId Long userId,
@Valid @RequestBody MeetingRegisterDto meetingRegisterDto
@UserId final Long userId,
@Valid @RequestBody final MeetingRegisterDto meetingRegisterDto
) {
meetingService.registerMeeting(userId, meetingRegisterDto);
return ResponseEntity.ok().build();
}

@GetMapping("/meetings")
public ResponseEntity<MeetingsDto> getMeetings(
@UserId Long userId
@UserId final Long userId
) {
return ResponseEntity.ok(meetingService.getMeetings(userId));
}

@IsMember(meetingIdParamIndex = 0)
@GetMapping("/meetings/{meetingId}")
public ResponseEntity<MeetingDto> getMeeting(
@PathVariable Long meetingId
@PathVariable final Long meetingId
) {
return ResponseEntity.ok(meetingService.getMeeting(meetingId));
}

@IsMember(meetingIdParamIndex = 0)
@GetMapping("/meetings/{meetingId}/members")
public ResponseEntity<MembersDto> getMembers(
@PathVariable Long meetingId
@PathVariable final Long meetingId
) {
return ResponseEntity.ok(meetingService.getMembers(meetingId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ public class ParticipantController {

@PatchMapping("/promises/{promiseId}/preperation")
public ResponseEntity<Void> preparePromise(
@UserId Long userId,
@PathVariable Long promiseId
@UserId final Long userId,
@PathVariable final Long promiseId
) {
participantService.preparePromise(userId, promiseId);
return ResponseEntity.ok().build();
}

@PatchMapping("/promises/{promiseId}/departure")
public ResponseEntity<Void> departurePromise(
@UserId Long userId,
@PathVariable Long promiseId
@UserId final Long userId,
@PathVariable final Long promiseId
) {
participantService.departurePromise(userId, promiseId);
return ResponseEntity.ok().build();
}

@PatchMapping("/promises/{promiseId}/arrival")
public ResponseEntity<Void> arrivalPromise(
@UserId Long userId,
@PathVariable Long promiseId
@UserId final Long userId,
@PathVariable final Long promiseId
) {
participantService.arrivalPromise(userId, promiseId);
return ResponseEntity.ok().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class PromiseController {
@IsMember(meetingIdParamIndex = 1)
@PostMapping("/meetings/{meetingId}/promises")
public ResponseEntity<Void> createPromise(
@UserId Long userId,
@PathVariable Long meetingId,
@Valid @RequestBody PromiseCreateDto createPromiseDto
@UserId final Long userId,
@PathVariable final Long meetingId,
@Valid @RequestBody final PromiseCreateDto createPromiseDto
) {
Long promiseId = promiseService.createPromise(userId, meetingId, createPromiseDto);
return ResponseEntity.created(URI.create(promiseId.toString())).build();
Expand All @@ -37,7 +37,7 @@ public ResponseEntity<Void> createPromise(
@IsParticipant(promiseIdParamIndex = 0)
@PatchMapping("/promises/{promiseId}/completion")
public ResponseEntity<Void> completePromise(
@PathVariable Long promiseId
@PathVariable final Long promiseId
) {
promiseService.completePromise(promiseId);
return ResponseEntity.ok().build();
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/org/kkumulkkum/server/domain/Participant.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public class Participant extends BaseTimeEntity {

private LocalDateTime arrivalAt;

private int preparationTime;
private Integer preparationTime;

private int travelTime;
private Integer travelTime;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "promise_id")
Expand All @@ -36,13 +36,14 @@ public class Participant extends BaseTimeEntity {
private Member member;

@Builder
public Participant(LocalDateTime preparationStartAt,
LocalDateTime departureAt,
LocalDateTime arrivalAt,
int preparationTime,
int travelTime,
Promise promise,
Member member
public Participant(
LocalDateTime preparationStartAt,
LocalDateTime departureAt,
LocalDateTime arrivalAt,
Integer preparationTime,
Integer travelTime,
Promise promise,
Member member
) {
this.preparationStartAt = preparationStartAt;
this.departureAt = departureAt;
Expand All @@ -65,11 +66,11 @@ public void arrivalPromise() {
this.arrivalAt = LocalDateTime.now();
}

public void updatePreparationTime(int preparationTime) {
public void updatePreparationTime(Integer preparationTime) {
this.preparationTime = preparationTime;
}

public void updateTravelTime(int travelTime) {
public void updateTravelTime(Integer travelTime) {
this.travelTime = travelTime;
}
}
21 changes: 11 additions & 10 deletions src/main/java/org/kkumulkkum/server/domain/Promise.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ public class Promise extends BaseTimeEntity {
private Meeting meeting;

@Builder
public Promise(String name,
LocalDateTime time,
DressUpLevel dressUpLevel,
String penalty,
String placeName,
Double x,
Double y,
String address,
String roadAddress,
Meeting meeting
public Promise(
String name,
LocalDateTime time,
DressUpLevel dressUpLevel,
String penalty,
String placeName,
Double x,
Double y,
String address,
String roadAddress,
Meeting meeting
) {
this.name = name;
this.time = time;
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/kkumulkkum/server/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public class User extends BaseTimeEntity {
private Role role;

@Builder
public User(Long id,
Provider provider,
String providerId,
Role role) {
public User(
Long id,
Provider provider,
String providerId,
Role role
) {
this.id = id;
this.provider = provider;
this.providerId = providerId;
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/kkumulkkum/server/domain/UserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public class UserInfo extends BaseTimeEntity {
private User user;

@Builder
public UserInfo(String name,
String profileImg,
String email,
User user) {
public UserInfo(
String name,
String profileImg,
String email,
User user
) {
this.name = name;
this.profileImg = profileImg;
this.email = email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public record MeetingDto (
int metCount,
String invitationCode
) {
public static MeetingDto of(Meeting meeting) {
public static MeetingDto from(Meeting meeting) {
return new MeetingDto(
meeting.getId(),
meeting.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public record MeetingsDto (
List<MeetingDto> meetings
) {

public static MeetingsDto of(List<Meeting> meetings) {
public static MeetingsDto from(List<Meeting> meetings) {
return new MeetingsDto(
meetings.size(),
meetings.stream()
.map(MeetingDto::of)
.map(MeetingDto::from)
.toList()
);
}
Expand All @@ -23,7 +23,7 @@ public record MeetingDto (
String name,
int memberCount
) {
public static MeetingDto of(Meeting meeting) {
public static MeetingDto from(Meeting meeting) {
return new MeetingDto(
meeting.getId(),
meeting.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public record MembersDto(
int memberCount,
List<MemberDto> members
) {
public static MembersDto of(List<MemberDto> members) {
public static MembersDto from(List<MemberDto> members) {
return new MembersDto(
members.size(),
members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public record ParticipantStatusUserInfoDto(
LocalDateTime departureAt,
LocalDateTime arrivalAt
) {
public static ParticipantStatusUserInfoDto from(
public static ParticipantStatusUserInfoDto of(
Long participantId,
Long memberId,
String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

public record PreparationInfoDto(
@Size(max = 1440)
int preparationTime,
Integer preparationTime,
@Size(max = 1440)
int travelTime
Integer travelTime
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.time.LocalDateTime;

public record PreparationStatusDto(
int preparationTime,
int travelTime,
Integer preparationTime,
Integer travelTime,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "a h:mm", locale = "en")
LocalDateTime preparationStartAt,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "a h:mm", locale = "en")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kkumulkkum/server/dto/test/TestDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public record TestDto(
String test
) {
public static TestDto of (String test) {
public static TestDto from(String test) {
return new TestDto(test);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatusCode;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClient;
Expand All @@ -28,6 +29,7 @@ public class NaverService {
@Value("${naver.location-search-url}")
private String naverLocationSearchUrl;

@Transactional(readOnly = true)
public List<LocationsDto> getLocations(String query) {
try {
NaverLocationResponse naverLocationResponse = locationSearch(requestMap(query));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public class MeetingRetriever {

private final MeetingRepository meetingRepository;

public boolean existsByInvitationCode(String invitationCode) {
public boolean existsByInvitationCode(final String invitationCode) {
return meetingRepository.existsByInvitationCode(invitationCode);
}

public Meeting findByInvitationCode(String invitationCode) {
public Meeting findByInvitationCode(final String invitationCode) {
return meetingRepository.findByInvitationCode(invitationCode)
.orElseThrow(() -> new MeetingException(MeetingErrorCode.NOT_FOUND_MEETING));
}

public List<Meeting> findAllByUserId(Long userId) {
public List<Meeting> findAllByUserId(final Long userId) {
return meetingRepository.findAllByUserId(userId);
}

public Meeting findById(Long meetingId) {
public Meeting findById(final Long meetingId) {
return meetingRepository.findById(meetingId)
.orElseThrow(() -> new MeetingException(MeetingErrorCode.NOT_FOUND_MEETING));
}
Expand Down
Loading

0 comments on commit 1dbbe78

Please sign in to comment.