Skip to content

Commit

Permalink
Merge branch 'dev' into 909-feature-ticket-apoorve-api
Browse files Browse the repository at this point in the history
  • Loading branch information
AreSain authored Aug 8, 2024
2 parents 0ed6853 + 0d39476 commit adcaa35
Show file tree
Hide file tree
Showing 74 changed files with 2,301 additions and 852 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/checkstyle-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
run: ./gradlew --console verbose clean checkstyleMain
- name: ️Test checkstyle
run: ./gradlew --console verbose clean checkstyleTest
- name: ️TestFixture checkstyle
run: ./gradlew --console verbose clean checkstyleTestFixture
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ subprojects {
"**/aws/*",
"*NotiMailSender*",
'*SlackbotService*',
"**/file/*",
"*AwsImageHandler*"
]

//커버리지 리포트 생성
Expand Down Expand Up @@ -323,4 +325,3 @@ project(':gg-utils') {
dependencies {
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package gg.admin.repo.agenda;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import gg.data.agenda.AgendaProfile;

@Repository
public interface AgendaProfileAdminRepository extends JpaRepository<AgendaProfile, Long> {


@Query("SELECT a FROM AgendaProfile a WHERE a.intraId = :intraId")
Optional<AgendaProfile> findByIntraId(String intraId);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package gg.agenda.api.admin.agenda.controller;

import static gg.utils.exception.ErrorCode.*;

import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;

Expand All @@ -12,22 +15,25 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
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;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import gg.agenda.api.admin.agenda.controller.request.AgendaAdminUpdateReqDto;
import gg.agenda.api.admin.agenda.controller.response.AgendaAdminResDto;
import gg.agenda.api.admin.agenda.service.AgendaAdminService;
import gg.utils.dto.PageRequestDto;
import gg.utils.exception.custom.InvalidParameterException;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/admin/agenda")
@RequestMapping("/agenda/admin")
@RequiredArgsConstructor
public class AgendaAdminController {

Expand All @@ -51,10 +57,14 @@ public ResponseEntity<List<AgendaAdminResDto>> agendaList(@RequestBody @Valid Pa
@ApiResponse(responseCode = "409", description = "Agenda 지역을 변경할 수 없음"),
@ApiResponse(responseCode = "409", description = "Agenda 팀 제한을 변경할 수 없음"),
@ApiResponse(responseCode = "409", description = "Agenda 팀 인원 제한을 변경할 수 없음")})
@PatchMapping("/request")
@PostMapping("/request")
public ResponseEntity<Void> agendaUpdate(@RequestParam("agenda_key") UUID agendaKey,
@RequestBody @Valid AgendaAdminUpdateReqDto agendaDto) {
agendaAdminService.updateAgenda(agendaKey, agendaDto);
@ModelAttribute @Valid AgendaAdminUpdateReqDto agendaDto,
@RequestParam(required = false) MultipartFile agendaPoster) {
if (Objects.nonNull(agendaPoster) && agendaPoster.getSize() > 1024 * 1024 * 2) { // 2MB
throw new InvalidParameterException(AGENDA_POSTER_SIZE_TOO_LARGE);
}
agendaAdminService.updateAgenda(agendaKey, agendaDto, agendaPoster);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package gg.agenda.api.admin.agenda.controller.request;

import java.net.URL;
import java.time.LocalDateTime;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.springframework.format.annotation.DateTimeFormat;

import gg.data.agenda.type.AgendaStatus;
import gg.data.agenda.type.Location;
Expand All @@ -20,20 +18,23 @@ public class AgendaAdminUpdateReqDto {

private String agendaTitle;

private String agendaContents;
private String agendaContent;

private String agendaPoster;
private URL agendaPosterUri;

private Boolean isOfficial;

private Boolean isRanking;

private AgendaStatus agendaStatus;

@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime agendaDeadLine;

@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime agendaStartTime;

@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime agendaEndTime;

private Location agendaLocation;
Expand All @@ -47,13 +48,13 @@ public class AgendaAdminUpdateReqDto {
private int agendaMaxPeople;

@Builder
public AgendaAdminUpdateReqDto(String agendaTitle, String agendaContents, String agendaPoster, Boolean isOfficial,
public AgendaAdminUpdateReqDto(String agendaTitle, String agendaContent, URL agendaPosterUri, Boolean isOfficial,
Boolean isRanking, AgendaStatus agendaStatus, LocalDateTime agendaDeadLine, LocalDateTime agendaStartTime,
LocalDateTime agendaEndTime, Location agendaLocation, int agendaMinTeam, int agendaMaxTeam,
int agendaMinPeople, int agendaMaxPeople) {
this.agendaTitle = agendaTitle;
this.agendaContents = agendaContents;
this.agendaPoster = agendaPoster;
this.agendaContent = agendaContent;
this.agendaPosterUri = agendaPosterUri;
this.isOfficial = isOfficial;
this.isRanking = isRanking;
this.agendaStatus = agendaStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@

import static gg.utils.exception.ErrorCode.*;

import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import gg.admin.repo.agenda.AgendaAdminRepository;
import gg.admin.repo.agenda.AgendaTeamAdminRepository;
import gg.agenda.api.admin.agenda.controller.request.AgendaAdminUpdateReqDto;
import gg.data.agenda.Agenda;
import gg.data.agenda.AgendaTeam;
import gg.utils.exception.custom.BusinessException;
import gg.utils.exception.custom.NotExistException;
import gg.utils.file.handler.ImageHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
@RequiredArgsConstructor
public class AgendaAdminService {
Expand All @@ -25,19 +34,33 @@ public class AgendaAdminService {

private final AgendaTeamAdminRepository agendaTeamAdminRepository;

private final ImageHandler imageHandler;

@Value("${info.image.defaultUrl}")
private String defaultUri;

@Transactional(readOnly = true)
public List<Agenda> getAgendaRequestList(Pageable pageable) {
return agendaAdminRepository.findAll(pageable).getContent();
}

@Transactional
public void updateAgenda(UUID agendaKey, AgendaAdminUpdateReqDto agendaDto) {
public void updateAgenda(UUID agendaKey, AgendaAdminUpdateReqDto agendaDto, MultipartFile agendaPoster) {
Agenda agenda = agendaAdminRepository.findByAgendaKey(agendaKey)
.orElseThrow(() -> new NotExistException(AGENDA_NOT_FOUND));
List<AgendaTeam> teams = agendaTeamAdminRepository.findAllByAgenda(agenda);

agenda.updateInformation(agendaDto.getAgendaTitle(), agendaDto.getAgendaContents(),
agendaDto.getAgendaPoster());
try {
if (Objects.nonNull(agendaPoster)) {
URL storedUrl = imageHandler.uploadImageOrDefault(agendaPoster, agenda.getTitle(), defaultUri);
agenda.updatePosterUri(storedUrl.toString());
}
} catch (IOException e) {
log.error("Failed to upload image", e);
throw new BusinessException(AGENDA_CREATE_FAILED);
}

agenda.updateInformation(agendaDto.getAgendaTitle(), agendaDto.getAgendaContent());
agenda.updateIsOfficial(agendaDto.getIsOfficial());
agenda.updateIsRanking(agendaDto.getIsRanking());
agenda.updateAgendaStatus(agendaDto.getAgendaStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/admin/agenda/announcement")
@RequestMapping("/agenda/admin/announcement")
@RequiredArgsConstructor
public class AgendaAnnouncementAdminController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
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.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import gg.agenda.api.admin.agendateam.controller.request.AgendaTeamKeyReqDto;
import gg.agenda.api.admin.agendateam.controller.request.AgendaTeamUpdateDto;
import gg.agenda.api.admin.agendateam.controller.response.AgendaTeamDetailResDto;
import gg.agenda.api.admin.agendateam.controller.response.AgendaTeamResDto;
import gg.agenda.api.admin.agendateam.service.AgendaTeamAdminService;
Expand All @@ -26,14 +29,14 @@
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/admin/agenda/team")
@RequestMapping("/agenda/admin/team")
@RequiredArgsConstructor
public class AgendaTeamAdminController {

private final AgendaTeamAdminService agendaTeamAdminService;

@GetMapping("/list")
public ResponseEntity<List<AgendaTeamResDto>> getAgendaTeamList(@RequestParam("agenda_key") UUID agendaKey,
public ResponseEntity<List<AgendaTeamResDto>> agendaTeamList(@RequestParam("agenda_key") UUID agendaKey,
@RequestBody @Valid PageRequestDto pageRequestDto) {
int page = pageRequestDto.getPage();
int size = pageRequestDto.getSize();
Expand All @@ -46,12 +49,18 @@ public ResponseEntity<List<AgendaTeamResDto>> getAgendaTeamList(@RequestParam("a
}

@GetMapping
public ResponseEntity<AgendaTeamDetailResDto> getAgendaTeamDetail(
public ResponseEntity<AgendaTeamDetailResDto> agendaTeamDetail(
@RequestBody @Valid AgendaTeamKeyReqDto agendaTeamKeyReqDto) {
AgendaTeam agendaTeam = agendaTeamAdminService.getAgendaTeamByTeamKey(agendaTeamKeyReqDto.getTeamKey());
List<AgendaProfile> participants = agendaTeamAdminService.getAgendaProfileListByAgendaTeam(agendaTeam);
AgendaTeamDetailResDto agendaTeamDetailResDto = AgendaTeamDetailResDto.MapStruct.INSTANCE
.toDto(agendaTeam, participants);
return ResponseEntity.ok(agendaTeamDetailResDto);
}

@PatchMapping
public ResponseEntity<Void> agendaTeamUpdate(@RequestBody @Valid AgendaTeamUpdateDto agendaTeamUpdateDto) {
agendaTeamAdminService.updateAgendaTeam(agendaTeamUpdateDto);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package gg.agenda.api.admin.agendateam.controller.request;

import javax.validation.constraints.NotNull;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class AgendaTeamMateReqDto {

@NotNull
private String intraId;

@Builder
public AgendaTeamMateReqDto(String intraId) {
this.intraId = intraId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package gg.agenda.api.admin.agendateam.controller.request;

import java.util.List;
import java.util.UUID;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import gg.data.agenda.type.AgendaTeamStatus;
import gg.data.agenda.type.Location;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class AgendaTeamUpdateDto {

@NotNull
private UUID teamKey;

@NotBlank
@Size(max = 30)
private String teamName;

@NotBlank
private String teamContent;

@NotNull
private AgendaTeamStatus teamStatus;

@NotNull
private Boolean teamIsPrivate;

@NotNull
private Location teamLocation;

@NotNull
private String teamAward;

@Min(1)
@Max(1000)
private Integer teamAwardPriority;

@Valid
@NotNull
private List<AgendaTeamMateReqDto> teamMates;

@Builder
public AgendaTeamUpdateDto(UUID teamKey, String teamName, String teamContent, AgendaTeamStatus teamStatus,
Location teamLocation, String teamAward, Integer teamAwardPriority, Boolean teamIsPrivate,
List<AgendaTeamMateReqDto> teamMates) {
this.teamKey = teamKey;
this.teamName = teamName;
this.teamContent = teamContent;
this.teamStatus = teamStatus;
this.teamAward = teamAward;
this.teamAwardPriority = teamAwardPriority;
this.teamIsPrivate = teamIsPrivate;
this.teamLocation = teamLocation;
this.teamMates = teamMates;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public class AgendaTeamDetailResDto {

private boolean teamIsPrivate;

private List<AgendaProfileResDto> teamMates;
private List<AgendaTeamMateResDto> teamMates;

@Builder
public AgendaTeamDetailResDto(String teamName, String teamLeaderIntraId, String teamStatus, String teamAward,
int teamAwardPriority, boolean teamIsPrivate, List<AgendaProfileResDto> teamMates) {
int teamAwardPriority, boolean teamIsPrivate, List<AgendaTeamMateResDto> teamMates) {
this.teamName = teamName;
this.teamLeaderIntraId = teamLeaderIntraId;
this.teamStatus = teamStatus;
Expand All @@ -60,9 +60,9 @@ public interface MapStruct {
AgendaTeamDetailResDto toDto(AgendaTeam team, List<AgendaProfile> teamMates);

@Named("toAgendaProfileResDtoList")
default List<AgendaProfileResDto> toAgendaProfileResDtoList(List<AgendaProfile> teamMates) {
default List<AgendaTeamMateResDto> toAgendaProfileResDtoList(List<AgendaProfile> teamMates) {
return teamMates.stream()
.map(AgendaProfileResDto.MapStruct.INSTANCE::toDto)
.map(AgendaTeamMateResDto.MapStruct.INSTANCE::toDto)
.collect(Collectors.toList());
}
}
Expand Down
Loading

0 comments on commit adcaa35

Please sign in to comment.