diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java index 1f6f2d9..60e06e0 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java @@ -4,7 +4,9 @@ import com.dbnt.kcscbackend.admin.boards.entity.TnBbs; import com.dbnt.kcscbackend.admin.config.entity.TcMenu; import com.dbnt.kcscbackend.admin.config.entity.TnPartnerSite; import com.dbnt.kcscbackend.admin.config.model.CreateCommitteeCodeManagementVO; +import com.dbnt.kcscbackend.admin.config.model.SetCommitteeCodeManagementVO; import com.dbnt.kcscbackend.admin.config.service.AdminCommitteeCodeManagementService; +import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO; import com.dbnt.kcscbackend.admin.standardResearch.service.AdminStandardResearchService; import com.dbnt.kcscbackend.commonCode.entity.TcCodeGrp; import com.dbnt.kcscbackend.commonCode.entity.TcCodeItem; @@ -26,6 +28,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.validation.Errors; import org.springframework.validation.FieldError; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -566,4 +569,43 @@ public class AdminConfigController extends BaseController { return resultVO; } + @Operation( + summary = "'위원회 코드 관리' 페이지에서 위원회 코드 수정하는 API", + description = "관리자 단에서 '환경설정' > '위원회코드 관리' 페이지에서 연필 모양 수정 버튼으로 항목 수정하는 API", + tags = {"AdminConfigController"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "등록 성공"), + @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"), + }) + @PutMapping(value = "/committee-code-management/{orgId}") + public ResultVO setCommitteeCodeManagement( + HttpServletRequest request, + @AuthenticationPrincipal LoginVO loginVO, + SetCommitteeCodeManagementVO setCommitteeCodeManagementVO, + @PathVariable("orgId") Long orgId + ) throws Exception { + ResultVO resultVO = new ResultVO(); + + try { + resultVO = adminCommitteeCodeManagementService.setCommitteeCodeManagement(resultVO, request, loginVO, setCommitteeCodeManagementVO, orgId); + } catch (Exception e) { + resultVO.setResultCode(ResponseCode.FAILED.getCode()); + resultVO.setResultMessage(e.getMessage()); + } + + + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " OUT:" + + "\n--------------------------------------------------------------\n" + + "resultVO.toString():" + "\n" + + resultVO.toString() + "\n" + + "\n--------------------------------------------------------------\n" + ); + + return resultVO; + + } + } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/model/SetCommitteeCodeManagementVO.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/model/SetCommitteeCodeManagementVO.java index 93c8af8..3edb0b2 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/model/SetCommitteeCodeManagementVO.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/model/SetCommitteeCodeManagementVO.java @@ -9,26 +9,17 @@ import lombok.ToString; import java.io.Serializable; -@ApiModel(value = "CreateCommitteeCodeManagementVO", description = - "관리자 단에서 '환경설정' > '위원회코드 관리' 페이지에서 +(추가) 버튼으로 항목 추가하는 API에 사용된다." + "" +@ApiModel(value = "SetCommitteeCodeManagementVO", description = + "관리자 단에서 '환경설정' > '위원회코드 관리' 페이지에서 수정 버튼으로 항목 수정하는 API에 사용된다." ) @RequiredArgsConstructor @Getter @Setter @ToString -public class CreateCommitteeCodeManagementVO implements Serializable { +public class SetCommitteeCodeManagementVO extends CreateCommitteeCodeManagementVO implements Serializable { private static final long serialVersionUID = -603047540959527181L; - @ApiModelProperty(value = "현재 등록하고 있는 항목의 level이 들어간다. '중앙건설기술심의'인 경우, LV_01이다. '총괄위원회'인 경우, LV_02이다. 이런 식으로 값이 들어간다.") - private String paramCodeLevel; - - @ApiModelProperty(value = "현재 등록하고 있는 항목의 상위 코드 값이 들어간다. '중앙건설기술심의'인 경우, 값이 00이다. 하지만 tn_cmt_org table에 cmt_seq 값이 00인 레코드는 존재하지 않는다.") - private String paramOrgId; - - @ApiModelProperty(value = "명칭") - private String paramOrgNm; - - @ApiModelProperty(value = "위원회 설명") - private String paramOrgDesc; + @ApiModelProperty(value = "cmtSeq") + private Long orgId; } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminCommitteeCodeManagementService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminCommitteeCodeManagementService.java index 4d83564..88112ac 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminCommitteeCodeManagementService.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminCommitteeCodeManagementService.java @@ -1,6 +1,7 @@ package com.dbnt.kcscbackend.admin.config.service; import com.dbnt.kcscbackend.admin.config.model.CreateCommitteeCodeManagementVO; +import com.dbnt.kcscbackend.admin.config.model.SetCommitteeCodeManagementVO; import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO; import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO; import com.dbnt.kcscbackend.auth.entity.LoginVO; @@ -15,7 +16,8 @@ import javax.servlet.http.HttpServletRequest; public interface AdminCommitteeCodeManagementService { public ResultVO createCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, CreateCommitteeCodeManagementVO createCommitteeCodeManagementVO) throws Exception; public ResultVO getCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long upCmtSeq, String cmtType) throws Exception; - public ResultVO setCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdateStandardResearchVO updateStandardResearchVO, Long popupId) throws Exception; - public ResultVO deleteCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception; + public ResultVO setCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, SetCommitteeCodeManagementVO setCommitteeCodeManagementVO, Long cmtSeq) throws Exception; + public ResultVO deleteCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long cmtSeq) throws Exception; + } \ No newline at end of file diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java index 244a8c8..24a6cbf 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java @@ -1,6 +1,7 @@ package com.dbnt.kcscbackend.admin.config.service.impl; import com.dbnt.kcscbackend.admin.config.model.CreateCommitteeCodeManagementVO; +import com.dbnt.kcscbackend.admin.config.model.SetCommitteeCodeManagementVO; import com.dbnt.kcscbackend.admin.config.service.AdminCommitteeCodeManagementService; import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO; import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO; @@ -13,6 +14,7 @@ import lombok.RequiredArgsConstructor; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo; import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -107,8 +109,48 @@ public class AdminCommitteeCodeManagementServiceImpl extends EgovAbstractService } @Override - public ResultVO setCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdateStandardResearchVO updateStandardResearchVO, Long popupId) throws Exception { - return null; + public ResultVO setCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, SetCommitteeCodeManagementVO setCommitteeCodeManagementVO, Long cmtSeq) throws Exception { + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " IN:" + + "\n--------------------------------------------------------------\n" + + "setCommitteeCodeManagementVO:" + "\n" + + setCommitteeCodeManagementVO.toString() + "\n" + + "cmtSeq:" + "\n" + + cmtSeq + "\n" + + "\n--------------------------------------------------------------\n" + ); + + // 유효성 검사 실시 + int isValid = tnCmtOrgRepository.spIsValidTnCmtOrgId(cmtSeq.intValue()); + + if( isValid == 0 ) { + throw new Exception("대상이 존재하지 않습니다."); + } + + TnCmtOrg tnCmtOrg = tnCmtOrgRepository.findByCmtSeq(cmtSeq); + + Map response = tnCmtOrgRepository.spUpdateTnCmtOrg( + cmtSeq.intValue(), + setCommitteeCodeManagementVO.getParamOrgNm(), + setCommitteeCodeManagementVO.getParamOrgDesc(), + tnCmtOrg.getCmtOrder(), + user.getId(), + null, + null, + null + ); + + + Map dto = new HashMap(); + dto.put("errorMessage", response.get("_error_message") ); + dto.put("orgId", cmtSeq); + + resultVO.setResult(dto); + resultVO.setResultCode(ResponseCode.SUCCESS.getCode()); + resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); + + return resultVO; } @Override diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java index 5783314..b174159 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java @@ -14,6 +14,7 @@ import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng; import com.dbnt.kcscbackend.commonCode.repository.TnPopupMngRepository; import com.dbnt.kcscbackend.config.common.ResponseCode; import com.dbnt.kcscbackend.config.common.ResultVO; +import com.dbnt.kcscbackend.file.service.FileService; import com.dbnt.kcscbackend.util.NetworkUtil; import lombok.RequiredArgsConstructor; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; @@ -41,8 +42,8 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU private final TnAttachFileRepository tnAttachFileRepository; - @Resource(name = "EgovFileMngUtil") - private EgovFileMngUtil fileUtil; + private final FileService fileService; + @Override public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception { @@ -113,7 +114,8 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU "\n--------------------------------------------------------------\n" ); - String fileGrpId = this.addTnAttachFile(request, user, file); + + String fileGrpId = fileService.addTnAttachFile(request, user, file, this.getMiddlePath()); Map response = tnPopupMngRepository.spAddTnPopupMng( createPopupVO.getTitle(), @@ -210,7 +212,7 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU throw new Exception("종료일시는 시작일시보다 앞 설 수 없습니다."); } - String fileGrpId = this.addTnAttachFile(request, user, file); + String fileGrpId = fileService.addTnAttachFile(request, user, file, this.getMiddlePath()); Map response = tnPopupMngRepository.spUpdateTnPopupMng( popupId.intValue(), @@ -324,6 +326,7 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU /** * 파일이 저장될 중간 경로를 생성한다. + * D:/kcscUploadFiles/XXXX/abc.jpg XXXX에 해당하는 경로다. * @return 중간 경로 */ private String getMiddlePath() { @@ -338,48 +341,7 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU } - private String addTnAttachFile(HttpServletRequest request, LoginVO user, MultipartFile file) throws Exception { - String ipAddress = NetworkUtil.getClientIpAddress(request); - String fileGrpId = null; - if( file != null && !file.isEmpty()) { - //파일이 저장될 중간 경로를 생성한다. - String middlePath = this.getMiddlePath(); - - Map filesMap = new HashMap(); - filesMap.put("file", file); - - //String fileGrpId = UUID.randomUUID().toString(); - fileGrpId = tnAttachFileRepository.makeFileGrpId(user.getId()); - - List files = fileUtil.parseFileInf(filesMap, "", 0, middlePath, null); - - - // 업로드된 file을 tnAttachFile에 insert한다. - for (Iterator iter = files.iterator(); iter.hasNext(); ) { - - FileVO item = iter.next(); - - tnAttachFileRepository.spAddTnAttachFile( - fileGrpId, - 1, - item.getOrignlFileNm(), - item.getStreFileNm() + "." + item.getFileExtsn(), - (item.getFileStreCours() + File.separator + item.getAtchFileId()).replaceAll("\\\\", "/"), - Long.parseLong(item.getFileMg()), - item.getFileExtsn(), - ipAddress, - user.getId(), - null, - null, - null - ); - - } - } - - return fileGrpId; - } } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java index a08b36d..11ced52 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java @@ -41,6 +41,26 @@ public interface TnCmtOrgRepository extends JpaRepository spUpdateTnCmtOrg( + @Param("_cmt_seq") Integer cmtSeq, + @Param("_cmt_nm") String cmtNm, + @Param("_cmt_desc") String cmtDesc, + @Param("_cmt_order") Integer cmtOrder, + @Param("_modi_id") String modiId, + @Param("_result_count") Integer resultCount, + @Param("_result_code") String resultCode, + @Param("_error_message") String errorMessage + ); @Query(value = "CALL sp_delete_tn_cmt_org (" + diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java index b96b197..3da38f8 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java @@ -1,10 +1,22 @@ package com.dbnt.kcscbackend.file.service; +import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO; +import com.dbnt.kcscbackend.auth.entity.LoginVO; import com.dbnt.kcscbackend.file.entity.TnAttachFile; import com.dbnt.kcscbackend.file.repository.TnAttachFileRepository; +import com.dbnt.kcscbackend.util.NetworkUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; @Service @RequiredArgsConstructor @@ -12,6 +24,9 @@ public class FileService { private final TnAttachFileRepository tnAttachFileRepository; + @Resource(name = "EgovFileMngUtil") + private EgovFileMngUtil fileUtil; + @Transactional public TnAttachFile selectTnAttachFile(TnAttachFile tnAttachFile) { if(tnAttachFile.getFileSeq()!=null){ @@ -24,4 +39,63 @@ public class FileService { tnAttachFileRepository.save(tnAttachFile); return tnAttachFile; } + + + + + + + /** + * TN_ATTACH_FILE table에 insert 후, 파일 그룹 ID를 return 한다. + * TN_ATTACH_FILE 참고. + * @param request + * @param user + * @param file + * @param middlePath 파일이 저장될 중간 경로다. + * D:/kcscUploadFiles/XXXX/abc.jpg XXXX에 해당하는 경로다. + * 참고로 D:/kcscUploadFiles 값은 application-xxx.properties에 있는 Globals.fileStorePath를 통해 얻는다. + * @return 파일 그룹 ID + * @throws Exception + */ + public String addTnAttachFile(HttpServletRequest request, LoginVO user, MultipartFile file, String middlePath) throws Exception { + String ipAddress = NetworkUtil.getClientIpAddress(request); + + String fileGrpId = null; + if( file != null && !file.isEmpty()) { + + Map filesMap = new HashMap(); + filesMap.put("file", file); + + //String fileGrpId = UUID.randomUUID().toString(); + fileGrpId = tnAttachFileRepository.makeFileGrpId(user.getId()); + + List files = fileUtil.parseFileInf(filesMap, "", 0, middlePath, null); + + int nCount = 1; + // 업로드된 file을 tnAttachFile에 insert한다. + for (Iterator iter = files.iterator(); iter.hasNext(); nCount++) { + + FileVO item = iter.next(); + + tnAttachFileRepository.spAddTnAttachFile( + fileGrpId, + nCount, + item.getOrignlFileNm(), + item.getStreFileNm() + "." + item.getFileExtsn(), + (item.getFileStreCours() + File.separator + item.getAtchFileId()).replaceAll("\\\\", "/"), + Long.parseLong(item.getFileMg()), + item.getFileExtsn(), + ipAddress, + user.getId(), + null, + null, + null + ); + + } + } + + return fileGrpId; + } + }