-
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.
Merge pull request #78 from ghdcksgml1/dev
Merge dev Branch
- Loading branch information
Showing
74 changed files
with
1,992 additions
and
188 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
plugins { | ||
id 'com.google.cloud.tools.jib' version '3.3.2' | ||
} | ||
|
||
bootJar { | ||
// 빌드된 Jar 파일명 지정 | ||
archiveFileName = "heachi-housework-" + buildVersion + ".jar" | ||
} | ||
|
||
dependencies { | ||
// 내부 모듈 | ||
implementation project(':heachi-support:common') | ||
implementation project(':heachi-support:logging') | ||
implementation project(':heachi-support:external-clients') | ||
implementation project(':heachi-domain-mysql') | ||
implementation project(':heachi-domain-redis') | ||
|
||
implementation 'org.springframework.boot:spring-boot-starter-web' // Spring Web | ||
implementation 'org.springframework.boot:spring-boot-starter-validation' // Bean Validation | ||
|
||
// Swagger | ||
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0") | ||
|
||
testCompileOnly project(':heachi-support:common') | ||
testCompileOnly project(':heachi-support:logging') | ||
testCompileOnly project(':heachi-domain-mysql') | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
} | ||
|
||
jib { | ||
from { | ||
image = 'eclipse-temurin:17-jre' // https://github.com/GoogleContainerTools/jib/issues/3483 | ||
platforms { | ||
platform { | ||
architecture = "arm64" | ||
os = "linux" | ||
} | ||
} | ||
} | ||
to { | ||
image = 'ghdcksgml1/heachi-housework' | ||
tags = [buildVersion, "latest"] | ||
auth { | ||
username = dockerUsername | ||
password = dockerPassword | ||
} | ||
} | ||
container { | ||
|
||
entrypoint = ['java', '-Dspring.profiles.active=prod', '-jar', 'heachi-housework-' + buildVersion + '.jar'] | ||
jvmFlags = ['-Xms2048m', '-Xmx2048m', '-Xdebug', '-XshowSettings:vm', '-XX:+UnlockExperimentalVMOptions', '-XX:+UseContainerSupport'] | ||
ports = ['8000'] | ||
environment = [SPRING_OUTPUT_ANSI_ENABLED: "ALWAYS"] | ||
|
||
creationTime = 'USE_CURRENT_TIMESTAMP' | ||
format = 'Docker' | ||
} | ||
|
||
// 어디 폴더로 부터 가져올지 | ||
extraDirectories { | ||
paths { | ||
path { | ||
from = file('build/libs') | ||
} | ||
} | ||
} | ||
} | ||
|
||
bootJar.enabled = true | ||
jar.enabled = false |
13 changes: 13 additions & 0 deletions
13
heachi-core/housework-api/src/main/java/com/heachi/housework/HeachiHouseworkApplication.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,13 @@ | ||
package com.heachi.housework; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; | ||
|
||
@SpringBootApplication(scanBasePackages = "com.heachi", exclude = SecurityAutoConfiguration.class) | ||
public class HeachiHouseworkApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(HeachiHouseworkApplication.class, args); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.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,33 @@ | ||
package com.heachi.housework.api.controller.housework.todo; | ||
|
||
import com.heachi.admin.common.response.JsonResult; | ||
import com.heachi.external.clients.auth.response.UserInfoResponse; | ||
import com.heachi.housework.api.service.auth.AuthExternalService; | ||
import com.heachi.housework.api.service.housework.todo.TodoService; | ||
import com.heachi.housework.api.service.housework.todo.request.TodoSelectRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/housework/todo") | ||
public class TodoController { | ||
|
||
private final AuthExternalService authExternalService; | ||
private final TodoService todoService; | ||
|
||
// Todo List 가져오기 | ||
@GetMapping("/{groupId}") | ||
public JsonResult<?> selectTodo(@RequestHeader(name = "Authorization") String authorization, | ||
@PathVariable(name = "groupId") Long groupId, | ||
@RequestParam(value = "date") LocalDate date) { | ||
UserInfoResponse userInfo = authExternalService.userAuthenticateAndGroupMatch(authorization, groupId); | ||
|
||
return JsonResult.successOf(todoService.cachedSelectTodo( | ||
TodoSelectRequest.builder().groupId(groupId).date(date).build())); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...ousework-api/src/main/java/com/heachi/housework/api/service/auth/AuthExternalService.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,54 @@ | ||
package com.heachi.housework.api.service.auth; | ||
|
||
import com.heachi.admin.common.exception.ExceptionMessage; | ||
import com.heachi.admin.common.exception.auth.AuthException; | ||
import com.heachi.admin.common.exception.group.member.GroupMemberException; | ||
import com.heachi.admin.common.response.JsonResult; | ||
import com.heachi.external.clients.auth.AuthClients; | ||
import com.heachi.external.clients.auth.response.UserInfoResponse; | ||
import com.heachi.mysql.define.group.member.repository.GroupMemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class AuthExternalService { | ||
|
||
private final AuthClients authClients; | ||
private final GroupMemberRepository groupMemberRepository; | ||
|
||
// Auth 서버에 인증 요청을 보낸다. | ||
public UserInfoResponse userAuthenticate(String authorization) { | ||
JsonResult<UserInfoResponse> jsonResult = authClients.getUserInfo(authorization).block(); // Mono 객체이므로 Block | ||
|
||
if (jsonResult.getResCode() != 200) { | ||
log.warn(">>>> 유저 인증에 실패했습니다."); | ||
|
||
throw new AuthException(ExceptionMessage.AUTH_SERVER_NOT_RESPOND); | ||
} | ||
|
||
return jsonResult.getResObj(); | ||
} | ||
|
||
// Auth 서버에 인증 요청을 보낸 후 가져온 정보로 해당 그룹원인지 판별한다. | ||
public UserInfoResponse userAuthenticateAndGroupMatch(String authorization, Long groupId) { | ||
JsonResult<UserInfoResponse> jsonResult = authClients.getUserInfo(authorization).block(); // Mono 객체이므로 Block | ||
|
||
if (jsonResult.getResCode() != 200) { | ||
log.warn(">>>> 유저 인증에 실패했습니다."); | ||
|
||
throw new AuthException(ExceptionMessage.AUTH_SERVER_NOT_RESPOND); | ||
} | ||
|
||
if (!groupMemberRepository.existsGroupMemberByUserEmailAndGroupInfoId( | ||
jsonResult.getResObj().getEmail(), groupId)) { | ||
log.warn(">>>> 해당 유저[{}]는 해당 그룹[{}]의 소속이 아닙니다.", jsonResult.getResObj().getEmail(), groupId); | ||
|
||
throw new GroupMemberException(ExceptionMessage.GROUP_MEMBER_NOT_FOUND); | ||
} | ||
|
||
return jsonResult.getResObj(); | ||
} | ||
} |
Oops, something went wrong.