Skip to content

Commit

Permalink
Merge branch 'main' into fix/batch
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 committed Jun 19, 2024
2 parents d94fe09 + ecc6394 commit a2d7a31
Show file tree
Hide file tree
Showing 151 changed files with 1,982 additions and 2,418 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface TrafficDetailRepository extends JpaRepository<TrafficDetailEnti
+ " FROM sorted_data "
+ " WHERE row_num BETWEEN :start AND :end ",
nativeQuery = true)
List<TrafficDetailEntity> findRecentlyData(
List<TrafficDetailEntity> findAllInIdsBetween(
@Param("trafficIds") List<Long> trafficIds,
@Param("start") Integer start,
@Param("end") Integer end);
Expand All @@ -44,5 +44,5 @@ List<TrafficDetailEntity> findRecentlyData(
+ "ON td.traffic_id = maxTd.traffic_id AND td.time_left_reg_dt = maxTd.maxTimeLeftRegDt "
+ "WHERE td.traffic_id IN :trafficIds",
nativeQuery = true)
List<TrafficDetailEntity> findMostRecenlyData(@Param("trafficIds") List<Long> trafficIds);
List<TrafficDetailEntity> findAllTopDataInTrafficIds(@Param("trafficIds") List<Long> trafficIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Repository
public interface TrafficFavoritesRepository extends JpaRepository<TrafficFavoritesEntity, Long> {

List<TrafficFavoritesEntity> findByMemberFk(MemberEntity memberFk);
List<TrafficFavoritesEntity> findByMemberFkAndDeletedFalse(MemberEntity memberFk);

Optional<TrafficFavoritesEntity> findByIdAndDeletedFalse(Long id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.walking.data.entity.traffic.TrafficEntity;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand All @@ -11,7 +12,7 @@
public interface TrafficRepository extends JpaRepository<TrafficEntity, Long> {

@Query("SELECT t FROM TrafficEntity t where t.id IN :ids")
List<TrafficEntity> findByIds(@Param("ids") List<Long> ids);
List<TrafficEntity> findAllInIds(@Param("ids") List<Long> ids);

// 주변 1km의 Polygon을 만들어 인덱스를 타도록
@Query(
Expand All @@ -34,6 +35,22 @@ public interface TrafficRepository extends JpaRepository<TrafficEntity, Long> {
List<TrafficEntity> findClosetTrafficByLocation(
@Param("longitude") Double longitude, @Param("latitude") Double latitude);

@Query(
value =
" SELECT *"
+ " FROM traffic t "
+ " WHERE ST_Contains( "
+ " ST_GeomFromText(CONCAT('POLYGON((', "
+ ":latitude - 0.0113, ' ', :longitude + 0.009, ', ', "
+ ":latitude + 0.0113, ' ', :longitude + 0.009, ', ', "
+ ":latitude + 0.0113, ' ', :longitude - 0.009, ', ', "
+ ":latitude - 0.0113, ' ', :longitude - 0.009, ', ', "
+ ":latitude - 0.0113, ' ', :longitude + 0.009, '))'), 4326), t.point_value) "
+ " ORDER BY ST_DISTANCE(t.point_value, ST_SRID(POINT(:longitude, :latitude), 4326)) ASC limit 1 ",
nativeQuery = true)
Optional<TrafficEntity> findClosestTraffic(
@Param("longitude") Double longitude, @Param("latitude") Double latitude);

@Query(
value =
"SELECT * FROM traffic "
Expand Down
9 changes: 4 additions & 5 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ dependencies {

// web
implementation 'org.springframework.boot:spring-boot-starter-web'
// webflux

// webflux todo remove related dependencies
implementation("org.springframework.boot:spring-boot-starter-webflux")
runtimeOnly 'io.netty:netty-resolver-dns-native-macos:4.1.104.Final:osx-aarch_64'

Expand All @@ -26,9 +27,6 @@ dependencies {
// actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'

// prometheus
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'

//jwt
implementation "io.jsonwebtoken:jjwt-api:${jsonwebtokenVersion}"
implementation "io.jsonwebtoken:jjwt-impl:${jsonwebtokenVersion}"
Expand All @@ -40,9 +38,9 @@ dependencies {
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: "${jsr305Version}"

// todo remove related dependencies
implementation 'org.json:json:20200518'


// security
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'
Expand All @@ -53,6 +51,7 @@ def releaseVersion = project.hasProperty('releaseVersion') ? releaseVersion : nu

def repository = "walking/${imageName}"

// todo refactor can use under tasks
task buildDockerImage {
dependsOn 'bootJar'
// dependsOn 'copySwaggerUI'
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.walking.api.domain.client;

public interface RestClient {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.walking.api.web.client;
package com.walking.api.domain.client;

import com.walking.api.web.client.dto.request.TMapRequestDto;
import com.walking.api.web.client.dto.response.TMapResponseDto;
import com.walking.api.web.client.webclient.WebClientUtil;
import com.walking.api.domain.client.dto.request.TMapRequestDto;
import com.walking.api.domain.client.dto.response.TMapResponseDto;
import com.walking.api.domain.client.util.WebClientUtil;
import java.util.HashMap;
import java.util.Map;
import lombok.RequiredArgsConstructor;
Expand All @@ -15,17 +15,16 @@
public class TMapClient implements RestClient {

private final WebClientUtil webClientUtil;

private final String url =
"https://apis.openapi.sk.com/tmap/routes/pedestrian?version=1&callback=function";
private final String apiKey = "4ftEOGkWCl4ChZ4K8Z5OG3pn8i0yRcDD7b73tqY5";

public TMapResponseDto TMapDetailPathSearch(TMapRequestDto requestDto) {
Map<String, String> Headers = new HashMap<>();
Headers.put("accept", " application/json");
Headers.put("content-type", " application/json");
Headers.put("appKey", apiKey);
public TMapResponseDto searchPath(TMapRequestDto requestDto) {
Map<String, String> headers = new HashMap<>();
headers.put("accept", " application/json");
headers.put("content-type", " application/json");
headers.put("appKey", apiKey);

return webClientUtil.postWithHeaders(url, requestDto, TMapResponseDto.class, Headers);
return webClientUtil.postWithHeaders(url, requestDto, TMapResponseDto.class, headers);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.walking.api.web.client.webclient;
package com.walking.api.domain.client.config;

import io.netty.channel.ChannelOption;
import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.walking.api.domain.client.dto.request;

public interface MapRequestDto {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.walking.api.web.client.dto.request;
package com.walking.api.domain.client.dto.request;

import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.walking.api.domain.client.dto.response;

import com.walking.api.domain.client.dto.response.detail.FeatureDetail;
import java.util.List;
import lombok.*;

@Data
@ToString
public class TMapResponseDto {

private String type;
private List<FeatureDetail> featureDetails;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.walking.api.domain.client.dto.response.detail;

import lombok.Data;

@Data
public class FeatureDetail {
private String type;
private GeometryDetail geometryDetail;
private PropertyDetails propertyDetails;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.walking.api.web.client.dto.response.detail;
package com.walking.api.domain.client.dto.response.detail;

import java.util.List;
import lombok.Data;

@Data
public class Geometry {
public class GeometryDetail {
private String type;
private List<?> coordinates; // LineString은 2차원 배열을 사용, Point는 1차원이지만 2차원으로 통일
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.walking.api.web.client.dto.response.detail;
package com.walking.api.domain.client.dto.response.detail;

import lombok.Data;

@Data
public class Properties {
public class PropertyDetails {
private Integer totalDistance;
private Integer totalTime;
private Integer index;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.walking.api.web.client.webclient;
package com.walking.api.domain.client.util;

import com.walking.api.domain.client.config.WebClientConfig;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import lombok.RequiredArgsConstructor;
Expand Down
39 changes: 39 additions & 0 deletions api/src/main/java/com/walking/api/domain/log/ServiceLogAspect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.walking.api.domain.log;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.StopWatch;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class ServiceLogAspect {

/** Service 패키지 내의 모든 메소드에 대해 로깅을 수행한다. */
@Pointcut(value = "execution(* com.walking.api.domain..*.service..*.*(..))")
public void serviceAdvice() {}

@Around("serviceAdvice()")
public Object requestLogging(ProceedingJoinPoint joinPoint) throws Throwable {
Signature signature = joinPoint.getSignature();
String[] splitByDot = signature.getDeclaringTypeName().split("\\.");
String serviceName = splitByDot[splitByDot.length - 1];

Object[] args = joinPoint.getArgs();

StopWatch stopWatch = new StopWatch();
stopWatch.start();
log.debug("{} execute with {}", serviceName, args);

Object proceed = joinPoint.proceed();

stopWatch.stop();
log.debug("{} finished in {}ms", serviceName, stopWatch.getTime());
return proceed;
}
}
Loading

0 comments on commit a2d7a31

Please sign in to comment.