Skip to content

Commit

Permalink
Merge branch 'dev' into 929-feature-agenda-이미지-업로드-기능-추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yhames authored Aug 6, 2024
2 parents e80b6c7 + 48703b8 commit 5226c08
Show file tree
Hide file tree
Showing 22 changed files with 386 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ResponseEntity<AgendaResDto> agendaDetails(@RequestParam("agenda_key") UU
Agenda agenda = agendaService.findAgendaByAgendaKey(agendaKey);
String announcementTitle = agendaAnnouncementService
.findLatestAnnounceTitleByAgendaOrDefault(agenda, "");
AgendaResDto agendaResDto = AgendaResDto.MapStruct.INSTANCE.toDto(agenda, announcementTitle);
AgendaResDto agendaResDto = AgendaResDto.MapStruct.INSTANCE.toDto(agenda, announcementTitle);
return ResponseEntity.ok(agendaResDto);
}

Expand All @@ -80,7 +80,8 @@ public ResponseEntity<AgendaKeyResDto> agendaAdd(@Login @Parameter(hidden = true
}

@GetMapping("/history")
public ResponseEntity<List<AgendaSimpleResDto>> agendaListHistory(@RequestBody @Valid PageRequestDto pageRequest) {
public ResponseEntity<List<AgendaSimpleResDto>> agendaListHistory(
@ModelAttribute @Valid PageRequestDto pageRequest) {
int page = pageRequest.getPage();
int size = pageRequest.getSize();
Pageable pageable = PageRequest.of(page - 1, size, Sort.by("startTime").descending());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.mapstruct.factory.Mappers;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;

import gg.agenda.api.user.agenda.controller.request.validator.AgendaCapacityValid;
import gg.agenda.api.user.agenda.controller.request.validator.AgendaScheduleValid;
import gg.data.agenda.Agenda;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
import gg.agenda.api.user.agenda.controller.request.AgendaAwardsReqDto;
import gg.agenda.api.user.agenda.controller.request.AgendaCreateReqDto;
import gg.agenda.api.user.agenda.controller.request.AgendaTeamAward;
import gg.agenda.api.user.agendateam.service.AgendaTeamService;
import gg.agenda.api.user.ticket.service.TicketService;
import gg.auth.UserDto;
import gg.data.agenda.Agenda;
import gg.data.agenda.AgendaProfile;
import gg.data.agenda.AgendaTeam;
import gg.data.agenda.AgendaTeamProfile;
import gg.data.agenda.type.AgendaStatus;
import gg.data.agenda.type.AgendaTeamStatus;
import gg.repo.agenda.AgendaRepository;
Expand All @@ -49,6 +48,8 @@ public class AgendaService {

private final TicketService ticketService;

private final AgendaTeamService agendaTeamService;

private final ImageHandler imageHandler;

@Value("${info.image.defaultUrl}")
Expand Down Expand Up @@ -115,13 +116,7 @@ public void confirmAgendaAndRefundTicketForOpenTeam(Agenda agenda) {

List<AgendaTeam> openTeams = agendaTeamRepository.findAllByAgendaAndStatus(agenda, AgendaTeamStatus.OPEN);
for (AgendaTeam openTeam : openTeams) {
// TODO: AgendaTeamService의 cancelTeam 메서드를 호출하는 것이 더 좋을 수도 있음
List<AgendaProfile> participants = agendaTeamProfileRepository
.findAllByAgendaTeamWithFetchProfile(openTeam).stream()
.map(AgendaTeamProfile::getProfile)
.collect(Collectors.toList());
ticketService.refundTickets(participants, agenda.getAgendaKey());
openTeam.cancelTeam();
agendaTeamService.leaveTeamAll(openTeam);
}
agenda.confirmAgenda();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -48,7 +49,7 @@ public ResponseEntity<Void> agendaAnnouncementAdd(@Login UserDto user, @RequestP

@GetMapping
public ResponseEntity<List<AgendaAnnouncementResDto>> agendaAnnouncementList(
@RequestParam("agenda_key") UUID agendaKey, @RequestBody @Valid PageRequestDto pageRequest) {
@RequestParam("agenda_key") UUID agendaKey, @ModelAttribute @Valid PageRequestDto pageRequest) {
Agenda agenda = agendaService.findAgendaByAgendaKey(agendaKey);
int page = pageRequest.getPage();
int size = pageRequest.getSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -17,13 +19,14 @@
import gg.agenda.api.user.agendaprofile.controller.request.AgendaProfileChangeReqDto;
import gg.agenda.api.user.agendaprofile.controller.response.AgendaProfileDetailsResDto;
import gg.agenda.api.user.agendaprofile.controller.response.AgendaProfileInfoDetailsResDto;
import gg.agenda.api.user.agendaprofile.controller.response.AttendedAgendaListResDto;
import gg.agenda.api.user.agendaprofile.controller.response.CurrentAttendAgendaListResDto;
import gg.agenda.api.user.agendaprofile.service.AgendaProfileFindService;
import gg.agenda.api.user.agendaprofile.service.AgendaProfileService;
import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.data.user.type.RoleType;
import gg.repo.user.UserRepository;
import gg.utils.dto.PageRequestDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;

Expand All @@ -33,8 +36,6 @@
public class AgendaProfileController {
private final AgendaProfileFindService agendaProfileFindService;
private final AgendaProfileService agendaProfileService;
private final UserRepository userRepository;
private static final Logger log = LoggerFactory.getLogger(AgendaProfileController.class);

/**
* AgendaProfile 상세 조회 API
Expand Down Expand Up @@ -92,5 +93,22 @@ public ResponseEntity<List<CurrentAttendAgendaListResDto>> getCurrentAttendAgend
intraId);
return ResponseEntity.ok(currentAttendAgendaList);
}

/**
* 과거에 참여했던 Agenda 목록 조회하는 메서드
* @param pageRequest 페이지네이션 요청 정보, agendaId 아젠다 아이디
*/
@GetMapping("/history/list")
public ResponseEntity<List<AttendedAgendaListResDto>> getAttendedAgendaList(
@Login @Parameter(hidden = true) UserDto user, @ModelAttribute @Valid PageRequestDto pageRequest) {
int page = pageRequest.getPage();
int size = pageRequest.getSize();
String intraId = user.getIntraId();

Pageable pageable = PageRequest.of(page - 1, size, Sort.by("id").descending());
List<AttendedAgendaListResDto> attendedAgendaList = agendaProfileFindService.findAttendedAgenda(
intraId, pageable);
return ResponseEntity.ok(attendedAgendaList);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package gg.agenda.api.user.agendaprofile.controller.response;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

import gg.agenda.api.user.agendateam.controller.response.TeamMateDto;
import gg.data.agenda.AgendaTeamProfile;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
public class AttendedAgendaListResDto {
private String agendaId;
private String agendaTitle;
private LocalDateTime agendaStartTime;
private LocalDateTime agendaEndTime;
private int agendaCurrentTeam;
private String agendaLocation;
private UUID teamKey;
private Boolean isOfficial;
private int agendaMaxPeople;
private String teamName;
private List<TeamMateDto> teamMates;

public AttendedAgendaListResDto(AgendaTeamProfile agendaTeamProfile,
List<AgendaTeamProfile> agendaTeamProfileList) {
this.agendaId = agendaTeamProfile.getAgenda().getId().toString();
this.agendaTitle = agendaTeamProfile.getAgenda().getTitle();
this.agendaStartTime = agendaTeamProfile.getAgenda().getStartTime();
this.agendaEndTime = agendaTeamProfile.getAgenda().getEndTime();
this.agendaCurrentTeam = agendaTeamProfile.getAgenda().getCurrentTeam();
this.agendaLocation = agendaTeamProfile.getAgenda().getLocation().toString();
this.teamKey = agendaTeamProfile.getAgendaTeam().getTeamKey();
this.isOfficial = agendaTeamProfile.getAgenda().getIsOfficial();
this.agendaMaxPeople = agendaTeamProfile.getAgenda().getMaxPeople();
this.teamName = agendaTeamProfile.getAgendaTeam().getName();
this.teamMates = agendaTeamProfileList.stream()
.map(TeamMateDto::new)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import gg.agenda.api.user.agendaprofile.controller.response.AgendaProfileDetailsResDto;
import gg.agenda.api.user.agendaprofile.controller.response.AttendedAgendaListResDto;
import gg.agenda.api.user.agendaprofile.controller.response.CurrentAttendAgendaListResDto;
import gg.data.agenda.AgendaProfile;
import gg.data.agenda.AgendaTeamProfile;
Expand Down Expand Up @@ -57,7 +60,7 @@ public List<CurrentAttendAgendaListResDto> findCurrentAttendAgenda(String intraI
AgendaProfile agendaProfile = agendaProfileRepository.findByIntraId(intraId)
.orElseThrow(() -> new NotExistException(AGENDA_PROFILE_NOT_FOUND));

List<AgendaTeamProfile> agendaTeamProfiles = agendaTeamProfileRepository.findByProfile(
List<AgendaTeamProfile> agendaTeamProfiles = agendaTeamProfileRepository.findByProfileAndIsExistTrue(
agendaProfile);

return agendaTeamProfiles.stream()
Expand All @@ -68,4 +71,26 @@ public List<CurrentAttendAgendaListResDto> findCurrentAttendAgenda(String intraI
.map(CurrentAttendAgendaListResDto::new)
.collect(Collectors.toList());
}

/**
* 자기가 참여했던 Agenda 목록 조회하는 메서드
* @param intraId,pageable 페이지네이션 요청 정보, 로그인한 유저의 id
*/
@Transactional(readOnly = true)
public List<AttendedAgendaListResDto> findAttendedAgenda(String intraId, Pageable pageable) {
AgendaProfile agendaProfile = agendaProfileRepository.findByIntraId(intraId)
.orElseThrow(() -> new NotExistException(AGENDA_PROFILE_NOT_FOUND));

Page<AgendaTeamProfile> agendaTeamProfilePage =
agendaTeamProfileRepository.findByProfileAndIsExistTrueAndAgendaStatus(
agendaProfile, AgendaStatus.FINISH, pageable);

return agendaTeamProfilePage.getContent().stream()
.map(agendaTeamProfile -> {
List<AgendaTeamProfile> agendaTeamProfiles = agendaTeamProfileRepository
.findByAgendaTeamAndIsExistTrue(agendaTeamProfile.getAgendaTeam());
return new AttendedAgendaListResDto(agendaTeamProfile, agendaTeamProfiles);
})
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gg.agenda.api.user.agendateam.controller;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand All @@ -12,6 +13,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -30,6 +32,7 @@
import gg.agenda.api.user.agendateam.service.AgendaTeamService;
import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.data.agenda.AgendaTeam;
import gg.utils.dto.PageRequestDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
Expand All @@ -47,8 +50,7 @@ public class AgendaTeamController {
*/
@GetMapping("/my")
public ResponseEntity<Optional<MyTeamSimpleResDto>> myTeamSimpleDetails(
@Parameter(hidden = true) @Login UserDto user,
@RequestParam("agenda_key") UUID agendaKey) {
@Parameter(hidden = true) @Login UserDto user, @RequestParam("agenda_key") UUID agendaKey) {
Optional<MyTeamSimpleResDto> myTeamSimpleResDto = agendaTeamService.detailsMyTeamSimple(user, agendaKey);
if (myTeamSimpleResDto.isEmpty()) {
return ResponseEntity.noContent().build();
Expand Down Expand Up @@ -98,16 +100,24 @@ public ResponseEntity<Void> confirmTeam(@Parameter(hidden = true) @Login UserDto
@PatchMapping("/cancel")
public ResponseEntity<Void> leaveAgendaTeam(@Parameter(hidden = true) @Login UserDto user,
@RequestBody @Valid TeamKeyReqDto teamKeyReqDto, @RequestParam("agenda_key") UUID agendaKey) {
agendaTeamService.agendaTeamLeave(user, agendaKey, teamKeyReqDto.getTeamKey());
UUID teamKey = teamKeyReqDto.getTeamKey();

AgendaTeam agendaTeam = agendaTeamService.getAgendaTeam(agendaKey, teamKey);
agendaTeam.getAgenda().leaveTeam(LocalDateTime.now());
if (agendaTeam.getLeaderIntraId().equals(user.getIntraId())) {
agendaTeamService.leaveTeamAll(agendaTeam);
} else {
agendaTeamService.leaveTeamMate(agendaTeam, user);
}
return ResponseEntity.noContent().build();
}

/**
* 아젠다 팀 공개 모집인 팀 목록 조회
* @param pageRequest 페이지네이션 요청 정보, agendaId 아젠다 아이디
*/
@GetMapping("/open")
public ResponseEntity<List<OpenTeamResDto>> openTeamList(@RequestBody @Valid PageRequestDto pageRequest,
@GetMapping("/open/list")
public ResponseEntity<List<OpenTeamResDto>> openTeamList(@ModelAttribute @Valid PageRequestDto pageRequest,
@RequestParam("agenda_key") UUID agendaKey) {
int page = pageRequest.getPage();
int size = pageRequest.getSize();
Expand All @@ -121,7 +131,7 @@ public ResponseEntity<List<OpenTeamResDto>> openTeamList(@RequestBody @Valid Pag
* @param pageRequest 페이지네이션 요청 정보, agendaId 아젠다 아이디
*/
@GetMapping("/confirm/list")
public ResponseEntity<List<ConfirmTeamResDto>> confirmTeamList(@RequestBody @Valid PageRequestDto pageRequest,
public ResponseEntity<List<ConfirmTeamResDto>> confirmTeamList(@ModelAttribute @Valid PageRequestDto pageRequest,
@RequestParam("agenda_key") UUID agendaKey) {
int page = pageRequest.getPage();
int size = pageRequest.getSize();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package gg.agenda.api.user.agendateam.controller.response;

import java.util.List;

import gg.data.agenda.AgendaTeam;
import gg.data.agenda.type.Coalition;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -11,11 +14,13 @@ public class OpenTeamResDto {
private String teamLeaderIntraId;
private int teamMateCount;
private String teamKey;
private List<Coalition> coalitions;

public OpenTeamResDto(AgendaTeam agendaTeam) {
public OpenTeamResDto(AgendaTeam agendaTeam, List<Coalition> coalitions) {
this.teamName = agendaTeam.getName();
this.teamLeaderIntraId = agendaTeam.getLeaderIntraId();
this.teamMateCount = agendaTeam.getMateCount();
this.teamKey = agendaTeam.getTeamKey().toString();
this.coalitions = coalitions;
}
}
Loading

0 comments on commit 5226c08

Please sign in to comment.