From 14e3b8b5130d168223383894d3c89e5487ea9ba8 Mon Sep 17 00:00:00 2001 From: Suh Date: Mon, 15 Jan 2024 10:27:55 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=84=EC=A0=95=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EA=B0=9C=EC=9D=B8=20=EA=B6=8C=ED=95=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../no1/wms/account/AccountController.java | 34 +++- .../java/com/no1/wms/account/AccountDto.java | 1 - .../com/no1/wms/account/AccountMapper.java | 4 + .../com/no1/wms/account/AccountService.java | 5 + .../wms/authority/AuthorityController.java | 11 +- .../no1/wms/authority/AuthorityMapper.java | 3 + .../no1/wms/authority/AuthorityService.java | 7 + src/main/resources/mappers/AccountMapper.xml | 7 + .../resources/mappers/AuthorityMapper.xml | 10 + .../webapp/WEB-INF/views/account/create.jsp | 7 +- .../webapp/WEB-INF/views/account/read.jsp | 19 ++ .../webapp/WEB-INF/views/account/update.jsp | 83 ++++++-- .../webapp/WEB-INF/views/authority/list.jsp | 12 +- .../views/authority/update_personal.jsp | 188 ++++++++++++++++++ .../WEB-INF/views/modal/personal_auth.jsp | 100 ++++++++++ 15 files changed, 465 insertions(+), 26 deletions(-) create mode 100644 src/main/webapp/WEB-INF/views/authority/update_personal.jsp create mode 100644 src/main/webapp/WEB-INF/views/modal/personal_auth.jsp diff --git a/src/main/java/com/no1/wms/account/AccountController.java b/src/main/java/com/no1/wms/account/AccountController.java index 7c413d0..fdcf617 100644 --- a/src/main/java/com/no1/wms/account/AccountController.java +++ b/src/main/java/com/no1/wms/account/AccountController.java @@ -1,6 +1,8 @@ package com.no1.wms.account; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.stream.JsonReader; import com.no1.wms.authority.AuthorityDto; import com.no1.wms.authority.AuthorityService; import com.no1.wms.utils.ConstantValues; @@ -9,7 +11,9 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; +import java.io.StringReader; import java.util.List; +import java.util.Map; import java.util.UUID; @Controller @@ -73,9 +77,24 @@ public class AccountController { @PostMapping("/update_process") @ResponseBody - public String updateProcess(AccountDto dto, Gson gson){ + public String updateProcess(@RequestBody Map data, Gson gson){ + AuthorityDto personalAuthorityDto= gson.fromJson(data.get("personalAuthorityDto").toString(), AuthorityDto.class); - accountService.update(dto); + + AccountDto accountDto = gson.fromJson(data.get("account").toString(), AccountDto.class); + + System.out.println(accountDto); + System.out.println(personalAuthorityDto); + accountService.update(accountDto); + authorityService.update(personalAuthorityDto); + + return gson.toJson("s"); + } + + @PostMapping("/reset_password") + @ResponseBody + public String resetPassword(AccountDto dto, Gson gson){ + accountService.resetPassword(dto); return gson.toJson("s"); } @@ -98,4 +117,15 @@ public class AccountController { return mav; } + @PostMapping("/show_personal_auth_modal") + public ModelAndView showPersonalAuthModal(ModelAndView mav, AuthorityDto dto){ + //db에서 데이터 가져오는거 필요 + dto = authorityService.selectById(dto); + + // + mav.addObject("dto", dto); + mav.setViewName("personal_auth"); + return mav; + } + } diff --git a/src/main/java/com/no1/wms/account/AccountDto.java b/src/main/java/com/no1/wms/account/AccountDto.java index cfa3859..aef8444 100644 --- a/src/main/java/com/no1/wms/account/AccountDto.java +++ b/src/main/java/com/no1/wms/account/AccountDto.java @@ -40,5 +40,4 @@ public class AccountDto { @Builder.Default private Boolean activation = true; - } diff --git a/src/main/java/com/no1/wms/account/AccountMapper.java b/src/main/java/com/no1/wms/account/AccountMapper.java index 1ffaa27..04481b4 100644 --- a/src/main/java/com/no1/wms/account/AccountMapper.java +++ b/src/main/java/com/no1/wms/account/AccountMapper.java @@ -25,4 +25,8 @@ public interface AccountMapper { List selectDeptAll(Map m); List selectPosAll(Map m); + + int resetPassword(AccountDto dto); + + } diff --git a/src/main/java/com/no1/wms/account/AccountService.java b/src/main/java/com/no1/wms/account/AccountService.java index 26ebfc7..59aeaa2 100644 --- a/src/main/java/com/no1/wms/account/AccountService.java +++ b/src/main/java/com/no1/wms/account/AccountService.java @@ -57,5 +57,10 @@ public class AccountService { return mapper.selectPosAll(map); } + int resetPassword(AccountDto dto){ + return mapper.resetPassword(dto); + } + + } diff --git a/src/main/java/com/no1/wms/authority/AuthorityController.java b/src/main/java/com/no1/wms/authority/AuthorityController.java index ab32e84..103a0a6 100644 --- a/src/main/java/com/no1/wms/authority/AuthorityController.java +++ b/src/main/java/com/no1/wms/authority/AuthorityController.java @@ -30,9 +30,16 @@ public class AuthorityController { @PostMapping("/read") public ModelAndView read(ModelAndView mav, AuthorityDto dto){ - dto = authorityService.selectById(dto); + if( dto.getIsGroupAuthority() ) { + dto = authorityService.selectById(dto); + + mav.setViewName("/authority/update_group"); + }else{ + dto = authorityService.selectPersonalAuthorityById(dto); + mav.setViewName("/authority/update_personal"); + } mav.addObject("dto", dto); - mav.setViewName("/authority/update_group"); + System.out.println(dto); return mav; } diff --git a/src/main/java/com/no1/wms/authority/AuthorityMapper.java b/src/main/java/com/no1/wms/authority/AuthorityMapper.java index 0c9f364..f541d4a 100644 --- a/src/main/java/com/no1/wms/authority/AuthorityMapper.java +++ b/src/main/java/com/no1/wms/authority/AuthorityMapper.java @@ -1,5 +1,6 @@ package com.no1.wms.authority; +import com.no1.wms.account.AccountDto; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @@ -18,4 +19,6 @@ public interface AuthorityMapper { int update(AuthorityDto dto); List selectAll(Map m); + + AuthorityDto selectPersonalAuthorityById(AuthorityDto dto); } diff --git a/src/main/java/com/no1/wms/authority/AuthorityService.java b/src/main/java/com/no1/wms/authority/AuthorityService.java index 3ebb8d3..9d8d076 100644 --- a/src/main/java/com/no1/wms/authority/AuthorityService.java +++ b/src/main/java/com/no1/wms/authority/AuthorityService.java @@ -1,6 +1,7 @@ package com.no1.wms.authority; +import com.no1.wms.account.AccountDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -35,4 +36,10 @@ public class AuthorityService { } public int update(AuthorityDto dto) { return mapper.update(dto); } + + public AuthorityDto selectPersonalAuthorityById(AuthorityDto dto){ + return mapper.selectPersonalAuthorityById(dto); + } + + } diff --git a/src/main/resources/mappers/AccountMapper.xml b/src/main/resources/mappers/AccountMapper.xml index eb37bd3..31d1fe0 100644 --- a/src/main/resources/mappers/AccountMapper.xml +++ b/src/main/resources/mappers/AccountMapper.xml @@ -15,6 +15,8 @@ + + @@ -101,6 +103,11 @@ where name like concat('%',#{search},'%') order by name limit #{start}, #{perPage} + + update account SET + password = ( SELECT employee_number from account where id = #{id} ) + WHERE id = #{id} + update account SET diff --git a/src/main/resources/mappers/AuthorityMapper.xml b/src/main/resources/mappers/AuthorityMapper.xml index 436c26e..6814b99 100644 --- a/src/main/resources/mappers/AuthorityMapper.xml +++ b/src/main/resources/mappers/AuthorityMapper.xml @@ -31,6 +31,16 @@ + +
부서 명 diff --git a/src/main/webapp/WEB-INF/views/account/read.jsp b/src/main/webapp/WEB-INF/views/account/read.jsp index c21c58f..0bc3675 100644 --- a/src/main/webapp/WEB-INF/views/account/read.jsp +++ b/src/main/webapp/WEB-INF/views/account/read.jsp @@ -26,6 +26,23 @@ $(".c_body").after($form); $form.submit(); } + function resetPassword(){ + const data = {}; + data.id = tid; + + $.ajax({ + type: 'post', // 타입 (get, post, put 등등) + url: '/account/reset_password', // 요청할 서버url + dataType: 'json', // 데이터 타입 (html, xml, json, text 등등) + data: data, + success: function (result) { // 결과 성공 콜백함수 + alert("비밀번호가 사번으로 변경되었습니다"); + }, + error: function (request, status, error) { + alert(error) + } + }); + }
@@ -45,6 +62,7 @@ 사번 : ${dto.employeeNumber} +
부서 : ${dto.departmentDto.name} @@ -72,6 +90,7 @@
+
diff --git a/src/main/webapp/WEB-INF/views/account/update.jsp b/src/main/webapp/WEB-INF/views/account/update.jsp index dbc5fce..66817f8 100644 --- a/src/main/webapp/WEB-INF/views/account/update.jsp +++ b/src/main/webapp/WEB-INF/views/account/update.jsp @@ -1,5 +1,6 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -
+
@@ -104,7 +163,7 @@ 권한 - +
이메일 @@ -118,7 +177,7 @@ 생일 - +
주소 diff --git a/src/main/webapp/WEB-INF/views/authority/list.jsp b/src/main/webapp/WEB-INF/views/authority/list.jsp index 86a5154..916501b 100644 --- a/src/main/webapp/WEB-INF/views/authority/list.jsp +++ b/src/main/webapp/WEB-INF/views/authority/list.jsp @@ -24,8 +24,8 @@ } }); - $(".group_authority_tr").on("click", function(event){ - readGroupAuthority($(event.currentTarget).data("tid")); + $(".authority_tr").on("click", function(event){ + readAuthority($(event.currentTarget).data("tid"), $(event.currentTarget).data("tgroup")); }); @@ -44,8 +44,9 @@ console.log(JSON.stringify(jsonData)); } - function readGroupAuthority(id){ + function readAuthority(id, group){ $("#formInput").val(id); + $("#isGroupInput").val(group); $("#form").attr("action", "/authority/read" ); $("#form").trigger("submit"); @@ -107,7 +108,7 @@ - + ${dto.accountDto.employeeNumber} ${dto.accountDto.name} ${dto.name} @@ -131,7 +132,7 @@ - + ${status.count} ${dto.name} @@ -157,4 +158,5 @@
+
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/authority/update_personal.jsp b/src/main/webapp/WEB-INF/views/authority/update_personal.jsp new file mode 100644 index 0000000..8a449e2 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/authority/update_personal.jsp @@ -0,0 +1,188 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + +
+
+
+

개인 권한 수정

+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ 사용자 명 ${dto.accountDto.name} + 사번 ${dto.accountDto.employeeNumber} +
+ + + +
+
+
+ 활성 여부 +
+
+
+ checked> + +
+
+ checked> + +
+
+
+
+
+ + + + + +
+
+
+
+
+ + +
+
+
+
diff --git a/src/main/webapp/WEB-INF/views/modal/personal_auth.jsp b/src/main/webapp/WEB-INF/views/modal/personal_auth.jsp new file mode 100644 index 0000000..70705d6 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/modal/personal_auth.jsp @@ -0,0 +1,100 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + +
+
+
+
+ + + + + +
+
+
+
+
+ +
+
+
+