feat: mpower 적용 - 자료관리
parent
8371c2dd4d
commit
484d62b4e1
@ -0,0 +1,120 @@
|
||||
package com.xit.biz.ctgy.v2.controller;
|
||||
|
||||
import com.xit.biz.cmm.dto.CmmCodeDto;
|
||||
import com.xit.biz.cmm.dto.ComboCodeDto;
|
||||
import com.xit.biz.cmm.entity.CmmCodeGrp;
|
||||
import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
|
||||
import com.xit.biz.ctgy.v2.service.ICmmCodeService;
|
||||
import com.xit.core.api.IRestResponse;
|
||||
import com.xit.core.api.RestResponse;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "CmmCodeMgtController", description = "코드 관리")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/v2/biz/cmm")
|
||||
public class CmmCodeMgtController {
|
||||
private final ICmmCodeService cmmCodeService;
|
||||
|
||||
@Operation(summary = "콤보코드조회" , description = "콤보코드를 조회")
|
||||
@GetMapping(value="/combo", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<? extends IRestResponse> findComboCodes(@Nonnull final CmmCodeSIds searchKeyDto) {
|
||||
Assert.notNull(searchKeyDto, "조회할 콤보코드 대상이 없습니다.");
|
||||
Assert.notNull(searchKeyDto.getCodeGrpId(), "조회할 대분류 코드를 선택해 주세요.");
|
||||
List<ComboCodeDto> list = cmmCodeService.findComboCodes(searchKeyDto);
|
||||
return RestResponse.of(list);
|
||||
//return RestResponse.of(cmmCodeService.findComboCodes(searchKeyDto));
|
||||
}
|
||||
|
||||
@Operation(summary = "코드그룹 목록 조회")
|
||||
@Parameters({
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeGrpId", description = "코드그룹ID", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeNm", description = "코드그룹명", required = false, example = " "),
|
||||
@Parameter(name = "codeCd", hidden = true),
|
||||
@Parameter(name = "codeMeta1", hidden = true),
|
||||
@Parameter(name = "codeMeta2", hidden = true),
|
||||
@Parameter(name = "codeMeta3", hidden = true),
|
||||
@Parameter(name = "codeMeta4", hidden = true),
|
||||
@Parameter(name = "codeMeta5", hidden = true),
|
||||
@Parameter(name = "createdBy", hidden = true),
|
||||
@Parameter(name = "modifiedBy", hidden = true),
|
||||
@Parameter(name = "createdDate", hidden = true),
|
||||
@Parameter(name = "modifiedDate", hidden = true),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10")
|
||||
//@Parameter(in = ParameterIn.QUERY, name = "sort", description = "정렬", required = true, example = "codeOrdr"),
|
||||
})
|
||||
@GetMapping(value="/grp", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<? extends IRestResponse> findCmmCodeGrps(
|
||||
@Parameter(hidden = true)
|
||||
final CmmCodeDto codeDto,
|
||||
@Parameter(hidden = true)
|
||||
@Nonnull final Pageable pageable) {
|
||||
return RestResponse.of(cmmCodeService.findCmmCodeGrps(codeDto, pageable));
|
||||
}
|
||||
|
||||
@Operation(summary = "코드 목록 조회")
|
||||
@Parameters({
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeGrpId", description = "코드그룹ID", required = true, example = "TRAFFIC"),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeLcd", description = "대분류코드", required = false, example = "GANGNAM_SIMSA"),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeMcd", description = "중분류코드", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeCd", description = "코드", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeNm", description = "코드명", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeMeta1", description = "코드메타1", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeMeta2", description = "코드메타2", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeMeta3", description = "코드메타3", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeMeta4", description = "코드메타4", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "codeMeta5", description = "코드메타5", required = false, example = " "),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "createdBy", hidden = true),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "modifiedBy", hidden = true),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "createdDate", hidden = true),
|
||||
@Parameter(in = ParameterIn.QUERY, name = "modifiedDate", hidden = true)
|
||||
})
|
||||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<? extends IRestResponse> findCmmCodes(@Parameter(hidden = true) @Nonnull final CmmCodeDto codeDto) {
|
||||
return RestResponse.of(cmmCodeService.findCmmCodes(codeDto));
|
||||
}
|
||||
|
||||
@Operation(summary = "코드그룹저장" , description = "코드그룹저장")
|
||||
@PostMapping(value="/grp", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<? extends IRestResponse> saveCmmCodeGrp(@RequestBody @Nonnull CmmCodeGrp cmmCodeGrp) {
|
||||
return RestResponse.of(cmmCodeService.saveCmmCodeGrp(cmmCodeGrp));
|
||||
}
|
||||
|
||||
// @Operation(summary = "대분류코드저장" , description = "대분류코드저장")
|
||||
// @PostMapping("/lcode")
|
||||
// public ResponseEntity<? extends RestResponse> saveCmmCodeL(@RequestBody @Nonnull CmmCodeL cmmCodeL) {
|
||||
// return RestResult.of(cmmCodeService.saveCmmCodeL(cmmCodeL));
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "중분류코드저장" , description = "중분류코드저장")
|
||||
// @PostMapping("/mcode")
|
||||
// public ResponseEntity<? extends RestResponse> saveCmmCodeM(@RequestBody @Nonnull CmmCodeM cmmCodeM) {
|
||||
// return RestResult.of(cmmCodeService.saveCmmCodeM(cmmCodeM));
|
||||
// }
|
||||
//
|
||||
// @Operation(summary = "소분류코드저장" , description = "소분류코드저장")
|
||||
// @PostMapping("/scode")
|
||||
// public ResponseEntity<? extends RestResponse> saveCmmCodeS(@RequestBody @Nonnull CmmCodeS cmmCodeS) {
|
||||
// return RestResult.of(cmmCodeService.saveCmmCodeS(cmmCodeS));
|
||||
// }
|
||||
|
||||
@Operation(summary = "코드 저장")
|
||||
@PostMapping
|
||||
public ResponseEntity<? extends IRestResponse> saveCmmCode(@RequestBody @Nonnull CmmCodeDto cmmCodeDto) {
|
||||
return RestResponse.of(cmmCodeService.saveCmmCode(cmmCodeDto));
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package com.xit.biz.ctgy.v2.controller;
|
||||
|
||||
import com.xit.biz.ctgy.CtgyConstants;
|
||||
import com.xit.biz.ctgy.dto.GnRecallScDto;
|
||||
import com.xit.biz.ctgy.dto.MinInfoBoard680Dto;
|
||||
import com.xit.biz.ctgy.v2.service.ICtgyFileService;
|
||||
import com.xit.biz.ctgy.v2.service.IResidentAndDisabledService;
|
||||
import com.xit.core.constant.ErrorCode;
|
||||
import com.xit.core.exception.CustomBaseException;
|
||||
import com.xit.core.util.Checks;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Tag(name = "CmmFileController", description = "파일 관리")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/v2/ctgy/cmm")
|
||||
public class CmmFileController {
|
||||
|
||||
private final Environment env;
|
||||
|
||||
@Value("${file.cmm.upload.root:c:/data/file/upload}")
|
||||
private String rootPath;
|
||||
|
||||
@Value("${file.cmm.upload.path:/kangnamSIM/simUpFile/}")
|
||||
private String uploadPath;
|
||||
|
||||
@Value("${file.cmm.upload.simsaPath:[simUpFile_sc1]}")
|
||||
private String[] judgeUploadPath;
|
||||
|
||||
@Value("${file.cmm.upload.url}")
|
||||
private String serviceUrl;
|
||||
|
||||
private final ICtgyFileService ctgyFileService;
|
||||
private final IResidentAndDisabledService judgeService;
|
||||
|
||||
@Operation(summary = "공지사항 파일 다운로드" , description = "공지사항 파일 다운로드")
|
||||
@GetMapping("/download/{inCode}")
|
||||
public void download(@PathVariable Long inCode, HttpServletResponse response) {
|
||||
|
||||
MinInfoBoard680Dto dto = ctgyFileService.findFiles(inCode);
|
||||
|
||||
String absFile = "";
|
||||
|
||||
if (Arrays.asList(env.getActiveProfiles()).contains("prod"))
|
||||
absFile = dto.getInFileurl() + File.separator + dto.getInFilename();
|
||||
else
|
||||
absFile = rootPath + dto.getInFileurl().split(serviceUrl)[1] + File.separator + dto.getInFilename();
|
||||
|
||||
download(absFile, dto.getInFilename(), response);
|
||||
}
|
||||
|
||||
@Operation(summary = "거주자/장애인 심사자료 파일 다운로드" , description = "거주자/장애인 심사자료 파일 다운로드")
|
||||
@GetMapping("/download/judge")
|
||||
public void download(@Nonnull final String scDatagb, @Nonnull final Long scCode, @Nonnull String methodName, HttpServletResponse response) {
|
||||
|
||||
GnRecallScDto savedDto = judgeService.findJudgeData(scCode);
|
||||
String fileName = "";
|
||||
try {
|
||||
Method method = GnRecallScDto.class.getMethod(methodName);
|
||||
fileName = String.valueOf(method.invoke(savedDto));
|
||||
if(Checks.isEmpty(fileName)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String absFile = "";
|
||||
|
||||
// TODO : 운영환경에 맞게 적용 필요
|
||||
if (Arrays.asList(env.getActiveProfiles()).contains("prod"))
|
||||
absFile = String.format("%s%s%s", "entity.getInFileurl()", File.separator, fileName);
|
||||
else
|
||||
absFile = String.format(
|
||||
"%s%s%s%s",
|
||||
rootPath,
|
||||
(CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(scDatagb)? judgeUploadPath[0] : judgeUploadPath[1]),
|
||||
File.separator, fileName);
|
||||
|
||||
download(absFile, fileName, response);
|
||||
}
|
||||
|
||||
private void download(String absFile, String fileName, HttpServletResponse response) {
|
||||
|
||||
Path path = Paths.get(absFile);
|
||||
String contentType = null;
|
||||
long fileSize = 0L;
|
||||
try {
|
||||
contentType = Files.probeContentType(path);
|
||||
fileSize = Files.size(path);
|
||||
} catch (IOException e) {
|
||||
//throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND);
|
||||
contentType = "application/octet-stream";
|
||||
//fileName = "FileNotFound";
|
||||
}
|
||||
|
||||
File file = new File(absFile);
|
||||
byte[] fileByte = new byte[0];
|
||||
try {
|
||||
fileByte = FileUtils.readFileToByteArray(file);
|
||||
} catch (IOException e) {
|
||||
fileByte = new byte[0];
|
||||
//throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
response.setContentType(contentType);
|
||||
response.setHeader(HttpHeaders.CONTENT_TYPE, contentType);
|
||||
response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(fileName, StandardCharsets.UTF_8) + "\";");
|
||||
//response.setHeader(HttpHeaders.CONTENT_ENCODING, "binary");
|
||||
response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileSize));
|
||||
try {
|
||||
response.getOutputStream().write(fileByte);
|
||||
response.getOutputStream().flush();
|
||||
response.getOutputStream().close();
|
||||
} catch (IOException e) {
|
||||
throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.xit.biz.ctgy.v2.repository;
|
||||
|
||||
import com.xit.biz.cmm.dto.ComboCodeDto;
|
||||
import com.xit.biz.ctgy.dto.MinUserinfoDto;
|
||||
import com.xit.core.config.database.BaseMpowerDaoSupport;
|
||||
import com.xit.core.support.sql.parser.QueryGenerator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@Slf4j
|
||||
public class CmmCodeDao extends BaseMpowerDaoSupport {
|
||||
private static final String NAME_SPACE = "cmmCode";
|
||||
|
||||
public List<ComboCodeDto> queryComboCodeClass(@NotNull final String codeGrpId, @NotNull final String codeLcd, @NotNull final String codeMcd) {
|
||||
final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "selectComboCodes")
|
||||
.setParameter("codeGrpId", codeGrpId)
|
||||
.setParameter("codeLcd", codeLcd)
|
||||
.setParameter("codeMcd", codeMcd)
|
||||
.getQueryString();
|
||||
|
||||
return selectList(ComboCodeDto.class, sql, "code, value");
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.xit.biz.ctgy.v2.service;
|
||||
|
||||
import com.xit.biz.cmm.dto.CmmCodeDto;
|
||||
import com.xit.biz.cmm.dto.ComboCodeDto;
|
||||
import com.xit.biz.cmm.entity.CmmCodeGrp;
|
||||
import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lim, Jong Uk (minuk926)
|
||||
* @since 2021-08-02
|
||||
*/
|
||||
public interface ICmmCodeService {
|
||||
List<ComboCodeDto> findComboCodes(CmmCodeSIds searchKeyDto);
|
||||
|
||||
CmmCodeGrp saveCmmCodeGrp(CmmCodeGrp cmmCodeGrp);
|
||||
// CmmCodeL saveCmmCodeL(CmmCodeL cmmCodeL);
|
||||
// CmmCodeM saveCmmCodeM(CmmCodeM cmmCodeM);
|
||||
// CmmCodeS saveCmmCodeS(CmmCodeS cmmCodeS);
|
||||
|
||||
Page<CmmCodeGrp> findCmmCodeGrps(CmmCodeDto cmmCodeDto, Pageable pageable);
|
||||
|
||||
List<?> findCmmCodes(CmmCodeDto cmmCodeDto);
|
||||
|
||||
Object saveCmmCode(CmmCodeDto cmmCodeDto);
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.xit.biz.ctgy.v2.service.impl;
|
||||
|
||||
import com.xit.biz.cmm.dto.CmmCodeDto;
|
||||
import com.xit.biz.cmm.dto.ComboCodeDto;
|
||||
import com.xit.biz.cmm.dto.struct.CmmCodeGrpMapstruct;
|
||||
import com.xit.biz.cmm.dto.struct.CmmCodeLMapstruct;
|
||||
import com.xit.biz.cmm.dto.struct.CmmCodeMMapstruct;
|
||||
import com.xit.biz.cmm.dto.struct.CmmCodeSMapstruct;
|
||||
import com.xit.biz.cmm.entity.CmmCodeGrp;
|
||||
import com.xit.biz.cmm.entity.CmmCodeL;
|
||||
import com.xit.biz.cmm.entity.CmmCodeM;
|
||||
import com.xit.biz.cmm.entity.CmmCodeS;
|
||||
import com.xit.biz.cmm.entity.ids.CmmCodeSIds;
|
||||
import com.xit.biz.cmm.repository.*;
|
||||
import com.xit.biz.ctgy.v2.repository.CmmCodeDao;
|
||||
import com.xit.biz.ctgy.v2.service.ICmmCodeService;
|
||||
import com.xit.core.util.AssertUtils;
|
||||
import com.xit.core.util.Checks;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.springframework.data.domain.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CmmCodeService implements ICmmCodeService {
|
||||
|
||||
private final ICmmCodeGrpRepository cmmCodeGrpRepository;
|
||||
private final ICmmCodeLRepostory cmmCodeLRepository;
|
||||
private final ICmmCodeMRepository cmmCodeMRepository;
|
||||
private final ICmmCodeSRepository cmmCodeSRepository;
|
||||
private final CmmCodeDao cmmCodeDao;
|
||||
|
||||
private CmmCodeGrpMapstruct codeGrpstruct = Mappers.getMapper(CmmCodeGrpMapstruct.class);
|
||||
private CmmCodeLMapstruct codeLstruct = Mappers.getMapper(CmmCodeLMapstruct.class);
|
||||
private CmmCodeMMapstruct codeMstruct = Mappers.getMapper(CmmCodeMMapstruct.class);
|
||||
private CmmCodeSMapstruct codeSstruct = Mappers.getMapper(CmmCodeSMapstruct.class);
|
||||
|
||||
@Override
|
||||
public List<ComboCodeDto> findComboCodes(CmmCodeSIds searchKeyDto) {
|
||||
AssertUtils.isTrue(!Checks.isEmpty(searchKeyDto.getCodeGrpId()), "조회할 코드그룹을 선택해 주세요.");
|
||||
|
||||
// 소분류 코드 조회
|
||||
if(StringUtils.hasText(searchKeyDto.getCodeMcd())){
|
||||
AssertUtils.isTrue(!Checks.isEmpty(searchKeyDto.getCodeLcd()), "대분류 코드가 선택되지 않았습니다.");
|
||||
List<ComboCodeDto> list = cmmCodeDao.queryComboCodeClass(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd(), searchKeyDto.getCodeMcd());
|
||||
//List<IComboCodeDto> list = cmmComboCodeRepository.queryComboCode(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd(), searchKeyDto.getCodeMcd());
|
||||
return list;
|
||||
//return cmmCodeSRepository.queryComboCode(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd(), searchKeyDto.getCodeMcd());
|
||||
}
|
||||
|
||||
// 중분류 코드 조회
|
||||
if(StringUtils.hasText(searchKeyDto.getCodeLcd())){
|
||||
return cmmCodeMRepository.queryComboCode(searchKeyDto.getCodeGrpId(), searchKeyDto.getCodeLcd());
|
||||
}
|
||||
|
||||
// 대분류 코드 조회
|
||||
return cmmCodeLRepository.queryComboCode(searchKeyDto.getCodeGrpId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CmmCodeGrp> findCmmCodeGrps(CmmCodeDto cmmCodeDto, Pageable pageable) {
|
||||
Sort sort = Sort.by(Sort.Direction.ASC, "codeOrdr");
|
||||
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
|
||||
Example<CmmCodeGrp> example = Example.of(codeGrpstruct.toEntity(cmmCodeDto), ExampleMatcher.matchingAny());
|
||||
return cmmCodeGrpRepository.findAll(example, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> findCmmCodes(CmmCodeDto cmmCodeDto) {
|
||||
Sort sort = Sort.by(Sort.Direction.ASC, "codeOrdr");
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeDto.getCodeGrpId()), "조회할 코드그룹을 선택해 주세요.");
|
||||
|
||||
// 소분류 코드 조회
|
||||
if(StringUtils.hasText(cmmCodeDto.getCodeMcd())){
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeDto.getCodeLcd()), "대분류 코드가 선택되지 않았습니다.");
|
||||
Example<CmmCodeS> example = Example.of(codeSstruct.toEntity(cmmCodeDto), ExampleMatcher.matchingAny());
|
||||
return cmmCodeSRepository.findAll(example, sort);
|
||||
}
|
||||
|
||||
// 중분류 코드 조회
|
||||
if(StringUtils.hasText(cmmCodeDto.getCodeLcd())){
|
||||
Example<CmmCodeM> example = Example.of(codeMstruct.toEntity(cmmCodeDto), ExampleMatcher.matchingAny());
|
||||
return cmmCodeMRepository.findAll(example, sort);
|
||||
}
|
||||
|
||||
// 대분류 코드 조회
|
||||
Example<CmmCodeL> example = Example.of(codeLstruct.toEntity(cmmCodeDto), ExampleMatcher.matchingAny());
|
||||
return cmmCodeLRepository.findAll(example, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CmmCodeGrp saveCmmCodeGrp(CmmCodeGrp cmmCodeGrp) {
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeGrp.getCodeGrpId()), "코드 그룹을 입력해 주세요.");
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeGrp.getCodeNm()), "코드 그룹명 입력해 주세요.");
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeGrp.getCodeOrdr()), "정렬 순서를 입력해 주세요.");
|
||||
return cmmCodeGrpRepository.save(cmmCodeGrp);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public CmmCodeL saveCmmCodeL(CmmCodeL cmmCodeL) {
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeL.getCodeGrpId()), "코드 그룹을 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeL.getCodeCd()), "대분류 코드를 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeL.getCodeNm()), "대분류 코드명 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeL.getCodeOrdr()), "정렬 순서를 입력해 주세요.");
|
||||
// return cmmCodeLRepository.save(cmmCodeL);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public CmmCodeM saveCmmCodeM(CmmCodeM cmmCodeM) {
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeM.getCodeGrpId()), "코드 그룹을 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeM.getCodeLcd()), "대분류 코드를 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeM.getCodeCd()), "중분류 코드를 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeM.getCodeNm()), "중분류 코드명 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeM.getCodeOrdr()), "정렬 순서를 입력해 주세요.");
|
||||
// return cmmCodeMRepository.save(cmmCodeM);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public CmmCodeS saveCmmCodeS(CmmCodeS cmmCodeS) {
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeGrpId()), "코드그룹을 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeLcd()), "대분류 코드를 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeMcd()), "중분류 코드를 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeCd()), "소분류 코드를 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeNm()), "소분류 코드명 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeOrdr()), "정렬 순서를 입력해 주세요.");
|
||||
// return cmmCodeSRepository.save(cmmCodeS);
|
||||
// }
|
||||
|
||||
// private void validate(Class<?> clz){
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeGrpId()), "코드그룹을 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeCd()), "대분류코드를 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeNm()), "대분류코드명 입력해 주세요.");
|
||||
// AssertUtils.state(!Checks.isEmpty(cmmCodeS.getCodeOrdr()), "정렬순서를 입력해 주세요.");
|
||||
// }
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Object saveCmmCode(CmmCodeDto cmmCodeDto) {
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeDto.getCodeGrpId()), "코드그룹을 입력해 주세요.");
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeDto.getCodeCd()), "코드를 입력해 주세요.");
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeDto.getCodeNm()), "코드명을 입력해 주세요.");
|
||||
|
||||
// 소분류 코드
|
||||
if(StringUtils.hasText(cmmCodeDto.getCodeMcd())){
|
||||
AssertUtils.isTrue(!Checks.isEmpty(cmmCodeDto.getCodeLcd()), "대분류 코드를 입력해 주세요.");
|
||||
return cmmCodeSRepository.save(codeSstruct.toEntity(cmmCodeDto));
|
||||
}
|
||||
|
||||
// 중분류 코드
|
||||
if(StringUtils.hasText(cmmCodeDto.getCodeLcd())){
|
||||
return cmmCodeMRepository.save(codeMstruct.toEntity(cmmCodeDto));
|
||||
}
|
||||
|
||||
// 대분류 코드
|
||||
return cmmCodeLRepository.save(codeLstruct.toEntity(cmmCodeDto));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<entity-mappings namespace="cmmCode">
|
||||
|
||||
<native-query id="selectComboCodes">
|
||||
/* refreshToken-mapper|selectComboCodes|julim */
|
||||
SELECT code_cd as code,
|
||||
, code_nm as value
|
||||
FROM tb_cmm_code_s
|
||||
WHERE code_grp_id = #{codeGrpId}
|
||||
AND code_lcd = #{codeLcd}
|
||||
AND code_mcd = #{codeMcd}
|
||||
AND use_yn = 'Y'
|
||||
ORDER BY code_ordr
|
||||
</native-query>
|
||||
|
||||
</entity-mappings>
|
Loading…
Reference in New Issue