Merge branch 'master' of http://118.219.150.34:50501/DBNT/kcscDev into thkim
commit
a51af7d97c
|
|
@ -294,7 +294,7 @@ function EgovAdminDashboard(props) {
|
|||
<Box sx={{ p: 3, pb: 0 }}>
|
||||
<Stack spacing={2}>
|
||||
<Typography variant="h3" color="textSecondary">
|
||||
주간 현황
|
||||
이번주 현황
|
||||
</Typography>
|
||||
<Typography variant="h6">총 {totalDownloads}건</Typography>
|
||||
</Stack>
|
||||
|
|
|
|||
|
|
@ -57,6 +57,25 @@ function UserInfoModal({savedInfo, reloadFunction}){
|
|||
)
|
||||
}
|
||||
|
||||
function modalOpen(){
|
||||
EgovNet.requestFetch(
|
||||
'/admin/users/info?userId='+savedInfo?.userId,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
},
|
||||
(resp) => {
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
modalOpen();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal.Header closeButton>
|
||||
|
|
|
|||
|
|
@ -89,25 +89,25 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public String modifyCodeItem(TcCodeItem codeItem) {
|
||||
TcCodeItem savedItem = codeItemRepository.findById(
|
||||
new TcCodeItem.TcCodeItemId(codeItem.getItemCd(), codeItem.getGrpCd())
|
||||
).orElse(null);
|
||||
if (savedItem != null) {
|
||||
savedItem.setItemNm(codeItem.getItemNm());
|
||||
savedItem.setLastChgId(codeItem.getLastChgId());
|
||||
savedItem.setLastChgDt(codeItem.getLastChgDt());
|
||||
savedItem.setGrpOrder(codeItem.getGrpOrder());
|
||||
savedItem.setUseYn(codeItem.getUseYn());
|
||||
codeItemRepository.save(savedItem);
|
||||
return "modified";
|
||||
}else{
|
||||
return "validGrpCd";
|
||||
public String modifyCodeItem(TcCodeItem codeItem) {
|
||||
TcCodeItem savedItem = codeItemRepository.findById(
|
||||
new TcCodeItem.TcCodeItemId(codeItem.getItemCd(), codeItem.getGrpCd())
|
||||
).orElse(null);
|
||||
if (savedItem != null) {
|
||||
savedItem.setItemNm(codeItem.getItemNm());
|
||||
savedItem.setLastChgId(codeItem.getLastChgId());
|
||||
savedItem.setLastChgDt(codeItem.getLastChgDt());
|
||||
savedItem.setGrpOrder(codeItem.getGrpOrder());
|
||||
savedItem.setUseYn(codeItem.getUseYn());
|
||||
codeItemRepository.save(savedItem);
|
||||
return "modified";
|
||||
}else{
|
||||
return "validGrpCd";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<TcMenu> selectMenuList() {
|
||||
return menuMapper.selectMenuList();
|
||||
public List<TcMenu> selectMenuList() {
|
||||
return menuMapper.selectMenuList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
@ -165,4 +165,4 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
|
|||
}
|
||||
menuRoleRepository.saveAll(roleList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.dbnt.kcscbackend.admin.dashboard;
|
||||
|
||||
//import com.dbnt.kcscbackend.admin.dashboard.dto.MonthlyUserLogDTO;
|
||||
import com.dbnt.kcscbackend.admin.dashboard.service.AdminDashboardService;
|
||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||
import com.dbnt.kcscbackend.config.common.BaseController;
|
||||
|
|
@ -13,17 +12,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -71,7 +65,7 @@ public class AdminDashboardController extends BaseController {
|
|||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/file", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO getfile(@AuthenticationPrincipal LoginVO user)
|
||||
public ResultVO getFile(@AuthenticationPrincipal LoginVO user)
|
||||
throws Exception {
|
||||
|
||||
ResultVO resultVO = new ResultVO();
|
||||
|
|
@ -90,60 +84,4 @@ public class AdminDashboardController extends BaseController {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
// @Operation(
|
||||
// summary = "일별 사용자 현황 차트 조회",
|
||||
// description = "일별 사용자 현황 차트 조회",
|
||||
// tags = {"AdminDashboardController"}
|
||||
// )
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
// @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
// })
|
||||
// @RequestMapping(method = RequestMethod.GET, value = "/daily-user-log-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public ResultVO getDailyUserLogList() throws Exception {
|
||||
// ResultVO resultVO = new ResultVO();
|
||||
// Map<String, Object> resultMap = new HashMap<>();
|
||||
//
|
||||
// // 현재 날짜
|
||||
// // todo endDate 뒤에 .minus 지워야함
|
||||
// LocalDate endDate = LocalDate.now().minusMonths(6);
|
||||
// // 3개월 전 날짜 계산
|
||||
// LocalDate startDate = endDate.minusMonths(3);
|
||||
//
|
||||
// resultMap.put("dailyUserLogList", adminDashboardService.selectDailyUserLogList(startDate, endDate));
|
||||
// resultVO.setResult(resultMap);
|
||||
// return resultVO;
|
||||
// }
|
||||
//
|
||||
// @Operation(
|
||||
// summary = "월별 사용자 현황 차트 조회",
|
||||
// description = "월별 사용자 현황 차트 조회",
|
||||
// tags = {"AdminDashboardController"}
|
||||
// )
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
// @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
// })
|
||||
// @RequestMapping(method = RequestMethod.GET, value = "/monthly-user-log-list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public ResultVO getMonthlyUserLogList() throws Exception {
|
||||
// ResultVO resultVO = new ResultVO();
|
||||
// Map<String, Object> resultMap = new HashMap<>();
|
||||
//
|
||||
// // 현재 날짜
|
||||
// // todo endDate 뒤에 .minus 지워야함
|
||||
// LocalDate endDate = LocalDate.now().minusMonths(6);
|
||||
// // 3개월 전 날짜 계산
|
||||
// LocalDate startDate = endDate.minusMonths(3);
|
||||
//
|
||||
// List<Object[]> result = adminDashboardService.selectMonthlyUserLogList(startDate, endDate);
|
||||
// List<MonthlyUserLogDTO> monthlyUserLogDTOList = result.stream()
|
||||
// .map(row -> new MonthlyUserLogDTO((String) row[0], (BigInteger) row[1]))
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// resultMap.put("dailyUserLogList", monthlyUserLogDTOList);
|
||||
// resultVO.setResult(resultMap);
|
||||
// return resultVO;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
package com.dbnt.kcscbackend.admin.dashboard.dto;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.dashboard.entity.TnDailyUserLog;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class MonthlyUserLogDTO {
|
||||
private String logDt;
|
||||
private BigInteger logCnt;
|
||||
|
||||
public MonthlyUserLogDTO(Object[] row) {
|
||||
this.logDt = (String) row[0];
|
||||
this.logCnt = (BigInteger) row[1];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
package com.dbnt.kcscbackend.admin.dashboard.entity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tn_daily_user_log")
|
||||
public class TnDailyUserLog {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "dul_seq")
|
||||
private Long dulSeq;
|
||||
|
||||
@Column(name = "log_dt")
|
||||
private LocalDate logDt;
|
||||
|
||||
@Column(name = "log_cnt")
|
||||
private Integer logCnt;
|
||||
|
||||
@Column(name = "mobile_cnt")
|
||||
private Integer mobileCnt;
|
||||
|
||||
@Column(name = "pc_cnt")
|
||||
private Integer pcCnt;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.dbnt.kcscbackend.admin.dashboard.repository;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.dashboard.entity.TnDailyUserLog;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public interface TnDailyUserLogRepository extends JpaRepository<TnDailyUserLog, Long> {
|
||||
List<TnDailyUserLog> findByLogDtBetweenOrderByLogDt(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
@Query(value = "SELECT TO_CHAR(log_dt, 'YYYYMM') as log_dt, "
|
||||
+ "SUM(log_cnt) as log_cnt "
|
||||
+ "FROM tn_daily_user_log "
|
||||
+ "WHERE log_dt BETWEEN :startDate AND :endDate "
|
||||
+ "GROUP BY TO_CHAR(log_dt, 'YYYYMM') "
|
||||
+ "ORDER BY log_dt", nativeQuery = true)
|
||||
List<Object[]> selectMonthlyUserLogStatistics(@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.dbnt.kcscbackend.admin.logs.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "th_login_log")
|
||||
public class ThLoginLog {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "ll_seq")
|
||||
private Long llSeq;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
@Column(name = "access_dt")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime accessDt;
|
||||
|
||||
@Column(name = "ip_address")
|
||||
private String ipAddress;
|
||||
|
||||
@Column(name = "session_id")
|
||||
private String sessionId;
|
||||
|
||||
@Column(name = "access_type")
|
||||
private String accessType;
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ public class ThPrivacyLog extends BoardParams implements Serializable {
|
|||
private static final long serialVersionUID = -3779821913760046011L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "upl_seq")
|
||||
private Long uplSeq;
|
||||
|
||||
|
|
@ -46,4 +47,7 @@ public class ThPrivacyLog extends BoardParams implements Serializable {
|
|||
@Column(name = "access_dt")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate accessDt;
|
||||
|
||||
@Column(name = "session_id")
|
||||
private String sessionId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
import java.awt.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
|
@ -20,15 +19,22 @@ import java.awt.*;
|
|||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(name = "tn_daily_user_log")
|
||||
public class TnDailyUserConnLog {
|
||||
public class TnDailyUserLog {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "dul_seq")
|
||||
private Long dulSeq;
|
||||
|
||||
@Column(name = "log_cnt")
|
||||
private Long logCnt;
|
||||
|
||||
@Column(name = "log_dt")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate logDt;
|
||||
|
||||
@Column(name = "log_cnt")
|
||||
private Long logCnt;
|
||||
|
||||
@Column(name = "mobile_cnt")
|
||||
private Long mobileCnt;
|
||||
|
||||
@Column(name = "pc_cnt")
|
||||
private Long pcCnt;
|
||||
}
|
||||
|
|
@ -5,6 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface PrivacyLogsRepository extends JpaRepository<ThPrivacyLog, String> {
|
||||
public interface PrivacyLogsRepository extends JpaRepository<ThPrivacyLog, Long> {
|
||||
List<ThPrivacyLog> findAllByOrderByUplSeqDesc();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.dbnt.kcscbackend.admin.logs.repository;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.entity.ThLoginLog;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface ThLoginLogRepository extends JpaRepository<ThLoginLog, Long> {
|
||||
|
||||
List<ThLoginLog> findByUserIdAndAccessDtAfter(String userId, LocalDateTime accessDt);
|
||||
}
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
package com.dbnt.kcscbackend.admin.logs.repository;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserConnLog;
|
||||
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UserLogsRepository extends JpaRepository<TnDailyUserConnLog, Long> {
|
||||
public interface UserLogsRepository extends JpaRepository<TnDailyUserLog, Long> {
|
||||
|
||||
@Query(value = "SELECT COUNT(DISTINCT log_dt) "
|
||||
+ "FROM tn_daily_user_log "
|
||||
|
|
@ -21,5 +23,5 @@ public interface UserLogsRepository extends JpaRepository<TnDailyUserConnLog, Lo
|
|||
+ "ORDER BY log_dt asc", nativeQuery = true)
|
||||
List<Object[]> selectCountUser(@Param("startDate") String startDate, @Param("endDate") String endDate);
|
||||
|
||||
|
||||
Optional<TnDailyUserLog> findByLogDt(LocalDate logDt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,18 @@
|
|||
package com.dbnt.kcscbackend.admin.logs.service;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.entity.ThLoginLog;
|
||||
import com.dbnt.kcscbackend.admin.logs.entity.ThPrivacyLog;
|
||||
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog;
|
||||
import com.dbnt.kcscbackend.admin.logs.repository.PrivacyLogsRepository;
|
||||
import com.dbnt.kcscbackend.admin.logs.repository.ThLoginLogRepository;
|
||||
import com.dbnt.kcscbackend.admin.logs.repository.UserLogsRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -15,6 +22,8 @@ import java.util.Map;
|
|||
public class AdminLogsService extends EgovAbstractServiceImpl {
|
||||
|
||||
private final PrivacyLogsRepository privacyLogsRepository;
|
||||
private final ThLoginLogRepository loginLogRepository;
|
||||
private final UserLogsRepository userLogsRepository;
|
||||
|
||||
public Map<String, Object> selectPrivacyList() {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
|
@ -33,4 +42,55 @@ public class AdminLogsService extends EgovAbstractServiceImpl {
|
|||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void insertPrivacyLog(String userId, String ipAddress, String accessType, String targetUserId){
|
||||
ThPrivacyLog log = new ThPrivacyLog();
|
||||
log.setUserId(userId);
|
||||
log.setAccessDt(LocalDate.now());
|
||||
log.setIpAddress(ipAddress);
|
||||
log.setAccessType(accessType);
|
||||
log.setTargetUserId(targetUserId);
|
||||
privacyLogsRepository.save(log);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void insertLoginLog(String userId, String ipAddress, String accessToken, String accessType, String webType){
|
||||
ThLoginLog loginLog = new ThLoginLog();
|
||||
loginLog.setUserId(userId);
|
||||
loginLog.setIpAddress(ipAddress);
|
||||
loginLog.setSessionId(accessToken);
|
||||
loginLog.setAccessType(accessType);
|
||||
loginLog.setAccessDt(LocalDateTime.now());
|
||||
loginLogRepository.save(loginLog);
|
||||
|
||||
// 로그인 기록이면 tn_daily_yser_log 카운트 조정
|
||||
if(accessType.equals("Y")){
|
||||
//오늘 일자 로그 조회
|
||||
TnDailyUserLog userConnLog = userLogsRepository.findByLogDt(LocalDate.now()).orElse(null);
|
||||
if(userConnLog==null){
|
||||
userConnLog = new TnDailyUserLog();
|
||||
userConnLog.setLogDt(LocalDate.now());
|
||||
userConnLog.setLogCnt(0L);
|
||||
userConnLog.setMobileCnt(0L);
|
||||
userConnLog.setPcCnt(0L);
|
||||
}
|
||||
if(webType.equals("PC")){
|
||||
userConnLog.setPcCnt(userConnLog.getPcCnt()+1);
|
||||
}else{
|
||||
userConnLog.setMobileCnt(userConnLog.getMobileCnt()+1);
|
||||
}
|
||||
//같은 일자 로그인 기록 확인
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
now = now.minusHours(now.getHour());
|
||||
now = now.minusMinutes(now.getMinute());
|
||||
now = now.minusSeconds(now.getSecond());
|
||||
List<ThLoginLog> todayLoginLog = loginLogRepository.findByUserIdAndAccessDtAfter(userId, now);
|
||||
if(todayLoginLog.size()==1){
|
||||
userConnLog.setLogCnt(userConnLog.getLogCnt()+1);
|
||||
}
|
||||
userLogsRepository.save(userConnLog);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.dbnt.kcscbackend.admin.users;
|
||||
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
|
||||
import com.dbnt.kcscbackend.admin.users.service.AdminUsersService;
|
||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||
|
|
@ -8,6 +9,7 @@ import com.dbnt.kcscbackend.commonCode.service.CommonCodeService;
|
|||
import com.dbnt.kcscbackend.config.common.BaseController;
|
||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||
import com.dbnt.kcscbackend.config.util.ClientUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
|
@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -33,6 +36,7 @@ import java.util.Map;
|
|||
public class AdminUsersController extends BaseController {
|
||||
|
||||
private final AdminUsersService adminUsersService;
|
||||
private final AdminLogsService adminLogsService;
|
||||
private final CommonCodeService commonCodeService;
|
||||
|
||||
@Operation(
|
||||
|
|
@ -45,7 +49,8 @@ public class AdminUsersController extends BaseController {
|
|||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/list")
|
||||
public ResultVO getUserList(UserInfo params) throws Exception{
|
||||
public ResultVO getUserList(UserInfo params, HttpServletRequest request, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||
adminLogsService.insertPrivacyLog(user.getId(), ClientUtils.getRemoteIP(request), "PRV_LIST", null);
|
||||
ResultVO resultVO = new ResultVO();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
params.setQueryInfo();
|
||||
|
|
@ -68,11 +73,12 @@ public class AdminUsersController extends BaseController {
|
|||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/info")
|
||||
public ResultVO getUserInfo(UserInfo params) throws Exception{
|
||||
public ResultVO getUserInfo(UserInfo params, HttpServletRequest request, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||
adminLogsService.insertPrivacyLog(user.getId(), ClientUtils.getRemoteIP(request), "PRV_VIEW", params.getUserId());
|
||||
ResultVO resultVO = new ResultVO();
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("userInfo", adminUsersService.selectUserInfo(params.getUserSeq()));
|
||||
resultVO.setResult(resultMap);
|
||||
/*resultMap.put("userInfo", adminUsersService.selectUserInfo(params.getUserSeq()));
|
||||
resultVO.setResult(resultMap);*/
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +92,8 @@ public class AdminUsersController extends BaseController {
|
|||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/info")
|
||||
public ResultVO modifyUserInfo(@RequestBody @Valid UserInfo info, Errors errors, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||
public ResultVO modifyUserInfo(@RequestBody @Valid UserInfo info, Errors errors, HttpServletRequest request, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||
adminLogsService.insertPrivacyLog(user.getId(), ClientUtils.getRemoteIP(request), "PRV_UPDT", info.getUserId());
|
||||
ResultVO resultVO = new ResultVO();
|
||||
if(errors.hasErrors()){
|
||||
StringBuilder msg = new StringBuilder();
|
||||
|
|
@ -130,7 +137,8 @@ public class AdminUsersController extends BaseController {
|
|||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||
})
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = "/info", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResultVO deleteUserInfo(@RequestBody UserInfo info) throws Exception{
|
||||
public ResultVO deleteUserInfo(@RequestBody UserInfo info, HttpServletRequest request, @AuthenticationPrincipal LoginVO user) throws Exception{
|
||||
adminLogsService.insertPrivacyLog(user.getId(), ClientUtils.getRemoteIP(request), "PRV_DLT", info.getUserId());
|
||||
ResultVO resultVO = new ResultVO();
|
||||
adminUsersService.deleteUserInfo(info.getUserSeq());
|
||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.dbnt.kcscbackend.admin.users.service;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.repository.PrivacyLogsRepository;
|
||||
import com.dbnt.kcscbackend.admin.users.mapper.AdminUsersMapper;
|
||||
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||
import com.dbnt.kcscbackend.auth.repository.UserInfoRepository;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.dbnt.kcscbackend.config.security;
|
||||
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
|
||||
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||
import com.dbnt.kcscbackend.config.jwt.EgovJwtTokenUtil;
|
||||
import com.dbnt.kcscbackend.config.util.ClientUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
|
|
@ -9,11 +13,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
|
|||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
|
||||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
|
||||
import org.springframework.security.web.savedrequest.RequestCache;
|
||||
import org.springframework.security.web.savedrequest.SavedRequest;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
|
|
@ -23,7 +23,10 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class CustomLogoutSuccessHandler implements LogoutSuccessHandler {
|
||||
private final EgovJwtTokenUtil jwtTokenUtil;
|
||||
private final AdminLogsService adminLogsService;
|
||||
|
||||
@Override
|
||||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
|
|
@ -37,6 +40,11 @@ public class CustomLogoutSuccessHandler implements LogoutSuccessHandler {
|
|||
|
||||
HashMap<String, Object> resultMap = new HashMap<String, Object>();
|
||||
resultMap.put("resultCode", "200");
|
||||
|
||||
//로그아웃 이력 생성
|
||||
String accessToken = request.getHeader("Authorization");
|
||||
adminLogsService.insertLoginLog(jwtTokenUtil.getUserIdFromToken(accessToken), ClientUtils.getRemoteIP(request), accessToken, "N", ClientUtils.getWebType(request));
|
||||
|
||||
if (jsonConverter.canWrite(resultMap.getClass(), jsonMimeType)) {
|
||||
jsonConverter.write(resultMap, jsonMimeType, new ServletServerHttpResponse(response));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.dbnt.kcscbackend.config.security;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
|
||||
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||
import com.dbnt.kcscbackend.config.egov.EgovProperties;
|
||||
|
|
@ -26,11 +27,13 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
||||
|
||||
private final EgovJwtTokenUtil jwtTokenUtil;
|
||||
private final AdminLogsService adminLogsService;
|
||||
private RequestCache requestCache = new HttpSessionRequestCache();
|
||||
|
||||
private static final List<String> adminIpList = Arrays.asList(EgovProperties.getProperty("Globals.admin.allow-ip").split(","));
|
||||
|
|
@ -53,12 +56,14 @@ public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticati
|
|||
securityUser = (UserInfo) principal;
|
||||
}
|
||||
}
|
||||
String accessIp = ClientUtils.getRemoteIP(request);
|
||||
|
||||
// application/json(ajax) 요청일 경우 아래의 처리!
|
||||
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
|
||||
MediaType jsonMimeType = MediaType.APPLICATION_JSON;
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
/*if(securityUser.getUserId().equals("admin") && !adminIpList.contains(ClientUtils.getRemoteIP(request))){
|
||||
|
||||
/*if(securityUser.getUserId().equals("admin") && !adminIpList.contains(accessIp)){
|
||||
resultMap.put("resultCode", ResponseCode.FAILED.getCode());
|
||||
resultMap.put("resultMessage", "관리자 계정은 지정된 아이피에서만 접속할 수 있습니다.\n필요한 경우 관리자에게 요청하십시오.\n접속자 아이피: "+ClientUtils.getRemoteIP(request));
|
||||
}else{
|
||||
|
|
@ -78,6 +83,9 @@ public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticati
|
|||
resultMap.put("accessToken", accessToken);
|
||||
resultMap.put("refreshToken", refreshToken);
|
||||
|
||||
//로그인 로그 기록
|
||||
adminLogsService.insertLoginLog(securityUser.getUserId(), accessIp, accessToken, "Y", ClientUtils.getWebType(request));
|
||||
|
||||
if (jsonConverter.canWrite(resultMap.getClass(), jsonMimeType)) {
|
||||
jsonConverter.write(resultMap, jsonMimeType, new ServletServerHttpResponse(response));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.dbnt.kcscbackend.config.security;
|
||||
|
||||
import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
|
||||
import com.dbnt.kcscbackend.config.jwt.EgovJwtTokenUtil;
|
||||
import com.dbnt.kcscbackend.config.jwt.JwtAuthenticationEntryPoint;
|
||||
import com.dbnt.kcscbackend.config.jwt.JwtAuthenticationFilter;
|
||||
|
|
@ -49,6 +50,7 @@ public class SecurityConfig {
|
|||
private UserDetailsService loginService;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final EgovJwtTokenUtil egovJwtTokenUtil;
|
||||
private final AdminLogsService adminLogsService;
|
||||
|
||||
//Http Methpd : Get 인증예외 List
|
||||
private String[] AUTH_GET_WHITELIST = {
|
||||
|
|
@ -131,7 +133,7 @@ public class SecurityConfig {
|
|||
|
||||
http.addFilterBefore(jsonUsernamePasswordAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
http.logout().logoutRequestMatcher(new AntPathRequestMatcher("/auth/logout")).logoutSuccessHandler(new CustomLogoutSuccessHandler());
|
||||
http.logout().logoutRequestMatcher(new AntPathRequestMatcher("/auth/logout")).logoutSuccessHandler(new CustomLogoutSuccessHandler(egovJwtTokenUtil, adminLogsService));
|
||||
|
||||
return http.build();
|
||||
}
|
||||
|
|
@ -145,7 +147,7 @@ public class SecurityConfig {
|
|||
|
||||
@Bean
|
||||
public JsonAuthenticationFilter jsonUsernamePasswordAuthenticationFilter() {
|
||||
JsonAuthenticationFilter jsonAuthenticationFilter = new JsonAuthenticationFilter(objectMapper, new CustomUrlAuthenticationSuccessHandler(egovJwtTokenUtil), loginFailureHandler());
|
||||
JsonAuthenticationFilter jsonAuthenticationFilter = new JsonAuthenticationFilter(objectMapper, new CustomUrlAuthenticationSuccessHandler(egovJwtTokenUtil, adminLogsService), loginFailureHandler());
|
||||
jsonAuthenticationFilter.setAuthenticationManager(authenticationManager());
|
||||
return jsonAuthenticationFilter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,20 @@ public class ClientUtils {
|
|||
|
||||
return ip;
|
||||
}
|
||||
|
||||
public static String getWebType(HttpServletRequest request) {
|
||||
String filter = "iphone|ipod|android|windows ce|blackberry|symbian|windows phone|webos|opera mini|opera mobi|polaris|iemobile|lgtelecom|nokia|sonyericsson|lg|samsung";
|
||||
String filters[] = filter.split("\\|");
|
||||
String webType = "";
|
||||
|
||||
for(String tmp : filters){
|
||||
if (request.getHeader("User-Agent").toLowerCase().contains(tmp)) {
|
||||
webType = "MOBILE";
|
||||
break;
|
||||
} else {
|
||||
webType = "PC";
|
||||
}
|
||||
}
|
||||
return webType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue