-
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.1
- Loading branch information
Showing
51 changed files
with
969 additions
and
365 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
7 changes: 7 additions & 0 deletions
7
layer-admin/src/main/java/org/layer/common/exception/AdminException.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,7 @@ | ||
package org.layer.common.exception; | ||
|
||
public class AdminException extends BaseCustomException { | ||
public AdminException(ExceptionType exceptionType) { | ||
super(exceptionType); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
layer-admin/src/main/java/org/layer/config/RedisConfig.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,68 @@ | ||
package org.layer.config; | ||
|
||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator; | ||
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
public class RedisConfig { | ||
@Value("${spring.data.redis.host}") | ||
private String host; | ||
|
||
@Value("${spring.data.redis.port}") | ||
private int port; | ||
|
||
@Value("${spring.data.redis.password}") | ||
private String password; | ||
|
||
// prod에서 최근 서비스 이용 시점 기록 - 1번 데이터베이스 | ||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); | ||
redisStandaloneConfiguration.setHostName(host); | ||
redisStandaloneConfiguration.setPort(port); | ||
redisStandaloneConfiguration.setDatabase(1); // 1번 데이터베이스 | ||
|
||
return new LettuceConnectionFactory(redisStandaloneConfiguration); | ||
|
||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, Object> redisTemplate() { | ||
RedisTemplate<String, Object> template = new RedisTemplate<>(); | ||
template.setConnectionFactory(redisConnectionFactory()); | ||
|
||
PolymorphicTypeValidator typeValidator = BasicPolymorphicTypeValidator | ||
.builder() | ||
.allowIfSubType(Object.class) | ||
.build(); | ||
|
||
ObjectMapper objectMapper = new ObjectMapper() | ||
.findAndRegisterModules() | ||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) | ||
.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false) | ||
.activateDefaultTyping(typeValidator, ObjectMapper.DefaultTyping.NON_FINAL) | ||
.registerModule(new JavaTimeModule()); | ||
|
||
template.setKeySerializer(new StringRedisSerializer()); | ||
template.setValueSerializer(new GenericJackson2JsonRedisSerializer(objectMapper)); | ||
|
||
return template; | ||
} | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
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
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
45 changes: 45 additions & 0 deletions
45
layer-admin/src/main/java/org/layer/retrospect/controller/AdminRetrospectApi.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,45 @@ | ||
package org.layer.retrospect.controller; | ||
|
||
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; | ||
import org.layer.domain.retrospect.dto.AdminRetrospectCountGroupBySpaceGetResponse; | ||
import org.layer.retrospect.controller.dto.AdminRetrospectCountGetResponse; | ||
import org.layer.retrospect.controller.dto.AdminRetrospectsGetResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Tag(name = "[ADMIN] 회고 데이터", description = "회고 관련 api") | ||
public interface AdminRetrospectApi { | ||
|
||
|
||
@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); | ||
|
||
@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<AdminRetrospectCountGetResponse> getRetrospectCount(@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<List<AdminRetrospectCountGroupBySpaceGetResponse>> getRetrospectCountGroupBySpace (@RequestParam("startDate") LocalDateTime startDate, | ||
@RequestParam("endDate") LocalDateTime endDate, | ||
@RequestParam("password") String password); | ||
} |
46 changes: 46 additions & 0 deletions
46
layer-admin/src/main/java/org/layer/retrospect/controller/AdminRetrospectController.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,46 @@ | ||
package org.layer.retrospect.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.layer.domain.retrospect.dto.AdminRetrospectCountGroupBySpaceGetResponse; | ||
import org.layer.retrospect.controller.dto.AdminRetrospectCountGetResponse; | ||
import org.layer.retrospect.controller.dto.AdminRetrospectsGetResponse; | ||
import org.layer.retrospect.service.AdminRetrospectService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@RequestMapping("/retrospect") | ||
@RequiredArgsConstructor | ||
@RestController | ||
public class AdminRetrospectController implements AdminRetrospectApi { | ||
private final AdminRetrospectService adminRetrospectService; | ||
|
||
@Override | ||
@GetMapping | ||
public ResponseEntity<AdminRetrospectsGetResponse> getRetrospectData( | ||
@RequestParam("startDate") LocalDateTime startDate, | ||
@RequestParam("endDate") LocalDateTime endDate, | ||
@RequestParam("password") String password) { | ||
|
||
return ResponseEntity.ok(adminRetrospectService.getRetrospectData(startDate, endDate, password)); | ||
} | ||
|
||
@Override | ||
@GetMapping("/count/user-only") | ||
public ResponseEntity<AdminRetrospectCountGetResponse> getRetrospectCount( | ||
@RequestParam("startDate") LocalDateTime startDate, | ||
@RequestParam("endDate") LocalDateTime endDate, | ||
@RequestParam("password") String password) { | ||
|
||
return ResponseEntity.ok(adminRetrospectService.getRetrospectCount(startDate, endDate, password)); | ||
} | ||
|
||
@Override | ||
@GetMapping("/count/group-by-space") | ||
public ResponseEntity<List<AdminRetrospectCountGroupBySpaceGetResponse>> getRetrospectCountGroupBySpace(LocalDateTime startDate, LocalDateTime endDate, String password) { | ||
return ResponseEntity.ok(adminRetrospectService.getRetrospectCountGroupSpace(startDate, endDate, password)); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../dto/AdminRetrospectCountGetResponse.java → .../dto/AdminRetrospectCountGetResponse.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
2 changes: 1 addition & 1 deletion
2
...ller/dto/AdminRetrospectsGetResponse.java → ...ller/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
52 changes: 52 additions & 0 deletions
52
layer-admin/src/main/java/org/layer/retrospect/service/AdminRetrospectService.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.retrospect.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.layer.domain.retrospect.dto.AdminRetrospectCountGroupBySpaceGetResponse; | ||
import org.layer.domain.retrospect.dto.AdminRetrospectGetResponse; | ||
import org.layer.domain.retrospect.repository.RetrospectAdminRepository; | ||
import org.layer.retrospect.controller.dto.AdminRetrospectCountGetResponse; | ||
import org.layer.retrospect.controller.dto.AdminRetrospectsGetResponse; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class AdminRetrospectService { | ||
private final RetrospectAdminRepository retrospectAdminRepository; | ||
|
||
@Value("${admin.password}") | ||
private String password; | ||
|
||
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()); | ||
} | ||
|
||
public AdminRetrospectCountGetResponse getRetrospectCount(LocalDateTime startDate, LocalDateTime endDate, String requestPassword) { | ||
if(!requestPassword.equals(password)) { | ||
throw new IllegalArgumentException("비밀번호가 틀렸습니다."); | ||
} | ||
|
||
Long count = retrospectAdminRepository.countRetrospectsExceptForAdminSpace(startDate, endDate); | ||
return new AdminRetrospectCountGetResponse(count); | ||
} | ||
|
||
public List<AdminRetrospectCountGroupBySpaceGetResponse> getRetrospectCountGroupSpace(LocalDateTime startDate, LocalDateTime endDate, String requestPassword) { | ||
if(!requestPassword.equals(password)) { | ||
throw new IllegalArgumentException("비밀번호가 틀렸습니다."); | ||
} | ||
|
||
return retrospectAdminRepository.countRetrospectsGroupBySpace(startDate, endDate); | ||
} | ||
} |
Oops, something went wrong.