From 3108af40a53a5049891dfe2f4cde1a63a6329339 Mon Sep 17 00:00:00 2001 From: limju Date: Thu, 31 Aug 2023 17:30:30 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/kr/xit/biz/package-info.java | 12 -- .../xit/core/biz/web/LoggingController.java | 60 ------ .../xit/core/biz/mapper/IAuthApiMapper.java | 28 --- .../xit/core/biz/service/AuthApiService.java | 42 ---- .../xit/core/biz/service/IAuthApiService.java | 32 --- .../xit/core/biz/web/AuthApiController.java | 184 ------------------ .../xit/core/biz/web/LoggingController.java | 60 ------ .../spring/config/SpringDocsApiConfig.java | 15 +- 8 files changed, 3 insertions(+), 430 deletions(-) delete mode 100644 mens-api/src/main/java/kr/xit/biz/package-info.java delete mode 100644 mens-api/src/main/java/kr/xit/core/biz/web/LoggingController.java delete mode 100644 mens-batch/src/main/java/kr/xit/core/biz/mapper/IAuthApiMapper.java delete mode 100644 mens-batch/src/main/java/kr/xit/core/biz/service/AuthApiService.java delete mode 100644 mens-batch/src/main/java/kr/xit/core/biz/service/IAuthApiService.java delete mode 100644 mens-batch/src/main/java/kr/xit/core/biz/web/AuthApiController.java delete mode 100644 mens-batch/src/main/java/kr/xit/core/biz/web/LoggingController.java diff --git a/mens-api/src/main/java/kr/xit/biz/package-info.java b/mens-api/src/main/java/kr/xit/biz/package-info.java deleted file mode 100644 index 74eaffc..0000000 --- a/mens-api/src/main/java/kr/xit/biz/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * ENS business packages - *

- * 전자고지 : ens - * 사전알림 : pni - * sms - *

