From 2ad0e5a09069cc7d389258ff12dc1cd8b8618fcb Mon Sep 17 00:00:00 2001 From: GA Pro Date: Tue, 12 May 2026 22:16:31 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8F=99=EA=B8=B0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/product/CompanyService.java | 57 ++++++++ .../api/service/product/ProductService.java | 57 ++++++++ .../api/service/receive/ReceiveService.java | 111 +++++++++++++++ .../com/ga/api/service/rule/RuleService.java | 131 ++++++++++++++++++ .../ga/api/service/system/RoleService.java | 86 ++++++++++++ 5 files changed, 442 insertions(+) create mode 100644 ga-api/src/main/java/com/ga/api/service/product/CompanyService.java create mode 100644 ga-api/src/main/java/com/ga/api/service/product/ProductService.java create mode 100644 ga-api/src/main/java/com/ga/api/service/receive/ReceiveService.java create mode 100644 ga-api/src/main/java/com/ga/api/service/rule/RuleService.java create mode 100644 ga-api/src/main/java/com/ga/api/service/system/RoleService.java diff --git a/ga-api/src/main/java/com/ga/api/service/product/CompanyService.java b/ga-api/src/main/java/com/ga/api/service/product/CompanyService.java new file mode 100644 index 0000000..ba75c6c --- /dev/null +++ b/ga-api/src/main/java/com/ga/api/service/product/CompanyService.java @@ -0,0 +1,57 @@ +package com.ga.api.service.product; + +import com.ga.common.exception.BizException; +import com.ga.common.exception.ErrorCode; +import com.ga.common.model.PageResponse; +import com.ga.core.mapper.product.InsuranceCompanyMapper; +import com.ga.core.mapstruct.ProductMapStruct; +import com.ga.core.vo.product.InsuranceCompanyResp; +import com.ga.core.vo.product.InsuranceCompanySaveReq; +import com.ga.core.vo.product.InsuranceCompanySearchParam; +import com.ga.core.vo.product.InsuranceCompanyVO; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class CompanyService { + + private final InsuranceCompanyMapper companyMapper; + private final ProductMapStruct mapStruct; + + public PageResponse list(InsuranceCompanySearchParam param) { + param.startPage(); + return PageResponse.of(companyMapper.selectRespList(param)); + } + + public InsuranceCompanyResp detail(Long companyId) { + InsuranceCompanyResp r = companyMapper.selectRespById(companyId); + if (r == null) throw new BizException(ErrorCode.NOT_FOUND); + return r; + } + + @Transactional + public Long create(InsuranceCompanySaveReq req) { + if (companyMapper.existsByCode(req.getCompanyCode()) > 0) { + throw new BizException(ErrorCode.DUPLICATE_DATA, "이미 등록된 보험사 코드입니다"); + } + InsuranceCompanyVO vo = mapStruct.toVO(req); + companyMapper.insert(vo); + return vo.getCompanyId(); + } + + @Transactional + public void update(Long companyId, InsuranceCompanySaveReq req) { + InsuranceCompanyVO vo = companyMapper.selectById(companyId); + if (vo == null) throw new BizException(ErrorCode.NOT_FOUND); + mapStruct.copyToVO(req, vo); + vo.setCompanyId(companyId); + companyMapper.update(vo); + } + + @Transactional + public void delete(Long companyId) { + companyMapper.deleteById(companyId); + } +} diff --git a/ga-api/src/main/java/com/ga/api/service/product/ProductService.java b/ga-api/src/main/java/com/ga/api/service/product/ProductService.java new file mode 100644 index 0000000..3e738c0 --- /dev/null +++ b/ga-api/src/main/java/com/ga/api/service/product/ProductService.java @@ -0,0 +1,57 @@ +package com.ga.api.service.product; + +import com.ga.common.exception.BizException; +import com.ga.common.exception.ErrorCode; +import com.ga.common.model.PageResponse; +import com.ga.core.mapper.product.ProductMapper; +import com.ga.core.mapstruct.ProductMapStruct; +import com.ga.core.vo.product.ProductResp; +import com.ga.core.vo.product.ProductSaveReq; +import com.ga.core.vo.product.ProductSearchParam; +import com.ga.core.vo.product.ProductVO; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class ProductService { + + private final ProductMapper productMapper; + private final ProductMapStruct mapStruct; + + public PageResponse list(ProductSearchParam param) { + param.startPage(); + return PageResponse.of(productMapper.selectByParam(param)); + } + + public ProductResp detail(Long productId) { + ProductResp r = productMapper.selectDetailById(productId); + if (r == null) throw new BizException(ErrorCode.NOT_FOUND); + return r; + } + + @Transactional + public Long create(ProductSaveReq req) { + if (productMapper.existsByCode(req.getCompanyId(), req.getProductCode()) > 0) { + throw new BizException(ErrorCode.DUPLICATE_DATA, "이미 등록된 상품 코드입니다"); + } + ProductVO vo = mapStruct.toVO(req); + productMapper.insert(vo); + return vo.getProductId(); + } + + @Transactional + public void update(Long productId, ProductSaveReq req) { + ProductVO vo = productMapper.selectById(productId); + if (vo == null) throw new BizException(ErrorCode.NOT_FOUND); + mapStruct.copyToVO(req, vo); + vo.setProductId(productId); + productMapper.update(vo); + } + + @Transactional + public void delete(Long productId) { + productMapper.deleteById(productId); + } +} diff --git a/ga-api/src/main/java/com/ga/api/service/receive/ReceiveService.java b/ga-api/src/main/java/com/ga/api/service/receive/ReceiveService.java new file mode 100644 index 0000000..658f0c6 --- /dev/null +++ b/ga-api/src/main/java/com/ga/api/service/receive/ReceiveService.java @@ -0,0 +1,111 @@ +package com.ga.api.service.receive; + +import com.ga.common.exception.BizException; +import com.ga.common.exception.ErrorCode; +import com.ga.common.model.PageResponse; +import com.ga.common.util.SecurityUtil; +import com.ga.core.mapper.receive.ReceiveMapper; +import com.ga.core.vo.receive.*; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class ReceiveService { + + private final ReceiveMapper receiveMapper; + + /* ========== company_profile ========== */ + public PageResponse listProfiles(CompanyProfileSearchParam p) { + p.startPage(); + return PageResponse.of(receiveMapper.selectProfileResp(p)); + } + + public CompanyProfileResp profileDetail(String companyCode) { + CompanyProfileResp r = receiveMapper.selectProfileRespByCode(companyCode); + if (r == null) throw new BizException(ErrorCode.NOT_FOUND); + return r; + } + + @Transactional + public void saveProfile(CompanyProfileSaveReq req) { + CompanyProfileVO existing = receiveMapper.selectProfile(req.getCompanyCode()); + CompanyProfileVO vo = new CompanyProfileVO(); + org.springframework.beans.BeanUtils.copyProperties(req, vo); + if (existing == null) receiveMapper.insertProfile(vo); + else receiveMapper.updateProfile(vo); + } + + /* ========== company_field_mapping ========== */ + public List listFieldMappings(String companyCode, String targetTable) { + return receiveMapper.selectFieldMappingResp(companyCode, targetTable); + } + + @Transactional + public Long createFieldMapping(CompanyFieldMappingSaveReq req) { + CompanyFieldMappingVO vo = new CompanyFieldMappingVO(); + org.springframework.beans.BeanUtils.copyProperties(req, vo); + receiveMapper.insertFieldMapping(vo); + return vo.getMappingId(); + } + + @Transactional + public void updateFieldMapping(Long mappingId, CompanyFieldMappingSaveReq req) { + CompanyFieldMappingVO vo = new CompanyFieldMappingVO(); + org.springframework.beans.BeanUtils.copyProperties(req, vo); + vo.setMappingId(mappingId); + receiveMapper.updateFieldMapping(vo); + } + + @Transactional + public void deleteFieldMapping(Long mappingId) { + receiveMapper.deleteFieldMapping(mappingId); + } + + /* ========== code_mapping ========== */ + public PageResponse listCodeMappings(CodeMappingSearchParam p) { + p.startPage(); + return PageResponse.of(receiveMapper.selectCodeMappingResp(p)); + } + + @Transactional + public Long createCodeMapping(CodeMappingSaveReq req) { + CodeMappingVO vo = new CodeMappingVO(); + org.springframework.beans.BeanUtils.copyProperties(req, vo); + receiveMapper.insertCodeMapping(vo); + return vo.getCodeId(); + } + + @Transactional + public void updateCodeMapping(Long codeId, CodeMappingSaveReq req) { + CodeMappingVO vo = new CodeMappingVO(); + org.springframework.beans.BeanUtils.copyProperties(req, vo); + vo.setCodeId(codeId); + receiveMapper.updateCodeMapping(vo); + } + + @Transactional + public void deleteCodeMapping(Long codeId) { + receiveMapper.deleteCodeMapping(codeId); + } + + /* ========== raw_commission_data ========== */ + public PageResponse listRaw(RawCommissionDataSearchParam p) { + p.startPage(); + return PageResponse.of(receiveMapper.selectRawResp(p)); + } + + /* ========== parse_error_log ========== */ + public PageResponse listErrors(ParseErrorLogSearchParam p) { + p.startPage(); + return PageResponse.of(receiveMapper.selectErrorResp(p)); + } + + @Transactional + public void resolveError(Long errorId, String status, String note) { + receiveMapper.resolveError(errorId, status, note, SecurityUtil.getCurrentUserId()); + } +} diff --git a/ga-api/src/main/java/com/ga/api/service/rule/RuleService.java b/ga-api/src/main/java/com/ga/api/service/rule/RuleService.java new file mode 100644 index 0000000..6270a73 --- /dev/null +++ b/ga-api/src/main/java/com/ga/api/service/rule/RuleService.java @@ -0,0 +1,131 @@ +package com.ga.api.service.rule; + +import com.ga.common.exception.BizException; +import com.ga.common.exception.ErrorCode; +import com.ga.common.model.PageResponse; +import com.ga.common.util.SecurityUtil; +import com.ga.core.mapper.rule.RuleMapper; +import com.ga.core.mapstruct.RuleMapStruct; +import com.ga.core.vo.rule.*; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class RuleService { + + private final RuleMapper ruleMapper; + private final RuleMapStruct mapStruct; + + /* ========== commission_rate ========== */ + public PageResponse listCommission(CommissionRateSearchParam p) { + p.startPage(); + return PageResponse.of(ruleMapper.selectCommissionRateResp(p)); + } + + @Transactional + public Long createCommission(CommissionRateSaveReq req) { + CommissionRateVO vo = mapStruct.toVO(req); + vo.setCreatedBy(SecurityUtil.getCurrentUserId()); + if (vo.getVersion() == null) vo.setVersion(1); + ruleMapper.insertCommissionRate(vo); + return vo.getRateId(); + } + + @Transactional + public void updateCommission(Long rateId, CommissionRateSaveReq req) { + CommissionRateVO vo = new CommissionRateVO(); + mapStruct.copyToVO(req, vo); + vo.setRateId(rateId); + ruleMapper.updateCommissionRate(vo); + } + + /* ========== payout_rule ========== */ + public PageResponse listPayout(PayoutRuleSearchParam p) { + p.startPage(); + return PageResponse.of(ruleMapper.selectPayoutRuleResp(p)); + } + + @Transactional + public Long createPayout(PayoutRuleSaveReq req) { + PayoutRuleVO vo = mapStruct.toVO(req); + vo.setCreatedBy(SecurityUtil.getCurrentUserId()); + if (vo.getVersion() == null) vo.setVersion(1); + ruleMapper.insertPayoutRule(vo); + return vo.getRuleId(); + } + + @Transactional + public void updatePayout(Long ruleId, PayoutRuleSaveReq req) { + PayoutRuleVO vo = new PayoutRuleVO(); + mapStruct.copyToVO(req, vo); + vo.setRuleId(ruleId); + ruleMapper.updatePayoutRule(vo); + } + + /* ========== override_rule ========== */ + public PageResponse listOverride(OverrideRuleSearchParam p) { + p.startPage(); + return PageResponse.of(ruleMapper.selectOverrideRuleResp(p)); + } + + @Transactional + public Long createOverride(OverrideRuleSaveReq req) { + OverrideRuleVO vo = mapStruct.toVO(req); + ruleMapper.insertOverrideRule(vo); + return vo.getOverrideId(); + } + + @Transactional + public void updateOverride(Long overrideId, OverrideRuleSaveReq req) { + OverrideRuleVO vo = new OverrideRuleVO(); + mapStruct.copyToVO(req, vo); + vo.setOverrideId(overrideId); + ruleMapper.updateOverrideRule(vo); + } + + /* ========== chargeback_rule ========== */ + public PageResponse listChargeback(ChargebackRuleSearchParam p) { + p.startPage(); + return PageResponse.of(ruleMapper.selectChargebackRuleResp(p)); + } + + @Transactional + public Long createChargeback(ChargebackRuleSaveReq req) { + ChargebackRuleVO vo = mapStruct.toVO(req); + ruleMapper.insertChargebackRule(vo); + return vo.getCbRuleId(); + } + + @Transactional + public void updateChargeback(Long cbRuleId, ChargebackRuleSaveReq req) { + ChargebackRuleVO vo = new ChargebackRuleVO(); + mapStruct.copyToVO(req, vo); + vo.setCbRuleId(cbRuleId); + ruleMapper.updateChargebackRule(vo); + } + + /* ========== exception_type_code ========== */ + public PageResponse listExceptionCodes(ExceptionTypeCodeSearchParam p) { + p.startPage(); + return PageResponse.of(ruleMapper.selectExceptionTypeCodeResp(p)); + } + + @Transactional + public void createExceptionCode(ExceptionTypeCodeSaveReq req) { + if (ruleMapper.selectExceptionCode(req.getExceptionCode()) != null) { + throw new BizException(ErrorCode.DUPLICATE_DATA); + } + ExceptionTypeCodeVO vo = mapStruct.toVO(req); + ruleMapper.insertExceptionCode(vo); + } + + @Transactional + public void updateExceptionCode(String exceptionCode, ExceptionTypeCodeSaveReq req) { + ExceptionTypeCodeVO vo = new ExceptionTypeCodeVO(); + mapStruct.copyToVO(req, vo); + vo.setExceptionCode(exceptionCode); + ruleMapper.updateExceptionCode(vo); + } +} diff --git a/ga-api/src/main/java/com/ga/api/service/system/RoleService.java b/ga-api/src/main/java/com/ga/api/service/system/RoleService.java new file mode 100644 index 0000000..1aaabb3 --- /dev/null +++ b/ga-api/src/main/java/com/ga/api/service/system/RoleService.java @@ -0,0 +1,86 @@ +package com.ga.api.service.system; + +import com.ga.common.exception.BizException; +import com.ga.common.exception.ErrorCode; +import com.ga.common.model.PageResponse; +import com.ga.core.mapper.user.RoleMapper; +import com.ga.core.mapstruct.UserMapStruct; +import com.ga.core.vo.user.RoleResp; +import com.ga.core.vo.user.RoleSaveReq; +import com.ga.core.vo.user.RoleSearchParam; +import com.ga.core.vo.user.RoleVO; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +@Service +@RequiredArgsConstructor +public class RoleService { + + private final RoleMapper roleMapper; + private final UserMapStruct mapStruct; + + public PageResponse list(RoleSearchParam p) { + p.startPage(); + return PageResponse.of(roleMapper.selectRespList(p)); + } + + public RoleResp detail(Long roleId) { + RoleResp r = roleMapper.selectRespById(roleId); + if (r == null) throw new BizException(ErrorCode.NOT_FOUND); + return r; + } + + @Transactional + public Long create(RoleSaveReq req) { + if (roleMapper.existsByCode(req.getRoleCode()) > 0) { + throw new BizException(ErrorCode.DUPLICATE_DATA, "이미 등록된 역할 코드입니다"); + } + RoleVO vo = mapStruct.toVO(req); + roleMapper.insert(vo); + return vo.getRoleId(); + } + + @Transactional + public void update(Long roleId, RoleSaveReq req) { + RoleVO vo = roleMapper.selectById(roleId); + if (vo == null) throw new BizException(ErrorCode.NOT_FOUND); + if ("Y".equals(vo.getIsSystem())) { + throw new BizException(ErrorCode.NOT_PERMITTED, "시스템 역할은 수정할 수 없습니다"); + } + mapStruct.copyToVO(req, vo); + vo.setRoleId(roleId); + roleMapper.update(vo); + } + + @Transactional + public void delete(Long roleId) { + roleMapper.deleteById(roleId); + } + + /* ========== 권한 ========== */ + public List> permissions(Long roleId) { + return roleMapper.selectRolePermissions(roleId); + } + + @Transactional + public void replacePermissions(Long roleId, List entries) { + roleMapper.deleteRolePermissions(roleId); + if (entries == null) return; + for (PermissionEntry e : entries) { + roleMapper.insertRolePermission(roleId, e.getMenuId(), e.getPermCode(), + e.getIsGranted() == null ? "Y" : e.getIsGranted()); + } + } + + @Data + public static class PermissionEntry { + private Long menuId; + private String permCode; + private String isGranted; + } +}