feat: access log JPA 제거

main
Jonguk. Lim 4 months ago
parent 8fa4829c03
commit ed6c5001ea

@ -179,7 +179,7 @@
<dependency> <dependency>
<groupId>com.github.gavlyukovskiy</groupId> <groupId>com.github.gavlyukovskiy</groupId>
<artifactId>p6spy-spring-boot-starter</artifactId> <artifactId>p6spy-spring-boot-starter</artifactId>
<version>1.8.0</version> <version>1.8.1</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.github.gavlyukovskiy</groupId>--> <!-- <groupId>com.github.gavlyukovskiy</groupId>-->

@ -0,0 +1,26 @@
// package cokr.xit.ens.biz.traffic.cheonan.signtalk.mapper;
//
// import org.apache.ibatis.annotations.Delete;
// import org.apache.ibatis.annotations.Insert;
// import org.apache.ibatis.annotations.Mapper;
// import org.apache.ibatis.annotations.Param;
// import org.apache.ibatis.annotations.Select;
// import org.apache.ibatis.annotations.Update;
//
// import cokr.xit.ens.biz.traffic.cheonan.signtalk.dto.TcaRlaybsnmManageDTO;
//
// @Mapper
// public interface TcaRlaybsnmManageMapper {
//
// @Select("SELECT * FROM TCA_RLAYBSNM_MANAGE WHERE id = #{id}")
// TcaRlaybsnmManageDTO findById(@Param("id") String id);
//
// @Insert("INSERT INTO TCA_RLAYBSNM_MANAGE (id, ...) VALUES (#{id}, ...)")
// void insert(TcaRlaybsnmManageDTO dto);
//
// @Update("UPDATE TCA_RLAYBSNM_MANAGE SET ... WHERE id = #{id}")
// void update(TcaRlaybsnmManageDTO dto);
//
// @Delete("DELETE FROM TCA_RLAYBSNM_MANAGE WHERE id = #{id}")
// void deleteById(@Param("id") String id);
// }

