From 0e417796ae1a7dd0559e64e81c5e23e2dc09bb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=84=9D=20=EC=B5=9C?= Date: Mon, 31 Oct 2022 18:23:22 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20=EA=B0=9C=EC=9D=B8=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95,?= =?UTF-8?q?=20=EC=97=B0=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faisp/main/userInfo/MyInfoController.java | 28 ++- .../userInfo/service/UserInfoService.java | 3 + .../main/userInfo/userMgtController.java | 6 +- src/main/resources/static/js/user/info.js | 50 ++++- .../resources/static/js/userMgt/userMgt.js | 44 ++-- .../adminPage/userMgt/userEditModal.html | 4 +- .../templates/fragments/leftMenu.html | 66 +++--- src/main/resources/templates/user/myInfo.html | 193 ++++++++++++++---- 8 files changed, 296 insertions(+), 98 deletions(-) diff --git a/src/main/java/com/dbnt/faisp/main/userInfo/MyInfoController.java b/src/main/java/com/dbnt/faisp/main/userInfo/MyInfoController.java index bbe18361..2004d506 100644 --- a/src/main/java/com/dbnt/faisp/main/userInfo/MyInfoController.java +++ b/src/main/java/com/dbnt/faisp/main/userInfo/MyInfoController.java @@ -1,5 +1,7 @@ package com.dbnt.faisp.main.userInfo; +import com.dbnt.faisp.kwms.service.KwmsService; +import com.dbnt.faisp.main.codeMgt.service.CodeMgtService; import com.dbnt.faisp.main.userInfo.model.DashboardConfig; import com.dbnt.faisp.main.userInfo.model.UserInfo; import com.dbnt.faisp.main.userInfo.service.UserInfoService; @@ -16,11 +18,21 @@ import java.util.List; public class MyInfoController { private final UserInfoService userInfoService; + private final CodeMgtService codeMgtService; + private final KwmsService kwmsService; @GetMapping("/myInfoPage") public ModelAndView myInfoPage(@AuthenticationPrincipal UserInfo loginUser){ ModelAndView mav = new ModelAndView("user/myInfo"); - mav.addObject("userInfo", loginUser); + mav.addObject("userInfo", userInfoService.selectUserInfo(loginUser.getUserSeq())); + mav.addObject("ogList", codeMgtService.selectCodeMgtList("OG")); + mav.addObject("ofcList", codeMgtService.selectCodeMgtList("OFC")); + mav.addObject("titleList", codeMgtService.selectCodeMgtList("JT")); + mav.addObject("outturnList", codeMgtService.selectCodeMgtList("OTC")); + mav.addObject("seriesList", codeMgtService.selectCodeMgtList("SRC")); + mav.addObject("languageList", codeMgtService.selectCodeMgtList("LNG")); + mav.addObject("statusList", codeMgtService.selectCodeMgtList("USC")); + mav.addObject("dashboardConfigList", userInfoService.getDashboardConfigList(loginUser.getUserSeq())); return mav; } @@ -44,4 +56,18 @@ public class MyInfoController { userInfoService.saveDashboardConfigList(loginUser.getUserSeq(), configList); } + @PostMapping("/updateSelf") + public void updateSelf(@AuthenticationPrincipal UserInfo loginUser, UserInfo userInfo) { + userInfo.setUserSeq(loginUser.getUserSeq()); + userInfoService.updateUserInfo(userInfo); + } + + @PostMapping("/syncSelfToKwms") + public void syncSelfToKwms(@AuthenticationPrincipal UserInfo loginUser, UserInfo userInfo) { + UserInfo kwmsInfo = kwmsService.selectEmpInfo(userInfo.getDicCode()); + if(kwmsInfo!= null){ + kwmsInfo.setUserSeq(loginUser.getUserSeq()); + userInfoService.updateUserInfo(kwmsInfo); + } + } } diff --git a/src/main/java/com/dbnt/faisp/main/userInfo/service/UserInfoService.java b/src/main/java/com/dbnt/faisp/main/userInfo/service/UserInfoService.java index 07a8a35e..34f57e14 100644 --- a/src/main/java/com/dbnt/faisp/main/userInfo/service/UserInfoService.java +++ b/src/main/java/com/dbnt/faisp/main/userInfo/service/UserInfoService.java @@ -42,6 +42,9 @@ public class UserInfoService implements UserDetailsService { public void updateUserInfo(UserInfo userInfo){ UserInfo savedInfo = userInfoRepository.findById(userInfo.getUserSeq()).orElse(null); if(savedInfo!=null){ + if(userInfo.getDicCode()!=null){ + savedInfo.setDicCode(userInfo.getDicCode()); + } if(userInfo.getUserNm()!=null){ savedInfo.setUserNm(userInfo.getUserNm()); } diff --git a/src/main/java/com/dbnt/faisp/main/userInfo/userMgtController.java b/src/main/java/com/dbnt/faisp/main/userInfo/userMgtController.java index ed3cd5de..1a5143a7 100644 --- a/src/main/java/com/dbnt/faisp/main/userInfo/userMgtController.java +++ b/src/main/java/com/dbnt/faisp/main/userInfo/userMgtController.java @@ -84,6 +84,10 @@ public class userMgtController { userInfoService.updateUserInfo(kwmsInfo); } } - return ""; + if(infoList.size()==1){ + return infoList.get(0).getUserSeq().toString(); + }else{ + return ""; + } } } diff --git a/src/main/resources/static/js/user/info.js b/src/main/resources/static/js/user/info.js index dece88b4..23157746 100644 --- a/src/main/resources/static/js/user/info.js +++ b/src/main/resources/static/js/user/info.js @@ -1,6 +1,11 @@ let selectedList = []; $(function (){ + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); $.ajax({ type : 'GET', url : "/myInfo/getDashBoardConfig", @@ -13,7 +18,50 @@ $(function (){ } }) }) - +$(document).on('click', '#updateBtn', function (){ + if(confirm("저장하시겠습니까?")){ + contentFade("in"); + const formData = new FormData($("#userInfoUpdate")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/myInfo/updateSelf", + processData: false, + contentType: false, + success : function() { + alert("저장되었습니다."); + contentFade("out"); + location.reload(); + }, + error : function(xhr, status) { + alert("저장에 실패하였습니다."); + contentFade("out"); + } + }) + } +}) +$(document).on('click', '#syncBtn', function (){ + if(confirm("연동하시겠습니까?")){ + contentFade("in"); + $.ajax({ + type : 'POST', + url : "/myInfo/syncSelfToKwms", + data : {dicCode: $("#dicCode").val()}, + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(data) { + alert("갱신 되었습니다."); + contentFade("out"); + location.reload(); + }, + error : function(xhr, status) { + alert("갱신에 실패하였습니다"); + contentFade("out"); + } + }) + } +}) $(document).on('click', '.configTr', function (event){ const target = event.target; if(!(target.className === "moveTd" || $(target).parents(".moveTd").length>0)){ diff --git a/src/main/resources/static/js/userMgt/userMgt.js b/src/main/resources/static/js/userMgt/userMgt.js index 5d460b14..9d4cd8e9 100644 --- a/src/main/resources/static/js/userMgt/userMgt.js +++ b/src/main/resources/static/js/userMgt/userMgt.js @@ -8,24 +8,7 @@ $(document).on('click', '#stayTab', function (){ $(document).on('click', '.userInfoTr', function (event){ if(!event.target.className.includes("heckBox")){ - $.ajax({ - url: '/userMgt/userEditModal', - data: {userSeq: Number($(this).find(".userSeq").val())}, - type: 'GET', - dataType:"html", - success: function(html){ - $("#userEditModalContent").empty().append(html) - $(".dateSelector").datepicker({ - format: "yyyy-mm-dd", - language: "ko", - autoclose: true - }); - $("#userEditModal").modal('show'); - }, - error:function(){ - - } - }); + openEditModal($(this).find(".userSeq").val()) } }) @@ -56,7 +39,6 @@ $(document).on('click', '#updateBtn', function (){ $(document).on('click', '#deleteBtn', function (){ if(confirm("삭제 하시겠습니까?")){ - console.log($("#userSeq").val()); deleteUser([{userSeq: Number($("#userSeq").val())}]) } }) @@ -110,6 +92,9 @@ function syncUserInfoToKwms(userList){ xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); }, success : function(data) { + if(userList.length===1){ + openEditModal(userList[0].userSeq); + } alert("갱신 되었습니다."); }, error : function(xhr, status) { @@ -197,4 +182,23 @@ function deleteUser(userList){ }) } - \ No newline at end of file +function openEditModal(userSeq){ + $.ajax({ + url: '/userMgt/userEditModal', + data: {userSeq: Number(userSeq)}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#userEditModalContent").empty().append(html) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#userEditModal").modal('show'); + }, + error:function(){ + + } + }); +} \ No newline at end of file diff --git a/src/main/resources/templates/adminPage/userMgt/userEditModal.html b/src/main/resources/templates/adminPage/userMgt/userEditModal.html index 5536648c..5e53fb31 100644 --- a/src/main/resources/templates/adminPage/userMgt/userEditModal.html +++ b/src/main/resources/templates/adminPage/userMgt/userEditModal.html @@ -5,7 +5,7 @@