mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 19:54:00 +09:00
authority group 부분 crud 기능 추가
This commit is contained in:
@@ -14,14 +14,11 @@ import java.util.UUID;
|
||||
public class AuthorityController {
|
||||
@Autowired
|
||||
AuthorityService authorityService;
|
||||
private static final int PER_PAGE = 10;
|
||||
private static final int PER_PAGE = 1000;
|
||||
|
||||
@GetMapping("/list")
|
||||
public ModelAndView list(ModelAndView mav, @RequestParam(defaultValue = "") String search, @RequestParam(defaultValue = "0") int start){
|
||||
List<AuthorityDto> list = authorityService.selectAll(search, start, PER_PAGE);
|
||||
for(int i=0; i < list.size(); ++i){
|
||||
System.out.println(list.get(i));
|
||||
}
|
||||
mav.addObject("list", list);
|
||||
mav.setViewName("/authority/list");
|
||||
return mav;
|
||||
@@ -29,7 +26,14 @@ public class AuthorityController {
|
||||
@GetMapping("/create")
|
||||
public String create(){
|
||||
return "/authority/create_group";
|
||||
}
|
||||
|
||||
@PostMapping("/read")
|
||||
public ModelAndView read(ModelAndView mav, AuthorityDto dto){
|
||||
dto = authorityService.selectById(dto);
|
||||
mav.addObject("dto", dto);
|
||||
mav.setViewName("/authority/update_group");
|
||||
return mav;
|
||||
}
|
||||
|
||||
@PostMapping("/checkNameDuplicate")
|
||||
@@ -45,4 +49,12 @@ public class AuthorityController {
|
||||
return gson.toJson(result);
|
||||
}
|
||||
|
||||
@PostMapping("/update_process")
|
||||
@ResponseBody
|
||||
public String updateProcess(AuthorityDto dto, Gson gson){
|
||||
int result = authorityService.update(dto);
|
||||
|
||||
return gson.toJson(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ public class AuthorityDto {
|
||||
|
||||
private AccountDto accountDto;
|
||||
|
||||
|
||||
private Boolean activation;
|
||||
private Boolean isGroupAuthority;
|
||||
}
|
||||
|
||||
@@ -15,5 +15,7 @@ public interface AuthorityMapper {
|
||||
|
||||
int insert(AuthorityDto dto);
|
||||
|
||||
int update(AuthorityDto dto);
|
||||
|
||||
List<AuthorityDto> selectAll(Map<String, Object> m);
|
||||
}
|
||||
|
||||
@@ -33,4 +33,6 @@ public class AuthorityService {
|
||||
public int insert(AuthorityDto dto){
|
||||
return mapper.insert(dto);
|
||||
}
|
||||
|
||||
public int update(AuthorityDto dto) { return mapper.update(dto); }
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
<result column="employee_number" property="employeeNumber" />
|
||||
<result column="acc_name" property="name" />
|
||||
</association>
|
||||
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -34,7 +33,8 @@
|
||||
</select>
|
||||
<select id="selectAll" resultMap="authorityResultMap" parameterType="map">
|
||||
SELECT
|
||||
auth.id, auth.name, auth.account, auth.authority, auth.product_category, auth.product,
|
||||
auth.id, auth.name,
|
||||
auth.account, auth.authority, auth.product_category, auth.product,
|
||||
auth.prices, auth.vendor, auth.warehouse, auth.stock, auth.plan_in, auth.product_in,
|
||||
auth.product_out, auth.board, auth.activation, auth.is_group_authority,
|
||||
acc.employee_number, acc.name acc_name
|
||||
@@ -61,4 +61,23 @@
|
||||
)
|
||||
|
||||
</insert>
|
||||
<update id="update" parameterType="AuthorityDto">
|
||||
update authority SET
|
||||
name = #{name},
|
||||
account = #{account},
|
||||
authority = #{authority},
|
||||
product_category = #{productCategory},
|
||||
product = #{product},
|
||||
prices = #{prices},
|
||||
vendor = #{vendor},
|
||||
warehouse = #{warehouse},
|
||||
stock = #{stock},
|
||||
plan_in = #{planIn},
|
||||
product_in = #{productIn},
|
||||
product_out = #{productOut},
|
||||
board = #{board},
|
||||
activation = #{activation},
|
||||
is_group_authority = #{isGroupAuthority}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -23,6 +23,8 @@
|
||||
{'eng':'board' ,'kor' : '게시판'}
|
||||
]
|
||||
|
||||
|
||||
|
||||
$(function(){
|
||||
const $div_check_box_body = $("#table_check_box_body");
|
||||
authorityCategoryList.reverse().forEach(function(element){
|
||||
@@ -54,7 +56,7 @@
|
||||
' </div></td>\n' +
|
||||
' </tr>');
|
||||
});
|
||||
|
||||
yesNoModalTextDefine("새 타이틀", "새 바디");
|
||||
});
|
||||
|
||||
function checkName(){
|
||||
@@ -102,18 +104,16 @@
|
||||
});
|
||||
data['isGroupAuthority'] = true;
|
||||
data['activation'] = true;
|
||||
console.log(data);
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/authority/create_process', // 요청할 서버url
|
||||
dataType : 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : data,
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
alert(result);
|
||||
if(result === 's'){
|
||||
$("#authority_name").attr('disabled','true');
|
||||
}else if(result === 'f'){
|
||||
alert("이미 존재하는 권한 명 입니다");
|
||||
if(Number(result) === 1){
|
||||
alert("권한 생성에 성공하였습니다");
|
||||
}else{
|
||||
alert("권한 생성중 오류가 발생하였습니다")
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
@@ -163,6 +163,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" onclick="onAuthorityProcess()">생성</button>
|
||||
<button class="btn btn-primary" onclick="window.history.back()">뒤로</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
$("#div_personal_search").show();
|
||||
}
|
||||
});
|
||||
|
||||
$(".group_authority_tr").on("click", function(event){
|
||||
readGroupAuthority($(event.currentTarget).data("tid"));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
function onSearch(isPersonalSearch){
|
||||
@@ -37,6 +43,16 @@
|
||||
|
||||
console.log(JSON.stringify(jsonData));
|
||||
}
|
||||
|
||||
function readGroupAuthority(id){
|
||||
$("#formInput").val(id);
|
||||
$("#form").attr("action", "/authority/read" );
|
||||
$("#form").trigger("submit");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
@@ -95,7 +111,12 @@
|
||||
<td>${dto.accountDto.employeeNumber}</td>
|
||||
<td>${dto.accountDto.name}</td>
|
||||
<td>${dto.name}</td>
|
||||
<td>${dto.activation}</td>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${dto.activation}">O</c:when>
|
||||
<c:otherwise>X</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
</c:forEach>
|
||||
@@ -105,12 +126,23 @@
|
||||
<div class="tab-pane fade" id="group_authority_tab" role="tabpanel" aria-labelledby="group-authority-tab">
|
||||
<table class="table" >
|
||||
<thead class="table-dark">
|
||||
<tr><th>번호</th><th>권한 명</th></tr>
|
||||
<tr><th>번호</th><th>권한 명</th><th>활성 여부</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>1</td><td>사장 권한</td></tr>
|
||||
<tr><td>2</td><td>관리자 권한</td></tr>
|
||||
<tr><td>3</td><td>사원 권한</td></tr>
|
||||
<c:forEach items="${list }" var="dto" varStatus="status">
|
||||
<c:if test="${dto.isGroupAuthority == true}">
|
||||
<tr class="group_authority_tr" data-tid ="${dto.id}">
|
||||
<td>${status.count}</td>
|
||||
<td>${dto.name}</td>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${dto.activation}">O</c:when>
|
||||
<c:otherwise>X</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -122,4 +154,7 @@
|
||||
<!-- 탭 부분 끝 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="form" method="post">
|
||||
<input name="id" id="formInput" hidden>
|
||||
</form>
|
||||
227
src/main/webapp/WEB-INF/views/authority/update_group.jsp
Normal file
227
src/main/webapp/WEB-INF/views/authority/update_group.jsp
Normal file
@@ -0,0 +1,227 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<script>
|
||||
/*
|
||||
yes no 모달의 확인 버튼을 누를때 재정의할 function
|
||||
|
||||
yesNoModal.yesFunction = myYesFunction;
|
||||
function myYesFunction(){
|
||||
alert("재정의 됨");
|
||||
}
|
||||
*/
|
||||
const originalAuthorityName = '${dto.name}';
|
||||
const authorityId = '${dto.id}';
|
||||
const authorityCategoryList = [
|
||||
{'eng' : 'account', 'kor' : '계정', 'value' : ${dto.account}},
|
||||
{'eng':'authority','kor' : '권한', 'value' : ${dto.authority}},
|
||||
{'eng' : 'productCategory', 'kor' : '제품 카테고리', 'value' : ${dto.productCategory}},
|
||||
{'eng': 'product' ,'kor' : '제품', 'value' : ${dto.product}},
|
||||
{'eng':'prices' ,'kor' : '가격', 'value' : ${dto.prices} },
|
||||
{'eng': 'vendor' ,'kor' : '거래처' , 'value' : ${dto.vendor}} ,
|
||||
{'eng':'warehouse' ,'kor' : '창고' , 'value' : ${dto.warehouse}},
|
||||
{'eng': 'stock' ,'kor' : '재고', 'value' : ${dto.stock} } ,
|
||||
{'eng':'planIn' ,'kor' : '입고 예정', 'value' : ${dto.planIn}},
|
||||
{'eng':'productIn' ,'kor' : '입고', 'value' : ${dto.productIn}},
|
||||
{'eng':'productOut' ,'kor' : '출고', 'value' : ${dto.productOut}},
|
||||
{'eng':'board' ,'kor' : '게시판', 'value' : ${dto.board}}
|
||||
]
|
||||
|
||||
/*뒤에서부터 index번째 비트가 1인가 확인하는 기능
|
||||
ex) data : 9(1001), index : 1 = true
|
||||
index : 2 = false
|
||||
index : 3 = false
|
||||
index : 4 = true
|
||||
*/
|
||||
function bitCalcResult(data, index){
|
||||
let v = 1;
|
||||
for(let i = 1 ; i < index; ++i ){
|
||||
v*=2;
|
||||
}
|
||||
return (data & v) > 0;
|
||||
}
|
||||
|
||||
$(function(){
|
||||
const $div_check_box_body = $("#table_check_box_body");
|
||||
authorityCategoryList.reverse().forEach(function(element){
|
||||
$div_check_box_body.after('<tr>' +
|
||||
' <td>'+element.kor+'</td>\n' +
|
||||
' <td><div id="'+element.eng+'_check_read" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="8" id="'+element.eng+'_read">\n' +
|
||||
' <label class="form-check-label" for='+element.eng+'_read">\n' +
|
||||
' 읽기\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_write" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="4" id="'+element.eng+'_create">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_create">\n' +
|
||||
' 쓰기\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_create" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="2" id="'+element.eng+'_update">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_update">\n' +
|
||||
' 수정\n' +
|
||||
' </label>\n' +
|
||||
' </div>\n' +
|
||||
' <div id="'+element.eng+'_check_delete" class="form-check form-check-inline">\n' +
|
||||
' <input class="form-check-input" data-category="'+element.eng+'" type="checkbox" value="1" id="'+element.eng+'_delete">\n' +
|
||||
' <label class="form-check-label" for="'+element.eng+'_delete">\n' +
|
||||
' 삭제\n' +
|
||||
' </label>\n' +
|
||||
' </div></td>\n' +
|
||||
' </tr>');
|
||||
});
|
||||
authorityCategoryList.reverse().forEach(function(element) {
|
||||
|
||||
const value =element.value;
|
||||
if( bitCalcResult(value, 4 ))
|
||||
$("#"+element.eng+"_read").attr('checked', true);
|
||||
if( bitCalcResult(value, 3 ))
|
||||
$("#"+element.eng+"_create").attr('checked', true);
|
||||
if( bitCalcResult(value, 2 ))
|
||||
$("#"+element.eng+"_update").attr('checked', true);
|
||||
if( bitCalcResult(value, 1 ))
|
||||
$("#"+element.eng+"_delete").attr('checked', true);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function checkName(){
|
||||
const name = $("#authority_name").val();
|
||||
|
||||
|
||||
if($("#btn_check_name").text() === "다시 설정"){
|
||||
$("#authority_name").removeAttr("disabled");
|
||||
$("#btn_check_name").text("중복 확인");
|
||||
return;
|
||||
}
|
||||
|
||||
if(originalAuthorityName === name){
|
||||
console.log(originalAuthorityName);
|
||||
console.log(name);
|
||||
$("#authority_name").attr('disabled','true');
|
||||
$("#btn_check_name").text("다시 설정");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/authority/checkNameDuplicate', // 요청할 서버url
|
||||
dataType : 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : {'name' : name},
|
||||
success : function(data) { // 결과 성공 콜백함수
|
||||
if(Number(data) === 0){
|
||||
$("#authority_name").attr('disabled','true');
|
||||
$("#btn_check_name").text("다시 설정");
|
||||
}else{
|
||||
alert("이미 존재하는 권한 명 입니다");
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onAuthorityUpdateProcess(){
|
||||
if($("#authority_name:disabled").length === 0 ){
|
||||
alert("'중복 확인'을 해주세요");
|
||||
return;
|
||||
}
|
||||
|
||||
let data = {};
|
||||
data.name = $("#authority_name").val();
|
||||
const $checkBoxList = $("input[type='checkbox']:checked");
|
||||
$checkBoxList.each(function(index, element){
|
||||
const category = $(element).data('category');
|
||||
if(data[category] == null){
|
||||
data[category] = 0;
|
||||
}
|
||||
data[category] += Number($(element).val());
|
||||
});
|
||||
data['isGroupAuthority'] = true;
|
||||
data['activation'] = $('input[name="activation"]:checked').val();
|
||||
data['id'] = authorityId;
|
||||
console.log(data);
|
||||
$.ajax({
|
||||
type : 'post', // 타입 (get, post, put 등등)
|
||||
url : '/authority/update_process', // 요청할 서버url
|
||||
dataType : 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||
data : data,
|
||||
success : function(result) { // 결과 성공 콜백함수
|
||||
if(Number(result) === 1){
|
||||
alert("권한 변경에 성공하였습니다");
|
||||
}else{
|
||||
alert("업데이트 중에 오류기 발생하였습니다");
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
alert(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
<h1>권한 추가</h1>
|
||||
</div>
|
||||
<div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
권한명
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<input disabled class="form-control w-30 d-inline" id="authority_name" name='name' type="text" placeholder="권한 명을 입력하세요" value="${dto.name}">
|
||||
<button id="btn_check_name" class="btn btn-primary" onclick="checkName()">다시 설정</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
활성 여부
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="activation" id="inlineRadio1" value="true" <c:if test="${dto.activation == true}"> checked</c:if>>
|
||||
<label class="form-check-label" for="inlineRadio1">활성</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="activation" id="inlineRadio2" value="false" <c:if test="${dto.activation == false}"> checked</c:if>>
|
||||
<label class="form-check-label" for="inlineRadio2">비활성</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table">
|
||||
<tbody id="table_check_box_body">
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" onclick="onAuthorityUpdateProcess()">수정</button>
|
||||
<button class="btn btn-primary" onclick="window.history.back()">뒤로</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -38,6 +38,8 @@
|
||||
//yes no 모달 관련
|
||||
const yesNoModalBootStrap = new bootstrap.Modal("#yes_no_modal");
|
||||
$("#yes_no_modal_show_button").on("click", function(){
|
||||
$("#yesNoModalLabel").text(yesNoModal.title);
|
||||
$("#yesNoModalBodyTextDiv").text(yesNoModal.body);
|
||||
yesNoModalBootStrap.show();
|
||||
});
|
||||
|
||||
@@ -52,7 +54,9 @@
|
||||
function modalYesFuncNotDefined(){ alert("onModalYes가 정의되어 있지 않음"); }
|
||||
yesNoModal = {
|
||||
//yesFunction 변수를 modal.정의된 함수명 으로 덮어씌워서 자기가 원하는 기능 넣기
|
||||
yesFunction : modalYesFuncNotDefined
|
||||
yesFunction : modalYesFuncNotDefined,
|
||||
title : '확인 취소 모달 제목',
|
||||
body : '모달의 내용'
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +90,10 @@
|
||||
//네비게이션 쪽 아이콘만들어 주는 함수
|
||||
feather.replace();
|
||||
});
|
||||
|
||||
function yesNoModalTextDefine(title, body){
|
||||
yesNoModal.title = title;
|
||||
yesNoModal.body = body;
|
||||
}
|
||||
</script>
|
||||
<!-- 스크립트 부분 끝 -->
|
||||
<div class="col body-bg">
|
||||
@@ -108,7 +115,7 @@
|
||||
<h1 class="modal-title fs-5" id="yesNoModalLabel">확인 취소 모달 제목</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="yesNoModalBodyTextDiv" class="modal-body">
|
||||
모달의 내용
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
Reference in New Issue
Block a user