관리자 메인 페이지 전체 이력 조회 기능 추가.

master
강석 최 2021-12-29 11:49:18 +09:00
parent 09434e72aa
commit d580800ea1
7 changed files with 117 additions and 15 deletions

View File

@ -1,13 +1,8 @@
package com.dbnt.kcgfilemanager.controller; package com.dbnt.kcgfilemanager.controller;
import com.dbnt.kcgfilemanager.model.BoardCategory; import com.dbnt.kcgfilemanager.config.LogStatus;
import com.dbnt.kcgfilemanager.model.CategoryRole; import com.dbnt.kcgfilemanager.model.*;
import com.dbnt.kcgfilemanager.model.CommonCode; import com.dbnt.kcgfilemanager.service.*;
import com.dbnt.kcgfilemanager.model.UserInfo;
import com.dbnt.kcgfilemanager.service.BoardCategoryService;
import com.dbnt.kcgfilemanager.service.CategoryRoleService;
import com.dbnt.kcgfilemanager.service.CommonCodeService;
import com.dbnt.kcgfilemanager.service.UserInfoService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -25,10 +20,17 @@ public class adminController {
private final BoardCategoryService boardCategoryService; private final BoardCategoryService boardCategoryService;
private final UserInfoService userInfoService; private final UserInfoService userInfoService;
private final CategoryRoleService categoryRoleService; private final CategoryRoleService categoryRoleService;
private final BoardService boardService;
@GetMapping("/main") @GetMapping("/main")
public ModelAndView goAdmin() { public ModelAndView goAdmin(BoardLog boardLog) {
ModelAndView mav = new ModelAndView("admin/main"); ModelAndView mav = new ModelAndView("admin/main");
boardLog.setQueryInfo();
mav.addObject("statusMap", LogStatus.getStatusMap());
mav.addObject("boardLogList", boardService.selectBoardLogList(boardLog));
boardLog.setContentCnt(boardService.selectBoardLogListCnt(boardLog));
boardLog.setPaginationInfo();
mav.addObject("searchParams", boardLog);
return mav; return mav;
} }
@GetMapping("/categoryMgt") @GetMapping("/categoryMgt")

View File

@ -13,4 +13,7 @@ public interface BoardMapper {
Integer selectContentListCnt(Board board); Integer selectContentListCnt(Board board);
List<HashTag> selectHashTagListFromContentSeq(Integer contentSeq); List<HashTag> selectHashTagListFromContentSeq(Integer contentSeq);
List<BoardLog> selectBoardLogFromContentSeq(Integer contentSeq); List<BoardLog> selectBoardLogFromContentSeq(Integer contentSeq);
List<BoardLog> selectBoardLogList(BoardLog boardLog);
Integer selectBoardLogListCnt(BoardLog boardLog);
} }

View File

@ -16,7 +16,7 @@ import java.time.LocalDateTime;
@DynamicUpdate @DynamicUpdate
@Table(name = "BOARD_LOG") @Table(name = "BOARD_LOG")
@IdClass(BoardLog.BoardLogId.class) @IdClass(BoardLog.BoardLogId.class)
public class BoardLog { public class BoardLog extends BaseModel{
@Id @Id
@Column(name = "CONTENT_SEQ", nullable = false) @Column(name = "CONTENT_SEQ", nullable = false)
@ -34,6 +34,15 @@ public class BoardLog {
@Column(name = "CREATE_DATE") @Column(name = "CREATE_DATE")
private LocalDateTime createDate; private LocalDateTime createDate;
@Transient
private String title;
@Transient
private String categoryName;
@Transient
private Integer categorySeq;
@Transient
private String createName;
@Embeddable @Embeddable
@Data @Data
@NoArgsConstructor @NoArgsConstructor

View File

@ -285,4 +285,12 @@ public class BoardService {
double unitSelector = Math.floor(Math.log(fileSize)/Math.log(1024)); double unitSelector = Math.floor(Math.log(fileSize)/Math.log(1024));
return Math.round((fileSize/Math.pow(1024, unitSelector))*100)/100d+" "+units[(int)unitSelector]; return Math.round((fileSize/Math.pow(1024, unitSelector))*100)/100d+" "+units[(int)unitSelector];
} }
public List<BoardLog> selectBoardLogList(BoardLog boardLog) {
return boardMapper.selectBoardLogList(boardLog);
}
public Integer selectBoardLogListCnt(BoardLog boardLog) {
return boardMapper.selectBoardLogListCnt(boardLog);
}
} }

View File

