Merge branch 'master' of http://118.219.150.34:50501/DBNT/FAISP
commit
466a000633
|
|
@ -60,5 +60,16 @@ public class userMgtController {
|
|||
int result = userInfoService.updateUserCompanion(userInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/updateUserInfo")
|
||||
public void updateUserInfo(UserInfo userInfo) {
|
||||
userInfoService.updateUser(userInfo);
|
||||
}
|
||||
|
||||
@PostMapping("/userDelete")
|
||||
@ResponseBody
|
||||
public void userDelete(@RequestBody List<UserInfo> userInfo) {
|
||||
userInfoService.userDelete(userInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,15 +78,15 @@ public class UserInfoService implements UserDetailsService {
|
|||
UserInfo dbUserInfo = userInfoRepository.findById(user.getUserSeq()).orElse(null);
|
||||
if(dbUserInfo != null) {
|
||||
dbUserInfo.setUserStatus(user.getUserStatus());
|
||||
userInfoRepository.save(dbUserInfo);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int updateUserCompanion(List<UserInfo> userInfo) {
|
||||
int cnt = 0;
|
||||
System.out.println("!!"+userInfo);
|
||||
for(UserInfo user: userInfo) {
|
||||
UserInfo dbUserInfo = userInfoRepository.findById(user.getUserSeq()).orElse(null);
|
||||
if(dbUserInfo != null) {
|
||||
|
|
@ -97,4 +97,14 @@ public class UserInfoService implements UserDetailsService {
|
|||
}
|
||||
return cnt;
|
||||
}
|
||||
@Transactional
|
||||
public void updateUser(UserInfo userInfo) {
|
||||
UserInfo dbUserInfo = userInfoRepository.findById(userInfo.getUserSeq()).orElse(null);
|
||||
dbUserInfo.setUserRole(userInfo.getUserRole());
|
||||
userInfoRepository.save(dbUserInfo);
|
||||
|
||||
}
|
||||
public void userDelete(List<UserInfo> userInfo) {
|
||||
userInfoRepository.deleteAll(userInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
user_id,
|
||||
user_nm,
|
||||
address,
|
||||
user_role,
|
||||
detail_addr,
|
||||
email,
|
||||
og_cd,
|
||||
|
|
@ -43,7 +44,15 @@
|
|||
<select id="selectUserInfoListCnt" resultType="int" parameterType="UserInfo">
|
||||
select count(*)
|
||||
from user_info
|
||||
where user_status != 'D'
|
||||
where
|
||||
<choose>
|
||||
<when test="userStatus != null and userStatus != ''">
|
||||
user_status = #{userStatus}
|
||||
</when>
|
||||
<otherwise>
|
||||
user_status != 'D'
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="userId != null and userId != ''">
|
||||
and user_id like '%'||#{userId}||'%'
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -95,4 +95,52 @@ function userCompanion(checkArr){
|
|||
})
|
||||
}
|
||||
|
||||
$(document).on('click', '#updateBtn', function (){
|
||||
if(confirm("저장하시겠습니까?")){
|
||||
contentFade("in");
|
||||
const formData = new FormData($("#userInfoUpdate")[0]);
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
data : formData,
|
||||
url : "/userMgt/updateUserInfo",
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success : function() {
|
||||
alert("저장되었습니다.");
|
||||
contentFade("out");
|
||||
},
|
||||
error : function(xhr, status) {
|
||||
alert("저장에 실패하였습니다.");
|
||||
contentFade("out");
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
$(document).on('click', '#deleteBtn', function (){
|
||||
if(confirm("삭제 하시겠습니까?")){
|
||||
console.log($("#userSeq").val());
|
||||
deleteUser([{userSeq: Number($("#userSeq").val())}])
|
||||
}
|
||||
})
|
||||
|
||||
function deleteUser(userList){
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : "/userMgt/userDelete",
|
||||
data : JSON.stringify(userList),
|
||||
contentType: 'application/json',
|
||||
beforeSend: function (xhr){
|
||||
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
||||
},
|
||||
success : function() {
|
||||
alert("삭제 처리되었습니다.");
|
||||
location.reload();
|
||||
},
|
||||
error : function(xhr, status) {
|
||||
alert("삭제 처리에 실패하였습니다");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,12 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
|
||||
<div class="tab-pane fade show active" id="accessTabPanel" role="tabpanel" aria-labelledby="accessTab" tabindex="0">
|
||||
<form id="userInfoInsert" action="#" th:action="@{/admin/insertUserInfo}" method="post">
|
||||
<form id="userInfoUpdate" action="#" th:action="@{/admin/insertUserInfo}" method="post">
|
||||
<label style="font-size: 12px">
|
||||
<input type="radio" name="userRole" value="ROLE_ADMIN,ROLE_USER" th:checked="${userInfo.userRole eq 'ROLE_ADMIN,ROLE_USER'}">
|
||||
관리자</label>
|
||||
<label style="font-size: 12px">
|
||||
<input type="radio" name="userRole" value="ROLE_USER" th:checked="${userInfo.userRole eq 'ROLE_USER'}">
|
||||
일반사용자</label>
|
||||
<div class="mb-3 row">
|
||||
<input type="hidden" name="userSeq" id="userSeq" class="userSeq" th:value="${userInfo.userSeq}">
|
||||
<div class="mb-3 mt-3 row">
|
||||
<label for="userId" class="col-sm-2 col-form-label text-center ">아이디</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="userId" name="userId" th:value="${userInfo.userId}" autocomplete="off">
|
||||
<input type="text" class="form-control" id="userId" name="userId" th:value="${userInfo.userId}" autocomplete="off" readonly>
|
||||
<label for="userId" style="font-size: 12px">6~20자 사이의 알파벳, 숫자를 입력하세요</label>
|
||||
</div>
|
||||
<label for="userNm" class="col-sm-2 col-form-label text-center">이름</label>
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr class="userInfoTr" th:each="userInfo:${userInfoList}">
|
||||
<input type="hidden" class="userSeq" th:value="${userInfo.userSeq}">
|
||||
<input type="hidden" name="userSeq" class="userSeq" th:value="${userInfo.userSeq}">
|
||||
<td>
|
||||
<input type="checkbox" id="userChk" name="userChk" class="userInfoCheckBox" th:value="${userInfo.userSeq}">
|
||||
</td>
|
||||
|
|
@ -164,7 +164,7 @@
|
|||
<div class="modal-dialog modal-lg modal-dialog-scrollable">
|
||||
<div class="modal-content" id="userEditModalContent">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="menuEditModalLabel">외사경찰 등록</h5>
|
||||
<h5 class="modal-title" id="menuEditModalLabel">외사경찰 수정</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
|
@ -173,8 +173,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn" id="deleteBtn" style='background-color : red;float:left;'>삭제</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
|
||||
<button type="button" class="btn btn-primary" id="saveAuthBtn">저장</button>
|
||||
<button type="button" class="btn btn-primary" id="updateBtn">저장</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue