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

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

@ -2,35 +2,39 @@ package egovframework.let.uat.esm.service.impl;
import java.util.Map;
import javax.annotation.Resource;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
import egovframework.let.uat.esm.service.EgovSiteManagerService;
import lombok.RequiredArgsConstructor;
/**
*
*
* @author
* @since 2023.04.15
* @version 1.0
* @see
*
* <pre>
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2023.04.15
* 2023.04.15
* 2024.08.29
*
* </pre>
* </pre>
*/
@Service("siteManagerService")
@Service
@RequiredArgsConstructor
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
* @return 1
* @throws Exception

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

Loading…
Cancel
Save