@ -154,11 +154,35 @@
SELECT A.LOG_SEQ AS logSeq, SELECT A.LOG_SEQ AS logSeq,
A.LOG_STATUS AS logStatus, A.LOG_STATUS AS logStatus,
A.DESCRIPTION AS description, A.DESCRIPTION AS description,
B.NAME AS createId , B.NAME AS createName ,
A.CREATE_DATE AS createDate A.CREATE_DATE AS createDate
FROM BOARD_LOG A FROM BOARD_LOG A
INNER JOIN USER_INFO B ON A.CREATE_ID = B.USER_ID INNER JOIN USER_INFO B ON A.CREATE_ID = B.USER_ID
WHERE A.CONTENT_SEQ = ${categorySeq} WHERE A.CONTENT_SEQ = ${categorySeq}
ORDER BY LOG_SEQ DESC ORDER BY LOG_SEQ DESC
</select> </select>
<select id="selectBoardLogList" resultType="BoardLog" parameterType="BoardLog">
SELECT C.TITLE AS title,
C.CATEGORY_SEQ AS categorySeq,
D.CATEGORY_NAME AS categoryName,
A.CONTENT_SEQ AS contentSeq,
A.LOG_SEQ AS logSeq,
A.LOG_STATUS AS logStatus,
A.DESCRIPTION AS description,
B.NAME AS createName ,
A.CREATE_DATE AS createDate
FROM BOARD_LOG A
INNER JOIN USER_INFO B ON A.CREATE_ID = B.USER_ID
INNER JOIN BOARD C ON A.CONTENT_SEQ = C.CONTENT_SEQ
INNER JOIN CONTENT_POSITION D ON C.CATEGORY_SEQ = D.CATEGORY_SEQ
ORDER BY A.CREATE_DATE DESC
LIMIT #{rowCnt} OFFSET #{firstIndex}
</select>
<select id="selectBoardLogListCnt" resultType="int" parameterType="BoardLog">
SELECT COUNT(*)
FROM BOARD_LOG A
INNER JOIN USER_INFO B ON A.CREATE_ID = B.USER_ID
INNER JOIN BOARD C ON A.CONTENT_SEQ = C.CONTENT_SEQ
INNER JOIN CONTENT_POSITION D ON C.CATEGORY_SEQ = D.CATEGORY_SEQ
</select>
</mapper> </mapper>

View File

@ -9,10 +9,66 @@
<div class="col-12 card"> <div class="col-12 card">
<div class="card-body"> <div class="card-body">
<div class="row justify-content-start"> <div class="row justify-content-start">
<div class="col-7"> <div class="col-4">
<h5><i class="bi bi-square-fill"></i><span> 저장공간</span></h5>
</div> </div>
<div class="col-5"> <div class="col-8">
<h5><i class="bi bi-square-fill"></i><span> 전체 이력</span></h5>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>제목</th>
<th>행동</th>
<th>내용</th>
<th>사용자</th>
<th>발생일시</th>
</tr>
</thead>
<tbody>
<th:block th:each="log:${boardLogList}">
<tr>
<td colspan="5" class="p-0">
<a class="fs-6 text-decoration-none" th:href="|/board/contentList?categorySeq=${log.categorySeq}|"
th:text="${log.categoryName}"></a>
</td>
</tr>
<tr>
<td th:text="${log.title}"></td>
<td th:text="${statusMap.get(log.logStatus)}"></td>
<td th:text="${log.description}"></td>
<td th:text="${log.createName}"></td>
<td th:text="${#temporals.format(log.createDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
</tr>
</th:block>
</tbody>
</table>
<div class="row justify-content-center">
<div class="col-auto">
<nav aria-label="Page navigation">
<ul class="pagination">
<th:block th:if="${searchParams.pageIndex>3}">
<li class="page-item">
<a class="page-link" th:href="|/admin/main?pageIndex=${(searchParams.pageIndex)-3}|" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
</th:block>
<th:block th:each="num : ${#numbers.sequence(searchParams.startNum, searchParams.endNum)}">
<li class="page-item" th:classappend="${searchParams.pageIndex==num?'active':''}">
<a class="page-link" th:href="|/admin/main?pageIndex=${(num)}|" th:text="${num}"></a>
</li>
</th:block>
<th:block th:if="${searchParams.maxNum>searchParams.endNum+2}">
<li class="page-item">
<a class="page-link" th:href="|/admin/main?pageIndex=${(searchParams.pageIndex)+3}|" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</th:block>
</ul>
</nav>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -18,7 +18,7 @@
<td th:text="${log.logSeq}"></td> <td th:text="${log.logSeq}"></td>
<td th:text="${statusMap.get(log.logStatus)}"></td> <td th:text="${statusMap.get(log.logStatus)}"></td>
<td th:text="${log.description}"></td> <td th:text="${log.description}"></td>
<td th:text="${log.createId}"></td> <td th:text="${log.createName}"></td>
<td th:text="${#temporals.format(log.createDate, 'yyyy-MM-dd HH:mm:ss')}"></td> <td th:text="${#temporals.format(log.createDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
</tr> </tr>
</th:block> </th:block>