- * @since 1.0 - * @author limju - * @version 1.0 - */ -package kr.xit.biz; diff --git a/mens-api/src/main/java/kr/xit/core/biz/web/LoggingController.java b/mens-api/src/main/java/kr/xit/core/biz/web/LoggingController.java deleted file mode 100644 index e11de9d..0000000 --- a/mens-api/src/main/java/kr/xit/core/biz/web/LoggingController.java +++ /dev/null @@ -1,60 +0,0 @@ -package kr.xit.core.biz.web; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.tags.Tag; -import kr.xit.core.model.ApiResponseDTO; -import kr.xit.core.biz.model.LoggingDTO; -import kr.xit.core.biz.service.ILoggingService; -import lombok.RequiredArgsConstructor; - -/** - *
- * description : API Logging cotroller
- *
- * packageName : kr.xit.core.biz.web
- * fileName    : LoggingController
- * author      : limju
- * date        : 2023-05-11
- * ======================================================================
- * 변경일         변경자        변경 내용
- * ----------------------------------------------------------------------
- * 2023-05-11    limju       최초 생성
- *
- * 
- */ -@Tag(name = "LoggingController", description = "API logging 관리") -@RequiredArgsConstructor -@RestController -@RequestMapping(value = "/api/core/log") -public class LoggingController { - - private final ILoggingService loggingService; - - @Operation(summary = "로깅 정보 저장" , description = "로깅 정보 저장") - @io.swagger.v3.oas.annotations.parameters.RequestBody( - required = true, - content = { - @Content( - mediaType = "application/json", - examples = { - @ExampleObject( - value = "{\"requestId\":\"7f1f5978fc1941c4a6d37351a6d692e6\"}") - } - ) - } - ) - @PostMapping(value = "/save", consumes = {MediaType.APPLICATION_JSON_VALUE , MediaType.TEXT_HTML_VALUE}) - public ApiResponseDTO saveLogging(@RequestBody final LoggingDTO reqDTO){ - loggingService.saveLogging(reqDTO); - return ApiResponseDTO.empty(); - } -} diff --git a/mens-batch/src/main/java/kr/xit/core/biz/mapper/IAuthApiMapper.java b/mens-batch/src/main/java/kr/xit/core/biz/mapper/IAuthApiMapper.java deleted file mode 100644 index 125e016..0000000 --- a/mens-batch/src/main/java/kr/xit/core/biz/mapper/IAuthApiMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package kr.xit.core.biz.mapper; - -import org.egovframe.rte.psl.dataaccess.mapper.Mapper; - -import egovframework.com.cmm.LoginVO; - -/** - *
- * description :
- *
- * packageName : kr.xit.core.biz.mapper
- * fileName    : IAuthApiMapper
- * author      : limju
- * date        : 2023-05-11
- * ======================================================================
- * 변경일         변경자        변경 내용
- * ----------------------------------------------------------------------
- * 2023-05-11    limju       최초 생성
- *
- * 
- */ -@Mapper -public interface IAuthApiMapper { - LoginVO actionLogin(LoginVO vo); - // LoginVO searchId(LoginVO vo); - // LoginVO searchPassword(LoginVO vo); - // void updatePassword(LoginVO vo); -} diff --git a/mens-batch/src/main/java/kr/xit/core/biz/service/AuthApiService.java b/mens-batch/src/main/java/kr/xit/core/biz/service/AuthApiService.java deleted file mode 100644 index 5e076ef..0000000 --- a/mens-batch/src/main/java/kr/xit/core/biz/service/AuthApiService.java +++ /dev/null @@ -1,42 +0,0 @@ -package kr.xit.core.biz.service; - -import javax.annotation.Resource; - -import egovframework.com.cmm.util.EgovFileScrty; -import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; -import org.springframework.stereotype.Service; - -import egovframework.com.cmm.LoginVO; -import kr.xit.core.biz.mapper.IAuthApiMapper; - -@Service -public class AuthApiService extends EgovAbstractServiceImpl implements IAuthApiService { - - @Resource - private IAuthApiMapper mapper; - - /** - * 일반 로그인 처리 - * @param vo LoginVO - * @return LoginVO - */ - @Override - public LoginVO actionLogin(LoginVO vo) { - - // 1. 입력한 비밀번호를 암호화한다. - String enpassword = EgovFileScrty.encryptPassword(vo.getPassword(), vo.getId()); - vo.setPassword(enpassword); - - // 2. 아이디와 암호화된 비밀번호가 DB와 일치하는지 확인한다. - LoginVO loginVO = mapper.actionLogin(vo); //loginDAO.actionLogin(vo); - - // 3. 결과를 리턴한다. - if (loginVO != null && !loginVO.getId().equals("") && !loginVO.getPassword().equals("")) { - return loginVO; - } else { - loginVO = new LoginVO(); - } - - return loginVO; - } -} diff --git a/mens-batch/src/main/java/kr/xit/core/biz/service/IAuthApiService.java b/mens-batch/src/main/java/kr/xit/core/biz/service/IAuthApiService.java deleted file mode 100644 index b0b6eef..0000000 --- a/mens-batch/src/main/java/kr/xit/core/biz/service/IAuthApiService.java +++ /dev/null @@ -1,32 +0,0 @@ -package kr.xit.core.biz.service; - -import egovframework.com.cmm.LoginVO; - -/** - * 일반 로그인을 처리하는 비즈니스 구현 클래스 - * @author 공통서비스 개발팀 박지욱 - * @since 2009.03.06 - * @version 1.0 - * @see - * - *
- * << 개정이력(Modification Information) >>
- *
- *   수정일      수정자          수정내용
- *  -------    --------    ---------------------------
- *  2009.03.06  박지욱          최초 생성
- *  2011.08.31  JJY            경량환경 템플릿 커스터마이징버전 생성
- *
- *  
- */ -public interface IAuthApiService { - - /** - * 일반 로그인 처리 - * - * @param vo LoginVO - * @return LoginVO - */ - LoginVO actionLogin(LoginVO vo); - -} diff --git a/mens-batch/src/main/java/kr/xit/core/biz/web/AuthApiController.java b/mens-batch/src/main/java/kr/xit/core/biz/web/AuthApiController.java deleted file mode 100644 index a6bc1cf..0000000 --- a/mens-batch/src/main/java/kr/xit/core/biz/web/AuthApiController.java +++ /dev/null @@ -1,184 +0,0 @@ -package kr.xit.core.biz.web; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; - -import egovframework.com.cmm.EgovMessageSource; -import egovframework.com.cmm.LoginVO; -import egovframework.com.cmm.jwt.config.EgovJwtTokenUtil; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.tags.Tag; -import kr.xit.core.model.ApiResponseDTO; -import kr.xit.core.biz.service.IAuthApiService; -import kr.xit.core.consts.Constants; -import lombok.RequiredArgsConstructor; - -/** - *
- * description : 인증 로그인 처리
- *
- * packageName : kr.xit.biz.auth
- * fileName    : AuthApiController
- * author      : limju
- * date        : 2023-04-26
- * ======================================================================
- * 변경일         변경자        변경 내용
- * ----------------------------------------------------------------------
- * 2023-04-26    limju       최초 생성
- *
- * 
- * @see - */ -//FIXME::세션에서 인증 관리 할지 여부 결정 필요 -@Tag(name = "AuthApiController", description = "인증 관리") -@RequiredArgsConstructor -@RestController -@RequestMapping(value = "/batch/core/auth") -public class AuthApiController { - @Value("${app.token.saveType:header}") - private String authSaveType; - - /** EgovLoginService */ - - private final IAuthApiService loginService; - - /** EgovMessageSource */ - - private final EgovMessageSource egovMessageSource; - private final EgovJwtTokenUtil egovJwtTokenUtil; - - /** - * 일반 로그인을 처리한다 - * @param loginVO 아이디, 비밀번호가 담긴 LoginVO - * @param request 세션처리를 위한 HttpServletRequest - * @return 로그인결과(세션정보) - */ - @Operation(summary = "로그인" , description = "로그인") - @io.swagger.v3.oas.annotations.parameters.RequestBody( - required = true, - content = { - @Content( - mediaType = "application/json", - examples = { - @ExampleObject( - value = "{\"id\":\"admin\",\"password\":\"1\",\"userSe\":\"USR\"}") - } - ) - } - ) - @PostMapping(value = "/login", consumes = {MediaType.APPLICATION_JSON_VALUE , MediaType.TEXT_HTML_VALUE}) - public ApiResponseDTO login(@RequestBody final LoginVO loginVO, HttpServletRequest request) { - // 1. 일반 로그인 처리 - LoginVO loginResultVO = loginService.actionLogin(loginVO); - - if (loginResultVO != null && loginResultVO.getId() != null && !loginResultVO.getId().equals("")) { - request.getSession().setAttribute(Constants.AuthSaveSession.LOGIN_VO.getCode(), loginResultVO); - return ApiResponseDTO.success(loginResultVO); - } - return ApiResponseDTO.success(egovMessageSource.getMessage("fail.common.login")); - } - - @Operation(summary = "로그인(JWT)" , description = "로그인(JWT)") - @io.swagger.v3.oas.annotations.parameters.RequestBody( - required = true, - content = { - @Content( - mediaType = "application/json", - examples = { - @ExampleObject( - name = "admin", - description = "admin", - value = "{\"id\":\"admin\",\"password\":\"1\",\"userSe\":\"USR\"}"), - @ExampleObject( - name = "admin1", - description = "admin1", - value = "{\"id\":\"admin1\",\"password\":\"1\",\"userSe\":\"USR\"}"), - @ExampleObject( - name = "admin2", - description = "admin2", - value = "{\"id\":\"admin2\",\"password\":\"1\",\"userSe\":\"USR\"}") - } - ) - } - ) - @PostMapping(value = "/loginJwt") - public ApiResponseDTO loginJWT(@RequestBody final LoginVO loginVO, HttpServletRequest request) { - HashMap resultMap = new HashMap(); - - // 1. 일반 로그인 처리 - LoginVO loginResultVO = loginService.actionLogin(loginVO); - - if (loginResultVO != null && loginResultVO.getId() != null && !loginResultVO.getId().equals("")) { - - Map claimsMap = new HashMap<>(); - // claimsMap.put("dkkdk", "kdkkdkdkd"); - String jwtToken = egovJwtTokenUtil.generateToken(loginVO, claimsMap); - // String jwtToken = egovJwtTokenUtil.generateToken(loginVO.getId()); - - String username = egovJwtTokenUtil.getUsernameFromToken(jwtToken); - - - // System.out.println("Dec jwtToken username = "+username); - - //서버사이드 권한 체크 통과를 위해 삽입 - //EgovUserDetailsHelper.isAuthenticated() 가 그 역할 수행. DB에 정보가 없으면 403을 돌려 줌. 로그인으로 튕기는 건 프론트 쪽에서 처리 - request.getSession().setAttribute(Constants.AuthSaveSession.LOGIN_VO.getCode(), loginResultVO); - - - - - // UsernamePasswordAuthenticationToken authenticationToken = jwtTokenProvider.toAuthentication(loginVO.getId(), loginVO.getPassword()); - // Authentication authentication = authenticationManager.authenticate(authenticationToken); - // - // - // // Authentication 저장 - // if(Objects.equals(authSaveType, Constants.AuthSaveType.SECURITY.getCode())){ - // // TODO :: SessionCreationPolicy.STATELESS 인 경우 사용 불가 - // SecurityContextHolder.getContext().setAuthentication(authentication); - // - // }else if(Objects.equals(authSaveType, Constants.AuthSaveType.SESSION.getCode())){ - // session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext()); - // } - - //Map infoMap = new HashMap<>(); - //infoMap.put(Constants.JwtToken.TOKEN_USER_ID.getCode(), loginVO.getId()); - //infoMap.put(Constants.JwtToken.TOKEN_USER_MAIL.getCode(), loginVO.getEmail()); - - //String jwtToken = jwtTokenProvider.generateJwtAccessToken(authentication, infoMap); - //String jwtToken = jwtTokenProvider.generateJwtAccessToken(loginVO.getId(), "ROLE_USER"); - - resultMap.put("resultVO", loginResultVO); - resultMap.put("token", jwtToken); - return ApiResponseDTO.success(resultMap); - - } - return ApiResponseDTO.error(egovMessageSource.getMessage("fail.common.login") ); - } - - /** - * 로그아웃한다. - * @return resultVO - * @exception Exception - */ - @Operation(summary = "logout" , description = "로그아웃") - @GetMapping(value = "/logout") - public ApiResponseDTO actionLogoutJSON(HttpServletRequest request) { - - RequestContextHolder.currentRequestAttributes().removeAttribute(Constants.AuthSaveSession.LOGIN_VO.getCode(), RequestAttributes.SCOPE_SESSION); - return ApiResponseDTO.empty(); - } -} diff --git a/mens-batch/src/main/java/kr/xit/core/biz/web/LoggingController.java b/mens-batch/src/main/java/kr/xit/core/biz/web/LoggingController.java deleted file mode 100644 index 7f404a3..0000000 --- a/mens-batch/src/main/java/kr/xit/core/biz/web/LoggingController.java +++ /dev/null @@ -1,60 +0,0 @@ -package kr.xit.core.biz.web; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.tags.Tag; -import kr.xit.core.model.ApiResponseDTO; -import kr.xit.core.biz.model.LoggingDTO; -import kr.xit.core.biz.service.ILoggingService; -import lombok.RequiredArgsConstructor; - -/** - *
- * description : API Logging cotroller
- *
- * packageName : kr.xit.core.biz.web
- * fileName    : LoggingController
- * author      : limju
- * date        : 2023-05-11
- * ======================================================================
- * 변경일         변경자        변경 내용
- * ----------------------------------------------------------------------
- * 2023-05-11    limju       최초 생성
- *
- * 
- */ -@Tag(name = "LoggingController", description = "API logging 관리") -@RequiredArgsConstructor -@RestController -@RequestMapping(value = "/batch/core/log") -public class LoggingController { - - private final ILoggingService loggingService; - - @Operation(summary = "로깅 정보 저장" , description = "로깅 정보 저장") - @io.swagger.v3.oas.annotations.parameters.RequestBody( - required = true, - content = { - @Content( - mediaType = "application/json", - examples = { - @ExampleObject( - value = "{\"requestId\":\"7f1f5978fc1941c4a6d37351a6d692e6\"}") - } - ) - } - ) - @PostMapping(value = "/save", consumes = {MediaType.APPLICATION_JSON_VALUE , MediaType.TEXT_HTML_VALUE}) - public ApiResponseDTO saveLogging(@RequestBody final LoggingDTO reqDTO){ - loggingService.saveLogging(reqDTO); - return ApiResponseDTO.empty(); - } -} diff --git a/mens-batch/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java b/mens-batch/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java index 93ff0f0..e4cffaf 100644 --- a/mens-batch/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java +++ b/mens-batch/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java @@ -23,20 +23,11 @@ import org.springframework.context.annotation.Configuration; @ConditionalOnProperty(value = "springdoc.swagger-ui.enabled", havingValue = "true", matchIfMissing = false) @Configuration public class SpringDocsApiConfig { - @Bean - public GroupedOpenApi authentification() { - return GroupedOpenApi.builder() - .group("1. Core API") - .pathsToMatch( - "/batch/core/**" - ) - .build(); - } @Bean public GroupedOpenApi kakaopayEltrcDocBatch() { return GroupedOpenApi.builder() - .group("2. 전자고지 통합발송 연계 Batch WEB") + .group("1. 전자고지 통합발송 연계 Batch WEB") .pathsToMatch( "/batch/v1/**" ) @@ -46,7 +37,7 @@ public class SpringDocsApiConfig { @Bean public GroupedOpenApi bizDoc() { return GroupedOpenApi.builder() - .group("3. 전자고지 통합발송 연계 API") + .group("2. 전자고지 발송 연계 Batch API") .pathsToMatch( "/batch/ens/**" ) @@ -56,7 +47,7 @@ public class SpringDocsApiConfig { @Bean public GroupedOpenApi pniDoc() { return GroupedOpenApi.builder() - .group("6. 사전고지 API") + .group("3. 사전고지 Batch API") .pathsToMatch( "/batch/pni/v1/**" )