Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ad0e5a090 |
@@ -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<InsuranceCompanyResp> 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);
|
||||
}
|
||||
}
|
||||
@@ -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<ProductResp> 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);
|
||||
}
|
||||
}
|
||||
@@ -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<CompanyProfileResp> 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<CompanyFieldMappingResp> 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<CodeMappingResp> 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<RawCommissionDataResp> listRaw(RawCommissionDataSearchParam p) {
|
||||
p.startPage();
|
||||
return PageResponse.of(receiveMapper.selectRawResp(p));
|
||||
}
|
||||
|
||||
/* ========== parse_error_log ========== */
|
||||
public PageResponse<ParseErrorLogResp> 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());
|
||||
}
|
||||
}
|
||||
@@ -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<CommissionRateResp> 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<PayoutRuleResp> 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<OverrideRuleResp> 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<ChargebackRuleResp> 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<ExceptionTypeCodeResp> 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);
|
||||
}
|
||||
}
|
||||
@@ -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<RoleResp> 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<Map<String, Object>> permissions(Long roleId) {
|
||||
return roleMapper.selectRolePermissions(roleId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void replacePermissions(Long roleId, List<PermissionEntry> 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user