|
|
|
@ -33,7 +33,7 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
|
|
|
|
|
if(XitCmmnUtil.notEmpty(voList)) {
|
|
|
|
|
for(XitAuthHierarchyMngVO vo : voList) {
|
|
|
|
|
String strAuthorRescueCode = this.getStrAuthHierarchy(vo.getAuthorCode());
|
|
|
|
|
String strAuthorRescueCode = this.getStrAuthHierarchy(vo.getAuthorId());
|
|
|
|
|
vo.setAuthorRescueCode(strAuthorRescueCode);
|
|
|
|
|
vo.setAuthorRescueCodeNm(this.convertKorNm(strAuthorRescueCode));
|
|
|
|
|
}
|
|
|
|
@ -51,9 +51,9 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String topButtonAuthorCode = this.getStrAuthHierarchy(listRoleSclsrtRescueVO.get(0).getChldrnRole());
|
|
|
|
|
topButtonAuthorCode = topButtonAuthorCode.split(">")[0].trim();
|
|
|
|
|
String strAuthorRescueCode = this.getStrAuthHierarchy(topButtonAuthorCode);
|
|
|
|
|
String topButtonAuthorId = this.getStrAuthHierarchy(listRoleSclsrtRescueVO.get(0).getChldrnRole());
|
|
|
|
|
topButtonAuthorId = topButtonAuthorId.split(">")[0].trim();
|
|
|
|
|
String strAuthorRescueCode = this.getStrAuthHierarchy(topButtonAuthorId);
|
|
|
|
|
result.setAuthorRescueCode(strAuthorRescueCode);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
@ -61,25 +61,25 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveAuthHierarchy(final XitAuthHierarchyMngVO vo) {
|
|
|
|
|
if(XitCmmnUtil.isEmpty(vo.getAuthorCode()))
|
|
|
|
|
if(XitCmmnUtil.isEmpty(vo.getAuthorId()))
|
|
|
|
|
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "권한코드는 필수조건 입니다.");
|
|
|
|
|
|
|
|
|
|
String[] arrAuthorCodeGrp = vo.getAuthorCode().split(","); //권한코드 묶음 목록
|
|
|
|
|
String[] arrAuthorIdGrp = vo.getAuthorId().split(","); //권한코드 묶음 목록
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 유효성 확인
|
|
|
|
|
* -최상위 부모는 반드시 한개 이어야 한다.
|
|
|
|
|
* -최하위 자녀(최고관리자)는 반드시 한개 이어야 한다.
|
|
|
|
|
*/
|
|
|
|
|
if(arrAuthorCodeGrp[0].split(";").length>1)
|
|
|
|
|
if(arrAuthorIdGrp[0].split(";").length>1)
|
|
|
|
|
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG,"최상위 부모는 한개만 설정 가능 합니다.");
|
|
|
|
|
// 최하위 자녀 갯수 확인
|
|
|
|
|
if(arrAuthorCodeGrp[arrAuthorCodeGrp.length-1].split(";").length>1)
|
|
|
|
|
if(arrAuthorIdGrp[arrAuthorIdGrp.length-1].split(";").length>1)
|
|
|
|
|
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG,"최하위 자녀는 한개만 설정 가능 합니다.");
|
|
|
|
|
// 다중상속 구간 갯수 확인
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
for(String authorCodeGrp : arrAuthorCodeGrp) {
|
|
|
|
|
if(authorCodeGrp.split(";").length > 1)
|
|
|
|
|
for(String authorIdGrp : arrAuthorIdGrp) {
|
|
|
|
|
if(authorIdGrp.split(";").length > 1)
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
if(cnt > 1)
|
|
|
|
@ -88,14 +88,14 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
//권한계층구조 일괄 제거
|
|
|
|
|
authAuthorMgtMapper.deleteRoleSclsrtRescue(new XitRoleSclsrtRescueVO());
|
|
|
|
|
//권한계층 데이터 등록
|
|
|
|
|
for(int i=0; i<arrAuthorCodeGrp.length; i++) {
|
|
|
|
|
for(int i=0; i<arrAuthorIdGrp.length; i++) {
|
|
|
|
|
//마지막 권한이면 stop
|
|
|
|
|
if(i==arrAuthorCodeGrp.length-1)
|
|
|
|
|
if(i==arrAuthorIdGrp.length-1)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] arrParntsRole = arrAuthorCodeGrp[i].split(";");
|
|
|
|
|
String[] arrChldrnRole = arrAuthorCodeGrp[i+1].split(";");
|
|
|
|
|
String[] arrParntsRole = arrAuthorIdGrp[i].split(";");
|
|
|
|
|
String[] arrChldrnRole = arrAuthorIdGrp[i+1].split(";");
|
|
|
|
|
for(int j=0; j<arrParntsRole.length; j++) {
|
|
|
|
|
String parntsRole = arrParntsRole[j];
|
|
|
|
|
for(int k=0; k<arrChldrnRole.length; k++) {
|
|
|
|
@ -112,26 +112,26 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>메소드 설명: 권한의 권한계층 구조를 문자열로 반환 한다.</pre>
|
|
|
|
|
* @param authorCode
|
|
|
|
|
* @param authorId
|
|
|
|
|
* @return String 요청처리 후 응답객체
|
|
|
|
|
* @author: 박민규
|
|
|
|
|
* @date: 2020. 11. 2.
|
|
|
|
|
*/
|
|
|
|
|
private String getStrAuthHierarchy(final String authorCode) {
|
|
|
|
|
private String getStrAuthHierarchy(final String authorId) {
|
|
|
|
|
LinkedHashMap<String, String> mParnts = new LinkedHashMap<String, String>();
|
|
|
|
|
LinkedHashMap<String, String> mChldrn = new LinkedHashMap<String, String>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<XitRoleSclsrtRescueVO> list = authAuthorMgtMapper.selectRoleSclsrtRescues(new XitRoleSclsrtRescueVO());
|
|
|
|
|
this.getAuthHierarchy(list, authorCode, false, mParnts);
|
|
|
|
|
this.getAuthHierarchy(list, authorCode, true, mChldrn);
|
|
|
|
|
this.getAuthHierarchy(list, authorId, false, mParnts);
|
|
|
|
|
this.getAuthHierarchy(list, authorId, true, mChldrn);
|
|
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
Iterator<String> it = mParnts.keySet().iterator();
|
|
|
|
|
while(it.hasNext()) {
|
|
|
|
|
sb.append(mParnts.get(it.next())).append(" > ");
|
|
|
|
|
}
|
|
|
|
|
sb.append(authorCode).append(" > ");
|
|
|
|
|
sb.append(authorId).append(" > ");
|
|
|
|
|
it = mChldrn.keySet().iterator();
|
|
|
|
|
while(it.hasNext()) {
|
|
|
|
|
sb.append(mChldrn.get(it.next())).append(" > ");
|
|
|
|
@ -144,29 +144,29 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
/**
|
|
|
|
|
* <pre>메소드 설명: 권한코드의 권한구조상의 상/하위 권한을 resultMap(LinkedHashMap)에 담아 반환 한다.</pre>
|
|
|
|
|
* @param list 역할계층구조 목록 데이터
|
|
|
|
|
* @param authorCode 권한코드
|
|
|
|
|
* @param authorId 권한코드
|
|
|
|
|
* @param isChldrnSearch 상위권한 탐색 여부(true: 상위권한 탐색, false: 하위권한 탐색)
|
|
|
|
|
* @param resultMap 응답객체
|
|
|
|
|
* @return void 요청처리 후 응답객체
|
|
|
|
|
* @author: 박민규
|
|
|
|
|
* @date: 2020. 11. 2.
|
|
|
|
|
*/
|
|
|
|
|
private void getAuthHierarchy(final List<XitRoleSclsrtRescueVO> list, final String authorCode, final boolean isChldrnSearch, final LinkedHashMap<String, String> resultMap) {
|
|
|
|
|
private void getAuthHierarchy(final List<XitRoleSclsrtRescueVO> list, final String authorId, final boolean isChldrnSearch, final LinkedHashMap<String, String> resultMap) {
|
|
|
|
|
|
|
|
|
|
for (XitRoleSclsrtRescueVO item : list) {
|
|
|
|
|
|
|
|
|
|
if(isChldrnSearch) {
|
|
|
|
|
// 권한코드가 일치하지 않으면 skip
|
|
|
|
|
if (!item.getParntsRole().equals(authorCode))
|
|
|
|
|
if (!item.getParntsRole().equals(authorId))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
//권한코드 Set
|
|
|
|
|
if(resultMap.containsKey(authorCode)) {
|
|
|
|
|
if(resultMap.containsKey(authorId)) {
|
|
|
|
|
//동일한 값이면 담지 않음
|
|
|
|
|
if(resultMap.get(authorCode).equals(item.getChldrnRole()))
|
|
|
|
|
if(resultMap.get(authorId).equals(item.getChldrnRole()))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
resultMap.put(authorCode, resultMap.get(authorCode)+", "+item.getChldrnRole());
|
|
|
|
|
resultMap.put(authorId, resultMap.get(authorId)+", "+item.getChldrnRole());
|
|
|
|
|
}else {
|
|
|
|
|
//동일한 값이 있으면 담지 않음
|
|
|
|
|
Iterator<String> it = resultMap.values().iterator();
|
|
|
|
@ -183,7 +183,7 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!isExists)
|
|
|
|
|
resultMap.put(authorCode, item.getChldrnRole());
|
|
|
|
|
resultMap.put(authorId, item.getChldrnRole());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -192,23 +192,23 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
// 권한코드가 일치하지 않으면 skip
|
|
|
|
|
if (!item.getChldrnRole().equals(authorCode))
|
|
|
|
|
if (!item.getChldrnRole().equals(authorId))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
//재탐색
|
|
|
|
|
this.getAuthHierarchy(list, item.getParntsRole(), isChldrnSearch, resultMap);
|
|
|
|
|
|
|
|
|
|
//권한코드 Set
|
|
|
|
|
if(resultMap.containsKey(authorCode)) {
|
|
|
|
|
if(resultMap.containsKey(authorId)) {
|
|
|
|
|
//동일한 값이면 담지 않음
|
|
|
|
|
if(resultMap.get(authorCode).equals(item.getParntsRole()))
|
|
|
|
|
if(resultMap.get(authorId).equals(item.getParntsRole()))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
resultMap.put(authorCode, resultMap.get(authorCode)+", "+item.getParntsRole());
|
|
|
|
|
resultMap.put(authorId, resultMap.get(authorId)+", "+item.getParntsRole());
|
|
|
|
|
}else {
|
|
|
|
|
//동일한 값이 있으면 담지 않음
|
|
|
|
|
if(!resultMap.containsValue(item.getParntsRole())) {
|
|
|
|
|
resultMap.put(authorCode, item.getParntsRole());
|
|
|
|
|
resultMap.put(authorId, item.getParntsRole());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -223,7 +223,7 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
List<XitAuthorInfoVO> listAuthorInfoVO = authAuthorMgtMapper.selectAuthorInfos(null);
|
|
|
|
|
Map<String, String> mAuthorInfo = new HashMap<String, String>();
|
|
|
|
|
for(XitAuthorInfoVO item : listAuthorInfoVO) {
|
|
|
|
|
mAuthorInfo.put(item.getAuthorCode(), item.getAuthorNm());
|
|
|
|
|
mAuthorInfo.put(item.getAuthorId(), item.getAuthorNm());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
@ -234,15 +234,15 @@ public class AuthHierarchyMgtServiceBean extends AbstractServiceBean implements
|
|
|
|
|
if(i>0)
|
|
|
|
|
sb.append(" > ");
|
|
|
|
|
|
|
|
|
|
String[] arrAuthorCode = item.split(",");
|
|
|
|
|
for(int j=0; j<arrAuthorCode.length; j++) {
|
|
|
|
|
String authorCode = arrAuthorCode[j].trim();
|
|
|
|
|
String[] arrAuthorId = item.split(",");
|
|
|
|
|
for(int j=0; j<arrAuthorId.length; j++) {
|
|
|
|
|
String authorId = arrAuthorId[j].trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(j==0)
|
|
|
|
|
sb.append(mAuthorInfo.get(authorCode));
|
|
|
|
|
sb.append(mAuthorInfo.get(authorId));
|
|
|
|
|
else
|
|
|
|
|
sb.append(", ").append(mAuthorInfo.get(authorCode));
|
|
|
|
|
sb.append(", ").append(mAuthorInfo.get(authorId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|