1. 로그인 후 업무권한 확인 추가

2. 사용자별 기본 업무 조회 추가
main
이범준 11 months ago
parent ca71b2f9b9
commit 70179576a8

@ -18,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.service.CodeQuery;
import cokr.xit.base.code.service.bean.CodeBean;
import cokr.xit.base.security.SecuredUserInfo;
import cokr.xit.base.user.ManagedUser;
import cokr.xit.base.user.service.UserService;
import cokr.xit.fims.cmmn.DirectoryStructureToJson;
@ -26,7 +29,6 @@ import cokr.xit.fims.cmmn.dao.FactionMapper;
import cokr.xit.fims.cmmn.service.bean.FactionBean;
import cokr.xit.fims.cmmn.service.bean.StngBean;
import cokr.xit.fims.crdn.service.bean.ImportServiceBean;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.smg.service.bean.SmgServiceBean;
@ -39,6 +41,9 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
@Resource(name="user2Bean")
private cokr.xit.fims.base.service.bean.UserBean userBean;
@Resource(name = "codeBean")
CodeBean codeBean;
@Resource(name="factionBean")
FactionBean factionBean;
@ -77,9 +82,27 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
public ModelAndView myInfo() {
ModelAndView mav = new ModelAndView("jsonView");
UserInfo userInfo = currentUser();
SecuredUserInfo userInfo = currentUser();
//시군구,기관,부서
factionBean.initUserInfo(userInfo);
//관리자여부,업무권한여부
boolean isAdmin = userInfo.hasAuthorities("ROLE_ADMIN");
CodeQuery codeQuery = new CodeQuery();
codeQuery.setGroupIDs("FIM054");
List<DataObject> taskList = codeBean.getCodeList(codeQuery);
String[] taskRoles = taskList.stream().map((item) -> { return "ROLE_"+item.string("CODE"); })
.toList().toArray(new String[taskList.size()]);
boolean hasTaskAuth = userInfo.hasAuthorities(taskRoles);
userInfo.getInfo().put("isAdmin", isAdmin);
userInfo.getInfo().put("hasTaskAuth", hasTaskAuth);
//기본업무
stngBean.initDefaultTask(userInfo);
mav.addObject("myInfo", userInfo);
return mav;

@ -10,6 +10,12 @@ import cokr.xit.foundation.data.DataObject;
@Mapper("stngMapper")
public interface StngMapper extends AbstractMapper {
/** .
* @param userId ID
* @return
*/
String selectDefaultTask(String userId);
/** .
* @param userId ID
* @return

@ -1,12 +1,18 @@
package cokr.xit.fims.cmmn.service.bean;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cokr.xit.base.code.service.CodeQuery;
import cokr.xit.base.code.service.bean.CodeBean;
import cokr.xit.base.security.Authority;
import cokr.xit.base.security.SecuredUserInfo;
import cokr.xit.fims.cmmn.dao.StngMapper;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.UserInfo;
@ -14,12 +20,14 @@ import cokr.xit.foundation.data.DataObject;
@Component("stngBean")
public class StngBean extends AbstractComponent {
@Resource(name = "codeBean")
private CodeBean codeBean;
@Resource(name = "factionBean")
FactionBean factionBean;
private FactionBean factionBean;
@Resource(name = "stngMapper")
StngMapper stngMapper;
private StngMapper stngMapper;
/** .
* @param type
@ -59,4 +67,44 @@ public class StngBean extends AbstractComponent {
return stngMapper.updateDtbnActno(params) == 1 ? true : false;
}
/** userInfo .
* @param userInfo
* @return
*/
public void initDefaultTask(SecuredUserInfo userInfo) {
List<String> hasTaskAuthList = new ArrayList<>();
CodeQuery codeQuery = new CodeQuery();
codeQuery.setGroupIDs("FIM054");
List<DataObject> taskList = codeBean.getCodeList(codeQuery);
List<Authority> authorities = userInfo.getAuthorities();
if(authorities != null && !authorities.isEmpty()) {
for(Authority authority : authorities) {
String authId = authority.getId();
for(int i=0; i<taskList.size(); i++) {
String task = taskList.get(i).string("CODE");
if(authId.equals("ROLE_"+task)) {
hasTaskAuthList.add(task);
}
}
}
}
if(hasTaskAuthList.size() == 1) {
userInfo.getInfo().put("defaultTask", hasTaskAuthList.get(0));
return;
}
String defaultTask = stngMapper.selectDefaultTask(userInfo.getId());
if(defaultTask == null) {
userInfo.getInfo().put("defaultTask", "");
} else {
userInfo.getInfo().put("defaultTask", defaultTask);
}
}
}

@ -2,6 +2,14 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cokr.xit.fims.cmmn.dao.StngMapper">
<select id="selectDefaultTask" parameterType="string" resultType="string">
/* 사용자 기본업무 조회 (stngMapper.selectDefaultTask) */
SELECT TM.TASK_SE_CD
FROM TB_TASK_MTCHG TM
WHERE TM.USER_ID = #{userId}
AND TM.USE_YN = 'Y'
</select>
<select id="selectUserStng" parameterType="string" resultType="dataobject">
/* 사용자 설정정보 조회 (stngMapper.selectUserStng) */
SELECT USER_ID

@ -146,7 +146,7 @@
<label for="taskSeCd5--top">밤샘주차</label>
</sapn>
<sapn>
<input type='radio' id='taskSeCd6--top' name='taskSeCd' value='AAA' title="미세먼지" />
<input type='radio' id='taskSeCd6--top' name='taskSeCd' value='DVS' title="미세먼지" />
<label for="taskSeCd6--top">미세먼지</label>
</sapn>
</div>

@ -33,26 +33,30 @@
</div>
</div>
</div>
<div id="selectTaskModal" class="modal fade" tabindex="-1" aria-hidden="true" style="height:auto;"
data-bs-backdrop="static" data-bs-focus="false" data-bs-keyboard="false">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-body" style="min-height:10em; min-width:30%;">
<span class="row g-3" style="display: flex;flex-direction:column">
<div style="text-align:center" class="h3 fw-bold">업무를 선택하세요.</div>
<button type="button" class="btn btn-xl btn-primary">주정차</button>
<button type="button" class="btn btn-xl btn-primary">전용차로</button>
<button type="button" class="btn btn-xl btn-primary">장애인</button>
<button type="button" class="btn btn-xl btn-primary">전기차</button>
<button type="button" class="btn btn-xl btn-primary">밤샘주차</button>
<button type="button" class="btn btn-xl btn-primary">미세먼지</button>
</span>
</div>
</div>
</div>
</div>
<jsp:include page="/WEB-INF/jsp/include/tail.jsp" />
<c:set var="onload">
if("${param.taskSeCd}" == "" || $("#layout-navbar").find("input[name='taskSeCd'][value='${param.taskSeCd}']").length == 0){
$("#layout-navbar input[name='taskSeCd'][value='DPV']").prop("checked", true);
} else {
$("#layout-navbar input[name='taskSeCd'][value='${param.taskSeCd}']").prop("checked", true);
}
var checkedId = $("#layout-navbar input[name='taskSeCd']:checked")[0].id;
var checkedText = $("label[for='"+checkedId+"']").text();
$("#home").html("과태료통합관리시스템<br/>("+checkedText+")");
$("#layout-navbar input[name='taskSeCd']").on("click", function(){
$("#userNav--top").click();
window.open(wctx.url("/")+"?taskSeCd="+this.value, "_blank", "");
return false;
});
</c:set>
<script>
@ -68,6 +72,8 @@
pageObject.childReq = [];
pageObject.parentRes = [];
var MY_INFO = {};
function getBrowserName() {
var agent = navigator.userAgent.toUpperCase();
if (agent.indexOf('TRIDENT') >= 0) {
@ -98,40 +104,79 @@
break;
}
var MY_INFO = {};
ajax.get({
url:wctx.url("/user/myInfo.do"),
data:{},
success:resp => {
MY_INFO = resp.myInfo;
if(MY_INFO.user.status == "A" || MY_INFO.user.status == "D" || MY_INFO.user.locked == "Y"){
if(MY_INFO.user.status == "A"){
alert("계정이 미승인 상태입니다.");
} else if(MY_INFO.user.status == "D"){
alert("삭제된 계정입니다.");
} else if(MY_INFO.user.locked == "Y"){
alert("잠금처리된 계정입니다.");
}
var form = $("<form action=\"/logout.do\", method=\"POST\">");
$("<input name=\"${_csrf.parameterName}\" value=\"${_csrf.token}\" type=\"hidden\">").appendTo(form);
form.appendTo("body").submit();
}
}
});
${functions}
${topScript}
${userMenus}
${dashboardScript}
$(function(){
${onload}
ajax.get({
url:wctx.url("/user/myInfo.do"),
data : {},
success : resp => {
MY_INFO = resp.myInfo;
var msg = "";
var available = true;
if(MY_INFO.user.status == "A" || MY_INFO.user.status == "D" || MY_INFO.user.locked == "Y"){
if(MY_INFO.user.status == "A"){
msg = "계정이 미승인 상태입니다.";
} else if(MY_INFO.user.status == "D"){
msg = "삭제된 계정입니다.";
} else if(MY_INFO.user.locked == "Y"){
msg = "잠금처리된 계정입니다.";
}
available = false;
}
if(!(MY_INFO.info.isAdmin) && !(MY_INFO.info.hasTaskAuth)){
msg = "계정에 부여된 업무권한이 없습니다.";
available = false;
}
if(msg != ""){
alert(msg);
}
//로그아웃
if(!available){
var form = $("<form action=\"/logout.do\", method=\"POST\">");
$("<input name=\"${_csrf.parameterName}\" value=\"${_csrf.token}\" type=\"hidden\">").appendTo(form);
form.appendTo("body").submit();
return;
}
//업무 체크
if("${param.taskSeCd}" == "" || $("#layout-navbar").find("input[name='taskSeCd'][value='${param.taskSeCd}']").length == 0){
$("#layout-navbar input[name='taskSeCd'][value='DPV']").prop("checked", true);
} else {
$("#layout-navbar input[name='taskSeCd'][value='${param.taskSeCd}']").prop("checked", true);
}
$("#layout-navbar input[name='taskSeCd']").on("click", function(){
$("#userNav--top").click();
window.open(wctx.url("/")+"?taskSeCd="+this.value, "_blank", "");
return false;
});
//좌측상단제목
var checkedId = $("#layout-navbar input[name='taskSeCd']:checked")[0].id;
var checkedText = $("label[for='"+checkedId+"']").text();
$("#home").html("과태료통합관리시스템<br/>("+checkedText+")");
//대시보드 로드
${dashboardScript}
}
});
});
</script>
</body>
</html>
Loading…
Cancel
Save