Skip to content

Commit

Permalink
Merge pull request #90 from HowMuchPay/feature89
Browse files Browse the repository at this point in the history
[Feature89] 지인 이름 조회 API 구현
  • Loading branch information
seongHyun-Min authored Sep 22, 2023
2 parents 0368547 + 8dc2a4a commit 893a415
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public ResponseEntity<GetAllAcEventsResponseDto> getAllAcEvents() {
);
}

@GetMapping("/acquaintance/name")
public ResponseEntity<GetAllAcNicknameResponseDto> getAllAcName(){
return new ResponseEntity<>(this.eventService.getAcName(), HttpStatus.OK);
}

// 지인 경조사 업데이트
@PatchMapping("/acquaintance/{id}")
public ResponseEntity<Long> updateAcEvents(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
public interface AcEventRepository extends JpaRepository<AcEvent, Long> {
List<AcEvent> findAllByUserOrderByEventAtDesc(User user);

List<AcEvent> findByUserOrderByAcquaintanceNicknameDesc(User user);

List<AcEvent> findAllByAcquaintanceType(AcType type);

List<AcEvent> findAllByUserAndAcquaintanceTypeAndEventCategoryOrderByEventAtDesc(User user, AcType acType, EventCategory category);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.howmuch.dto.event;

import com.example.howmuch.domain.entity.AcEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GetAllAcNicknameResponse {

String name;

public static GetAllAcNicknameResponse from(AcEvent acEvent){
return new GetAllAcNicknameResponse(acEvent.getAcquaintanceNickname());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.howmuch.dto.event;

import com.example.howmuch.domain.entity.AcEvent;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GetAllAcNicknameResponseDto {

List<GetAllAcNicknameResponse> names;


public static GetAllAcNicknameResponseDto from(List<AcEvent> acEvents) {
return new GetAllAcNicknameResponseDto(acEvents.stream()
.map(GetAllAcNicknameResponse::from).toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ public GetAllAcEventsResponseDto getAcEventsByName(String acquaintanceName) {
return new GetAllAcEventsResponseDto((long) totalCost, sortedAcEvents);
}

// 지인 이름 조회
@Transactional(readOnly = true)
public GetAllAcNicknameResponseDto getAcName(){
User user = getUser();
return GetAllAcNicknameResponseDto.from(acEventRepository.findByUserOrderByAcquaintanceNicknameDesc(user));
}

private Map<String, List<GetAllMyEventsResponse>> getAllMyEvent(User user) {
Map<String, List<GetAllMyEventsResponse>> allMyEvents = this.myEventRepository.findAllByUserOrderByEventAtDesc(
user)
Expand Down

0 comments on commit 893a415

Please sign in to comment.