@ -1,5 +1,14 @@
package cokr.xit.ens.biz.traffic.cheonan.signtalk.service; package cokr.xit.ens.biz.traffic.cheonan.signtalk.service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cokr.xit.ens.biz.traffic.cheonan.code.SndngProcessSttusCd; import cokr.xit.ens.biz.traffic.cheonan.code.SndngProcessSttusCd;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.TcaElctrnNticSndng; import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.TcaElctrnNticSndng;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.repository.TcaElctrnNticSndngRepository; import cokr.xit.ens.biz.traffic.cheonan.signtalk.domain.repository.TcaElctrnNticSndngRepository;
@ -14,14 +23,6 @@ import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.event.IntgrnNotiSendReserveEvent; import cokr.xit.ens.modules.common.ctgy.intgrnnoti.service.event.IntgrnNotiSendReserveEvent;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@ -42,6 +43,7 @@ public class TrafficCaSigntalkService {
/** /**
* (TRAFFIC -> ENS) * (TRAFFIC -> ENS)
*/ */
@Transactional(readOnly = true)
public EnsResponseVO accept(String elctrnNticSndngId) { public EnsResponseVO accept(String elctrnNticSndngId) {
try { try {

@ -1,17 +1,17 @@
package cokr.xit.ens.core.aop; package cokr.xit.ens.core.aop;
import cokr.xit.ens.core.utils.CmmnUtil;
import cokr.xit.ens.core.monitor.Message;
import lombok.Builder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import cokr.xit.ens.core.monitor.Message;
import cokr.xit.ens.core.utils.CmmnUtil;
import lombok.Builder;
@Builder @Builder
public class AccessErrorMessage implements Message { public class AccessErrorMessage implements Message {
private final String ACTIVE_PROFILE; private final String ACTIVE_PROFILE;
private final AccessLog accessLog; private final AccessLogDTO accessLogDTO;
private final String serverUrl; private final String serverUrl;
public String create() { public String create() {
@ -27,11 +27,11 @@ public class AccessErrorMessage implements Message {
.append("[Occurrence time]: ") .append("[Occurrence time]: ")
.append(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"))) .append(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")))
.append(System.getProperty("line.separator")) .append(System.getProperty("line.separator"))
.append("[Client Ip]: " + accessLog.getIp()) .append("[Client Ip]: " + accessLogDTO.getIp())
.append(System.getProperty("line.separator")) .append(System.getProperty("line.separator"))
.append("[Request Url]: " + accessLog.getHttpMethod() + " " + accessLog.getUrl()) .append("[Request Url]: " + accessLogDTO.getHttpMethod() + " " + accessLogDTO.getUrl())
.append(System.getProperty("line.separator")) .append(System.getProperty("line.separator"))
.append("[Request Param]: " + accessLog.getParam()) .append("[Request Param]: " + accessLogDTO.getParam())
.append(System.getProperty("line.separator")) .append(System.getProperty("line.separator"))
// .append("[Details]: ") // .append("[Details]: ")
// .append(accessLog.getErrorMsg()) // .append(accessLog.getErrorMsg())
@ -39,7 +39,7 @@ public class AccessErrorMessage implements Message {
.append(System.getProperty("line.separator")) .append(System.getProperty("line.separator"))
.append("[StackTrace]:") .append("[StackTrace]:")
.append(System.getProperty("line.separator")) .append(System.getProperty("line.separator"))
.append(accessLog.getErrorMsg()); .append(accessLogDTO.getErrorMsg());
return sb.toString(); return sb.toString();
} }

@ -1,15 +1,15 @@
package cokr.xit.ens.core.aop; package cokr.xit.ens.core.aop;
import cokr.xit.ens.core.aop.repository.AccessLogRepository; import java.io.BufferedReader;
import cokr.xit.ens.core.exception.EnsException; import java.util.Arrays;
import cokr.xit.ens.core.exception.code.EnsErrCd; import java.util.List;
import cokr.xit.ens.core.monitor.slack.event.MonitorEvent; import java.util.Map;
import cokr.xit.ens.core.utils.CmmnUtil; import java.util.regex.Matcher;
import cokr.xit.ens.core.utils.JwtUtil; import java.util.regex.Pattern;
import com.fasterxml.jackson.core.JsonProcessingException; import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor; import javax.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
@ -23,14 +23,16 @@ import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.BufferedReader; import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Arrays;
import java.util.List; import cokr.xit.ens.core.exception.EnsException;
import java.util.Map; import cokr.xit.ens.core.exception.code.EnsErrCd;
import java.util.regex.Matcher; import cokr.xit.ens.core.monitor.slack.event.MonitorEvent;
import java.util.regex.Pattern; import cokr.xit.ens.core.utils.CmmnUtil;
import java.util.stream.Collectors; import cokr.xit.ens.core.utils.JwtUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/** /**
* @author () * @author ()
@ -51,7 +53,7 @@ public class AccessLogAspect {
@Value("${spring.profiles.active}") @Value("${spring.profiles.active}")
private String ACTIVE_PROFILE; private String ACTIVE_PROFILE;
private final AccessLogRepository accessLogRepository; private final AccessLogService accessLogService;
private final String ACCESS_TOKEN_NAME = "Authorization"; private final String ACCESS_TOKEN_NAME = "Authorization";
private final ApplicationEventPublisher applicationEventPublisher; private final ApplicationEventPublisher applicationEventPublisher;
@ -88,14 +90,12 @@ public class AccessLogAspect {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Object result = null; Object result = null;
AccessLog accessLog = null; AccessLogDTO accessLogDTO = null;
try { try {
log.info("[BEFORE] : ..."); log.info("[BEFORE] : ...");
accessLog = this.setRequestInfo(request); accessLogDTO = this.setRequestInfo(request);
accessLogRepository.save(accessLog); accessLogService.save(accessLogDTO);
if (this.isCertified(request)) { if (this.isCertified(request)) {
@ -103,8 +103,8 @@ public class AccessLogAspect {
log.info("[AFTER] : ..."); log.info("[AFTER] : ...");
this.setResponseInfo(accessLog, result); this.setResponseInfo(accessLogDTO, result);
accessLogRepository.save(accessLog); accessLogService.save(accessLogDTO);
} else { } else {
@ -117,16 +117,15 @@ public class AccessLogAspect {
log.error(String.format("[NoAuth] : %s => %s", ACCESS_TOKEN_NAME, request.getHeader(ACCESS_TOKEN_NAME))); log.error(String.format("[NoAuth] : %s => %s", ACCESS_TOKEN_NAME, request.getHeader(ACCESS_TOKEN_NAME)));
accessLog.setResponseNoAuth(msg); accessLogDTO.setResponseNoAuth(msg);
accessLogRepository.save(accessLog); accessLogService.save(accessLogDTO);
} }
} catch (EnsException e) { } catch (EnsException e) {
log.error(String.format("[ERROR] : %s", e.getMessage())); log.error(String.format("[ERROR] : %s", e.getMessage()));
accessLog.setResponseFail(String.format("%s: %s", e.getErrCd(), e.getMessage())); accessLogDTO.setResponseFail(String.format("%s: %s", e.getErrCd(), e.getMessage()));
accessLogRepository.save(accessLog); accessLogService.save(accessLogDTO);
if (result == null) { if (result == null) {
EnsResponseVO restResponseVO = EnsResponseVO EnsResponseVO restResponseVO = EnsResponseVO
.errBuilder() .errBuilder()
@ -138,8 +137,8 @@ public class AccessLogAspect {
} catch (Exception e) { } catch (Exception e) {
log.error(String.format("[%s ERROR] : %s", EnsErrCd.UNKNOWN, e.getMessage()), e); log.error(String.format("[%s ERROR] : %s", EnsErrCd.UNKNOWN, e.getMessage()), e);
accessLog.setResponseFail(String.format("%s: %s", EnsErrCd.UNKNOWN, CmmnUtil.printStackTraceToString(e))); accessLogDTO.setResponseFail(String.format("%s: %s", EnsErrCd.UNKNOWN, CmmnUtil.printStackTraceToString(e)));
accessLogRepository.save(accessLog); accessLogService.save(accessLogDTO);
if (result == null) { if (result == null) {
EnsResponseVO restResponseVO = EnsResponseVO EnsResponseVO restResponseVO = EnsResponseVO
.errBuilder() .errBuilder()
@ -150,7 +149,7 @@ public class AccessLogAspect {
applicationEventPublisher.publishEvent(MonitorEvent.builder() applicationEventPublisher.publishEvent(MonitorEvent.builder()
.message(AccessErrorMessage.builder().ACTIVE_PROFILE(ACTIVE_PROFILE).accessLog(accessLog).serverUrl(CmmnUtil.getServerUrl()).build()) .message(AccessErrorMessage.builder().ACTIVE_PROFILE(ACTIVE_PROFILE).accessLogDTO(accessLogDTO).serverUrl(CmmnUtil.getServerUrl()).build())
.build()); .build());
} }
@ -174,7 +173,7 @@ public class AccessLogAspect {
* @date: 2021. 11. 30. * @date: 2021. 11. 30.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private AccessLog setRequestInfo(HttpServletRequest request) throws JsonProcessingException { private AccessLogDTO setRequestInfo(HttpServletRequest request) throws JsonProcessingException {
String sessionId = request.getSession().getId(); String sessionId = request.getSession().getId();
String param = null; String param = null;
try { try {
@ -185,7 +184,7 @@ public class AccessLogAspect {
param = String.format("[요청 parameter 변환 실패]: %s", e.getMessage()); param = String.format("[요청 parameter 변환 실패]: %s", e.getMessage());
} }
return AccessLog.reqBuilder() return AccessLogDTO.reqBuilder()
.accessToken(request.getHeader(ACCESS_TOKEN_NAME)) .accessToken(request.getHeader(ACCESS_TOKEN_NAME))
.sessionId(sessionId) .sessionId(sessionId)
.ip(this.getClientIpAddr(request)) .ip(this.getClientIpAddr(request))
@ -199,12 +198,12 @@ public class AccessLogAspect {
/** /**
* <pre> : </pre> * <pre> : </pre>
* *
* @param accessLog * @param accessLogDTO
* @param result * @param result
* @author: * @author:
* @date: 2021. 11. 30. * @date: 2021. 11. 30.
*/ */
private void setResponseInfo(AccessLog accessLog, Object result) { private void setResponseInfo(AccessLogDTO accessLogDTO, Object result) {
String response = null; String response = null;
if (result instanceof String) if (result instanceof String)
response = (String) result; response = (String) result;
@ -215,7 +214,7 @@ public class AccessLogAspect {
else else
response = String.valueOf(result); response = String.valueOf(result);
accessLog.setResponseCompleted(response); accessLogDTO.setResponseCompleted(response);
} }

@ -1,28 +1,15 @@
package cokr.xit.ens.core.aop; package cokr.xit.ens.core.aop;
import cokr.xit.ens.core.aop.code.AccessStatusCd;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Entity import cokr.xit.ens.core.aop.code.AccessStatusCd;
@Getter import lombok.Builder;
@RequiredArgsConstructor import lombok.Data;
@Table(name = "ens_access_log", schema = "", catalog = "")
public class AccessLog {
@Id @Data
@GeneratedValue(strategy = GenerationType.AUTO) public class AccessLogDTO {
private Long logId; private Long logId;
@Column(length = 2000)
private String accessToken; private String accessToken;
private String reqSystemId; private String reqSystemId;
@ -37,27 +24,22 @@ public class AccessLog {
private String uri; private String uri;
@Lob
private String param; private String param;
@Lob
private String response; private String response;
@Enumerated(EnumType.STRING)
private AccessStatusCd status; private AccessStatusCd status;
@Lob
private String errorMsg; private String errorMsg;
@CreationTimestamp
private LocalDateTime startDt; private LocalDateTime startDt;
@UpdateTimestamp
private LocalDateTime endDt; private LocalDateTime endDt;
@Builder(builderClassName = "reqBuilder", builderMethodName = "reqBuilder") @Builder(builderClassName = "reqBuilder", builderMethodName = "reqBuilder")
public AccessLog(String accessToken, String sessionId, String ip, String httpMethod, String url, String uri, String param) { public AccessLogDTO(String accessToken, String sessionId, String ip, String httpMethod, String url, String uri, String param) {
this.accessToken = accessToken; this.accessToken = accessToken;
this.sessionId = sessionId; this.sessionId = sessionId;
this.ip = ip; this.ip = ip;

@ -0,0 +1,39 @@
package cokr.xit.ens.core.aop;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import cokr.xit.ens.core.aop.mapper.IAccessLogMapper;
import lombok.RequiredArgsConstructor;
/**
* <pre>
* description :
* packageName : cokr.xit.ens.core.aop
* fileName : AccessLogService
* author : limju
* date : 2024-08-01
* ======================================================================
*
* ----------------------------------------------------------------------
* 2024-08-01 limju
*
* </pre>
*/
@Service
@RequiredArgsConstructor
public class AccessLogService {
// private final AccessLogRepository accessLogRepository;
private final IAccessLogMapper accessLogMapper;
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void save(AccessLogDTO accessLogDTO) {
if(ObjectUtils.isEmpty(accessLogDTO.getLogId())) {
accessLogMapper.insertAccessLog(accessLogDTO);
}else{
accessLogMapper.updateAccessLog(accessLogDTO);
}
}
}

@ -0,0 +1,11 @@
package cokr.xit.ens.core.aop.mapper;
import org.apache.ibatis.annotations.Mapper;
import cokr.xit.ens.core.aop.AccessLogDTO;
@Mapper
public interface IAccessLogMapper {
int insertAccessLog(AccessLogDTO accessLogDTO);
int updateAccessLog(AccessLogDTO accessLogDTO);
}

@ -1,8 +0,0 @@
package cokr.xit.ens.core.aop.repository;
import cokr.xit.ens.core.aop.AccessLog;
import org.springframework.data.jpa.repository.JpaRepository;
public interface AccessLogRepository extends JpaRepository<AccessLog, Long>{
}

@ -14,4 +14,9 @@ public class P6SpyConfig {
public P6SpyFormatter p6SpyCustomFormatter() { public P6SpyFormatter p6SpyCustomFormatter() {
return new P6SpyFormatter(); return new P6SpyFormatter();
} }
// @PostConstruct
// public void setLogMessageFormat() {
// P6SpyOptions.getActiveInstance().setLogMessageFormat(P6SpyFormatter.class.getName());
// }
} }

@ -17,24 +17,27 @@ public class P6SpyFormatter implements MessageFormattingStrategy {
private static final String ALTER = "alter"; private static final String ALTER = "alter";
private static final String DROP = "drop"; private static final String DROP = "drop";
private static final String COMMENT = "comment"; private static final String COMMENT = "comment";
private static final String COMMIT = "commit";
@Override @Override
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) { public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
if(category.equals(COMMIT)) return "Connection ID: " + connectionId + " " + COMMIT; if (sql == null || sql.trim().isEmpty()) {
if (sql.trim().isEmpty()) { return formatByCommand(connectionId, category);
return formatByCommand(category);
} }
return formatBySql(sql, category) + getAdditionalMessages(connectionId, elapsed); return "\n----------------------------------------------------------------------------------------------------\n"
+ "Execute DML : \n"
+ TAP + TAP
+ sql + ";"
+ getAdditionalMessages(connectionId, elapsed);
//return formatBySql(sql, category) + getAdditionalMessages(connectionId, elapsed);
} }
private static String formatByCommand(String category) { private static String formatByCommand(int connectionId, String category) {
return NEW_LINE return NEW_LINE
+ "----------------------------------------------------------------------------------------------------\n"
+ "Execute Command : " + "Execute Command : "
+ NEW_LINE + NEW_LINE
+ NEW_LINE
+ TAP + TAP
+ category + category + ", Connection ID - " + connectionId
+ NEW_LINE
+ NEW_LINE + NEW_LINE
+ "----------------------------------------------------------------------------------------------------"; + "----------------------------------------------------------------------------------------------------";
} }
@ -48,6 +51,7 @@ public class P6SpyFormatter implements MessageFormattingStrategy {
.format(sql); .format(sql);
} }
return NEW_LINE return NEW_LINE
+ "----------------------------------------------------------------------------------------------------\n"
+ "Execute DML : " + "Execute DML : "
+ NEW_LINE + NEW_LINE
+ FormatStyle.BASIC + FormatStyle.BASIC
@ -57,7 +61,7 @@ public class P6SpyFormatter implements MessageFormattingStrategy {
private String getAdditionalMessages(int connectionId, long elapsed) { private String getAdditionalMessages(int connectionId, long elapsed) {
return NEW_LINE return NEW_LINE
+ NEW_LINE + NEW_LINE
+ String.format("Connection ID: %s Execution Time: %s ms", connectionId, elapsed) + String.format("Execution Time: %s ms, Connection ID - %s", elapsed, connectionId)
+ NEW_LINE + NEW_LINE
+ "----------------------------------------------------------------------------------------------------"; + "----------------------------------------------------------------------------------------------------";
} }

@ -1,20 +0,0 @@
package cokr.xit.ens.core.config.logging;
import javax.annotation.PostConstruct;
import org.springframework.context.annotation.Configuration;
import com.p6spy.engine.spy.P6SpyOptions;
@Configuration
public class P6spyLoggingConfig {
/**
* JPA SQL Logging
* decorator.datasource.p6spy.enable-logging: true / false
*/
@PostConstruct
public void setLogMessageFormat() {
P6SpyOptions.getActiveInstance().setLogMessageFormat(P6SpyFormatter.class.getName());
}
}

@ -1,18 +1,17 @@
package cokr.xit.ens.modules; package cokr.xit.ens.modules;
import cokr.xit.ens.core.aop.repository.AccessLogRepository; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import cokr.xit.ens.core.code.CodeMapperFactory; import cokr.xit.ens.core.code.CodeMapperFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Slf4j @Slf4j
@Controller @Controller
@RequiredArgsConstructor @RequiredArgsConstructor
public class IndexController { public class IndexController {
private final AccessLogRepository accessLogRepository;
private final CodeMapperFactory codeMapperFactory; private final CodeMapperFactory codeMapperFactory;
@GetMapping("/") @GetMapping("/")

@ -59,7 +59,7 @@ spring:
jpa: jpa:
database-platform: org.hibernate.dialect.MariaDB103Dialect database-platform: org.hibernate.dialect.MariaDB103Dialect
# show-sql: true show-sql: true
# generate-ddl: true #TODO: 필요 시 주석해제. generate-ddl를 true 설정 시 ddl-auto의 설정값과 무관하게 DDL 스크립트 실행 # generate-ddl: true #TODO: 필요 시 주석해제. generate-ddl를 true 설정 시 ddl-auto의 설정값과 무관하게 DDL 스크립트 실행
hibernate: hibernate:
ddl-auto: none ddl-auto: none
@ -68,7 +68,7 @@ spring:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
properties: properties:
hibernate: hibernate:
# format_sql: true format_sql: true
# use_sql_comments: true # use_sql_comments: true
order_inserts: true order_inserts: true
order_updates: true order_updates: true

@ -15,7 +15,7 @@ logging:
file: utf-8 file: utf-8
level: level:
root: info root: info
'[org.hibernate.type.descriptor.sql]': off #jpa "?" 부분(binding 파라미터) 출력 #'[org.hibernate.type.descriptor.sql]': off #jpa "?" 부분(binding 파라미터) 출력
# '[org.springframework.orm.jpa]': debug # '[org.springframework.orm.jpa]': debug
# '[org.springframework.transaction]': debug # '[org.springframework.transaction]': debug
# '[org.springframework.transaction.interceptor]': trace # '[org.springframework.transaction.interceptor]': trace

@ -0,0 +1,43 @@
<?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="cokr.xit.ens.core.aop.mapper.IAccessLogMapper">
<insert id="insertAccessLog" parameterType="cokr.xit.ens.core.aop.AccessLogDTO">
<selectKey keyProperty="logId" resultType="long" order="BEFORE">
SELECT nextval(hibernate_sequence)
</selectKey>
INSERT INTO ens_access_log (
log_id,
access_token,
http_method,
ip,
param,
req_system_id,
session_id,
start_dt,
status,
uri,
url
) VALUES (
#{logId},
#{accessToken},
#{httpMethod},
#{ip},
#{param},
#{reqSystemId},
#{sessionId},
now(),
#{status},
#{uri},
#{url}
)
</insert>
<update id="updateAccessLog" parameterType="cokr.xit.ens.core.aop.AccessLogDTO">
UPDATE ens_access_log
SET end_dt = now()
, status = #{status}
WHERE log_id = #{logId}
</update>
</mapper>
Loading…
Cancel
Save