From c51c1649adb13c0dbcd6cf5fd139536a42f8a154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=84=9D=20=EC=B5=9C?= Date: Thu, 23 Dec 2021 18:19:31 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=B6=94=EA=B0=80=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD,=20=ED=99=95=EC=9D=B8=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=9E=91=EC=97=85=EC=A4=91.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kcgfilemanager/config/SecurityConfig.java | 1 + .../{ => controller}/BaseController.java | 37 ++++- .../controller/BoardController.java | 5 +- .../controller/LoginController.java | 38 ----- .../dbnt/kcgfilemanager/model/BaseModel.java | 3 + src/main/resources/static/js/user/info.js | 37 +++++ .../resources/templates/fragments/header.html | 2 +- .../layout/defaultContentLayout.html | 4 +- .../resources/templates/login/myInfo.html | 9 -- src/main/resources/templates/user/myInfo.html | 150 ++++++++++++++++++ 10 files changed, 231 insertions(+), 55 deletions(-) rename src/main/java/com/dbnt/kcgfilemanager/{ => controller}/BaseController.java (61%) delete mode 100644 src/main/java/com/dbnt/kcgfilemanager/controller/LoginController.java create mode 100644 src/main/resources/static/js/user/info.js delete mode 100644 src/main/resources/templates/login/myInfo.html create mode 100644 src/main/resources/templates/user/myInfo.html diff --git a/src/main/java/com/dbnt/kcgfilemanager/config/SecurityConfig.java b/src/main/java/com/dbnt/kcgfilemanager/config/SecurityConfig.java index 67ea1e4..5f42d2b 100644 --- a/src/main/java/com/dbnt/kcgfilemanager/config/SecurityConfig.java +++ b/src/main/java/com/dbnt/kcgfilemanager/config/SecurityConfig.java @@ -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() // 로그인 설정 diff --git a/src/main/java/com/dbnt/kcgfilemanager/BaseController.java b/src/main/java/com/dbnt/kcgfilemanager/controller/BaseController.java similarity index 61% rename from src/main/java/com/dbnt/kcgfilemanager/BaseController.java rename to src/main/java/com/dbnt/kcgfilemanager/controller/BaseController.java index 612bfe5..5a77d3d 100644 --- a/src/main/java/com/dbnt/kcgfilemanager/BaseController.java +++ b/src/main/java/com/dbnt/kcgfilemanager/controller/BaseController.java @@ -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; + } } diff --git a/src/main/java/com/dbnt/kcgfilemanager/controller/BoardController.java b/src/main/java/com/dbnt/kcgfilemanager/controller/BoardController.java index 4e5e30d..a7e42aa 100644 --- a/src/main/java/com/dbnt/kcgfilemanager/controller/BoardController.java +++ b/src/main/java/com/dbnt/kcgfilemanager/controller/BoardController.java @@ -79,10 +79,7 @@ public class BoardController { } @GetMapping("/contentList") - public ModelAndView contentList( - Board board, - @RequestParam(value = "tagName", required = false) List tagNameList - ){ + public ModelAndView contentList(Board board, @RequestParam(value = "tagName", required = false) List tagNameList){ ModelAndView mav = new ModelAndView("board/contentList"); mav.addObject("pageTitle", boardCategoryService.getDepth4PageTitle(board.getCategorySeq())); board.setQueryInfo(); diff --git a/src/main/java/com/dbnt/kcgfilemanager/controller/LoginController.java b/src/main/java/com/dbnt/kcgfilemanager/controller/LoginController.java deleted file mode 100644 index d8cbf7b..0000000 --- a/src/main/java/com/dbnt/kcgfilemanager/controller/LoginController.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/com/dbnt/kcgfilemanager/model/BaseModel.java b/src/main/java/com/dbnt/kcgfilemanager/model/BaseModel.java index 82e631a..4e15227 100644 --- a/src/main/java/com/dbnt/kcgfilemanager/model/BaseModel.java +++ b/src/main/java/com/dbnt/kcgfilemanager/model/BaseModel.java @@ -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(); diff --git a/src/main/resources/static/js/user/info.js b/src/main/resources/static/js/user/info.js new file mode 100644 index 0000000..90548e7 --- /dev/null +++ b/src/main/resources/static/js/user/info.js @@ -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; +} \ No newline at end of file diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index 3f1edfa..2fee39f 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -8,7 +8,7 @@ diff --git a/src/main/resources/templates/layout/defaultContentLayout.html b/src/main/resources/templates/layout/defaultContentLayout.html index c8eef53..d3cf07e 100644 --- a/src/main/resources/templates/layout/defaultContentLayout.html +++ b/src/main/resources/templates/layout/defaultContentLayout.html @@ -3,13 +3,13 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/layout}"> - +

페이지 이름

-
+
diff --git a/src/main/resources/templates/login/myInfo.html b/src/main/resources/templates/login/myInfo.html deleted file mode 100644 index b1d1643..0000000 --- a/src/main/resources/templates/login/myInfo.html +++ /dev/null @@ -1,9 +0,0 @@ - - -
-

This is MyInfo Page.

-
-
- \ No newline at end of file diff --git a/src/main/resources/templates/user/myInfo.html b/src/main/resources/templates/user/myInfo.html new file mode 100644 index 0000000..4013480 --- /dev/null +++ b/src/main/resources/templates/user/myInfo.html @@ -0,0 +1,150 @@ + + + + + +
+
+
+

개인정보

+
+ + + + +
+
+
+
+
+
+
+
계정정보
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + + + +
+
+
+ +
+ + + + + + +
+
+
+ +
+ +
+
+
+
+
+
+ +
+
권한정보
+
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
연도중분류소분류
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ \ No newline at end of file