수정요청 작성, 조회 작업중.

master
강석 최 2021-12-24 13:54:33 +09:00
parent 2f8fc492f8
commit ce5ca53691
10 changed files with 352 additions and 24 deletions

View File

@ -1,14 +1,18 @@
package com.dbnt.kcgfilemanager.controller; package com.dbnt.kcgfilemanager.controller;
import com.dbnt.kcgfilemanager.model.CategoryRole; import com.dbnt.kcgfilemanager.model.CategoryRole;
import com.dbnt.kcgfilemanager.model.ModifyRequest;
import com.dbnt.kcgfilemanager.model.UserInfo; import com.dbnt.kcgfilemanager.model.UserInfo;
import com.dbnt.kcgfilemanager.service.CategoryRoleService; import com.dbnt.kcgfilemanager.service.CategoryRoleService;
import com.dbnt.kcgfilemanager.service.ModifyRequestService;
import com.dbnt.kcgfilemanager.service.UserInfoService; import com.dbnt.kcgfilemanager.service.UserInfoService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/info") @RequestMapping("/info")
@ -16,6 +20,7 @@ public class InfoController {
private final CategoryRoleService categoryRoleService; private final CategoryRoleService categoryRoleService;
private final UserInfoService userInfoService; private final UserInfoService userInfoService;
private final ModifyRequestService modifyRequestService;
@GetMapping("/myInfo") @GetMapping("/myInfo")
public ModelAndView myInfo(@AuthenticationPrincipal UserInfo loginUser) { public ModelAndView myInfo(@AuthenticationPrincipal UserInfo loginUser) {
@ -33,4 +38,28 @@ public class InfoController {
public String passwordModify(@AuthenticationPrincipal UserInfo loginUser, UserInfo modifyInfo){ public String passwordModify(@AuthenticationPrincipal UserInfo loginUser, UserInfo modifyInfo){
return userInfoService.updatePassword(loginUser, modifyInfo); return userInfoService.updatePassword(loginUser, modifyInfo);
} }
@GetMapping("/modifyRequestWrite")
public ModelAndView modifyRequestWrite(@AuthenticationPrincipal UserInfo loginUser, ModifyRequest modifyRequest){
ModelAndView mav = new ModelAndView("user/modifyRequestWrite");
mav.addObject("loginUser", loginUser);
if(modifyRequest.getRequestSeq()==null){
mav.addObject("type", "new");
mav.addObject("modifyRequest", modifyRequest);
CategoryRole categoryRole = new CategoryRole();
categoryRole.setUserSeq(loginUser.getUserSeq());
mav.addObject("categorySeqList", categoryRoleService.selectCategorySeqListToUser(categoryRole));
}else{
mav.addObject("type", "modify");
// 이하 수정기능 추가시 작업 필요.
mav.addObject("modifyRequest", modifyRequest);
mav.addObject("categorySeqList", new ArrayList<>());
}
return mav;
}
@PostMapping("/saveModifyRequest")
public Integer saveModifyRequest(ModifyRequest modifyRequest){
return modifyRequestService.saveModifyRequest(modifyRequest);
}
} }

View File

@ -0,0 +1,46 @@
package com.dbnt.kcgfilemanager.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.web.multipart.MultipartFile;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "MODIFY_REQUEST")
public class ModifyRequest extends BaseModel{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "REQUEST_SEQ")
private Integer requestSeq;
@Column(name = "REQUEST_TYPE")
private String requestType;
@Column(name = "TITLE")
private String title;
@Column(name = "STATUS")
private String status;
@Column(name = "REQUEST_NAME")
private String requestName;
@Column(name = "REQUEST_POSITION")
private Integer requestPosition;
@Column(name = "REQUEST_DEPARTMENT")
private Integer requestDepartment;
@Column(name = "REQUEST_CATEGORY_ARY")
private String requestCategoryAry;
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "CREATE_ID")
private String createId;
@Column(name = "CREATE_DATE")
private LocalDateTime createDate;
}

View File

@ -0,0 +1,8 @@
package com.dbnt.kcgfilemanager.repository;
import com.dbnt.kcgfilemanager.model.ModifyRequest;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ModifyRequestRepository extends JpaRepository<ModifyRequest, Integer> {
}

View File

@ -0,0 +1,18 @@
package com.dbnt.kcgfilemanager.service;
import com.dbnt.kcgfilemanager.model.ModifyRequest;
import com.dbnt.kcgfilemanager.repository.ModifyRequestRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class ModifyRequestService {
private final ModifyRequestRepository modifyRequestRepository;
public Integer saveModifyRequest(ModifyRequest modifyRequest) {
return modifyRequestRepository.save(modifyRequest).getRequestSeq();
}
}

View File

