개시물 조회 기능 작업중.

master
강석 최 2021-12-15 18:33:47 +09:00
parent 0d2f7b92ab
commit 6a1e3dd031
15 changed files with 229 additions and 40 deletions

View File

@ -0,0 +1,30 @@
package com.dbnt.kcgfilemanager.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.HashMap;
@AllArgsConstructor
@Getter
public enum LogStatus {
WRITE("WRITE", "작성"),
MODIFY("MODIFY", "수정"),
MOVE("MOVE", "이동"),
DELETE("DELETE", "삭제"),
FILE_ADD("FILE_ADD", "파일추가"),
FILE_REMOVE("FILE_REMOVE", "파일삭제"),
FILE_DOWN("FILE_DOWN", "파일다운로드");
private String key;
private String value;
public static HashMap<String, String> getStatusMap(){
HashMap<String, String> statusMap = new HashMap<>();
for(LogStatus status: LogStatus.values()){
statusMap.put(status.getKey(), status.getValue());
}
return statusMap;
}
}

View File

@ -3,6 +3,8 @@ package com.dbnt.kcgfilemanager.config;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.HashMap;
@AllArgsConstructor
@Getter
public enum Role {

View File

@ -1,5 +1,6 @@
package com.dbnt.kcgfilemanager.controller;
import com.dbnt.kcgfilemanager.config.LogStatus;
import com.dbnt.kcgfilemanager.model.Board;
import com.dbnt.kcgfilemanager.model.UserInfo;
import com.dbnt.kcgfilemanager.service.BoardService;
@ -10,6 +11,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import java.security.Principal;
import java.util.HashMap;
@RestController
@RequiredArgsConstructor
@ -44,4 +46,18 @@ public class BoardController {
mav.addObject("searchParams", board);
return mav;
}
@GetMapping("/selectBoardContent")
public ModelAndView selectBoardContent(Board content){
ModelAndView mav = new ModelAndView("board/contentDetail");
mav.addObject("content", boardService.selectContentDetail(content.getContentSeq()));
return mav;
}
@GetMapping("/selectBoardLog")
public ModelAndView selectBoardLog(Board content){
ModelAndView mav = new ModelAndView("board/contentLog");
mav.addObject("statusMap", LogStatus.getStatusMap());
mav.addObject("logList", boardService.selectContentLog(content.getContentSeq()));
return mav;
}
}

View File

@ -1,6 +1,8 @@
package com.dbnt.kcgfilemanager.mapper;
import com.dbnt.kcgfilemanager.model.Board;
import com.dbnt.kcgfilemanager.model.BoardLog;
import com.dbnt.kcgfilemanager.model.HashTag;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -9,4 +11,6 @@ import java.util.List;
public interface BoardMapper {
List<Board> selectContentList(Board board);
Integer selectContentListCnt(Board board);
List<HashTag> selectHashTagListFromContentSeq(Integer contentSeq);
List<BoardLog> selectBoardLogFromContentSeq(Integer contentSeq);
}

View File

