대시보드 방문자 수 표현 기능 추가.
parent
a78e10480c
commit
5d7b47fc13
|
|
@ -0,0 +1,12 @@
|
|||
package com.mca.cmmn.mapper;
|
||||
|
||||
import com.mca.cmmn.vo.BaseSearchVO;
|
||||
import com.mca.cmmn.vo.LogVO;
|
||||
import egovframework.rte.psl.dataaccess.mapper.Mapper;
|
||||
|
||||
@Mapper("logMapper")
|
||||
public interface LogMapper {
|
||||
void insertLog(LogVO logVO);
|
||||
|
||||
int selectLoginCnt(BaseSearchVO searchVO);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.mca.cmmn.service;
|
||||
|
||||
import com.mca.cmmn.mapper.LogMapper;
|
||||
import com.mca.cmmn.vo.BaseSearchVO;
|
||||
import com.mca.cmmn.vo.LogVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service("logService")
|
||||
public class LogService {
|
||||
|
||||
@Resource(name="logMapper")
|
||||
LogMapper logMapper;
|
||||
|
||||
public void insertLog(LogVO logVO){
|
||||
logMapper.insertLog(logVO);
|
||||
}
|
||||
|
||||
public int selectLoginCnt(BaseSearchVO searchVO){
|
||||
return logMapper.selectLoginCnt(searchVO);
|
||||
}
|
||||
|
||||
// public LayersVO selectFacility(String layer) {
|
||||
// return layersMapper.selectFacility(layer);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.mca.cmmn.vo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class BaseSearchVO {
|
||||
|
||||
/**
|
||||
|
|
@ -34,6 +36,9 @@ public class BaseSearchVO {
|
|||
/** recordCountPerPage */
|
||||
private int recordCountPerPage = 10;
|
||||
|
||||
private String searchStartDate;
|
||||
private String searchEndDate;
|
||||
|
||||
public String getSearchCondition() {
|
||||
return searchCondition;
|
||||
}
|
||||
|
|
@ -105,4 +110,21 @@ public class BaseSearchVO {
|
|||
public void setRecordCountPerPage(int recordCountPerPage) {
|
||||
this.recordCountPerPage = recordCountPerPage;
|
||||
}
|
||||
|
||||
|
||||
public String getSearchStartDate() {
|
||||
return searchStartDate;
|
||||
}
|
||||
|
||||
public void setSearchStartDate(String searchStartDate) {
|
||||
this.searchStartDate = searchStartDate;
|
||||
}
|
||||
|
||||
public String getSearchEndDate() {
|
||||
return searchEndDate;
|
||||
}
|
||||
|
||||
public void setSearchEndDate(String searchEndDate) {
|
||||
this.searchEndDate = searchEndDate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.mca.cmmn.vo;
|
||||
|
||||
public enum LogActions {
|
||||
LOGIN("login"),
|
||||
LOGOUT("logout");
|
||||
|
||||
private String value;
|
||||
|
||||
LogActions(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue(){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.mca.cmmn.vo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class LogVO {
|
||||
|
||||
private String log_cd;
|
||||
private String userid;
|
||||
private String action;
|
||||
private String etc;
|
||||
private LocalDateTime created_date;
|
||||
|
||||
public String getLog_cd() {
|
||||
return log_cd;
|
||||
}
|
||||
|
||||
public void setLog_cd(String log_cd) {
|
||||
this.log_cd = log_cd;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getEtc() {
|
||||
return etc;
|
||||
}
|
||||
|
||||
public void setEtc(String etc) {
|
||||
this.etc = etc;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreated_date() {
|
||||
return created_date;
|
||||
}
|
||||
|
||||
public void setCreated_date(LocalDateTime created_date) {
|
||||
this.created_date = created_date;
|
||||
}
|
||||
|
||||
public void setLog(String userid, String logAction, String etc, LocalDateTime now){
|
||||
setLog_cd(now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")).substring(2));
|
||||
setUserid(userid);
|
||||
setAction(logAction);
|
||||
setEtc(etc);
|
||||
setCreated_date(now);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,15 @@
|
|||
package com.mca.cmmn.web;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.mca.cmmn.service.LogService;
|
||||
import com.mca.cmmn.vo.BaseSearchVO;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
|
@ -60,6 +64,9 @@ public class AdminController {
|
|||
@Resource(name="fieldDataService")
|
||||
private FieldDataService fieldDataService;
|
||||
|
||||
@Resource(name = "logService")
|
||||
private LogService logService;
|
||||
|
||||
/**
|
||||
* 대시보드 페이지 이동
|
||||
*
|
||||
|
|
@ -79,6 +86,15 @@ public class AdminController {
|
|||
int standByCount = userService.selectUserStandByCount();
|
||||
model.addAttribute("standByCount", standByCount);
|
||||
|
||||
BaseSearchVO searchVO = new BaseSearchVO();
|
||||
LocalDate searchStartDate = LocalDate.now();
|
||||
searchVO.setSearchStartDate(searchStartDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
searchVO.setSearchEndDate(searchStartDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
model.addAttribute("dayLoginCount", logService.selectLoginCnt(searchVO));
|
||||
|
||||
searchVO.setSearchStartDate(searchStartDate.minusMonths(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
model.addAttribute("monthLoginCount", logService.selectLoginCnt(searchVO));
|
||||
|
||||
return "admin/dashBoard";
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
package com.mca.sec;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.mca.cmmn.service.LogService;
|
||||
import com.mca.cmmn.vo.LogActions;
|
||||
import com.mca.cmmn.vo.LogVO;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
|
||||
|
|
@ -16,32 +21,45 @@ import com.mca.sec.UserUtil;
|
|||
public class LoginSuccessHandler implements AuthenticationSuccessHandler{
|
||||
private String roleName;
|
||||
|
||||
@Resource(name="logService")
|
||||
private LogService logService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||
Authentication authentication) throws IOException, ServletException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
LoginUserVO user = UserUtil.getMemberInfo();
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("userVO", user);
|
||||
|
||||
LoginSuccessHandler loginSuccessHandler = new LoginSuccessHandler();
|
||||
authentication.getAuthorities().forEach(authority ->{
|
||||
loginSuccessHandler.roleName = authority.getAuthority();
|
||||
});
|
||||
|
||||
if(loginSuccessHandler.roleName.equals("ROLE_USER")) {
|
||||
response.sendRedirect("/map/request");
|
||||
return;
|
||||
}else if(loginSuccessHandler.roleName.equals("ROLE_ADMIN")) {
|
||||
response.sendRedirect("/admin/dashBoard");
|
||||
return;
|
||||
}else if(loginSuccessHandler.roleName.equals("ROLE_DISABLE")) {
|
||||
response.sendRedirect("/login?fail");
|
||||
return;
|
||||
}
|
||||
response.sendRedirect("/");
|
||||
if(user == null){
|
||||
response.sendRedirect("/");
|
||||
}else{
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("userVO", user);
|
||||
|
||||
LoginSuccessHandler loginSuccessHandler = new LoginSuccessHandler();
|
||||
authentication.getAuthorities().forEach(authority ->{
|
||||
loginSuccessHandler.roleName = authority.getAuthority();
|
||||
});
|
||||
|
||||
LogVO logVO = new LogVO();
|
||||
logVO.setLog(user.getUserid(), LogActions.LOGIN.getValue(), null, LocalDateTime.now());
|
||||
logService.insertLog(logVO);
|
||||
|
||||
switch (loginSuccessHandler.roleName) {
|
||||
case "ROLE_USER":
|
||||
response.sendRedirect("/map/request");
|
||||
return;
|
||||
case "ROLE_ADMIN":
|
||||
response.sendRedirect("/admin/dashBoard");
|
||||
return;
|
||||
case "ROLE_DISABLE":
|
||||
response.sendRedirect("/login?fail");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,24 @@
|
|||
package com.mca.sec;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.mca.cmmn.service.LogService;
|
||||
import com.mca.cmmn.vo.LogActions;
|
||||
import com.mca.cmmn.vo.LogVO;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
|
||||
|
||||
public class LogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler{
|
||||
|
||||
|
||||
@Resource(name="logService")
|
||||
private LogService logService;
|
||||
|
||||
private String successUrl = "/";
|
||||
|
||||
public void setSuccessUrl(String successUrl){
|
||||
|
|
@ -18,8 +26,14 @@ public class LogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler{
|
|||
}
|
||||
|
||||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
setDefaultTargetUrl(successUrl);
|
||||
super.onLogoutSuccess(request, response, authentication);
|
||||
}
|
||||
|
||||
LogVO logVO = new LogVO();
|
||||
logVO.setLog(authentication.getName(), LogActions.LOGOUT.getValue(), null, LocalDateTime.now());
|
||||
logService.insertLog(logVO);
|
||||
|
||||
setDefaultTargetUrl(successUrl);
|
||||
super.onLogoutSuccess(request, response, authentication);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mca.cmmn.mapper.LogMapper">
|
||||
|
||||
<insert id="insertLog" parameterType="logVO">
|
||||
insert into t_logs values(
|
||||
#{log_cd}, #{userid}, #{action}, #{etc}, #{created_date}
|
||||
);
|
||||
</insert>
|
||||
|
||||
<select id="selectLoginCnt" parameterType="baseSearchVO" resultType="int">
|
||||
select
|
||||
count(*)
|
||||
from t_logs
|
||||
where created_date >= concat(#{searchStartDate},' 00:00:00')
|
||||
and created_date <= concat(#{searchEndDate}' 23:59:59')
|
||||
and action = 'login'
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -2,24 +2,25 @@
|
|||
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
|
||||
<configuration>
|
||||
<typeAliases>
|
||||
<!-- <typeAlias alias="searchVO" type="egovframework.example.sample.service.SampleDefaultVO"/> -->
|
||||
|
||||
<typeAlias alias="baseSearchVO" type="com.mca.cmmn.vo.BaseSearchVO" />
|
||||
<typeAlias alias="layersVO" type="com.mca.cmmn.vo.LayersVO" />
|
||||
<typeAlias alias="areaCodeVO" type="com.mca.cmmn.vo.AreaCodeVO" />
|
||||
|
||||
<typeAlias alias="useRequestVO" type="com.mca.map.vo.UseRequestVO"/>
|
||||
<typeAlias alias="useRequestSearchVO" type="com.mca.map.vo.UseRequestSearchVO" />
|
||||
<typeAlias alias="useHistoryVO" type="com.mca.map.vo.UseHistoryVO"/>
|
||||
<typeAlias alias="useHistorySearchVO" type="com.mca.map.vo.UseHistorySearchVO" />
|
||||
<typeAlias alias="fieldDataVO" type="com.mca.map.vo.FieldDataVO"/>
|
||||
<typeAlias alias="fieldDataSearchVO" type="com.mca.map.vo.FieldDataSearchVO" />
|
||||
|
||||
<typeAlias alias="securityRolesVO" type="com.mca.sec.vo.SecurityRolesVO" />
|
||||
<typeAlias alias="loginUserVO" type="com.mca.sec.vo.LoginUserVO" />
|
||||
|
||||
<typeAlias alias="userVO" type="com.mca.user.vo.UserVO"/>
|
||||
<typeAlias alias="userSearchVO" type="com.mca.user.vo.UserSearchVO"/>
|
||||
</typeAliases>
|
||||
<typeAliases>
|
||||
<!-- <typeAlias alias="searchVO" type="egovframework.example.sample.service.SampleDefaultVO"/> -->
|
||||
|
||||
<typeAlias alias="baseSearchVO" type="com.mca.cmmn.vo.BaseSearchVO" />
|
||||
<typeAlias alias="layersVO" type="com.mca.cmmn.vo.LayersVO" />
|
||||
<typeAlias alias="logVO" type="com.mca.cmmn.vo.LogVO" />
|
||||
<typeAlias alias="areaCodeVO" type="com.mca.cmmn.vo.AreaCodeVO" />
|
||||
|
||||
<typeAlias alias="useRequestVO" type="com.mca.map.vo.UseRequestVO"/>
|
||||
<typeAlias alias="useRequestSearchVO" type="com.mca.map.vo.UseRequestSearchVO" />
|
||||
<typeAlias alias="useHistoryVO" type="com.mca.map.vo.UseHistoryVO"/>
|
||||
<typeAlias alias="useHistorySearchVO" type="com.mca.map.vo.UseHistorySearchVO" />
|
||||
<typeAlias alias="fieldDataVO" type="com.mca.map.vo.FieldDataVO"/>
|
||||
<typeAlias alias="fieldDataSearchVO" type="com.mca.map.vo.FieldDataSearchVO" />
|
||||
|
||||
<typeAlias alias="securityRolesVO" type="com.mca.sec.vo.SecurityRolesVO" />
|
||||
<typeAlias alias="loginUserVO" type="com.mca.sec.vo.LoginUserVO" />
|
||||
|
||||
<typeAlias alias="userVO" type="com.mca.user.vo.UserVO"/>
|
||||
<typeAlias alias="userSearchVO" type="com.mca.user.vo.UserSearchVO"/>
|
||||
</typeAliases>
|
||||
</configuration>
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
</div>
|
||||
<div class="col-auto">
|
||||
<p class="mb-0 text-black-50">오늘 방문자 수</p>
|
||||
<h3><c:out value="${statusCnt}" /></h3>
|
||||
<h3><c:out value="${dayLoginCount}" /></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
</div>
|
||||
<div class="col-auto">
|
||||
<p class="mb-0 text-black-50">최근 한달 방문자 수</p>
|
||||
<h3><c:out value="${statusCnt}" /></h3>
|
||||
<h3><c:out value="${monthLoginCount}" /></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ a {
|
|||
transform: translate(-50%);
|
||||
background-color: rgba(55, 55, 55, 1);
|
||||
border: 1px solid #ccc;
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
box-shadow: 5px 5px 20px grey;
|
||||
}
|
||||
.login_title{
|
||||
|
|
|
|||
Loading…
Reference in New Issue