From 1ddc62ea2a1a034f2d1c2e5fbbbb281d353e2d5f Mon Sep 17 00:00:00 2001 From: YuJeeun Date: Mon, 25 Nov 2024 17:15:17 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95:=20CampaignTemplateController=20->=20listTem?= =?UTF-8?q?plates=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CampaignTemplateController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/controller/CampaignTemplateController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/controller/CampaignTemplateController.java index 9ed3b2d9..8ecd5fee 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/controller/CampaignTemplateController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/controller/CampaignTemplateController.java @@ -1,6 +1,7 @@ package intbyte4.learnsmate.campaign_template.controller; import intbyte4.learnsmate.campaign_template.domain.dto.CampaignTemplateDTO; +import intbyte4.learnsmate.campaign_template.domain.dto.FindAllCampaignTemplatesDTO; import intbyte4.learnsmate.campaign_template.domain.vo.request.RequestEditTemplateVO; import intbyte4.learnsmate.campaign_template.domain.vo.request.RequestRegisterTemplateVO; import intbyte4.learnsmate.campaign_template.domain.vo.response.ResponseEditTemplateVO; @@ -96,10 +97,10 @@ public ResponseEntity deleteTemplate(@PathVariable("campaignTemplateCode") Lo @Operation(summary = "직원 - 캠페인 템플릿 전체 조회") @GetMapping("/list") public ResponseEntity> listTemplates() { - List campaignTemplateDTOList = campaignTemplateService.findAllByTemplate(); + List campaignTemplateDTOList = campaignTemplateService.findAllByTemplate(); List response = new ArrayList<>(); - for (CampaignTemplateDTO campaignTemplateDTO : campaignTemplateDTOList) { - ResponseFindTemplateVO vocVO = campaignTemplateMapper.fromDtoToFindResponseVO(campaignTemplateDTO); + for (FindAllCampaignTemplatesDTO findAllCampaignTemplateDTO : campaignTemplateDTOList) { + ResponseFindTemplateVO vocVO = campaignTemplateMapper.fromFindAllDtoToFindResponseVO(findAllCampaignTemplateDTO); response.add(vocVO); } return ResponseEntity.status(HttpStatus.OK).body(response); From 4c3d4945a7ac360481019dd2c125f9d5d62d36da Mon Sep 17 00:00:00 2001 From: YuJeeun Date: Mon, 25 Nov 2024 17:15:40 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80:=20CampaignTemplateMapper=20->=20fromEntityToFindAllD?= =?UTF-8?q?TO,=20fromFindAllDtoToFindResponseVO=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/CampaignTemplateMapper.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/mapper/CampaignTemplateMapper.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/mapper/CampaignTemplateMapper.java index 180b0ccb..8a657b09 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/mapper/CampaignTemplateMapper.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/mapper/CampaignTemplateMapper.java @@ -3,6 +3,7 @@ import intbyte4.learnsmate.admin.domain.entity.Admin; import intbyte4.learnsmate.campaign_template.domain.CampaignTemplate; import intbyte4.learnsmate.campaign_template.domain.dto.CampaignTemplateDTO; +import intbyte4.learnsmate.campaign_template.domain.dto.FindAllCampaignTemplatesDTO; import intbyte4.learnsmate.campaign_template.domain.vo.request.RequestEditTemplateVO; import intbyte4.learnsmate.campaign_template.domain.vo.request.RequestRegisterTemplateVO; import intbyte4.learnsmate.campaign_template.domain.vo.response.ResponseEditTemplateVO; @@ -83,4 +84,30 @@ public CampaignTemplate toEntity(CampaignTemplateDTO campaignTemplateDTO, Admin .admin(admin) .build(); } + + public FindAllCampaignTemplatesDTO fromEntityToFindAllDTO(CampaignTemplate entity, String adminName) { + return FindAllCampaignTemplatesDTO.builder() + .campaignTemplateCode(entity.getCampaignTemplateCode()) + .campaignTemplateTitle(entity.getCampaignTemplateTitle()) + .campaignTemplateContents(entity.getCampaignTemplateContents()) + .campaignTemplateFlag(entity.getCampaignTemplateFlag()) + .createdAt(entity.getCreatedAt()) + .updatedAt(entity.getUpdatedAt()) + .adminCode(entity.getAdmin().getAdminCode()) + .adminName(adminName) + .build(); + } + + public ResponseFindTemplateVO fromFindAllDtoToFindResponseVO(FindAllCampaignTemplatesDTO dto) { + return ResponseFindTemplateVO.builder() + .campaignTemplateCode(dto.getCampaignTemplateCode()) + .campaignTemplateTitle(dto.getCampaignTemplateTitle()) + .campaignTemplateContents(dto.getCampaignTemplateContents()) + .campaignTemplateFlag(dto.getCampaignTemplateFlag()) + .createdAt(dto.getCreatedAt()) + .updatedAt(dto.getUpdatedAt()) + .adminCode(dto.getAdminCode()) + .adminName(dto.getAdminName()) + .build(); + } } From 2414f3b55f402f89d580744a8adc061c07e76232 Mon Sep 17 00:00:00 2001 From: YuJeeun Date: Mon, 25 Nov 2024 17:16:02 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95:=20CampaignTemplateService=20->=20findAllByT?= =?UTF-8?q?emplate=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../campaign_template/service/CampaignTemplateService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateService.java index 2f76641f..197dbdad 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateService.java @@ -1,6 +1,7 @@ package intbyte4.learnsmate.campaign_template.service; import intbyte4.learnsmate.campaign_template.domain.dto.CampaignTemplateDTO; +import intbyte4.learnsmate.campaign_template.domain.dto.FindAllCampaignTemplatesDTO; import java.util.List; @@ -11,7 +12,7 @@ public interface CampaignTemplateService { void deleteTemplate(CampaignTemplateDTO campaignTemplateDTO); - List findAllByTemplate(); + List findAllByTemplate(); CampaignTemplateDTO findByTemplateCode(Long campaignTemplateCode); } From 7808d3eefa92c8c7b767f80d2dd5842826cf87c7 Mon Sep 17 00:00:00 2001 From: YuJeeun Date: Mon, 25 Nov 2024 17:16:10 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95:=20CampaignTemplateService=20->=20findAllByT?= =?UTF-8?q?emplate=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CampaignTemplateServiceImpl.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateServiceImpl.java index 4f9b1688..d9648b72 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/service/CampaignTemplateServiceImpl.java @@ -6,6 +6,7 @@ import intbyte4.learnsmate.admin.service.AdminService; import intbyte4.learnsmate.campaign_template.domain.CampaignTemplate; import intbyte4.learnsmate.campaign_template.domain.dto.CampaignTemplateDTO; +import intbyte4.learnsmate.campaign_template.domain.dto.FindAllCampaignTemplatesDTO; import intbyte4.learnsmate.campaign_template.mapper.CampaignTemplateMapper; import intbyte4.learnsmate.campaign_template.repository.CampaignTemplateRepository; import intbyte4.learnsmate.common.exception.CommonException; @@ -70,15 +71,18 @@ public void deleteTemplate(CampaignTemplateDTO campaignTemplateDTO) { } @Override - public List findAllByTemplate() { + public List findAllByTemplate() { log.info("템플릿 전체 조회 중"); List campaignTemplateList = campaignTemplateRepository.findAll(); - List campaignTemplateVOList = new ArrayList<>(); + List findAllCampaignTemplatesDTOList = new ArrayList<>(); for (CampaignTemplate campaignTemplate : campaignTemplateList) { - campaignTemplateVOList.add(campaignTemplateMapper.fromEntityToDTO(campaignTemplate)); + CampaignTemplateDTO campaignTemplateDTO = campaignTemplateMapper.fromEntityToDTO(campaignTemplate); + AdminDTO adminDTO = adminService.findByAdminCode(campaignTemplateDTO.getAdminCode()); + findAllCampaignTemplatesDTOList.add(campaignTemplateMapper.fromEntityToFindAllDTO(campaignTemplate, adminDTO.getAdminName())); } - return campaignTemplateVOList; + + return findAllCampaignTemplatesDTOList; } @Override From 1a8fd66ea700503f4fd1f098fda16619c975284e Mon Sep 17 00:00:00 2001 From: YuJeeun Date: Mon, 25 Nov 2024 17:16:21 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E2=9C=A8=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80:=20FindAllCampaignTemplatesDTO=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/FindAllCampaignTemplatesDTO.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/dto/FindAllCampaignTemplatesDTO.java diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/dto/FindAllCampaignTemplatesDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/dto/FindAllCampaignTemplatesDTO.java new file mode 100644 index 00000000..0da2139f --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/dto/FindAllCampaignTemplatesDTO.java @@ -0,0 +1,22 @@ +package intbyte4.learnsmate.campaign_template.domain.dto; + +import lombok.*; + +import java.time.LocalDateTime; + +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +@ToString +@Builder +public class FindAllCampaignTemplatesDTO { + private Long campaignTemplateCode; + private String campaignTemplateTitle; + private String campaignTemplateContents; + private Boolean campaignTemplateFlag; + private LocalDateTime createdAt; + private LocalDateTime updatedAt; + private Long adminCode; + private String adminName; +} From 982fb62b21fe1cdd195ed6bc62fbfdc5de1d1a48 Mon Sep 17 00:00:00 2001 From: YuJeeun Date: Mon, 25 Nov 2024 17:16:40 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95:=20ResponseFindTemplateVO=20->=20adminName?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/vo/response/ResponseFindTemplateVO.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/vo/response/ResponseFindTemplateVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/vo/response/ResponseFindTemplateVO.java index bfa79149..4d421f78 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/vo/response/ResponseFindTemplateVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/campaign_template/domain/vo/response/ResponseFindTemplateVO.java @@ -31,4 +31,7 @@ public class ResponseFindTemplateVO { @JsonProperty("admin_code") private final Long adminCode; + + @JsonProperty("admin_name") + private final String adminName; }