사용자 페이지 추가

수정 요청, 확인 기능 작업중.
master
강석 최 2021-12-23 18:19:31 +09:00
parent 7f1af5f14a
commit c51c1649ad
10 changed files with 231 additions and 55 deletions

View File

@ -34,6 +34,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests() // 페이지 권한 설정
.antMatchers("/board/**").hasRole(Role.USER.name()) // USER, ADMIN 접근 허용
.antMatchers("/info").hasRole(Role.USER.name()) // USER, ADMIN 접근 허용
.antMatchers("/admin/**").hasRole(Role.ADMIN.name()) // ADMIN만 접근 허용
.antMatchers("/user/login").permitAll() // 로그인 페이지는 권한 없이 접근 허용
.and() // 로그인 설정

View File

@ -1,10 +1,13 @@
package com.dbnt.kcgfilemanager;
package com.dbnt.kcgfilemanager.controller;
import com.dbnt.kcgfilemanager.model.CategoryRole;
import com.dbnt.kcgfilemanager.model.UserInfo;
import com.dbnt.kcgfilemanager.service.BoardCategoryService;
import com.dbnt.kcgfilemanager.service.CategoryRoleService;
import com.dbnt.kcgfilemanager.service.CommonCodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@ -19,6 +22,7 @@ public class BaseController {
private final CommonCodeService commonCodeService;
private final BoardCategoryService boardCategoryService;
private final CategoryRoleService categoryRoleService;
@GetMapping("/")
public ModelAndView loginCheck(Principal principal, HttpSession session) {
@ -44,4 +48,35 @@ public class BaseController {
session.setAttribute("departmentList", commonCodeService.selectCommonCodeValue("DEPARTMENT"));
session.setAttribute("categoryList", boardCategoryService.selectBoardCategoryAll(null, 1));
}
@GetMapping("/user/login")
public ModelAndView goLogin() {
ModelAndView mav = new ModelAndView("login");
return mav;
}
@GetMapping("/login-error")
public ModelAndView loginError() {
ModelAndView mav = new ModelAndView("/login");
mav.addObject("loginError", true);
return mav;
}
@GetMapping("/denied")
public ModelAndView doDenied() {
ModelAndView mav = new ModelAndView("login/denied");
return mav;
}
@GetMapping("/info")
public ModelAndView goMyInfo(@AuthenticationPrincipal UserInfo loginUser) {
ModelAndView mav = new ModelAndView("user/myInfo");
mav.addObject("loginUser", loginUser);
if(!loginUser.getUserRole().contains("ADMIN")){
CategoryRole categoryRole = new CategoryRole();
categoryRole.setUserSeq(loginUser.getUserSeq());
mav.addObject("categorySeqList", categoryRoleService.selectCategorySeqListToUser(categoryRole));
}
return mav;
}
}

View File

@ -79,10 +79,7 @@ public class BoardController {
}
@GetMapping("/contentList")
public ModelAndView contentList(
Board board,
@RequestParam(value = "tagName", required = false) List<String> tagNameList
){
public ModelAndView contentList(Board board, @RequestParam(value = "tagName", required = false) List<String> tagNameList){
ModelAndView mav = new ModelAndView("board/contentList");
mav.addObject("pageTitle", boardCategoryService.getDepth4PageTitle(board.getCategorySeq()));
board.setQueryInfo();

View File

@ -1,38 +0,0 @@
package com.dbnt.kcgfilemanager.controller;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
@RestController
@RequiredArgsConstructor
public class LoginController {
@GetMapping("/user/login")
public ModelAndView goLogin() {
ModelAndView mav = new ModelAndView("login");
return mav;
}
@GetMapping("/login-error")
public ModelAndView loginError() {
ModelAndView mav = new ModelAndView("/login");
mav.addObject("loginError", true);
return mav;
}
@GetMapping("/denied")
public ModelAndView doDenied() {
ModelAndView mav = new ModelAndView("login/denied");
return mav;
}
@GetMapping("/info")
public ModelAndView goMyInfo() {
ModelAndView mav = new ModelAndView("login/myinfo");
return mav;
}
}

View File

@ -37,6 +37,9 @@ public class BaseModel {
int contentCnt = getContentCnt();
int rowCnt = getRowCnt();
int maxNum = (int)Math.ceil(((double)contentCnt)/rowCnt);
if (maxNum==0){
maxNum = 1;
}
setMaxNum(maxNum);
int pageIndex = getPageIndex();

View File

@ -0,0 +1,37 @@
$(function (){
tableSort();
})
$(document).on('click', '#moveRightBtn', function (){
moveCategorySelectBody(1);
})
$(document).on('click', '#moveLeftBtn', function (){
moveCategorySelectBody(-1);
})
function moveCategorySelectBody(direction){
const categorySelectBody = $("#categorySelectBody");
const nowX = categorySelectBody.scrollLeft();
categorySelectBody.animate({scrollLeft:(direction*200+nowX)},200);
}
function tableSort(){
$("#categorySelectBody").find("tbody").each(function (idx, tbody){
let lastCategorySeq = 0
$(tbody).find(".depth2Td").each(function (idx, td){
lastCategorySeq = removeInnerText(td, lastCategorySeq);
})
$(tbody).find(".depth3Td").each(function (idx, td){
lastCategorySeq = removeInnerText(td, lastCategorySeq);
})
})
}
function removeInnerText(td, lastCategorySeq){
const categorySeq = Number($(td).attr("data-categoryseq"));
if(lastCategorySeq !== categorySeq){
lastCategorySeq = categorySeq;
}else{
td.innerText = ''
}
return lastCategorySeq;
}

View File

@ -8,7 +8,7 @@
<!--<span class="fs-4">해양경찰청 파일관리 시스템</span>-->
</a>
<ul class="nav nav-pills" sec:authorize="isAuthenticated()">
<li class="nav-item"><a href="#" class="nav-link">개인정보</a></li>
<li class="nav-item"><a href="/info" class="nav-link">개인정보</a></li>
<li class="nav-item"><a href="/logout" class="nav-link">로그아웃</a></li>
</ul>
</header>

View File

@ -3,13 +3,13 @@
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
<script type="text/javascript" th:src="@{/static/js/admin/userMgt.js}"></script>
<script type="text/javascript" th:src="@{/js/admin/userMgt.js}"></script>
</th:block>
<div layout:fragment="content">
<main class="pt-3">
<h4>페이지 이름</h4>
<div class="row mx-0">
<div class="col-12 card text-center">
<div class="col-12 card">
<div class="card-body">
<div class="row justify-content-start">
<div class="col-7">

View File

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<div layout:fragment="content">
<h1>This is MyInfo Page.</h1>
<hr />
</div>
</html>

View File

@ -0,0 +1,150 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
<script type="text/javascript" th:src="@{/js/user/info.js}"></script>
</th:block>
<div layout:fragment="content">
<main class="pt-3">
<div class="row justify-content-between">
<div class="col-auto"><h4>개인정보</h4></div>
<div class="col-auto">
<th:block th:if="${!#strings.contains(loginUser.userRole,'ADMIN')}">
<button class="btn btn-success"> 요청 현황</button>
<button class="btn btn-warning"> 수정 요청</button>
</th:block>
</div>
</div>
<div class="row mx-0">
<div class="col-12 card">
<div class="card-body">
<div class="row justify-content-start">
<div class="col-4">
<h5 class="ps-3">계정정보</h5>
<div class="card">
<div class="card-body">
<div class="p-3">
<div class="mb-3 row">
<label for="userId" class="col-sm-3 col-form-label">아이디</label>
<div class="col-sm-9">
<input type="text" readonly class="form-control-plaintext" id="userId" th:value="${loginUser.userId}">
</div>
</div>
<div class="mb-3 row">
<label for="name" class="col-sm-3 col-form-label">이름</label>
<div class="col-sm-9">
<input type="text" readonly class="form-control-plaintext" id="name" th:value="${loginUser.name}">
</div>
</div>
<div class="mb-3 row">
<label for="staticEmail" class="col-sm-3 col-form-label">권한</label>
<div class="col-sm-9">
<input type="text" readonly class="form-control-plaintext" id="staticEmail" th:value="${#strings.contains(loginUser.userRole, 'ADMIN')?'관리자':'사용자'}">
</div>
</div>
<div class="mb-3 row">
<label for="department" class="col-sm-3 col-form-label">부서</label>
<div class="col-sm-9">
<th:block th:each="department:${session.departmentList}">
<th:block th:if="${department.codeSq==loginUser.department}">
<input type="text" readonly class="form-control-plaintext" id="department" th:value="${department.value}">
</th:block>
</th:block>
</div>
</div>
<div class="mb-3 row">
<label for="position" class="col-sm-3 col-form-label">직책</label>
<div class="col-sm-9">
<th:block th:each="position:${session.positionList}">
<th:block th:if="${position.codeSq==loginUser.position}">
<input type="text" readonly class="form-control-plaintext" id="position" th:value="${position.value}">
</th:block>
</th:block>
</div>
</div>
<div class="mb-3 row">
<label for="createDate" class="col-sm-3 col-form-label">계정생성일</label>
<div class="col-sm-9">
<input type="text" readonly class="form-control-plaintext" id="createDate" th:value="${#temporals.format(loginUser.createDate, 'yyyy-MM-dd')}">
</div>
</div>
</div>
</div>
</div>
</div>
<th:block th:if="${!#strings.contains(loginUser.userRole,'ADMIN')}">
<div class="col-8">
<h5 class="ps-3">권한정보</h5>
<div class="card">
<div class="card-body">
<div class="p-3">
<div class="row justify-content-between">
<div class="col-auto"><button type="button" class="btn btn-warning" id="moveLeftBtn"><i class="bi bi-arrow-left"></i></button></div>
<div class="col-auto"><button type="button" class="btn btn-warning" id="moveRightBtn"><i class="bi bi-arrow-right"></i></button></div>
</div>
<div class="row overflow-auto flex-nowrap" id="categorySelectBody">
<th:block th:each="depth1:${session.categoryList}">
<div class="col-auto">
<table class="table table-striped">
<thead>
<tr>
<th colspan="3" class="text-center" th:text="${depth1.categoryName}"></th>
</tr>
<tr>
<th>연도</th>
<th>중분류</th>
<th>소분류</th>
</tr>
</thead>
<tbody>
<th:block th:each="depth2:${depth1.childCategoryList}">
<th:block th:each="depth3:${depth2.childCategoryList}">
<th:block th:each="depth4:${depth3.childCategoryList}">
<tr th:class="${#lists.contains(categorySeqList, depth4.categorySeq)}?'bg-success bg-opacity-25':''">
<td class="depth2Td" th:data-categoryseq="${depth2.categorySeq}" th:text="${depth2.categoryName}"></td>
<td class="depth3Td" th:data-categoryseq="${depth3.categorySeq}" th:text="${depth3.categoryName}"></td>
<td class="depth4Td" th:data-categoryseq="${depth4.categorySeq}" th:text="${depth4.categoryName}"></td>
</tr>
</th:block>
</th:block>
</th:block>
<!--<th:block th:each="depth2:${depth1.childCategoryList}">
<tr th:classappend="${#lists.contains(categorySeqList, depth2.categorySeq)}?'bg-success bg-opacity-25':''">
<td th:text="${depth2.categoryName}"></td>
<td></td>
<td></td>
</tr>
<th:block th:each="depth3:${depth2.childCategoryList}">
<tr th:classappend="${#lists.contains(categorySeqList, depth3.categorySeq)}?'bg-success bg-opacity-25':''">
<td></td>
<td th:text="${depth3.categoryName}"></td>
<td></td>
</tr>
<th:block th:each="depth4:${depth3.childCategoryList}">
<tr th:classappend="${#lists.contains(categorySeqList, depth4.categorySeq)}?'bg-success bg-opacity-25':''">
<td></td>
<td></td>
<td th:text="${depth4.categoryName}"></td>
</tr>
</th:block>
</th:block>
</th:block>-->
</tbody>
</table>
</div>
</th:block>
</div>
</div>
</div>
</div>
</div>
</th:block>
</div>
</div>
</div>
</div>
</main>
</div>
</html>