-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* config: init logbat_meta project * refactor: copy Project, Apps code * refactor: Project endpoint 수정 - projects/{projectId} 로 통일 * refactor: App endpoint 수정 - projects/apps -> /projects/{projectId}/apps * refactor: 미사용 메서드 삭제 * refactor: copy and 개선 App, Project 테스트코드 * refactor: delete App, Project code in logbat project - logbat_meta 프로젝트로 이전 * refactor: JPA 관련 코드 제거 * refactor: AsyncLogProcessor 생성자 개선 - this 참조 추가 - database poolsize debug로그 추가 * fix: 데이터베이스 poolsize 직접 지정 * feat: AppJDBCRepository 추가 - JDBC Template를 사용한 데이터베이스 조회 구현 * refactor: JPA 설정 제거 * fix: 에러를 반환하지 않고 빈값을 반환하도록 수정 * test: 도메인 분리로 불가능한 테스트 수정 * config: Nginx 설정 변경 * fix: 서버 주소 변경 * config: 변경된 도메인 적용 * refactor: 변수명 변경 - l -> id
- Loading branch information
Showing
51 changed files
with
949 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
logbat/src/main/java/info/logbat/common/config/JpaConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 5 additions & 48 deletions
53
logbat/src/main/java/info/logbat/domain/project/application/AppService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,30 @@ | ||
package info.logbat.domain.project.application; | ||
|
||
import info.logbat.domain.project.domain.App; | ||
import info.logbat.domain.project.domain.Project; | ||
import info.logbat.domain.project.domain.enums.AppType; | ||
import info.logbat.domain.project.presentation.payload.response.AppCommonResponse; | ||
import info.logbat.domain.project.repository.AppJpaRepository; | ||
import info.logbat.domain.project.repository.ProjectJpaRepository; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import info.logbat.domain.project.repository.AppRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.cache.annotation.CacheConfig; | ||
import org.springframework.cache.annotation.CacheEvict; | ||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
@CacheConfig(cacheNames = {"app"}) | ||
public class AppService { | ||
|
||
private static final String APP_NOT_FOUND_MESSAGE = "앱을 찾을 수 없습니다."; | ||
|
||
private final AppJpaRepository appRepository; | ||
private final ProjectJpaRepository projectRepository; | ||
private final AppRepository appRepository; | ||
|
||
public AppCommonResponse createApp(Long projectId, String appTypeStr) { | ||
Project project = getProject(projectId); | ||
AppType appType = AppType.from(appTypeStr); | ||
return AppCommonResponse.from(appRepository.save(App.of(project, appType))); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
@Cacheable(key = "#token") | ||
public AppCommonResponse getAppByToken(String token) { | ||
UUID tokenUUID = UUID.fromString(token); | ||
App app = appRepository.findByAppKey(tokenUUID) | ||
.orElseThrow(() -> new IllegalArgumentException(APP_NOT_FOUND_MESSAGE)); | ||
return AppCommonResponse.from(app); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public AppCommonResponse getAppById(Long id) { | ||
App app = appRepository.findById(id) | ||
public Long getAppIdByToken(String token) { | ||
return appRepository.getAppIdByToken(token) | ||
.orElseThrow(() -> new IllegalArgumentException(APP_NOT_FOUND_MESSAGE)); | ||
return AppCommonResponse.from(app); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<AppCommonResponse> getAppsByProjectId(Long projectId) { | ||
List<App> apps = appRepository.findByProject_Id(projectId); | ||
return apps.stream().map(AppCommonResponse::from).toList(); | ||
} | ||
|
||
public Long deleteApp(Long projectId, Long appId) { | ||
App app = appRepository.findByProject_IdAndId(projectId, appId) | ||
.orElseThrow(() -> new IllegalArgumentException(APP_NOT_FOUND_MESSAGE)); | ||
appRepository.delete(app); | ||
evictAppCache(app.getAppKey().toString()); | ||
return app.getId(); | ||
} | ||
|
||
@CacheEvict(key = "#token") | ||
public void evictAppCache(String token) { | ||
} | ||
// TODO: Implement cache eviction | ||
|
||
private Project getProject(Long id) { | ||
return projectRepository.findById(id) | ||
.orElseThrow(() -> new IllegalArgumentException("프로젝트를 찾을 수 없습니다.")); | ||
} | ||
} |
48 changes: 0 additions & 48 deletions
48
logbat/src/main/java/info/logbat/domain/project/presentation/AppController.java
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
logbat/src/main/java/info/logbat/domain/project/presentation/ProjectController.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...c/main/java/info/logbat/domain/project/presentation/payload/request/AppCreateRequest.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...in/java/info/logbat/domain/project/presentation/payload/request/ProjectCreateRequest.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...in/java/info/logbat/domain/project/presentation/payload/request/ProjectUpdateRequest.java
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
logbat/src/main/java/info/logbat/domain/project/repository/AppRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package info.logbat.domain.project.repository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class AppRepository { | ||
|
||
private final JdbcTemplate jdbcTemplate; | ||
|
||
public Optional<Long> getAppIdByToken(String token) { | ||
try { | ||
String sql = "SELECT id FROM apps WHERE app_key = UNHEX(REPLACE(?, '-', ''))"; | ||
Long id = jdbcTemplate.queryForObject(sql, Long.class, token); | ||
return Optional.ofNullable(id); | ||
} | ||
catch (Exception e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.