-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1.0
- Loading branch information
Showing
27 changed files
with
458 additions
and
25 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
Binary file not shown.
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,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"] |
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,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); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
layer-admin/src/main/java/org/layer/config/SecurityConfig.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,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(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
layer-admin/src/main/java/org/layer/member/controller/AdminMemberApi.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,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 = "페이지 수, 최솟값 1", example = "1", required = true), | ||
@Parameter(name = "take", description = "가져올 데이터 수", example = "20", required = true) | ||
}) | ||
ResponseEntity<GetMembersActivitiesResponse> getMemberActivities( | ||
@RequestParam String password, | ||
@RequestParam int page, | ||
@RequestParam int take); | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
layer-admin/src/main/java/org/layer/member/controller/AdminMemberController.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,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("/members") | ||
@RequiredArgsConstructor | ||
@RestController | ||
public class AdminMemberController implements AdminMemberApi { | ||
private final AdminMemberService adminMemberService; | ||
|
||
@Override | ||
@GetMapping | ||
public ResponseEntity<GetMembersActivitiesResponse> getMemberActivities( | ||
@RequestParam String password, | ||
@RequestParam(defaultValue = "1") int page, | ||
@RequestParam(defaultValue = "20") int take) { | ||
|
||
return ResponseEntity.ok().body(adminMemberService.getMemberActivities(password, page, take)); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
layer-admin/src/main/java/org/layer/member/controller/dto/GetMemberActivityResponse.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,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 | ||
) { | ||
} |
15 changes: 15 additions & 0 deletions
15
layer-admin/src/main/java/org/layer/member/controller/dto/GetMembersActivitiesResponse.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,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<GetMemberActivityResponse> responses | ||
|
||
) { | ||
} |
52 changes: 52 additions & 0 deletions
52
layer-admin/src/main/java/org/layer/member/service/AdminMemberService.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,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 - 1, take); | ||
Page<Member> members = adminMemberRepository.findAll(pageRequest); | ||
|
||
List<GetMemberActivityResponse> 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); | ||
} | ||
} |
Oops, something went wrong.