-
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.
* add: 비밀번호 추가 * add: dto 추가 * chore: 화이트리스트에 추가 * feat: 어드민 API 구현 * del: 사용하지 않는 메서드 삭제
- Loading branch information
Showing
15 changed files
with
268 additions
and
15 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
35 changes: 35 additions & 0 deletions
35
layer-api/src/main/java/org/layer/domain/admin/controller/AdminApi.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,35 @@ | ||
package org.layer.domain.admin.controller; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.layer.domain.admin.controller.dto.AdminRetrospectsGetResponse; | ||
import org.layer.domain.admin.controller.dto.AdminSpacesGetResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
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.media.Schema; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@Tag(name = "어드민", description = "어드민 관련 API") | ||
public interface AdminApi { | ||
@Operation(summary = "스페이스 관련 데이터 조회", description = "") | ||
@Parameters({ | ||
@Parameter(name = "startDate", description = "검색 시작 시간", example = "2024-09-05T15:30:45", required = true), | ||
@Parameter(name = "endDate", description = "검색 종료 시간", example = "2024-09-13T15:30:45", required = true), | ||
@Parameter(name = "password", description = "비밀번호 [카톡방으로 공유]", example = "[카톡방으로 공유]", required = true) | ||
}) | ||
ResponseEntity<AdminSpacesGetResponse> getSpaceData(@RequestParam("startDate") LocalDateTime startDate, | ||
@RequestParam("endDate") LocalDateTime endDate, @RequestParam("password") String password); | ||
|
||
@Operation(summary = "회고 관련 데이터 조회", description = "") | ||
@Parameters({ | ||
@Parameter(name = "startDate", description = "검색 시작 시간", example = "2024-09-05T15:30:45", required = true, schema = @Schema(type = "string")), | ||
@Parameter(name = "endDate", description = "검색 종료 시간", example = "2024-09-13T15:30:45", required = true, schema = @Schema(type = "string")), | ||
@Parameter(name = "password", description = "비밀번호 [카톡방으로 공유]", example = "[카톡방으로 공유]", required = true, schema = @Schema(type = "string", format = "string"))}) | ||
ResponseEntity<AdminRetrospectsGetResponse> getRetrospectData(@RequestParam("startDate") LocalDateTime startDate, | ||
@RequestParam("endDate") LocalDateTime endDate, @RequestParam("password") String password); | ||
} |
44 changes: 44 additions & 0 deletions
44
layer-api/src/main/java/org/layer/domain/admin/controller/AdminController.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,44 @@ | ||
package org.layer.domain.admin.controller; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.layer.common.annotation.MemberId; | ||
import org.layer.domain.admin.controller.dto.AdminRetrospectsGetResponse; | ||
import org.layer.domain.admin.controller.dto.AdminSpacesGetResponse; | ||
import org.layer.domain.admin.service.AdminService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/admin") | ||
public class AdminController implements AdminApi { | ||
private final AdminService adminService; | ||
|
||
@Override | ||
@GetMapping("/space") | ||
public ResponseEntity<AdminSpacesGetResponse> getSpaceData( | ||
@RequestParam("startDate") LocalDateTime startDate, | ||
@RequestParam("endDate") LocalDateTime endDate, | ||
@RequestParam("password") String password) { | ||
|
||
return ResponseEntity.ok(adminService.getSpaceData(startDate, endDate, password)); | ||
} | ||
|
||
@Override | ||
@GetMapping("/retrospect") | ||
public ResponseEntity<AdminRetrospectsGetResponse> getRetrospectData( | ||
@RequestParam("startDate") LocalDateTime startDate, | ||
@RequestParam("endDate") LocalDateTime endDate, | ||
@RequestParam("password") String password) { | ||
|
||
|
||
return ResponseEntity.ok(adminService.getRetrospectData(startDate, endDate, password)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...-api/src/main/java/org/layer/domain/admin/controller/dto/AdminRetrospectsGetResponse.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,17 @@ | ||
package org.layer.domain.admin.controller.dto; | ||
|
||
import java.util.List; | ||
|
||
import org.layer.domain.retrospect.dto.AdminRetrospectGetResponse; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
public class AdminRetrospectsGetResponse { | ||
|
||
private final List<AdminRetrospectGetResponse> retrospects; | ||
private final Integer totalCount; | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
layer-api/src/main/java/org/layer/domain/admin/controller/dto/AdminSpacesGetResponse.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,22 @@ | ||
package org.layer.domain.admin.controller.dto; | ||
|
||
import java.util.List; | ||
|
||
import org.layer.domain.space.dto.AdminSpaceGetResponse; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
@Schema(name = "AdminSpacesGetResponse", description = "Admin 스페이스 조회") | ||
public class AdminSpacesGetResponse { | ||
|
||
@Schema(description = "스페이스 객체", example = "") | ||
private final List<AdminSpaceGetResponse> spaces; | ||
|
||
@Schema(description = "총 개수", example = "30") | ||
private final Integer totalCount; | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
layer-api/src/main/java/org/layer/domain/admin/service/AdminService.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.domain.admin.service; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.layer.domain.admin.controller.dto.AdminRetrospectsGetResponse; | ||
import org.layer.domain.admin.controller.dto.AdminSpacesGetResponse; | ||
import org.layer.domain.retrospect.dto.AdminRetrospectGetResponse; | ||
import org.layer.domain.retrospect.repository.RetrospectAdminRepository; | ||
import org.layer.domain.space.dto.AdminSpaceGetResponse; | ||
import org.layer.domain.space.entity.Space; | ||
import org.layer.domain.space.repository.SpaceAdminRepository; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class AdminService { | ||
|
||
private final SpaceAdminRepository spaceAdminRepository; | ||
private final RetrospectAdminRepository retrospectAdminRepository; | ||
|
||
@Value("${admin.password}") | ||
private String password; | ||
|
||
public AdminSpacesGetResponse getSpaceData(LocalDateTime startDate, LocalDateTime endDate, String requestPassword){ | ||
|
||
if(!requestPassword.equals(password)){ | ||
throw new IllegalArgumentException("비밀번호가 틀렸습니다."); | ||
} | ||
|
||
List<AdminSpaceGetResponse> spaces = spaceAdminRepository.findAllByCreatedAtAfterAndCreatedAtBefore(startDate, endDate); | ||
|
||
return new AdminSpacesGetResponse(spaces, spaces.size()); | ||
} | ||
|
||
public AdminRetrospectsGetResponse getRetrospectData(LocalDateTime startDate, LocalDateTime endDate, String requestPassword){ | ||
|
||
if(!requestPassword.equals(password)){ | ||
throw new IllegalArgumentException("비밀번호가 틀렸습니다."); | ||
} | ||
|
||
List<AdminRetrospectGetResponse> retrospects = retrospectAdminRepository.findAllByCreatedAtAfterAndCreatedAtBefore(startDate, endDate); | ||
|
||
return new AdminRetrospectsGetResponse(retrospects, retrospects.size()); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
layer-domain/src/main/java/org/layer/domain/retrospect/dto/AdminRetrospectGetResponse.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,14 @@ | ||
package org.layer.domain.retrospect.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class AdminRetrospectGetResponse { | ||
private final String retrospectTitle; | ||
private final String retrospectCreator; | ||
|
||
public AdminRetrospectGetResponse(String retrospectTitle, String retrospectCreator) { | ||
this.retrospectTitle = retrospectTitle; | ||
this.retrospectCreator = retrospectCreator; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...omain/src/main/java/org/layer/domain/retrospect/repository/RetrospectAdminRepository.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.domain.retrospect.repository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import org.layer.domain.retrospect.dto.AdminRetrospectGetResponse; | ||
import org.layer.domain.retrospect.entity.Retrospect; | ||
import org.layer.domain.space.dto.AdminSpaceGetResponse; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface RetrospectAdminRepository extends JpaRepository<Retrospect, Long> { | ||
|
||
@Query | ||
("SELECT new org.layer.domain.retrospect.dto.AdminRetrospectGetResponse(r.title, m.name) " | ||
+ "FROM Retrospect r " | ||
+ "JOIN Space s ON r.spaceId = s.id " | ||
+ "JOIN Member m ON s.leaderId = m.id " | ||
+ "WHERE s.createdAt >= :startDate " | ||
+ "AND s.createdAt <= :endDate" | ||
) | ||
List<AdminRetrospectGetResponse> findAllByCreatedAtAfterAndCreatedAtBefore( | ||
@Param("startDate") LocalDateTime startDate, | ||
@Param("endDate") LocalDateTime endDate); | ||
} |
15 changes: 15 additions & 0 deletions
15
layer-domain/src/main/java/org/layer/domain/space/dto/AdminSpaceGetResponse.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.domain.space.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class AdminSpaceGetResponse { | ||
|
||
private final String spaceName; | ||
private final String spaceLeaderName; | ||
|
||
public AdminSpaceGetResponse(String spaceName, String spaceLeaderName) { | ||
this.spaceName = spaceName; | ||
this.spaceLeaderName = spaceLeaderName; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
layer-domain/src/main/java/org/layer/domain/space/repository/SpaceAdminRepository.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 org.layer.domain.space.repository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import org.layer.domain.space.dto.AdminSpaceGetResponse; | ||
import org.layer.domain.space.entity.Space; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface SpaceAdminRepository extends JpaRepository<Space, Long> { | ||
|
||
@Query | ||
("SELECT new org.layer.domain.space.dto.AdminSpaceGetResponse(s.name, m.name) " | ||
+ "FROM Space s " | ||
+ "JOIN Member m ON s.leaderId = m.id " | ||
+ "WHERE s.createdAt >= :startDate " | ||
+ "AND s.createdAt <= :endDate" | ||
) | ||
List<AdminSpaceGetResponse> findAllByCreatedAtAfterAndCreatedAtBefore( | ||
@Param("startDate") LocalDateTime startDate, | ||
@Param("endDate") LocalDateTime endDate | ||
); | ||
} |
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