|
|
|
@ -2,28 +2,44 @@ package kr.xit.framework.biz.mng.auth.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import org.apache.ibatis.session.RowBounds;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import egovframework.rte.fdl.cmmn.exception.FdlException;
|
|
|
|
|
import egovframework.rte.fdl.idgnr.EgovIdGnrService;
|
|
|
|
|
import kr.xit.framework.biz.cmm.model.XitAuthorGroupInfoVO;
|
|
|
|
|
import kr.xit.framework.biz.cmm.model.XitRoleSclsrtRescueVO;
|
|
|
|
|
import kr.xit.framework.biz.cmm.model.XitUserScrtySetupVO;
|
|
|
|
|
import kr.xit.framework.biz.cmm.service.XitFrameCrudService;
|
|
|
|
|
import kr.xit.framework.biz.cmm.service.XitFrameUnitService;
|
|
|
|
|
import kr.xit.framework.biz.mng.auth.mapper.AuthAuthorMgtMapper;
|
|
|
|
|
import kr.xit.framework.biz.mng.auth.mapper.AuthGrpMgtMapper;
|
|
|
|
|
import kr.xit.framework.biz.mng.auth.model.XitAuthGrpMngSearchVO;
|
|
|
|
|
import kr.xit.framework.biz.mng.auth.model.XitAuthGrpMngVO;
|
|
|
|
|
import kr.xit.framework.biz.mng.auth.service.AuthGrpMgtService;
|
|
|
|
|
import kr.xit.framework.biz.mng.user.mapper.UserMgtMapper;
|
|
|
|
|
import kr.xit.framework.core.message.XitMessageSource;
|
|
|
|
|
import kr.xit.framework.core.utils.XitCmmnUtil;
|
|
|
|
|
import kr.xit.framework.support.exception.BizRuntimeException;
|
|
|
|
|
import kr.xit.framework.support.util.constants.MessageKey;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class AuthGrpMgtServiceImpl implements AuthGrpMgtService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private AuthGrpMgtMapper xitAuthGrpMngMapper;
|
|
|
|
|
private AuthGrpMgtMapper mapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private AuthAuthorMgtMapper authAuthorMgtMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private UserMgtMapper userMgtMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private XitFrameCrudService xitFrameCrudService;
|
|
|
|
|
@Resource
|
|
|
|
@ -33,11 +49,145 @@ public class AuthGrpMgtServiceImpl implements AuthGrpMgtService {
|
|
|
|
|
@Resource
|
|
|
|
|
private XitMessageSource xitMessageSource;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<XitAuthorGroupInfoVO> findAuthGrps(final Map<String, Object> paraMap, final RowBounds rowBounds) {
|
|
|
|
|
return mapper.selectAuthorGroupInfos(paraMap, rowBounds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public XitAuthorGroupInfoVO findAuthGrp(final String groupId) {
|
|
|
|
|
return mapper.selectAuthorGroupInfo(groupId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addAuthGrp(final XitAuthorGroupInfoVO vo) {
|
|
|
|
|
// 유효성 확인
|
|
|
|
|
boolean isChangePermission = isCheckUserForCanChange(XitCmmnUtil.getUserInfo().getUniqId(), vo.getAuthorCode());
|
|
|
|
|
if(!isChangePermission)
|
|
|
|
|
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "자신의 권한보다 상위 권한을 설정 할 수 없습니다.");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
vo.setGroupId(idgenService.getNextStringId());
|
|
|
|
|
} catch (FdlException e) {
|
|
|
|
|
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
mapper.insertAuthorGroupInfo(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void modifyAuthGrp(final XitAuthorGroupInfoVO vo) {
|
|
|
|
|
// 유효성 확인
|
|
|
|
|
boolean isChangePermission = isCheckUserForCanChange(XitCmmnUtil.getUserInfo().getUniqId(), vo.getAuthorCode());
|
|
|
|
|
if(!isChangePermission)
|
|
|
|
|
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "자신의 권한보다 상위 권한을 설정 할 수 없습니다.");
|
|
|
|
|
|
|
|
|
|
mapper.updateAuthorGroupInfo(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void removeAuthGrp(final String groupId) {
|
|
|
|
|
mapper.deleteAuthorGroupInfo(groupId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isCheckUserForCanChange(String uniqId, String trgetAuthorCode) {
|
|
|
|
|
//사용자보안설정 조회
|
|
|
|
|
XitUserScrtySetupVO userScrtySetupVO = new XitUserScrtySetupVO();
|
|
|
|
|
userScrtySetupVO.setScrtySetupTrgetId(uniqId);
|
|
|
|
|
List<XitUserScrtySetupVO> listUserScrtySetupVO = userMgtMapper.selectUserScrtySetups(userScrtySetupVO);
|
|
|
|
|
String userAuthorCode = XitCmmnUtil.isEmpty(listUserScrtySetupVO)?null:listUserScrtySetupVO.get(0).getAuthorCode();
|
|
|
|
|
|
|
|
|
|
return this.isCheckUserAuthorCodeForCanChange(userAuthorCode, trgetAuthorCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isCheckUserAuthorCodeForCanChange(String userAuthorCode, String trgetAuthorCode) {
|
|
|
|
|
//역할(권한)계층구조 데이터 목록 조회
|
|
|
|
|
List<XitRoleSclsrtRescueVO> listRoleSclsrtRescueVO = authAuthorMgtMapper.selectRoleSclsrtRescues(null);
|
|
|
|
|
//역할(권한)계층구조를 사용하지 않고 있는 경우 true 반환
|
|
|
|
|
if(XitCmmnUtil.isEmpty(listRoleSclsrtRescueVO)) {
|
|
|
|
|
log.debug("Do not use a RoleSclsrtRescue Data !!");
|
|
|
|
|
return true;
|
|
|
|
|
}else {
|
|
|
|
|
//사용자의 권한 정보가 없을 때(비정상적인 루트로 등록한 사용자 계정으로 판단)
|
|
|
|
|
if(XitCmmnUtil.isEmpty(userAuthorCode)) {
|
|
|
|
|
log.debug("This user is have not UserScrtySetup Data !!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
boolean isExists = false;
|
|
|
|
|
//사용자 권한과 매칭되는 역할(권한)계층정보 유무 확인
|
|
|
|
|
for(XitRoleSclsrtRescueVO item : listRoleSclsrtRescueVO) {
|
|
|
|
|
if(item.getParntsRole().equals(userAuthorCode)) {
|
|
|
|
|
isExists = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//사용자 권한이 최상위 권한이면 true 반환
|
|
|
|
|
if(!isExists)
|
|
|
|
|
for(XitRoleSclsrtRescueVO item : listRoleSclsrtRescueVO) {
|
|
|
|
|
if(item.getChldrnRole().equals(userAuthorCode)) {
|
|
|
|
|
log.debug("This user is Top-Level Author !!");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//사용자의 역할(권한)정보가 없으면 false 반환
|
|
|
|
|
if(!isExists) {
|
|
|
|
|
log.debug("This user is have not RoleSclsrtRescue Data !!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 상위권한 여부 확인
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
return this.isHighAuthor(listRoleSclsrtRescueVO, userAuthorCode, trgetAuthorCode)?false:true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isHighAuthor(List<XitRoleSclsrtRescueVO> list, String authorCode, String highAuthorCode) {
|
|
|
|
|
boolean result = false;
|
|
|
|
|
|
|
|
|
|
for (XitRoleSclsrtRescueVO item : list) {
|
|
|
|
|
// 상위 권한으로 확인 되었으면 stop
|
|
|
|
|
if (result)
|
|
|
|
|
break;
|
|
|
|
|
// 권한코드가 일치하지 않으면 skip
|
|
|
|
|
if (!item.getParntsRole().equals(authorCode))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (item.getChldrnRole().equals(highAuthorCode)) { // 상위 권한과 일치하면
|
|
|
|
|
result = true;
|
|
|
|
|
} else { // 상위 권한과 일치하지 않으면 재호출
|
|
|
|
|
result = this.isHighAuthor(list, item.getChldrnRole(), highAuthorCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<XitAuthGrpMngVO> findList(XitAuthGrpMngSearchVO searchVO) {
|
|
|
|
|
List<XitAuthGrpMngVO> result = null;
|
|
|
|
|
try {
|
|
|
|
|
result = xitAuthGrpMngMapper.findList(searchVO);
|
|
|
|
|
result = mapper.findList(searchVO);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new RuntimeException("사용자그룹관리 목록 조회 FAIL::", e);
|
|
|
|
|
}
|
|
|
|
@ -48,7 +198,7 @@ public class AuthGrpMgtServiceImpl implements AuthGrpMgtService {
|
|
|
|
|
public int findListTotCnt(XitAuthGrpMngSearchVO searchVO) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
try {
|
|
|
|
|
result = xitAuthGrpMngMapper.findListTotCnt(searchVO);
|
|
|
|
|
result = mapper.findListTotCnt(searchVO);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new RuntimeException("사용자그룹관리 목록 총건수 조회 FAIL::", e);
|
|
|
|
|
}
|
|
|
|
@ -59,7 +209,7 @@ public class AuthGrpMgtServiceImpl implements AuthGrpMgtService {
|
|
|
|
|
public XitAuthGrpMngVO findView(XitAuthGrpMngVO vo) {
|
|
|
|
|
XitAuthGrpMngVO result = null;
|
|
|
|
|
try {
|
|
|
|
|
result = xitAuthGrpMngMapper.findView(vo);
|
|
|
|
|
result = mapper.findView(vo);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new RuntimeException("사용자그룹관리 상세정보 조회 FAIL::", e);
|
|
|
|
|
}
|
|
|
|
@ -155,11 +305,11 @@ public class AuthGrpMgtServiceImpl implements AuthGrpMgtService {
|
|
|
|
|
*/
|
|
|
|
|
private XitAuthorGroupInfoVO convertToCrudVO(XitAuthGrpMngVO vo) {
|
|
|
|
|
XitAuthorGroupInfoVO authorGroupInfoVO = new XitAuthorGroupInfoVO();
|
|
|
|
|
authorGroupInfoVO.setGroup_id (vo.getGroupId()); //그룹 id
|
|
|
|
|
authorGroupInfoVO.setGroup_nm (vo.getGroupNm()); //그룹 명
|
|
|
|
|
authorGroupInfoVO.setGroupId(vo.getGroupId()); //그룹 id
|
|
|
|
|
authorGroupInfoVO.setGroupNm(vo.getGroupNm()); //그룹 명
|
|
|
|
|
// authorGroupInfoVO.setGroup_creat_de(); //그룹 생성 일
|
|
|
|
|
authorGroupInfoVO.setGroup_dc (vo.getGroupDc()); //그룹 설명
|
|
|
|
|
authorGroupInfoVO.setAuthor_code (vo.getAuthorCode()); //권한 코드
|
|
|
|
|
authorGroupInfoVO.setGroupDc(vo.getGroupDc()); //그룹 설명
|
|
|
|
|
authorGroupInfoVO.setAuthorCode(vo.getAuthorCode()); //권한 코드
|
|
|
|
|
|
|
|
|
|
return authorGroupInfoVO;
|
|
|
|
|
}
|
|
|
|
|