@ -42,6 +42,11 @@ public class Board extends BaseModel{
@Transient
private Integer fileCnt;
@Transient
private List<FileInfo> childFileList;
@Transient
private List<HashTag> hashTagList;
@Transient
private String hashTagStr;
@Transient

View File

@ -3,8 +3,10 @@ package com.dbnt.kcgfilemanager.repository;
import com.dbnt.kcgfilemanager.model.FileInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
import java.util.Optional;
public interface FileInfoRepository extends JpaRepository<FileInfo, FileInfo.FileInfoId> {
Optional<FileInfo> findTopByContentSeqOrderByFileSeqDesc(Integer contentSeq);
List<FileInfo> findByContentSeqOrderByFileSeqAsc(Integer contentSeq);
}

View File

@ -1,5 +1,6 @@
package com.dbnt.kcgfilemanager.service;
import com.dbnt.kcgfilemanager.config.LogStatus;
import com.dbnt.kcgfilemanager.mapper.BoardMapper;
import com.dbnt.kcgfilemanager.model.*;
import com.dbnt.kcgfilemanager.repository.*;
@ -29,18 +30,18 @@ public class BoardService {
@Transactional
public Integer saveContent(Board content){
Integer contentSeq = boardRepository.save(content).getContentSeq();
saveBoardLog(contentSeq, "I", null, content.getCreateId());
saveBoardLog(content.getContentSeq(), LogStatus.WRITE, null, content.getCreateId());
saveHashTagLink(contentSeq, content.getHashTagStr());
saveUploadFiles(contentSeq, content.getCategorySeq(), content.getFileList());
saveUploadFiles(content);
return contentSeq;
}
private void saveBoardLog(Integer contentSeq, String status, String description, String createId){
private void saveBoardLog(Integer contentSeq, LogStatus status, String description, String createId){
BoardLog lastLog = boardLogRepository.findTopByContentSeqOrderByLogSeqDesc(contentSeq).orElse(null);
BoardLog log = new BoardLog();
log.setContentSeq(contentSeq);
log.setLogSeq(lastLog == null?1:(lastLog.getLogSeq()+1));
log.setLogStatus(status);
log.setLogStatus(status.getKey());
log.setDescription(description);
log.setCreateId(createId);
boardLogRepository.save(log);
@ -67,13 +68,12 @@ public class BoardService {
}
}
}
private void saveUploadFiles(Integer contentSeq, Integer categorySeq, List<MultipartFile> files){
FileInfo lastFileInfo = fileInfoRepository.findTopByContentSeqOrderByFileSeqDesc(contentSeq).orElse(null);
private void saveUploadFiles(Board content){
FileInfo lastFileInfo = fileInfoRepository.findTopByContentSeqOrderByFileSeqDesc(content.getContentSeq()).orElse(null);
int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1);
for(MultipartFile file : files){
System.out.println(file.getName());
for(MultipartFile file : content.getFileList()){
String saveName = UUID.randomUUID().toString();
String path = makeFilePath(categorySeq);
String path = makeFilePath(content.getCategorySeq());
File saveFile = new File(path+"\\"+saveName);
if(file.getSize()!=0){ // 저장될 파일 확인
@ -95,13 +95,14 @@ public class BoardService {
String[] originalFilename = Objects.requireNonNull(file.getOriginalFilename()).split("\\.");
FileInfo fileInfo = new FileInfo();
fileInfo.setContentSeq(contentSeq);
fileInfo.setContentSeq(content.getContentSeq());
fileInfo.setFileSeq(fileSeq++);
fileInfo.setOriginalName(originalFilename[0]);
fileInfo.setExtention(originalFilename[1]);
fileInfo.setConversionName(saveName);
fileInfo.setSavePath(path);
fileInfoRepository.save(fileInfo);
saveBoardLog(content.getContentSeq(), LogStatus.FILE_ADD, file.getOriginalFilename(), content.getCreateId());
}
}
@ -127,4 +128,14 @@ public class BoardService {
public Integer selectContentListCnt(Board board) {
return boardMapper.selectContentListCnt(board);
}
public Board selectContentDetail(Integer contentSeq) {
Board target = boardRepository.findById(contentSeq).orElse(null);
target.setHashTagList(boardMapper.selectHashTagListFromContentSeq(contentSeq));
target.setChildFileList(fileInfoRepository.findByContentSeqOrderByFileSeqAsc(contentSeq));
return target;
}
public List<BoardLog> selectContentLog(Integer contentSeq){
return boardMapper.selectBoardLogFromContentSeq(contentSeq);
}
}

View File

@ -5,7 +5,8 @@
<mapper namespace="com.dbnt.kcgfilemanager.mapper.BoardMapper">
<select id="selectContentList" resultType="Board" parameterType="Board">
SELECT A.TITLE AS title,
SELECT A.CONTENT_SEQ AS contentSeq,
A.TITLE AS title,
C.FILE_CNT AS fileCnt,
B.NAME AS createName,
A.CREATE_DATE AS createDate
@ -34,4 +35,23 @@
ON A.CONTENT_SEQ = C.CONTENT_SEQ
WHERE CATEGORY_SEQ = ${categorySeq}
</select>
<select id="selectHashTagListFromContentSeq" resultType="HashTag" parameterType="int">
SELECT C.*
FROM BOARD A
INNER JOIN HASH_TAG_LINK B ON A.CONTENT_SEQ = B.CONTENT_SEQ
INNER JOIN HASH_TAG C ON B.TAG_SEQ = C.TAG_SEQ
WHERE A.CONTENT_SEQ = ${categorySeq}
</select>
<select id="selectBoardLogFromContentSeq" resultType="BoardLog" parameterType="int">
SELECT A.LOG_SEQ AS logSeq,
A.LOG_STATUS AS logStatus,
A.DESCRIPTION AS description,
B.NAME AS createId ,
A.CREATE_DATE AS createDate
FROM BOARD_LOG A
INNER JOIN USER_INFO B ON A.CREATE_ID = B.USER_ID
WHERE A.CONTENT_SEQ = ${categorySeq}
ORDER BY LOG_SEQ DESC
</select>
</mapper>

View File

@ -178,24 +178,6 @@ function valueCheck(form){
return returnFlag;
}
function setSearchCondition(){
const searchConditionSelector = $("#searchConditionSelector").val();
const searchTextDiv = $("#searchTextDiv");
const dateSelectorDiv = $("#dateSelectorDiv");
if(searchConditionSelector === "createDate"){
dateSelectorDiv.show();
dateSelectorDiv.children().removeAttr("disabled");
searchTextDiv.hide();
searchTextDiv.children().attr("disabled", "disabled");
}else{
$("#textSearch").attr("name", searchConditionSelector);
searchTextDiv.show();
searchTextDiv.children().removeAttr("disabled");
dateSelectorDiv.hide();
dateSelectorDiv.children().attr("disabled", "disabled");
}
}
function getUserSeq(){
return $(".userInfoCheckBox:checked").val();
}

View File

@ -0,0 +1,64 @@
$(function(){
setSearchCondition();
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
})
$(document).on('click', '.contentTr', function (){
$(".contentCheckBox").prop('checked', false);
const target = $(this).find(".contentCheckBox")[0];
target.checked = true;
const selectedTab = $(".nav-tabs").find(".active")[0].id;
if(selectedTab === "contentTab"){
getBoardContent(target.value);
}else if(selectedTab === "logTab"){
getBoardLog(target.value);
}
})
$(document).on('click', '#contentTab', function (){
getBoardContent(getContentSeq())
})
$(document).on('click', '#logTab', function (){
getBoardLog(getContentSeq())
})
function getContentSeq(){
return $(".contentCheckBox:checked").val();
}
function getBoardContent(contentSeq){
if(contentSeq !== undefined){
$.ajax({
url: '/board/selectBoardContent',
data: {contentSeq: contentSeq},
type: 'GET',
dataType:"html",
success: function(html){
$("#boardDiv").empty().append(html)
},
error:function(){
}
});
}
}
function getBoardLog(contentSeq){
if(contentSeq !== undefined){
$.ajax({
url: '/board/selectBoardLog',
data: {contentSeq: contentSeq},
type: 'GET',
dataType:"html",
success: function(html){
$("#boardDiv").empty().append(html)
},
error:function(){
}
});
}
}

View File

@ -0,0 +1,18 @@
function setSearchCondition(){
const searchConditionSelector = $("#searchConditionSelector").val();
const searchTextDiv = $("#searchTextDiv");
const dateSelectorDiv = $("#dateSelectorDiv");
if(searchConditionSelector === "createDate"){
dateSelectorDiv.show();
dateSelectorDiv.children().removeAttr("disabled");
searchTextDiv.hide();
searchTextDiv.children().attr("disabled", "disabled");
}else{
$("#textSearch").attr("name", searchConditionSelector);
searchTextDiv.show();
searchTextDiv.children().removeAttr("disabled");
dateSelectorDiv.hide();
dateSelectorDiv.children().attr("disabled", "disabled");
}
}

View File

@ -0,0 +1,3 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
contentDetail

View File

@ -16,7 +16,7 @@
<div class="row justify-content-start">
<div class="col-7">
<!--검색 form-->
<!--<form method="get" th:action="@{/admin/userMgt}">
<form method="get" th:action="@{/board/contentList}">
<input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
<div class="row justify-content-between">
<div class="col-auto row">
@ -35,15 +35,19 @@
<div class="row justify-content-end">
<div class="col-auto">
<select class="form-select" id="searchConditionSelector">
<option>검색조건</option>
</select>
<!--<select class="form-select" id="searchConditionSelector">
<option value="userId" th:selected="${searchParams.userId!=null and searchParams.userId!=''}">아이디</option>
<option value="name" th:selected="${searchParams.name!=null and searchParams.name!=''}">이름</option>
<option value="positionName" th:selected="${searchParams.positionName!=null and searchParams.positionName!=''}">부서</option>
<option value="departmentName" th:selected="${searchParams.departmentName!=null and searchParams.departmentName!=''}">직급</option>
<option value="createDate" th:selected="${searchParams.startDate!=null and searchParams.startDate!=''} or ${searchParams.endDate!=null and searchParams.endDate!=''}">생성일</option>
</select>
</select>-->
</div>
<div class="col-auto" id="searchTextDiv">
<input type="text" class="form-control" id="textSearch" th:value="${
<input type="text" class="form-control" id="textSearch">
<!--<input type="text" class="form-control" id="textSearch" th:value="${
(searchParams.userId!=null and searchParams.userId!='')?searchParams.userId:(
(searchParams.name!=null and searchParams.name!='')?searchParams.name:(
(searchParams.positionName!=null and searchParams.positionName!='')?searchParams.positionName:(
@ -51,7 +55,7 @@
)
)
)
}">
}">-->
</div>
<div class="col-auto input-group w-auto input-daterange" id="dateSelectorDiv" style="display: none">
<input type="text" class="form-control" id="startDate" name="startDate" placeholder="시작일" autocomplete="off" disabled th:value="${searchParams.startDate}">
@ -63,7 +67,7 @@
</div>
</div>
</div>
</form>-->
</form>
<div class="row-cols-6">
<table class="table table-striped">
<thead>
@ -122,15 +126,15 @@
</div>
</div>
<div class="col-5">
<ul class="nav nav-tabs" id="userTab" role="tablist">
<ul class="nav nav-tabs" id="boardTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="infoTab" data-bs-toggle="tab" type="button" role="tab">내용</button>
<button class="nav-link active" id="contentTab" data-bs-toggle="tab" type="button" role="tab">내용</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="categoryTab" data-bs-toggle="tab" type="button" role="tab">이력</button>
<button class="nav-link" id="logTab" data-bs-toggle="tab" type="button" role="tab">이력</button>
</li>
</ul>
<div class="tab-content border border-top-0" id="userContent">
<div class="tab-content border border-top-0" id="boardDiv">
<div class="py-5">
<h3>왼쪽 목록에서 선택해주세요.</h3>
</div>

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="p-3">
<div class="row-cols-6 overflow-auto">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>행동</th>
<th>내용</th>
<th>사용자</th>
<th>발생일시</th>
</tr>
</thead>
<tbody>
<th:block th:each="log:${logList}">
<tr>
<td th:text="${log.logSeq}"></td>
<td th:text="${statusMap.get(log.logStatus)}"></td>
<td th:text="${log.description}"></td>
<td th:text="${log.createId}"></td>
<td th:text="${#temporals.format(log.createDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
</tr>
</th:block>
</tbody>
</table>
</div>
</div>

View File

@ -2,7 +2,7 @@
<html lang="ko"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5" xmlns="http://www.w3.org/1999/html">
<div class="mx-2 pt-3" th:fragment="leftMenuFragment">
<div class="mx-3 pt-3" th:fragment="leftMenuFragment">
<div sec:authorize="hasRole('ROLE_ADMIN')">
<div class="list-group py-2">
<a href="/admin/categoryMgt" class="list-group-item list-group-item-action">게시판 분류 관리</a>
@ -13,7 +13,7 @@
</div>
</div>
<div class="d-grid gap-2">
<button class="bi bi-search btn btn-info"> 통합 검색</button>
<button class="bi bi-search btn btn-outline-info"> 통합 검색</button>
</div>
<div class="d-grid gap-2 pt-1">
<a class="btn btn-success" href="/board/contentWrite"><i class="bi bi-file-earmark-plus "></i> 자료 등록</a>