[사이트관리자 암호변경] 롬복 생성자 기반 종속성 주입

main
이백행 1 year ago
parent c4bd52ec02
commit 02fc25698d

@ -2,35 +2,39 @@ package egovframework.let.uat.esm.service.impl;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import egovframework.let.uat.esm.service.EgovSiteManagerService; import egovframework.let.uat.esm.service.EgovSiteManagerService;
import lombok.RequiredArgsConstructor;
/** /**
* *
*
* @author * @author
* @since 2023.04.15 * @since 2023.04.15
* @version 1.0 * @version 1.0
* @see * @see
* *
* <pre> * <pre>
* << (Modification Information) >> * << (Modification Information) >>
* *
* *
* ------- -------- --------------------------- * ------- -------- ---------------------------
* 2023.04.15 * 2023.04.15
* 2024.08.29
* *
* </pre> * </pre>
*/ */
@Service("siteManagerService") @Service
@RequiredArgsConstructor
public class EgovSiteManagerServiceImpl extends EgovAbstractServiceImpl implements EgovSiteManagerService { public class EgovSiteManagerServiceImpl extends EgovAbstractServiceImpl implements EgovSiteManagerService {
@Resource(name = "siteManagerDAO")
private SiteManagerDAO siteManagerDAO; private final SiteManagerDAO siteManagerDAO;
/** /**
* . * .
*
* @param map String: login_id, old_password, new_password * @param map String: login_id, old_password, new_password
* @return 1 * @return 1
* @throws Exception * @throws Exception

@ -7,26 +7,29 @@ import org.springframework.stereotype.Repository;
/** /**
* *
*
* @author * @author
* @since 2023.04.15 * @since 2023.04.15
* @version 1.0 * @version 1.0
* @see * @see
* *
* <pre> * <pre>
* << (Modification Information) >> * << (Modification Information) >>
* *
* *
* ------- -------- --------------------------- * ------- -------- ---------------------------
* 2023.04.15 * 2023.04.15
* 2024.08.29
* *
* </pre> * </pre>
*/ */
@Repository("siteManagerDAO") @Repository
public class SiteManagerDAO extends EgovAbstractMapper { public class SiteManagerDAO extends EgovAbstractMapper {
/** /**
* . * .
*
* @param map String: login_id, old_password, new_password * @param map String: login_id, old_password, new_password
* @return 1 * @return 1
* @exception Exception * @exception Exception
*/ */
public Integer updateAdminPassword(Map<?, ?> map) throws Exception { public Integer updateAdminPassword(Map<?, ?> map) throws Exception {

@ -3,7 +3,6 @@ package egovframework.let.uat.esm.web;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
@ -26,51 +25,49 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
* *
*
* @author * @author
* @since 2023.04.15 * @since 2023.04.15
* @version 1.0 * @version 1.0
* @see * @see
* *
* <pre> * <pre>
* << (Modification Information) >> * << (Modification Information) >>
* *
* *
* ------- -------- --------------------------- * ------- -------- ---------------------------
* 2023.04.15 * 2023.04.15
* 2023.04.20 * 2023.04.20
* 2024.07.17 @RequestParam @RequestBody * 2024.07.17 @RequestParam @RequestBody
* </pre> * 2024.08.29
* </pre>
*/ */
@Slf4j @Slf4j
@RestController @RestController
@Tag(name="EgovSiteManagerApiController",description = "사용자 관리") @Tag(name = "EgovSiteManagerApiController", description = "사용자 관리")
@RequiredArgsConstructor
public class EgovSiteManagerApiController { public class EgovSiteManagerApiController {
/** EgovSiteManagerService */ /** EgovSiteManagerService */
@Resource(name = "siteManagerService") private final EgovSiteManagerService siteManagerService;
private EgovSiteManagerService siteManagerService;
/** /**
* . * .
*
* @param map: String old_password, new_password * @param map: String old_password, new_password
* @param request - HttpServletRequest * @param request - HttpServletRequest
* @return result - JWT * @return result - JWT
* @exception Exception * @exception Exception
*/ */
@Operation( @Operation(summary = "토큰값 검증", description = "Headers에서 Authorization 속성값에 발급한 토큰값 검증", security = {
summary = "토큰값 검증", @SecurityRequirement(name = "Authorization") }, tags = { "EgovSiteManagerApiController" })
description = "Headers에서 Authorization 속성값에 발급한 토큰값 검증", @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"),
security = {@SecurityRequirement(name = "Authorization")}, @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님") })
tags = {"EgovSiteManagerApiController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
@PostMapping(value = "/jwtAuthAPI") @PostMapping(value = "/jwtAuthAPI")
public ResultVO jwtAuthentication(HttpServletRequest request) throws Exception { public ResultVO jwtAuthentication(HttpServletRequest request) throws Exception {
ResultVO resultVO = new ResultVO(); ResultVO resultVO = new ResultVO();
@ -79,50 +76,41 @@ public class EgovSiteManagerApiController {
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
return resultVO; return resultVO;
} }
/** /**
* . * .
*
* @param map: String old_password, new_password * @param map: String old_password, new_password
* @param request - HttpServletRequest * @param request - HttpServletRequest
* @return result - * @return result -
* @exception Exception * @exception Exception
*/ */
@Operation( @Operation(summary = "비밀번호 변경", description = "사이트관리자의 기존 비번과 비교하여 변경된 비밀번호를 저장", security = {
summary = "비밀번호 변경", @SecurityRequirement(name = "Authorization") }, tags = { "EgovSiteManagerApiController" })
description = "사이트관리자의 기존 비번과 비교하여 변경된 비밀번호를 저장", @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"),
security = {@SecurityRequirement(name = "Authorization")},
tags = {"EgovSiteManagerApiController"}
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"), @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"),
@ApiResponse(responseCode = "800", description = "저장시 내부 오류") @ApiResponse(responseCode = "800", description = "저장시 내부 오류") })
})
@PatchMapping(value = "/admin/password") @PatchMapping(value = "/admin/password")
public ResultVO updateAdminPassword( public ResultVO updateAdminPassword(
@Parameter( @Parameter(schema = @Schema(type = "object", additionalProperties = Schema.AdditionalPropertiesValue.TRUE, ref = "#/components/schemas/passwordMap"), style = ParameterStyle.FORM, explode = Explode.TRUE) @RequestBody Map<String, String> param,
schema = @Schema(type = "object", HttpServletRequest request, @Parameter(hidden = true) @AuthenticationPrincipal LoginVO user)
additionalProperties = Schema.AdditionalPropertiesValue.TRUE, throws Exception {
ref = "#/components/schemas/passwordMap"),
style = ParameterStyle.FORM,
explode = Explode.TRUE
) @RequestBody Map<String, String> param, HttpServletRequest request,
@Parameter(hidden = true) @AuthenticationPrincipal LoginVO user) throws Exception {
ResultVO resultVO = new ResultVO(); ResultVO resultVO = new ResultVO();
String old_password = param.get("old_password"); String old_password = param.get("old_password");
String new_password = param.get("new_password"); String new_password = param.get("new_password");
String login_id = user.getId(); String login_id = user.getId();
Map<String,Object> resultMap = new HashMap<String,Object>(); Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("old_password", EgovFileScrty.encryptPassword(old_password, login_id)); resultMap.put("old_password", EgovFileScrty.encryptPassword(old_password, login_id));
resultMap.put("new_password", EgovFileScrty.encryptPassword(new_password, login_id)); resultMap.put("new_password", EgovFileScrty.encryptPassword(new_password, login_id));
resultMap.put("login_id", login_id); resultMap.put("login_id", login_id);
log.debug("===>>> loginVO.getId() = "+login_id); log.debug("===>>> loginVO.getId() = " + login_id);
Integer result = siteManagerService.updateAdminPassword(resultMap); //저장성공 시 1, 실패 시 0 반환 Integer result = siteManagerService.updateAdminPassword(resultMap); // 저장성공 시 1, 실패 시 0 반환
log.debug("===>>> result = "+result); log.debug("===>>> result = " + result);
if(result > 0) { if (result > 0) {
resultVO.setResultCode(ResponseCode.SUCCESS.getCode()); resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
}else{ } else {
resultVO.setResultCode(ResponseCode.SAVE_ERROR.getCode()); resultVO.setResultCode(ResponseCode.SAVE_ERROR.getCode());
resultVO.setResultMessage(ResponseCode.SAVE_ERROR.getMessage()); resultVO.setResultMessage(ResponseCode.SAVE_ERROR.getMessage());
} }

Loading…
Cancel
Save