@ -120,17 +120,6 @@ $(document).on('click', '#saveCategoryRoleBtn', function (){
}) })
}) })
$(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 valueCheck(form){ function valueCheck(form){
const targetForm = $("#"+form); const targetForm = $("#"+form);
const userId = targetForm.find("#userId").val(); const userId = targetForm.find("#userId").val();

View File

@ -0,0 +1,12 @@
$(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);
}

View File

@ -2,12 +2,6 @@ $(function (){
tableSort(); tableSort();
}) })
$(document).on('click', '#moveRightBtn', function (){
moveCategorySelectBody(1);
})
$(document).on('click', '#moveLeftBtn', function (){
moveCategorySelectBody(-1);
})
$(document).on('click', '#savePasswordBtn', function (){ $(document).on('click', '#savePasswordBtn', function (){
if(passwordCheck()){ if(passwordCheck()){
const formData = new FormData($("#modifyPasswordForm")[0]); const formData = new FormData($("#modifyPasswordForm")[0]);
@ -65,11 +59,6 @@ function passwordCheck(){
} }
function moveCategorySelectBody(direction){
const categorySelectBody = $("#categorySelectBody");
const nowX = categorySelectBody.scrollLeft();
categorySelectBody.animate({scrollLeft:(direction*200+nowX)},200);
}
function tableSort(){ function tableSort(){
$("#categorySelectBody").find("tbody").each(function (idx, tbody){ $("#categorySelectBody").find("tbody").each(function (idx, tbody){
let lastCategorySeq = 0 let lastCategorySeq = 0

View File

@ -0,0 +1,53 @@
$(function (){
$("#description").summernote({
lang:'ko-KR',
height: 120,
disableDragAndDrop: true,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']]
]
})
})
$(document).on('change', '#categorySelector', function (){
$("#modifyInfoDiv").empty().append($("#"+this.value+"Div").children().clone());
})
$(document).on('click', '#saveBtn', function (){
if(contentCheck()){
if(confirm("저장하시겠습니까?")){
const formData = new FormData($("#requestForm")[0]);
$.ajax({
type : 'POST',
data : formData,
url : pageType==='modify'?"/info/updateModifyRequest":"/info/saveModifyRequest",
processData: false,
contentType: false,
success : function(result) {
if(result>0){
alert("저장되었습니다.");
// location.href = "/board/contentList?categorySeq="+$("#categorySeq").val();
}
},
error : function(xhr, status) {
}
})
}
}
})
function contentCheck(){
let flag = true;
if(!$("#categorySelector").val()){
alert("분류 선택이 되지 않았습니다.")
flag = false;
}
if(!$("#title").val()){
alert("제목을 입력해주세요.")
flag = false;
}
return flag;
}

View File

@ -0,0 +1,184 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<th:block layout:fragment="css">
<style>
.col-form-label{
text-align: right;
}
</style>
</th:block>
<th:block layout:fragment="script">
<script type="text/javascript">
const pageType = '[[${type}]]';
</script>
<script type="text/javascript" th:src="@{/js/user/modifyRequestWrite.js}"></script>
</th:block>
<div layout:fragment="content">
<main class="pt-3">
<h4 th:text="${type=='new'?'수정 요청 등록':'수정 요청 변경'}"></h4>
<div class="row mx-0">
<div class="col-7 card">
<div class="card-body">
<div class="row mb-3 justify-content-end">
<div class="col-auto">
<button class="bi bi-save btn btn-primary" id="saveBtn"> 저장</button>
</div>
</div>
<form id="requestForm" th:action="@{/info/saveModifyRequest}" method="post">
<th:block th:if="${type!='new'}">
<input type="hidden" name="requestSeq">
</th:block>
<div class="row mb-3">
<label for="title" class="col-sm-2 col-form-label">분류 선택</label>
<div class="col-sm">
<select class="form-select" id="categorySelector" name="requestType">
<option value="" disabled selected>분류를 선택해주세요</option>
<option value="userInfo">계정정보</option>
<option value="categoryRole">권한정보</option>
</select>
</div>
</div>
<div class="row mb-3">
<label for="title" class="col-sm-2 col-form-label">제목</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="title" name="title" autocomplete="off" th:value="${modifyRequest.title}">
</div>
</div>
<div class="row mb-3">
<label for="createName" class="col-sm-2 col-form-label">작성자</label>
<div class="col-sm-4">
<input type="hidden" name="createId" th:value="${loginUser.userId}">
<input type="text" class="form-control" id="createName" th:value="${loginUser.name}" readonly>
</div>
<label for="createDate" class="col-sm-2 col-form-label">작성일</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="createDate"
th:value="${type!='new'?(#temporals.format(modifyRequest.createDate, 'yyyy-MM-dd HH:mm:dd')):'저장시 생성'}" readonly>
</div>
</div>
<div class="row mb-3">
<label for="description" class="col-sm-2 col-form-label">변경 내용</label>
<div class="col-sm-10" id="modifyInfoDiv">
<div class="p-3 border rounded">분류를 선택해주세요.</div>
</div>
</div>
<div class="row mb-3">
<label for="description" class="col-sm-2 col-form-label">설명</label>
<div class="col-sm-10">
<textarea id="description" name="description" th:text="${modifyRequest.description}"></textarea>
</div>
</div>
</form>
</div>
</div>
</div>
</main>
<div class="d-none">
<div id="userInfoDiv">
<div class="p-3 border rounded">
<div class="row mb-3">
<label for="requestName" class="col-sm-2 col-form-label">이름</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="requestName" name="requestName" th:value="${type!='new'?loginUser.name:modifyRequest.requestName}">
</div>
</div>
<div class="row mb-3">
<label for="requestDepartment" class="col-sm-2 col-form-label">부서</label>
<div class="col-sm-10">
<select class="form-select" id="requestDepartment" name="requestDepartment">
<th:block th:each="deparement:${session.departmentList}">
<option th:value="${deparement.codeSq}" th:text="${deparement.value}" th:selected="${type!='new'?loginUser.department:modifyRequest.requestDepartment}"></option>
</th:block>
</select>
</div>
</div>
<div class="row mb-3">
<label for="requestPosition" class="col-sm-2 col-form-label">직책</label>
<div class="col-sm-10">
<select class="form-select" id="requestPosition" name="requestPosition">
<th:block th:each="position:${session.positionList}">
<option th:value="${position.codeSq}" th:text="${position.value}" th:selected="${type!='new'?loginUser.position:modifyRequest.requestPosition}"></option>
</th:block>
</select>
</div>
</div>
</div>
</div>
<div id="categoryRoleDiv">
<div class="p-3 border rounded">
<div class="row justify-content-between">
<div class="col-auto"><button type="button" class="btn btn-info" id="moveLeftBtn"><i class="bi bi-arrow-left"></i></button></div>
<div class="col-auto"><button type="button" class="btn btn-info" id="moveRightBtn"><i class="bi bi-arrow-right"></i></button></div>
</div>
<div class="row overflow-auto flex-nowrap" id="categorySelectBody">
<th:block th:each="depth1:${session.categoryList}">
<div class="col-auto">
<table class="table table-striped">
<thead>
<tr>
<th>
<input type="checkbox" class="categoryCheckBox parentSeq" th:data-categoryseq="${depth1.categorySeq}"
th:checked="${#lists.contains(categorySeqList, depth1.categorySeq)}">
</th>
<th colspan="3" class="text-center" th:text="${depth1.categoryName}"></th>
</tr>
<tr>
<th></th>
<th>연도</th>
<th>중분류</th>
<th>소분류</th>
</tr>
</thead>
<tbody>
<th:block th:each="depth2:${depth1.childCategoryList}">
<tr>
<td>
<input type="checkbox" class="categoryCheckBox parentSeq"
th:data-categoryseq="${depth2.categorySeq}" th:data-parentseq="${depth2.parentSeq}"
th:checked="${#lists.contains(categorySeqList, depth2.categorySeq)}">
</td>
<td th:text="${depth2.categoryName}"></td>
<td></td>
<td></td>
</tr>
<th:block th:each="depth3:${depth2.childCategoryList}">
<tr>
<td>
<input type="checkbox" class="categoryCheckBox parentSeq"
th:data-categoryseq="${depth3.categorySeq}" th:data-parentseq="${depth3.parentSeq}"
th:checked="${#lists.contains(categorySeqList, depth3.categorySeq)}">
</td>
<td></td>
<td th:text="${depth3.categoryName}"></td>
<td></td>
</tr>
<th:block th:each="depth4:${depth3.childCategoryList}">
<tr>
<td>
<input type="checkbox" class="categoryCheckBox" th:data-categoryseq="${depth4.categorySeq}"
th:data-parentseq="${depth4.parentSeq}" th:checked="${#lists.contains(categorySeqList, depth4.categorySeq)}">
</td>
<td></td>
<td></td>
<td th:text="${depth4.categoryName}"></td>
</tr>
</th:block>
</th:block>
</th:block>
</tbody>
</table>
</div>
</th:block>
</div>
<div class="row justify-content-end">
<div class="col-auto">
<button type="button" class="btn btn-primary" id="saveCategoryRoleBtn">저장</button>
</div>
</div>
</div>
</div>
</div>
</div>
</html>

View File

@ -11,8 +11,8 @@
<div class="col-auto"><h4>개인정보</h4></div> <div class="col-auto"><h4>개인정보</h4></div>
<div class="col-auto"> <div class="col-auto">
<th:block th:if="${!#strings.contains(loginUser.userRole,'ADMIN')}"> <th:block th:if="${!#strings.contains(loginUser.userRole,'ADMIN')}">
<button class="btn btn-success mb-2"> 요청 현황</button> <a class="btn btn-success mb-2" href="#"> 요청 현황</a>
<button class="btn btn-warning mb-2"> 수정 요청</button> <a class="btn btn-warning mb-2" href="/info/modifyRequestWrite"> 수정 요청</a>
</th:block> </th:block>
</div> </div>
</div> </div>