From 76cd94fa482dc7d3379bd8211066a5115fb9a88b Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:15:19 +0900 Subject: [PATCH 01/13] =?UTF-8?q?add:=20=EC=96=B4=EB=93=9C=EB=AF=BC=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 22 ++++++++++++++++++++-- config/tokens/StoredCredential.txt | Bin 0 -> 1130 bytes 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 config/tokens/StoredCredential.txt diff --git a/build.gradle b/build.gradle index a9a41f8e..ac8dbd9e 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,6 @@ project(":layer-api") { implementation project(path: ':layer-domain') implementation project(path: ':layer-external') - implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-validation' @@ -82,7 +81,6 @@ project(":layer-api") { implementation 'org.springframework.boot:spring-boot-starter-data-redis' testImplementation 'org.springframework.boot:spring-boot-starter-test' - // openfeign implementation("org.springframework.cloud:spring-cloud-starter-openfeign:4.1.2") @@ -195,4 +193,24 @@ project(":layer-batch") { runtimeOnly 'com.mysql:mysql-connector-j' } +} + +project(":layer-admin") { + jar.enabled = false + bootJar.enabled = true + + dependencies { + implementation project(path: ':layer-domain') + + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + runtimeOnly 'com.mysql:mysql-connector-j' + + // swagger + implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0") + + // Security + implementation 'org.springframework.boot:spring-boot-starter-security' + } + } \ No newline at end of file diff --git a/config/tokens/StoredCredential.txt b/config/tokens/StoredCredential.txt new file mode 100644 index 0000000000000000000000000000000000000000..63b1c6c17b9026d421421e9725d098cde63b28b2 GIT binary patch literal 1130 zcma)5L66%+6rN;vp>!*>Z~zGjq^dn|sGZo`>=N}*yh)vSv7Jqvgv}xW6MO88V|$YE zOq>M7v8vQVi&XvqCqRq1!U-WR9Jp}hKr4ZSs)`dA)KkaVN?R_~jx_J`-uJ%uzWL_( zAFz>9@Ja}0Q05FraucQ_3r;p({Qak&U;FsCHBi*S`G`PIhb|-3057o-Md^q{-h6WX zU67v(**Oun#4Rwe&QnA=1;r2cj{klAzZcGR9~1$YPXJhZe0)Nux+InZLV^g%aDrtw z!YE-fk)Cs3|u_Pv z>kAb5xdJQtDfkQ&<`V|~SU|NZ!?NaDJBpe)i!>ct4ZXv7Fx20Vc-Qu~r@D?QuTFc? z_O9L1=uy9}br!XyPI^map+vFTt#wB?+P#6*$e5<}m!ThHR38t!3ki=?hZ}<~VG6F= z^_^B6WKPEolPq+$tyz6GHJW&24LVev#P&hiqmtq_ss?4?{1wlIVx zw1#%ou`^vVs|KwdE%u%CqoAY1UNQ}(YCl}KjrQ13! Date: Sun, 1 Dec 2024 01:15:27 +0900 Subject: [PATCH 02/13] =?UTF-8?q?add:=20=EC=96=B4=EB=93=9C=EB=AF=BC=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/settings.gradle b/settings.gradle index b5e01a2c..b8ffbacd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,4 +4,5 @@ include 'layer-common' include 'layer-domain' include 'layer-external' include 'layer-batch' +include 'layer-admin' From aaffb13ca1314ed53a38b2ebf013363f188e9511 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:16:33 +0900 Subject: [PATCH 03/13] =?UTF-8?q?add:=20=EC=96=B4=EB=93=9C=EB=AF=BC=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20docker=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layer-admin/Dockerfile-admin | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 layer-admin/Dockerfile-admin diff --git a/layer-admin/Dockerfile-admin b/layer-admin/Dockerfile-admin new file mode 100644 index 00000000..7c2422f7 --- /dev/null +++ b/layer-admin/Dockerfile-admin @@ -0,0 +1,10 @@ +FROM openjdk:17 + +ARG JAR_FILE=./build/libs/*.jar +ARG SPRING_PROFILE + +COPY ${JAR_FILE} layer-admin.jar + +ENV SPRING_PROFILE=${SPRING_PROFILE} + +ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul" ,"-jar" ,"layer-admin.jar"] \ No newline at end of file From 5d2b5e4f9f08fb5b92478e0214a7c7a668b33216 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:17:19 +0900 Subject: [PATCH 04/13] =?UTF-8?q?feat:=20=EC=96=B4=EB=93=9C=EB=AF=BC=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EB=A0=88=ED=8F=AC=EC=A7=80=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=97=90=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../answer/repository/AdminAnswerRepository.java | 8 ++++++++ .../member/repository/AdminMemberRepository.java | 10 ++++++++++ .../repository/AdminMemberSpaceRelationRepository.java | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 layer-domain/src/main/java/org/layer/domain/answer/repository/AdminAnswerRepository.java create mode 100644 layer-domain/src/main/java/org/layer/domain/member/repository/AdminMemberRepository.java create mode 100644 layer-domain/src/main/java/org/layer/domain/space/repository/AdminMemberSpaceRelationRepository.java diff --git a/layer-domain/src/main/java/org/layer/domain/answer/repository/AdminAnswerRepository.java b/layer-domain/src/main/java/org/layer/domain/answer/repository/AdminAnswerRepository.java new file mode 100644 index 00000000..b0b044c6 --- /dev/null +++ b/layer-domain/src/main/java/org/layer/domain/answer/repository/AdminAnswerRepository.java @@ -0,0 +1,8 @@ +package org.layer.domain.answer.repository; + +import org.layer.domain.answer.entity.Answer; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface AdminAnswerRepository extends JpaRepository { + Long countAllByMemberId(Long memberId); +} diff --git a/layer-domain/src/main/java/org/layer/domain/member/repository/AdminMemberRepository.java b/layer-domain/src/main/java/org/layer/domain/member/repository/AdminMemberRepository.java new file mode 100644 index 00000000..2c8aa81e --- /dev/null +++ b/layer-domain/src/main/java/org/layer/domain/member/repository/AdminMemberRepository.java @@ -0,0 +1,10 @@ +package org.layer.domain.member.repository; + +import org.layer.domain.member.entity.Member; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface AdminMemberRepository extends JpaRepository { + Page findAll(Pageable pageable); +} diff --git a/layer-domain/src/main/java/org/layer/domain/space/repository/AdminMemberSpaceRelationRepository.java b/layer-domain/src/main/java/org/layer/domain/space/repository/AdminMemberSpaceRelationRepository.java new file mode 100644 index 00000000..7d3307e1 --- /dev/null +++ b/layer-domain/src/main/java/org/layer/domain/space/repository/AdminMemberSpaceRelationRepository.java @@ -0,0 +1,9 @@ +package org.layer.domain.space.repository; + +import org.layer.domain.space.entity.MemberSpaceRelation; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface AdminMemberSpaceRelationRepository extends JpaRepository { + + Long countAllByMemberId(Long memberId); +} From 6ada6249336e758be6e1a6e56783b9c45c84ea48 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:25:25 +0900 Subject: [PATCH 05/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=ED=99=9C?= =?UTF-8?q?=EB=8F=99=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/AdminMemberApi.java | 26 ++++++++++ .../controller/AdminMemberController.java | 29 +++++++++++ .../dto/GetMemberActivityResponse.java | 29 +++++++++++ .../dto/GetMembersActivitiesResponse.java | 15 ++++++ .../member/service/AdminMemberService.java | 52 +++++++++++++++++++ 5 files changed, 151 insertions(+) create mode 100644 layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java create mode 100644 layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java create mode 100644 layer-admin/src/main/java/org/layer/member/controller/dto/GetMemberActivityResponse.java create mode 100644 layer-admin/src/main/java/org/layer/member/controller/dto/GetMembersActivitiesResponse.java create mode 100644 layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java diff --git a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java new file mode 100644 index 00000000..9c60311d --- /dev/null +++ b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java @@ -0,0 +1,26 @@ +package org.layer.member.controller; + +import org.layer.member.controller.dto.GetMembersActivitiesResponse; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestParam; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.tags.Tag; + +@Tag(name = "[ADMIN] 회원 서비스", description = "회원 관련 api") +public interface AdminMemberApi { + + @Operation(summary = "회원 활동 목록 조회") + @Parameters({ + @Parameter(name = "password", description = "패스워드", example = "abcdef", required = true), + @Parameter(name = "page", description = "페이지 수", example = "1", required = true), + @Parameter(name = "take", description = "가져올 데이터 수", example = "10", required = true) + }) + ResponseEntity getMemberActivities( + @RequestParam String password, + @RequestParam int page, + @RequestParam int take); + +} diff --git a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java new file mode 100644 index 00000000..f966201f --- /dev/null +++ b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java @@ -0,0 +1,29 @@ +package org.layer.member.controller; + +import org.layer.member.controller.dto.GetMembersActivitiesResponse; +import org.layer.member.service.AdminMemberService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import lombok.RequiredArgsConstructor; + +@RequestMapping("/admin/members") +@RequiredArgsConstructor +@RestController +public class AdminMemberController implements AdminMemberApi { + private final AdminMemberService adminMemberService; + + @Override + @GetMapping + public ResponseEntity getMemberActivities( + @RequestParam String password, + @RequestParam int page, + @RequestParam int take) { + + return ResponseEntity.ok().body(adminMemberService.getMemberActivities(password, page, take)); + } + +} diff --git a/layer-admin/src/main/java/org/layer/member/controller/dto/GetMemberActivityResponse.java b/layer-admin/src/main/java/org/layer/member/controller/dto/GetMemberActivityResponse.java new file mode 100644 index 00000000..3a957e66 --- /dev/null +++ b/layer-admin/src/main/java/org/layer/member/controller/dto/GetMemberActivityResponse.java @@ -0,0 +1,29 @@ +package org.layer.member.controller.dto; + +import java.time.LocalDateTime; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +@Schema(name = "GetMemberActivityResponse", description = "회원 활동 Dto") +public record GetMemberActivityResponse( + @NotNull + @Schema(description = "회원 이름", example = "홍길동") + String name, + @NotNull + @Schema(description = "최근 활동 날짜", example = "2024-11-30T16:21:47.031Z") + LocalDateTime recentActivityDate, + @NotNull + @Schema(description = "소속된 스페이스 수", example = "7") + long spaceCount, + @NotNull + @Schema(description = "작성한 회고 수", example = "15") + long retrospectAnswerCount, + @NotNull + @Schema(description = "회원가입 날짜", example = "2024-10-30T16:21:47.031Z") + LocalDateTime signUpDate, + @NotNull + @Schema(description = "회원가입 플랫폼", example = "KAKAO") + String socialType +) { +} diff --git a/layer-admin/src/main/java/org/layer/member/controller/dto/GetMembersActivitiesResponse.java b/layer-admin/src/main/java/org/layer/member/controller/dto/GetMembersActivitiesResponse.java new file mode 100644 index 00000000..3db49acb --- /dev/null +++ b/layer-admin/src/main/java/org/layer/member/controller/dto/GetMembersActivitiesResponse.java @@ -0,0 +1,15 @@ +package org.layer.member.controller.dto; + +import java.util.List; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +@Schema(name = "GetMembersActivitiesResponse", description = "회원 활동 목록 Dto") +public record GetMembersActivitiesResponse( + @NotNull + @Schema(description = "회원 활동 목록", example = "") + List responses + +) { +} diff --git a/layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java b/layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java new file mode 100644 index 00000000..b74455ea --- /dev/null +++ b/layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java @@ -0,0 +1,52 @@ +package org.layer.member.service; + +import java.util.List; + +import org.layer.domain.answer.repository.AdminAnswerRepository; +import org.layer.domain.member.entity.Member; +import org.layer.domain.member.repository.AdminMemberRepository; +import org.layer.domain.space.repository.AdminMemberSpaceRelationRepository; +import org.layer.member.controller.dto.GetMemberActivityResponse; +import org.layer.member.controller.dto.GetMembersActivitiesResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class AdminMemberService { + private final AdminMemberRepository adminMemberRepository; + private final AdminMemberSpaceRelationRepository adminMemberSpaceRelationRepository; + private final AdminAnswerRepository adminAnswerRepository; + + @Value("${admin.password}") + private String password; + + public GetMembersActivitiesResponse getMemberActivities(String password, int page, int take){ + + // TODO: 검증 로직 필터단으로 옮기기 + if(!password.equals(this.password)){ + throw new IllegalArgumentException("비밀번호가 올바르지 않습니다."); + } + + PageRequest pageRequest = PageRequest.of(page, take); + Page members = adminMemberRepository.findAll(pageRequest); + + List responses = members.getContent().stream() + .map(member -> { + + Long spaceCount = adminMemberSpaceRelationRepository.countAllByMemberId(member.getId()); + Long retrospectAnswerCount = adminAnswerRepository.countAllByMemberId(member.getId()); + + return new GetMemberActivityResponse(member.getName(), null, spaceCount, retrospectAnswerCount, + member.getCreatedAt(), member.getSocialType().name()); + }).toList(); + + return new GetMembersActivitiesResponse(responses); + } +} From 23337db0b8a1fa1af1f038b57f6b3ad6adf4738a Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:26:49 +0900 Subject: [PATCH 06/13] =?UTF-8?q?add:=20admin=20=EC=8A=A4=ED=94=84?= =?UTF-8?q?=EB=A7=81=20=EC=84=9C=EB=B2=84=20=ED=99=98=EA=B2=BD=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- .../main/java/org/layer/AdminApplication.java | 14 +++++++++++ .../src/main/resources/application-prod.yml | 23 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 layer-admin/src/main/java/org/layer/AdminApplication.java create mode 100644 layer-admin/src/main/resources/application-prod.yml diff --git a/.gitignore b/.gitignore index e0630052..4e76a4c9 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,5 @@ credentials.json layer-api/src/main/resources/tokens/StoredCredential -layer-batch/src/main/resources/application-secret.properties \ No newline at end of file +layer-batch/src/main/resources/application-secret.properties +layer-admin/src/main/resources/application-secret.properties \ No newline at end of file diff --git a/layer-admin/src/main/java/org/layer/AdminApplication.java b/layer-admin/src/main/java/org/layer/AdminApplication.java new file mode 100644 index 00000000..c13ea0e3 --- /dev/null +++ b/layer-admin/src/main/java/org/layer/AdminApplication.java @@ -0,0 +1,14 @@ +package org.layer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + +@SpringBootApplication +@EnableJpaAuditing +public class AdminApplication { + public static void main(String[] args) { + SpringApplication.run(AdminApplication.class, args); + } + +} diff --git a/layer-admin/src/main/resources/application-prod.yml b/layer-admin/src/main/resources/application-prod.yml new file mode 100644 index 00000000..d053cad6 --- /dev/null +++ b/layer-admin/src/main/resources/application-prod.yml @@ -0,0 +1,23 @@ +server: + port: 3000 + +spring: + config: + import: application-secret.properties + datasource: + url: ${AWS_PROD_DB_URL} + username: ${AWS_PROD_DB_NAME} + password: ${AWS_PROD_DB_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + hibernate: + ddl-auto: validate + properties: + hibernate: + format_sql: true + show_sql: true + open-in-view: false + database: mysql + +admin: + password: ${ADMIN_PASSWORD} \ No newline at end of file From 2f5b31f4784e85d73f0223c40854dad6d56463bc Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:27:09 +0900 Subject: [PATCH 07/13] =?UTF-8?q?add:=20=EB=AA=A8=EB=93=A0=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=ED=97=88=EC=9A=A9=ED=95=98=EB=8A=94=20=EC=8B=9C?= =?UTF-8?q?=ED=81=90=EB=A6=AC=ED=8B=B0=20=EC=84=A4=EC=A0=95=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/layer/config/SecurityConfig.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 layer-admin/src/main/java/org/layer/config/SecurityConfig.java diff --git a/layer-admin/src/main/java/org/layer/config/SecurityConfig.java b/layer-admin/src/main/java/org/layer/config/SecurityConfig.java new file mode 100644 index 00000000..43d2555b --- /dev/null +++ b/layer-admin/src/main/java/org/layer/config/SecurityConfig.java @@ -0,0 +1,23 @@ +package org.layer.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +public class SecurityConfig { + + @Bean + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http + .csrf(AbstractHttpConfigurer::disable) // CSRF 비활성화 + .authorizeHttpRequests(auth -> auth + .anyRequest().permitAll() // 모든 요청 허용 + ) + .httpBasic(AbstractHttpConfigurer::disable); // HTTP Basic 인증 비활성화 + + return http.build(); + } +} From 5f6c6253a820fc4ba2fd18e0cdca82cbd0489684 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:39:27 +0900 Subject: [PATCH 08/13] =?UTF-8?q?add:=20dev=20yml=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 layer-admin/src/main/resources/application-dev.yml diff --git a/layer-admin/src/main/resources/application-dev.yml b/layer-admin/src/main/resources/application-dev.yml new file mode 100644 index 00000000..941c6352 --- /dev/null +++ b/layer-admin/src/main/resources/application-dev.yml @@ -0,0 +1,23 @@ +server: + port: 3000 + +spring: + config: + import: application-secret.properties + datasource: + url: ${AWS_DEV_DB_URL} + username: ${AWS_PROD_DB_NAME} + password: ${AWS_PROD_DB_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + jpa: + hibernate: + ddl-auto: validate + properties: + hibernate: + format_sql: true + show_sql: true + open-in-view: false + database: mysql + +admin: + password: ${ADMIN_PASSWORD} \ No newline at end of file From 5459af2fb888303e3c2f2a1a31752957cc5e215f Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:42:46 +0900 Subject: [PATCH 09/13] =?UTF-8?q?chore:=20admin=20=EB=AA=A8=EB=93=88=20ci-?= =?UTF-8?q?cd=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/aws-cicd-dev.yml | 20 ++++++++++++++++++++ .github/workflows/aws-cicd-prod.yml | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/.github/workflows/aws-cicd-dev.yml b/.github/workflows/aws-cicd-dev.yml index 83033cf9..9fdcb789 100644 --- a/.github/workflows/aws-cicd-dev.yml +++ b/.github/workflows/aws-cicd-dev.yml @@ -4,6 +4,7 @@ on: push: branches: - develop + - feat/LA-20 env: REGISTRY: "docker.io" @@ -56,6 +57,7 @@ jobs: run: | echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-api/src/main/resources/application-secret.properties echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-batch/src/main/resources/application-secret.properties + echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-admin/src/main/resources/application-secret.properties - name: Build layer-api module run: ./gradlew :layer-api:build @@ -69,6 +71,12 @@ jobs: - name: Test layer-batch module run: ./gradlew :layer-batch:test + - name: Build layer-admin module + run: ./gradlew :layer-admin:build + + - name: Test layer-admin module + run: ./gradlew :layer-admin:test + - name: Docker Hub Login uses: docker/login-action@v1 with: @@ -82,6 +90,7 @@ jobs: images: | ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-api ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-batch + ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-admin - name: Push layer-api Docker Image uses: docker/build-push-action@v4 @@ -104,6 +113,16 @@ jobs: tags: | ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-batch:latest + - name: Push layer-admin Docker Image + uses: docker/build-push-action@v4 + with: + context: ./layer-admin + file: ./layer-admin/Dockerfile-admin # Dockerfile 이름 지정 + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-admin:latest + deploy: name: Deploy needs: [ build, setup ] @@ -119,6 +138,7 @@ jobs: run: | echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-api/infra/${{ env.DEPLOY_TARGET }}/application-secret.properties echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-batch/src/main/resources/application-secret.properties + echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-admin/src/main/resources/application-secret.properties - name: Archive Files run: | diff --git a/.github/workflows/aws-cicd-prod.yml b/.github/workflows/aws-cicd-prod.yml index 6b3c8eb9..120105e4 100644 --- a/.github/workflows/aws-cicd-prod.yml +++ b/.github/workflows/aws-cicd-prod.yml @@ -57,6 +57,7 @@ jobs: run: | echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-api/src/main/resources/application-secret.properties echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-batch/src/main/resources/application-secret.properties + echo "${APPLICATION_SECRET_PROPERTIES}" > ./layer-admin/src/main/resources/application-secret.properties - name: Build layer-api module run: ./gradlew :layer-api:build @@ -70,6 +71,12 @@ jobs: - name: Test layer-batch module run: ./gradlew :layer-batch:test + - name: Build layer-admin module + run: ./gradlew :layer-admin:build + + - name: Test layer-admin module + run: ./gradlew :layer-admin:test + - name: Docker Hub Login uses: docker/login-action@v1 with: @@ -83,6 +90,7 @@ jobs: images: | ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-api ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-batch + ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-admin - name: Push layer-api Docker Image uses: docker/build-push-action@v4 @@ -106,6 +114,16 @@ jobs: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-batch:latest no-cache: true + - name: Push layer-admin Docker Image + uses: docker/build-push-action@v4 + with: + context: ./layer-admin + file: ./layer-admin/Dockerfile-admin # Dockerfile 이름 지정 + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}_layer-admin:latest + deploy: name: Deploy needs: [ build, setup ] @@ -121,6 +139,7 @@ jobs: run: | echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-api/infra/${{ env.DEPLOY_TARGET }}/application-secret.properties echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-batch/src/main/resources/application-secret.properties + echo "${{ secrets.APPLICATION_SECRET_PROPERTIES }}" > ./layer-admin/src/main/resources/application-secret.properties - name: Archive Files run: | From e20716c96406193218abd4d4d562b9f1772c2f28 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 01:56:24 +0900 Subject: [PATCH 10/13] =?UTF-8?q?chore:=20admin=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=20=EB=B0=8F=20=ED=94=84?= =?UTF-8?q?=EB=A1=9D=EC=8B=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/development/docker-compose.yaml | 18 ++++++++++++++++++ layer-api/infra/development/nginx.conf | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/layer-api/infra/development/docker-compose.yaml b/layer-api/infra/development/docker-compose.yaml index edd2b8c9..b0ea5bbe 100644 --- a/layer-api/infra/development/docker-compose.yaml +++ b/layer-api/infra/development/docker-compose.yaml @@ -29,6 +29,24 @@ services: - java-app restart: always + admin-app: + image: docker.io/clean01/layer-server_layer-admin:latest # + container_name: layer-admin + ports: + - "3000:3000" + environment: + - TZ=Asia/Seoul + - SPRING_PROFILES_ACTIVE=dev + volumes: + - ./application-secret.properties:/config/application-secret.properties + - ./log:/log + - ./tokens:/config/tokens + networks: + - app-network + depends_on: + - java-app + restart: always + nginx: image: nginx:latest container_name: nginx diff --git a/layer-api/infra/development/nginx.conf b/layer-api/infra/development/nginx.conf index 4bcbe484..7a9701e8 100644 --- a/layer-api/infra/development/nginx.conf +++ b/layer-api/infra/development/nginx.conf @@ -5,6 +5,10 @@ http { server layer-api:8080; } + upstream layer-admin { + server layer-admin:3000; + } + server { listen 80; @@ -15,5 +19,13 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + + location /admin/ { + proxy_pass http://layer-admin; # Proxy to layer-admin + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } } } \ No newline at end of file From 5d196e00c63619547a0401f0284d6b456fddb273 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 13:50:19 +0900 Subject: [PATCH 11/13] =?UTF-8?q?style:=20=EA=B3=B5=EB=B0=B1=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layer-api/infra/development/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layer-api/infra/development/nginx.conf b/layer-api/infra/development/nginx.conf index 7a9701e8..639490fb 100644 --- a/layer-api/infra/development/nginx.conf +++ b/layer-api/infra/development/nginx.conf @@ -6,7 +6,7 @@ http { } upstream layer-admin { - server layer-admin:3000; + server layer-admin:3000; } server { From be98b9a1f1d74c84dc3f39465e7fddf538bd7acc Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 14:00:26 +0900 Subject: [PATCH 12/13] =?UTF-8?q?chore:=20page=201=EB=B6=80=ED=84=B0=20?= =?UTF-8?q?=EC=8B=9C=EC=9E=91=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/layer/member/controller/AdminMemberApi.java | 2 +- .../java/org/layer/member/service/AdminMemberService.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java index 9c60311d..c6b664c2 100644 --- a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java +++ b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java @@ -15,7 +15,7 @@ public interface AdminMemberApi { @Operation(summary = "회원 활동 목록 조회") @Parameters({ @Parameter(name = "password", description = "패스워드", example = "abcdef", required = true), - @Parameter(name = "page", description = "페이지 수", example = "1", required = true), + @Parameter(name = "page", description = "페이지 수, 최솟값 1", example = "1", required = true), @Parameter(name = "take", description = "가져올 데이터 수", example = "10", required = true) }) ResponseEntity getMemberActivities( diff --git a/layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java b/layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java index b74455ea..d761a368 100644 --- a/layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java +++ b/layer-admin/src/main/java/org/layer/member/service/AdminMemberService.java @@ -27,14 +27,14 @@ public class AdminMemberService { @Value("${admin.password}") private String password; - public GetMembersActivitiesResponse getMemberActivities(String password, int page, int take){ + public GetMembersActivitiesResponse getMemberActivities(String password, int page, int take) { // TODO: 검증 로직 필터단으로 옮기기 - if(!password.equals(this.password)){ + if (!password.equals(this.password)) { throw new IllegalArgumentException("비밀번호가 올바르지 않습니다."); } - PageRequest pageRequest = PageRequest.of(page, take); + PageRequest pageRequest = PageRequest.of(page - 1, take); Page members = adminMemberRepository.findAll(pageRequest); List responses = members.getContent().stream() From 3950bcd09b9e14993da9149bbe33c32776d5d4a8 Mon Sep 17 00:00:00 2001 From: mikekks Date: Sun, 1 Dec 2024 14:02:09 +0900 Subject: [PATCH 13/13] =?UTF-8?q?chore:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20default=20value=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/layer/member/controller/AdminMemberApi.java | 2 +- .../org/layer/member/controller/AdminMemberController.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java index c6b664c2..747b24d8 100644 --- a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java +++ b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.java @@ -16,7 +16,7 @@ public interface AdminMemberApi { @Parameters({ @Parameter(name = "password", description = "패스워드", example = "abcdef", required = true), @Parameter(name = "page", description = "페이지 수, 최솟값 1", example = "1", required = true), - @Parameter(name = "take", description = "가져올 데이터 수", example = "10", required = true) + @Parameter(name = "take", description = "가져올 데이터 수", example = "20", required = true) }) ResponseEntity getMemberActivities( @RequestParam String password, diff --git a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java index f966201f..1d85167b 100644 --- a/layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java +++ b/layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.java @@ -20,8 +20,8 @@ public class AdminMemberController implements AdminMemberApi { @GetMapping public ResponseEntity getMemberActivities( @RequestParam String password, - @RequestParam int page, - @RequestParam int take) { + @RequestParam(defaultValue = "1") int page, + @RequestParam(defaultValue = "20") int take) { return ResponseEntity.ok().body(adminMemberService.getMemberActivities(password, page, take)); }