From 10af9cdbf80aa473f15c9ce0788aedbe83aa8f08 Mon Sep 17 00:00:00 2001 From: 5uhwann <106325839+5uhwann@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:43:00 +0900 Subject: [PATCH] =?UTF-8?q?[DDING-000]=20ClubMember=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=ED=8C=A8=ED=82=A4=EC=A7=80=20=EB=B6=84=EB=A6=AC=20?= =?UTF-8?q?(#140)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddingdongBE/domain/club/entity/QClub.java | 2 +- .../domain/club/entity/QClubMember.java | 71 ------------------- .../controller/CentralClubApiController.java | 14 ++-- .../dto/request/UpdateClubMemberRequest.java | 5 +- .../dto/response/ClubMemberResponse.java | 2 +- .../ddingdongBE/domain/club/entity/Club.java | 1 + .../club/repository/ClubMemberRepository.java | 20 ------ .../entity/ClubMember.java | 4 +- .../repository/ClubMemberRepository.java | 8 +++ .../clubmember/service/ClubMemberService.java | 13 ++++ .../service/FacadeClubMemberService.java | 14 ++++ .../service/FacadeClubMemberServiceImpl.java} | 38 +++++----- .../service/GeneralClubMemberService.java} | 15 ++-- .../dto/command}/UpdateClubMemberCommand.java | 5 +- .../command/UpdateClubMemberListCommand.java | 12 ++++ .../file/service/ExcelFileService.java | 2 +- .../file/service/dto/ExcelClubMemberDto.java | 2 +- .../common/support/WebApiUnitTestSupport.java | 6 -- ...> FacadeGeneralClubMemberServiceTest.java} | 29 +++++--- .../file/service/ExcelFileServiceTest.java | 52 +------------- 20 files changed, 122 insertions(+), 193 deletions(-) delete mode 100644 src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClubMember.java delete mode 100644 src/main/java/ddingdong/ddingdongBE/domain/club/repository/ClubMemberRepository.java rename src/main/java/ddingdong/ddingdongBE/domain/{club => clubmember}/entity/ClubMember.java (92%) create mode 100644 src/main/java/ddingdong/ddingdongBE/domain/clubmember/repository/ClubMemberRepository.java create mode 100644 src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/ClubMemberService.java create mode 100644 src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/FacadeClubMemberService.java rename src/main/java/ddingdong/ddingdongBE/domain/{club/service/FacadeClubMemberService.java => clubmember/service/FacadeClubMemberServiceImpl.java} (59%) rename src/main/java/ddingdong/ddingdongBE/domain/{club/service/ClubMemberService.java => clubmember/service/GeneralClubMemberService.java} (68%) rename src/main/java/ddingdong/ddingdongBE/domain/{club/service/dto => clubmember/service/dto/command}/UpdateClubMemberCommand.java (77%) create mode 100644 src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/dto/command/UpdateClubMemberListCommand.java rename src/test/java/ddingdong/ddingdongBE/domain/club/service/{FacadeClubMemberServiceTest.java => FacadeGeneralClubMemberServiceTest.java} (81%) diff --git a/src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClub.java b/src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClub.java index 44ad4e4e..5755d435 100644 --- a/src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClub.java +++ b/src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClub.java @@ -28,7 +28,7 @@ public class QClub extends EntityPathBase { public final StringPath category = createString("category"); - public final ListPath clubMembers = this.createList("clubMembers", ClubMember.class, QClubMember.class, PathInits.DIRECT2); + public final ListPath clubMembers = this.createList("clubMembers", ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember.class, ddingdong.ddingdongBE.domain.clubmember.entity.QClubMember.class, PathInits.DIRECT2); public final StringPath content = createString("content"); diff --git a/src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClubMember.java b/src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClubMember.java deleted file mode 100644 index 66648174..00000000 --- a/src/main/generated/ddingdong/ddingdongBE/domain/club/entity/QClubMember.java +++ /dev/null @@ -1,71 +0,0 @@ -package ddingdong.ddingdongBE.domain.club.entity; - -import static com.querydsl.core.types.PathMetadataFactory.*; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.PathMetadata; -import javax.annotation.processing.Generated; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; - - -/** - * QClubMember is a Querydsl query type for ClubMember - */ -@Generated("com.querydsl.codegen.DefaultEntitySerializer") -public class QClubMember extends EntityPathBase { - - private static final long serialVersionUID = 2035559072L; - - private static final PathInits INITS = PathInits.DIRECT2; - - public static final QClubMember clubMember = new QClubMember("clubMember"); - - public final ddingdong.ddingdongBE.common.QBaseEntity _super = new ddingdong.ddingdongBE.common.QBaseEntity(this); - - public final QClub club; - - //inherited - public final DateTimePath createdAt = _super.createdAt; - - public final DateTimePath deletedAt = createDateTime("deletedAt", java.time.LocalDateTime.class); - - public final StringPath department = createString("department"); - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath name = createString("name"); - - public final StringPath phoneNumber = createString("phoneNumber"); - - public final EnumPath position = createEnum("position", Position.class); - - public final StringPath studentNumber = createString("studentNumber"); - - //inherited - public final DateTimePath updatedAt = _super.updatedAt; - - public QClubMember(String variable) { - this(ClubMember.class, forVariable(variable), INITS); - } - - public QClubMember(Path path) { - this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); - } - - public QClubMember(PathMetadata metadata) { - this(metadata, PathInits.getFor(metadata, INITS)); - } - - public QClubMember(PathMetadata metadata, PathInits inits) { - this(ClubMember.class, metadata, inits); - } - - public QClubMember(Class type, PathMetadata metadata, PathInits inits) { - super(type, metadata, inits); - this.club = inits.isInitialized("club") ? new QClub(forProperty("club"), inits.get("club")) : null; - } - -} - diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/controller/CentralClubApiController.java b/src/main/java/ddingdong/ddingdongBE/domain/club/controller/CentralClubApiController.java index 999cef93..2fffc370 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/controller/CentralClubApiController.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/club/controller/CentralClubApiController.java @@ -10,7 +10,8 @@ import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubRequest; import ddingdong.ddingdongBE.domain.club.controller.dto.response.DetailClubResponse; import ddingdong.ddingdongBE.domain.club.service.ClubService; -import ddingdong.ddingdongBE.domain.club.service.FacadeClubMemberService; +import ddingdong.ddingdongBE.domain.clubmember.service.FacadeClubMemberService; +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberListCommand; import ddingdong.ddingdongBE.domain.user.entity.User; import ddingdong.ddingdongBE.file.service.FileService; import java.net.URLEncoder; @@ -78,12 +79,15 @@ public void updateClub(@AuthenticationPrincipal PrincipalDetails principalDetail @Override public void updateClubMemberList(PrincipalDetails principalDetails, MultipartFile clubMemberListFile) { User user = principalDetails.getUser(); - facadeClubMemberService.updateMemberList(user.getId(), clubMemberListFile); + UpdateClubMemberListCommand command = UpdateClubMemberListCommand.builder() + .userId(user.getId()) + .clubMemberListFile(clubMemberListFile) + .build(); + facadeClubMemberService.updateMemberList(command); } @Override - public void updateClubMembers(Long clubMemberId, - UpdateClubMemberRequest request) { - facadeClubMemberService.update(clubMemberId, request.toCommand()); + public void updateClubMembers(Long clubMemberId, UpdateClubMemberRequest request) { + facadeClubMemberService.update(request.toCommand(clubMemberId)); } } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/request/UpdateClubMemberRequest.java b/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/request/UpdateClubMemberRequest.java index 4bcc6948..59c86397 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/request/UpdateClubMemberRequest.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/request/UpdateClubMemberRequest.java @@ -1,7 +1,7 @@ package ddingdong.ddingdongBE.domain.club.controller.dto.request; import ddingdong.ddingdongBE.domain.club.entity.Position; -import ddingdong.ddingdongBE.domain.club.service.dto.UpdateClubMemberCommand; +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberCommand; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Builder; @@ -37,8 +37,9 @@ public record UpdateClubMemberRequest( String department ) { - public UpdateClubMemberCommand toCommand() { + public UpdateClubMemberCommand toCommand(Long clubMemberId) { return UpdateClubMemberCommand.builder() + .clubMemberId(clubMemberId) .name(name) .studentNumber(studentNumber) .phoneNumber(phoneNumber) diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/response/ClubMemberResponse.java b/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/response/ClubMemberResponse.java index a849a591..e4bfe309 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/response/ClubMemberResponse.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/club/controller/dto/response/ClubMemberResponse.java @@ -1,6 +1,6 @@ package ddingdong.ddingdongBE.domain.club.controller.dto.response; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/entity/Club.java b/src/main/java/ddingdong/ddingdongBE/domain/club/entity/Club.java index 8908b820..3d0a6565 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/entity/Club.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/club/entity/Club.java @@ -2,6 +2,7 @@ import ddingdong.ddingdongBE.common.BaseEntity; import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubRequest; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; import ddingdong.ddingdongBE.domain.scorehistory.entity.Score; import ddingdong.ddingdongBE.domain.user.entity.User; import jakarta.persistence.Column; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/repository/ClubMemberRepository.java b/src/main/java/ddingdong/ddingdongBE/domain/club/repository/ClubMemberRepository.java deleted file mode 100644 index 08b29eda..00000000 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/repository/ClubMemberRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package ddingdong.ddingdongBE.domain.club.repository; - -import ddingdong.ddingdongBE.domain.club.entity.Club; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; - - -import java.util.List; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -public interface ClubMemberRepository extends JpaRepository { - - List findClubMembersByClubId(Long clubId); - - @Modifying - @Query("delete from ClubMember c where c.club = :club") - void deleteAllByClub(@Param("club") Club club); -} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/entity/ClubMember.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/entity/ClubMember.java similarity index 92% rename from src/main/java/ddingdong/ddingdongBE/domain/club/entity/ClubMember.java rename to src/main/java/ddingdong/ddingdongBE/domain/clubmember/entity/ClubMember.java index 125f8079..8dcba3bb 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/entity/ClubMember.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/entity/ClubMember.java @@ -1,6 +1,8 @@ -package ddingdong.ddingdongBE.domain.club.entity; +package ddingdong.ddingdongBE.domain.clubmember.entity; import ddingdong.ddingdongBE.common.BaseEntity; +import ddingdong.ddingdongBE.domain.club.entity.Club; +import ddingdong.ddingdongBE.domain.club.entity.Position; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; diff --git a/src/main/java/ddingdong/ddingdongBE/domain/clubmember/repository/ClubMemberRepository.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/repository/ClubMemberRepository.java new file mode 100644 index 00000000..17d3de1b --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/repository/ClubMemberRepository.java @@ -0,0 +1,8 @@ +package ddingdong.ddingdongBE.domain.clubmember.repository; + +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ClubMemberRepository extends JpaRepository { + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/ClubMemberService.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/ClubMemberService.java new file mode 100644 index 00000000..7ef75569 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/ClubMemberService.java @@ -0,0 +1,13 @@ +package ddingdong.ddingdongBE.domain.clubmember.service; + +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; +import java.util.List; + +public interface ClubMemberService { + + ClubMember getById(Long clubMemberId); + + void saveAll(List clubMembers); + + void deleteAll(List clubMembers); +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/FacadeClubMemberService.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/FacadeClubMemberService.java new file mode 100644 index 00000000..48d964b0 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/FacadeClubMemberService.java @@ -0,0 +1,14 @@ +package ddingdong.ddingdongBE.domain.clubmember.service; + +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberCommand; +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberListCommand; + +public interface FacadeClubMemberService { + + byte[] getClubMemberListFile(Long userId); + + void updateMemberList(UpdateClubMemberListCommand command); + + void update(UpdateClubMemberCommand updateClubMemberCommand); + +} diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/service/FacadeClubMemberService.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/FacadeClubMemberServiceImpl.java similarity index 59% rename from src/main/java/ddingdong/ddingdongBE/domain/club/service/FacadeClubMemberService.java rename to src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/FacadeClubMemberServiceImpl.java index c7567607..8aa83afd 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/service/FacadeClubMemberService.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/FacadeClubMemberServiceImpl.java @@ -1,8 +1,10 @@ -package ddingdong.ddingdongBE.domain.club.service; +package ddingdong.ddingdongBE.domain.clubmember.service; import ddingdong.ddingdongBE.domain.club.entity.Club; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; -import ddingdong.ddingdongBE.domain.club.service.dto.UpdateClubMemberCommand; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; +import ddingdong.ddingdongBE.domain.club.service.ClubService; +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberCommand; +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberListCommand; import ddingdong.ddingdongBE.file.service.ExcelFileService; import java.util.HashSet; import java.util.List; @@ -11,26 +13,28 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; @Service -@Transactional +@Transactional(readOnly = true) @RequiredArgsConstructor -public class FacadeClubMemberService { +public class FacadeClubMemberServiceImpl implements FacadeClubMemberService { private final ClubService clubService; - private final ClubMemberService clubMemberService; + private final GeneralClubMemberService generalClubMemberService; private final ExcelFileService excelFileService; - @Transactional(readOnly = true) + @Override public byte[] getClubMemberListFile(Long userId) { Club club = clubService.getByUserId(userId); return excelFileService.generateClubMemberListFile(club.getClubMembers()); } - public void updateMemberList(Long userId, MultipartFile clubMemberListFile) { - Club club = clubService.getByUserId(userId); - List updatedClubMembers = excelFileService.extractClubMembersInformation(club, clubMemberListFile); + @Override + @Transactional + public void updateMemberList(UpdateClubMemberListCommand command) { + Club club = clubService.getByUserId(command.userId()); + List updatedClubMembers = + excelFileService.extractClubMembersInformation(club, command.clubMemberListFile()); List clubMembers = club.getClubMembers(); Set updatedMemberIds = updatedClubMembers.stream() .map(ClubMember::getId) @@ -39,13 +43,15 @@ public void updateMemberList(Long userId, MultipartFile clubMemberListFile) { .map(ClubMember::getId) .collect(Collectors.toSet()); - clubMemberService.saveAll(filterCreatedMembers(updatedClubMembers, updatedMemberIds, currentMemberIds)); - clubMemberService.deleteAll(filterDeletedMembers(clubMembers, updatedMemberIds, currentMemberIds)); + generalClubMemberService.saveAll(filterCreatedMembers(updatedClubMembers, updatedMemberIds, currentMemberIds)); + generalClubMemberService.deleteAll(filterDeletedMembers(clubMembers, updatedMemberIds, currentMemberIds)); } - public void update(Long clubMemberId, UpdateClubMemberCommand updateClubMemberCommand) { - ClubMember clubMember = clubMemberService.getById(clubMemberId); - clubMember.updateInformation(updateClubMemberCommand.toEntity()); + @Override + @Transactional + public void update(UpdateClubMemberCommand command) { + ClubMember clubMember = generalClubMemberService.getById(command.clubMemberId()); + clubMember.updateInformation(command.toEntity()); } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/service/ClubMemberService.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/GeneralClubMemberService.java similarity index 68% rename from src/main/java/ddingdong/ddingdongBE/domain/club/service/ClubMemberService.java rename to src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/GeneralClubMemberService.java index 5251f114..86d147e4 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/service/ClubMemberService.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/GeneralClubMemberService.java @@ -1,29 +1,34 @@ -package ddingdong.ddingdongBE.domain.club.service; +package ddingdong.ddingdongBE.domain.clubmember.service; import ddingdong.ddingdongBE.common.exception.PersistenceException.ResourceNotFound; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; -import ddingdong.ddingdongBE.domain.club.repository.ClubMemberRepository; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; +import ddingdong.ddingdongBE.domain.clubmember.repository.ClubMemberRepository; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service -@Transactional +@Transactional(readOnly = true) @RequiredArgsConstructor -public class ClubMemberService { +public class GeneralClubMemberService implements ClubMemberService { private final ClubMemberRepository clubMemberRepository; + @Override public ClubMember getById(Long clubMemberId) { return clubMemberRepository.findById(clubMemberId) .orElseThrow(() -> new ResourceNotFound("존재하지 않는 동아리원입니다.")); } + @Override + @Transactional public void saveAll(List clubMembers) { clubMemberRepository.saveAll(clubMembers); } + @Override + @Transactional public void deleteAll(List clubMembers) { clubMemberRepository.deleteAllInBatch(clubMembers); } diff --git a/src/main/java/ddingdong/ddingdongBE/domain/club/service/dto/UpdateClubMemberCommand.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/dto/command/UpdateClubMemberCommand.java similarity index 77% rename from src/main/java/ddingdong/ddingdongBE/domain/club/service/dto/UpdateClubMemberCommand.java rename to src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/dto/command/UpdateClubMemberCommand.java index 627d4161..bcb2fbfd 100644 --- a/src/main/java/ddingdong/ddingdongBE/domain/club/service/dto/UpdateClubMemberCommand.java +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/dto/command/UpdateClubMemberCommand.java @@ -1,11 +1,12 @@ -package ddingdong.ddingdongBE.domain.club.service.dto; +package ddingdong.ddingdongBE.domain.clubmember.service.dto.command; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; import ddingdong.ddingdongBE.domain.club.entity.Position; import lombok.Builder; @Builder public record UpdateClubMemberCommand( + Long clubMemberId, String name, String studentNumber, String phoneNumber, diff --git a/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/dto/command/UpdateClubMemberListCommand.java b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/dto/command/UpdateClubMemberListCommand.java new file mode 100644 index 00000000..cf45f842 --- /dev/null +++ b/src/main/java/ddingdong/ddingdongBE/domain/clubmember/service/dto/command/UpdateClubMemberListCommand.java @@ -0,0 +1,12 @@ +package ddingdong.ddingdongBE.domain.clubmember.service.dto.command; + +import lombok.Builder; +import org.springframework.web.multipart.MultipartFile; + +@Builder +public record UpdateClubMemberListCommand( + Long userId, + MultipartFile clubMemberListFile +) { + +} diff --git a/src/main/java/ddingdong/ddingdongBE/file/service/ExcelFileService.java b/src/main/java/ddingdong/ddingdongBE/file/service/ExcelFileService.java index badcd98d..952dc0af 100644 --- a/src/main/java/ddingdong/ddingdongBE/file/service/ExcelFileService.java +++ b/src/main/java/ddingdong/ddingdongBE/file/service/ExcelFileService.java @@ -3,7 +3,7 @@ import ddingdong.ddingdongBE.common.exception.ParsingExcelFileException.ExcelIO; import ddingdong.ddingdongBE.common.exception.ParsingExcelFileException.NonExcelFile; import ddingdong.ddingdongBE.domain.club.entity.Club; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; import ddingdong.ddingdongBE.file.service.dto.ExcelClubMemberDto; import java.awt.Color; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/ddingdong/ddingdongBE/file/service/dto/ExcelClubMemberDto.java b/src/main/java/ddingdong/ddingdongBE/file/service/dto/ExcelClubMemberDto.java index 6063dbc5..b0f326d1 100644 --- a/src/main/java/ddingdong/ddingdongBE/file/service/dto/ExcelClubMemberDto.java +++ b/src/main/java/ddingdong/ddingdongBE/file/service/dto/ExcelClubMemberDto.java @@ -2,7 +2,7 @@ import ddingdong.ddingdongBE.common.exception.InvalidatedMappingException.InvalidatedEnumValue; import ddingdong.ddingdongBE.domain.club.entity.Club; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; import ddingdong.ddingdongBE.domain.club.entity.Position; import java.util.Arrays; import java.util.Iterator; diff --git a/src/test/java/ddingdong/ddingdongBE/common/support/WebApiUnitTestSupport.java b/src/test/java/ddingdong/ddingdongBE/common/support/WebApiUnitTestSupport.java index b5db0383..f61b3867 100644 --- a/src/test/java/ddingdong/ddingdongBE/common/support/WebApiUnitTestSupport.java +++ b/src/test/java/ddingdong/ddingdongBE/common/support/WebApiUnitTestSupport.java @@ -7,11 +7,9 @@ import ddingdong.ddingdongBE.domain.club.service.ClubService; import ddingdong.ddingdongBE.domain.documents.controller.AdminDocumentController; import ddingdong.ddingdongBE.domain.documents.controller.DocumentController; -import ddingdong.ddingdongBE.domain.documents.service.DocumentService; import ddingdong.ddingdongBE.domain.documents.service.FacadeAdminDocumentService; import ddingdong.ddingdongBE.domain.documents.service.FacadeDocumentService; import ddingdong.ddingdongBE.domain.fileinformation.service.FileInformationService; -import ddingdong.ddingdongBE.domain.question.service.GeneralQuestionService; import ddingdong.ddingdongBE.domain.scorehistory.controller.AdminScoreHistoryController; import ddingdong.ddingdongBE.file.service.FileService; import org.junit.jupiter.api.BeforeEach; @@ -36,8 +34,6 @@ public abstract class WebApiUnitTestSupport { @Autowired protected MockMvc mockMvc; @MockBean - protected DocumentService documentService; - @MockBean protected FacadeDocumentService facadeDocumentService; @MockBean protected FacadeAdminDocumentService facadeAdminDocumentService; @@ -46,8 +42,6 @@ public abstract class WebApiUnitTestSupport { @MockBean protected FileInformationService fileInformationService; @MockBean - protected GeneralQuestionService generalQuestionService; - @MockBean protected ClubService clubService; @Autowired diff --git a/src/test/java/ddingdong/ddingdongBE/domain/club/service/FacadeClubMemberServiceTest.java b/src/test/java/ddingdong/ddingdongBE/domain/club/service/FacadeGeneralClubMemberServiceTest.java similarity index 81% rename from src/test/java/ddingdong/ddingdongBE/domain/club/service/FacadeClubMemberServiceTest.java rename to src/test/java/ddingdong/ddingdongBE/domain/club/service/FacadeGeneralClubMemberServiceTest.java index e975fe7e..e4c39b9f 100644 --- a/src/test/java/ddingdong/ddingdongBE/domain/club/service/FacadeClubMemberServiceTest.java +++ b/src/test/java/ddingdong/ddingdongBE/domain/club/service/FacadeGeneralClubMemberServiceTest.java @@ -6,11 +6,14 @@ import ddingdong.ddingdongBE.common.support.FixtureMonkeyFactory; import ddingdong.ddingdongBE.common.support.TestContainerSupport; import ddingdong.ddingdongBE.domain.club.entity.Club; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; import ddingdong.ddingdongBE.domain.club.entity.Position; -import ddingdong.ddingdongBE.domain.club.repository.ClubMemberRepository; +import ddingdong.ddingdongBE.domain.clubmember.repository.ClubMemberRepository; import ddingdong.ddingdongBE.domain.club.repository.ClubRepository; -import ddingdong.ddingdongBE.domain.club.service.dto.UpdateClubMemberCommand; +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberCommand; +import ddingdong.ddingdongBE.domain.clubmember.service.GeneralClubMemberService; +import ddingdong.ddingdongBE.domain.clubmember.service.FacadeClubMemberServiceImpl; +import ddingdong.ddingdongBE.domain.clubmember.service.dto.command.UpdateClubMemberListCommand; import ddingdong.ddingdongBE.domain.scorehistory.entity.Score; import ddingdong.ddingdongBE.domain.user.entity.User; import ddingdong.ddingdongBE.domain.user.repository.UserRepository; @@ -31,10 +34,10 @@ import org.springframework.web.multipart.MultipartFile; @SpringBootTest -class FacadeClubMemberServiceTest extends TestContainerSupport { +class FacadeGeneralClubMemberServiceTest extends TestContainerSupport { @Autowired - private FacadeClubMemberService facadeClubMemberService; + private FacadeClubMemberServiceImpl facadeClubMemberServiceImpl; @Autowired private UserRepository userRepository; @Autowired @@ -42,7 +45,7 @@ class FacadeClubMemberServiceTest extends TestContainerSupport { @Autowired private ClubMemberRepository clubMemberRepository; @Autowired - private ClubMemberService clubMemberService; + private GeneralClubMemberService generalClubMemberService; private final FixtureMonkey fixtureMonkey = FixtureMonkeyFactory.getBuilderIntrospectorMonkey(); @@ -97,8 +100,13 @@ void updateClubList() throws IOException { .sampleList(5); clubMemberRepository.saveAll(clubMembers); + UpdateClubMemberListCommand command = UpdateClubMemberListCommand.builder() + .userId(savedClub.getId()) + .clubMemberListFile(validExcelFile) + .build(); + //when - facadeClubMemberService.updateMemberList(savedUser.getId(), validExcelFile); + facadeClubMemberServiceImpl.updateMemberList(command); //then List updatedClubMemberList = clubMemberRepository.findAll(); @@ -120,7 +128,8 @@ void update() { ClubMember savedClubMember = clubMemberRepository.save( fixtureMonkey.giveMeBuilder(ClubMember.class).set("club", savedClub).sample()); - UpdateClubMemberCommand updateClubMemberCommand = UpdateClubMemberCommand.builder() + UpdateClubMemberCommand command = UpdateClubMemberCommand.builder() + .clubMemberId(savedClubMember.getId()) .name("test") .phoneNumber("010-1234-5678") .studentNumber("60001234") @@ -128,10 +137,10 @@ void update() { .department("test").build(); //when - facadeClubMemberService.update(savedClubMember.getId(), updateClubMemberCommand); + facadeClubMemberServiceImpl.update(command); //then - ClubMember updatedClubMember = clubMemberService.getById(savedClubMember.getId()); + ClubMember updatedClubMember = generalClubMemberService.getById(savedClubMember.getId()); assertThat(updatedClubMember.getName()).isEqualTo("test"); assertThat(updatedClubMember.getPhoneNumber()).isEqualTo("010-1234-5678"); assertThat(updatedClubMember.getStudentNumber()).isEqualTo("60001234"); diff --git a/src/test/java/ddingdong/ddingdongBE/file/service/ExcelFileServiceTest.java b/src/test/java/ddingdong/ddingdongBE/file/service/ExcelFileServiceTest.java index 685dd148..5919cdf1 100644 --- a/src/test/java/ddingdong/ddingdongBE/file/service/ExcelFileServiceTest.java +++ b/src/test/java/ddingdong/ddingdongBE/file/service/ExcelFileServiceTest.java @@ -13,7 +13,7 @@ import ddingdong.ddingdongBE.common.support.FixtureMonkeyFactory; import ddingdong.ddingdongBE.common.support.TestContainerSupport; import ddingdong.ddingdongBE.domain.club.entity.Club; -import ddingdong.ddingdongBE.domain.club.entity.ClubMember; +import ddingdong.ddingdongBE.domain.clubmember.entity.ClubMember; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -35,8 +35,6 @@ class ExcelFileServiceTest extends TestContainerSupport { @Autowired private ExcelFileService excelFileService; - private final FixtureMonkey fixtureMonkey = FixtureMonkeyFactory.getBuilderIntrospectorMonkey(); - @Test @DisplayName("엑셀 파일을 정상적으로 파싱하는 경우") @@ -169,52 +167,4 @@ void extractClubMembersInformationWithNonValidatedStringCellValue() throws IOExc .isInstanceOf(InvalidatedEnumValue.class) .hasMessage("동아리원의 역할은 LEADER, EXECUTIVE, MEMBER 중 하나입니다."); } - -// @DisplayName("동아리원 명단 엑셀 파일을 생성한다.") -// @Test -// void generateClubMemberListFile() throws IOException { -// //given -// List clubMembers = fixtureMonkey.giveMeBuilder(ClubMember.class) -// .setNotNull("id") -// .setNotNull("name") -// .setNotNull("studentNumber") -// .setNotNull("phoneNumber") -// .setNotNull("position") -// .setNotNull("department") -// .sampleList(5); -// -// //when -// byte[] excelFileBytes = excelFileService.generateClubMemberListFile(clubMembers); -// -// //then -// try (Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(excelFileBytes))) { -// Sheet sheet = workbook.getSheet("동아리원 명단"); -// assertThat(sheet).isNotNull(); -// -// // header -// Row headerRow = sheet.getRow(0); -// assertThat(headerRow.getCell(0).getStringCellValue()).isEqualTo("식별자(수정X)"); -// assertThat(headerRow.getCell(1).getStringCellValue()).isEqualTo("이름"); -// assertThat(headerRow.getCell(2).getStringCellValue()).isEqualTo("학번"); -// assertThat(headerRow.getCell(3).getStringCellValue()).isEqualTo("연락처"); -// assertThat(headerRow.getCell(4).getStringCellValue()).isEqualTo("비교(임원진) - 영어만"); -// assertThat(headerRow.getCell(5).getStringCellValue()).isEqualTo("학과(부)"); -// -// CellStyle headerStyle = headerRow.getCell(0).getCellStyle(); -// Font font = workbook.getFontAt(headerStyle.getFontIndex()); -// assertThat(font.getBold()).isTrue(); -// -// // data -// for (int i = 0; i < clubMembers.size(); i++) { -// Row dataRow = sheet.getRow(i + 1); -// ClubMember member = clubMembers.get(i); -// -// assertThat(dataRow.getCell(1).getStringCellValue()).isEqualTo(member.getName()); -// assertThat(dataRow.getCell(2).getStringCellValue()).isEqualTo(member.getStudentNumber()); -// assertThat(dataRow.getCell(3).getStringCellValue()).isEqualTo(member.getPhoneNumber()); -// assertThat(dataRow.getCell(4).getStringCellValue()).isEqualTo(member.getPosition().name()); -// assertThat(dataRow.getCell(5).getStringCellValue()).isEqualTo(member.getDepartment()); -// } -// } -// } }