From 4b211ecdfeb26d5c60b0550c70353c1a0fef8053 Mon Sep 17 00:00:00 2001 From: GA Pro Date: Tue, 12 May 2026 23:42:58 +0900 Subject: [PATCH] =?UTF-8?q?feat(core):=20AgentOrgHistoryResp=20+=20MapStru?= =?UTF-8?q?ct=20mapper=203=EC=A2=85=20=EC=B6=94=EA=B0=80=20(=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=205a)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 코드 품질 5단계 ga-core 준비물. ga-api 적용은 5b에서 진행. AgentOrgHistoryResp 추가: - AgentOrgHistoryVO 직접 노출 문제 해소 (감사 필드 누설 + FK ID만 노출) - 표시용 조인 필드 포함: agentName, from/toOrgName, from/toGradeName, changeTypeName (CHANGE_TYPE 코드그룹 스칼라 서브쿼리) - AgentMapper.selectHistoryResp + AgentMapper.xml 조인 쿼리 추가 MapStruct mapper 3종 (com.ga.core.mapstruct): - ContractMapStruct (ContractSaveReq → ContractVO + update 패턴) - ExceptionLedgerMapStruct (ExceptionLedgerSaveReq → ExceptionLedgerVO) - UserMapStruct (UserSaveReq → UserVO) - @Mapper(componentModel="spring"), 감사 필드 ignore --- .../com/ga/core/mapper/org/AgentMapper.java | 2 + .../ga/core/mapstruct/ContractMapStruct.java | 27 +++++++++++ .../mapstruct/ExceptionLedgerMapStruct.java | 24 ++++++++++ .../com/ga/core/mapstruct/UserMapStruct.java | 34 ++++++++++++++ .../ga/core/vo/org/AgentOrgHistoryResp.java | 27 +++++++++++ .../main/resources/mapper/org/AgentMapper.xml | 47 +++++++++++++++++++ 6 files changed, 161 insertions(+) create mode 100644 ga-core/src/main/java/com/ga/core/mapstruct/ContractMapStruct.java create mode 100644 ga-core/src/main/java/com/ga/core/mapstruct/ExceptionLedgerMapStruct.java create mode 100644 ga-core/src/main/java/com/ga/core/mapstruct/UserMapStruct.java create mode 100644 ga-core/src/main/java/com/ga/core/vo/org/AgentOrgHistoryResp.java diff --git a/ga-core/src/main/java/com/ga/core/mapper/org/AgentMapper.java b/ga-core/src/main/java/com/ga/core/mapper/org/AgentMapper.java index 000f340..6067eea 100644 --- a/ga-core/src/main/java/com/ga/core/mapper/org/AgentMapper.java +++ b/ga-core/src/main/java/com/ga/core/mapper/org/AgentMapper.java @@ -1,6 +1,7 @@ package com.ga.core.mapper.org; import com.ga.core.vo.org.AgentExcelVO; +import com.ga.core.vo.org.AgentOrgHistoryResp; import com.ga.core.vo.org.AgentOrgHistoryVO; import com.ga.core.vo.org.AgentResp; import com.ga.core.vo.org.AgentSearchParam; @@ -28,5 +29,6 @@ public interface AgentMapper { /** 이력 */ List selectHistory(@Param("agentId") Long agentId); + List selectHistoryResp(@Param("agentId") Long agentId); int insertHistory(AgentOrgHistoryVO vo); } diff --git a/ga-core/src/main/java/com/ga/core/mapstruct/ContractMapStruct.java b/ga-core/src/main/java/com/ga/core/mapstruct/ContractMapStruct.java new file mode 100644 index 0000000..2c0dc90 --- /dev/null +++ b/ga-core/src/main/java/com/ga/core/mapstruct/ContractMapStruct.java @@ -0,0 +1,27 @@ +package com.ga.core.mapstruct; + +import com.ga.core.vo.product.ContractSaveReq; +import com.ga.core.vo.product.ContractVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.MappingTarget; + +@Mapper(componentModel = "spring") +public interface ContractMapStruct { + + @Mapping(target = "contractId", ignore = true) + @Mapping(target = "status", ignore = true) + @Mapping(target = "lapseDate", ignore = true) + @Mapping(target = "revivalDate", ignore = true) + @Mapping(target = "createdAt", ignore = true) + @Mapping(target = "updatedAt", ignore = true) + ContractVO toVO(ContractSaveReq req); + + @Mapping(target = "contractId", ignore = true) + @Mapping(target = "status", ignore = true) + @Mapping(target = "lapseDate", ignore = true) + @Mapping(target = "revivalDate", ignore = true) + @Mapping(target = "createdAt", ignore = true) + @Mapping(target = "updatedAt", ignore = true) + void updateVO(ContractSaveReq req, @MappingTarget ContractVO vo); +} diff --git a/ga-core/src/main/java/com/ga/core/mapstruct/ExceptionLedgerMapStruct.java b/ga-core/src/main/java/com/ga/core/mapstruct/ExceptionLedgerMapStruct.java new file mode 100644 index 0000000..fc21d14 --- /dev/null +++ b/ga-core/src/main/java/com/ga/core/mapstruct/ExceptionLedgerMapStruct.java @@ -0,0 +1,24 @@ +package com.ga.core.mapstruct; + +import com.ga.core.vo.ledger.ExceptionLedgerSaveReq; +import com.ga.core.vo.ledger.ExceptionLedgerVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper(componentModel = "spring") +public interface ExceptionLedgerMapStruct { + + @Mapping(target = "ledgerId", ignore = true) + @Mapping(target = "contractId", ignore = true) + @Mapping(target = "commissionYear", ignore = true) + @Mapping(target = "taxAmount", ignore = true) + @Mapping(target = "approveStatus", ignore = true) + @Mapping(target = "approverId", ignore = true) + @Mapping(target = "approveDate", ignore = true) + @Mapping(target = "recurringLeft", ignore = true) + @Mapping(target = "status", ignore = true) + @Mapping(target = "version", ignore = true) + @Mapping(target = "createdAt", ignore = true) + @Mapping(target = "updatedAt", ignore = true) + ExceptionLedgerVO toVO(ExceptionLedgerSaveReq req); +} diff --git a/ga-core/src/main/java/com/ga/core/mapstruct/UserMapStruct.java b/ga-core/src/main/java/com/ga/core/mapstruct/UserMapStruct.java new file mode 100644 index 0000000..9a07877 --- /dev/null +++ b/ga-core/src/main/java/com/ga/core/mapstruct/UserMapStruct.java @@ -0,0 +1,34 @@ +package com.ga.core.mapstruct; + +import com.ga.core.vo.user.UserSaveReq; +import com.ga.core.vo.user.UserVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.MappingTarget; + +@Mapper(componentModel = "spring") +public interface UserMapStruct { + + @Mapping(target = "userId", ignore = true) + @Mapping(target = "password", ignore = true) + @Mapping(target = "failCount", ignore = true) + @Mapping(target = "lastLoginAt", ignore = true) + @Mapping(target = "pwdChangedAt", ignore = true) + @Mapping(target = "createdAt", ignore = true) + @Mapping(target = "createdBy", ignore = true) + @Mapping(target = "updatedAt", ignore = true) + @Mapping(target = "updatedBy", ignore = true) + UserVO toVO(UserSaveReq req); + + @Mapping(target = "userId", ignore = true) + @Mapping(target = "loginId", ignore = true) + @Mapping(target = "password", ignore = true) + @Mapping(target = "failCount", ignore = true) + @Mapping(target = "lastLoginAt", ignore = true) + @Mapping(target = "pwdChangedAt", ignore = true) + @Mapping(target = "createdAt", ignore = true) + @Mapping(target = "createdBy", ignore = true) + @Mapping(target = "updatedAt", ignore = true) + @Mapping(target = "updatedBy", ignore = true) + void updateVO(UserSaveReq req, @MappingTarget UserVO vo); +} diff --git a/ga-core/src/main/java/com/ga/core/vo/org/AgentOrgHistoryResp.java b/ga-core/src/main/java/com/ga/core/vo/org/AgentOrgHistoryResp.java new file mode 100644 index 0000000..69a18b1 --- /dev/null +++ b/ga-core/src/main/java/com/ga/core/vo/org/AgentOrgHistoryResp.java @@ -0,0 +1,27 @@ +package com.ga.core.vo.org; + +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class AgentOrgHistoryResp { + private Long historyId; + private Long agentId; + private String agentName; + + private Long fromOrgId; + private String fromOrgName; + private Long toOrgId; + private String toOrgName; + + private Long fromGradeId; + private String fromGradeName; + private Long toGradeId; + private String toGradeName; + + private String changeType; // TRANSFER / PROMOTE / DEMOTE / JOIN / LEAVE + private String changeTypeName; + private LocalDate changeDate; + private String changeReason; +} diff --git a/ga-core/src/main/resources/mapper/org/AgentMapper.xml b/ga-core/src/main/resources/mapper/org/AgentMapper.xml index 7104b9b..19ecd5a 100644 --- a/ga-core/src/main/resources/mapper/org/AgentMapper.xml +++ b/ga-core/src/main/resources/mapper/org/AgentMapper.xml @@ -143,10 +143,57 @@ WHERE agent_id = #{agentId} + + + + + + + + + + + + + + + + + + + + + INSERT INTO agent_org_history (agent_id, from_org_id, to_org_id, from_grade_id, to_grade_id, change_type, change_date, change_reason, created_at, created_by)