-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Weekly/8/issue#144 동시성 제어 (#189) * Feat: RedissonConfig 설정 * Feat: Redisson Lock 구현(임시) * Fix: RaceCondition 테스트 오류 수정 1. RedissonLock의 value로 hostId만 넘기기 2. RaceConditionTest를 SpringBootTest로 테스트 3. BeforeEach로 Redis 초기화 * Refactor: GroupMember 조회 fetch join 적용 * Refactor: random GroupMember 조회 fetch join 적용 * Refactor: 방문자 조회수 비동기 로직 추가 * Feat: 질문 지목 시 count 증가 동시성 제어 * Refactor: merge weekly9 * Refactor: 누락된 코드 추가 * Refactor: 누락된 코드 추가 * Refactor: 코드 수정 * Refactor: redissonClient 제거 * Refactor: redis 설정 변경 * Refactor: redis 설정 변경 * HotFix: 이미지 파일 resize 비율 조정 * Refactor: RedissonClient 사용 테스트 ActiveProfile 설정 * Refactor: RedissonClient 사용 테스트 Profile 설정 * Fix: Profile() 메서드에 적용 * Fix: ProfileIntegrationTest, RaceConditionTest 주석처리 * Fix: 충돌 해결 * Refactor: Random Question Response 수정 * Chore: 불필요한 Import 제거 * Import: 충돌 해결 --------- Co-authored-by: hjinshin <gudwls818@gmail.com> Co-authored-by: Kwon Da woon <82216606+momnpa333@users.noreply.github.com> * Refactor: 알림 타임아웃 수정 * Refactor: 프로필 질문 createdAt 형식 변경 * Fix: 포인트 결제 method 변경 * Feat: 관리자 api 구현 * Feat: alarm 연결 시 로그 --------- Co-authored-by: yso8296 <66588512+yso8296@users.noreply.github.com> Co-authored-by: Kwon Da woon <82216606+momnpa333@users.noreply.github.com>
- Loading branch information
1 parent
05e9100
commit 480d147
Showing
23 changed files
with
315 additions
and
40 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
12 changes: 12 additions & 0 deletions
12
src/main/java/supernova/whokie/global/annotation/AdminAuthenticate.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,12 @@ | ||
package supernova.whokie.global.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface AdminAuthenticate { | ||
|
||
} |
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
36 changes: 36 additions & 0 deletions
36
src/main/java/supernova/whokie/global/resolver/LoginAdminArgumentResolver.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,36 @@ | ||
package supernova.whokie.global.resolver; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
import supernova.whokie.global.annotation.AdminAuthenticate; | ||
import supernova.whokie.global.exception.AuthenticationException; | ||
import supernova.whokie.global.exception.ForbiddenException; | ||
import supernova.whokie.user.Role; | ||
|
||
public class LoginAdminArgumentResolver implements HandlerMethodArgumentResolver { | ||
|
||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
return parameter.hasParameterAnnotation(AdminAuthenticate.class); | ||
} | ||
|
||
@Override | ||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { | ||
HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); | ||
String userId = (String) request.getAttribute("userId"); | ||
String role = (String) request.getAttribute("role"); | ||
|
||
if (userId == null) { | ||
throw new AuthenticationException("로그인 후 이용해 주세요."); | ||
} | ||
if (!role.equals(Role.ADMIN.toString())) { | ||
throw new ForbiddenException("관리자만 이용할 수 있습니다."); | ||
} | ||
return Long.parseLong(userId); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/supernova/whokie/group/controller/AdminGroupController.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,34 @@ | ||
package supernova.whokie.group.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import supernova.whokie.global.annotation.AdminAuthenticate; | ||
import supernova.whokie.global.dto.PagingResponse; | ||
import supernova.whokie.group.controller.dto.GroupResponse; | ||
import supernova.whokie.group.service.GroupService; | ||
import supernova.whokie.group.service.dto.GroupModel; | ||
|
||
@RestController | ||
@RequestMapping("/api/admin/group") | ||
@RequiredArgsConstructor | ||
public class AdminGroupController { | ||
|
||
private final GroupService groupService; | ||
|
||
@GetMapping("") | ||
public PagingResponse<GroupResponse.Info> getAllGroups( | ||
@AdminAuthenticate Long userId, | ||
@PageableDefault(page = 0, size = 10, sort = "id", direction = Sort.Direction.ASC) Pageable pageable | ||
) { | ||
Page<GroupModel.Info> models = groupService.getAllGroupPaging(pageable); | ||
Page<GroupResponse.Info> response = models.map(GroupResponse.Info::from); | ||
return PagingResponse.from(response); | ||
} | ||
|
||
} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/supernova/whokie/question/controller/AdminQuestionController.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,43 @@ | ||
package supernova.whokie.question.controller; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.web.bind.annotation.*; | ||
import supernova.whokie.global.annotation.AdminAuthenticate; | ||
import supernova.whokie.global.dto.GlobalResponse; | ||
import supernova.whokie.global.dto.PagingResponse; | ||
import supernova.whokie.question.controller.dto.QuestionRequest; | ||
import supernova.whokie.question.controller.dto.QuestionResponse; | ||
import supernova.whokie.question.service.QuestionService; | ||
import supernova.whokie.question.service.dto.QuestionModel; | ||
|
||
@RestController | ||
@RequestMapping("/api/admin/question") | ||
@RequiredArgsConstructor | ||
public class AdminQuestionController { | ||
|
||
private final QuestionService questionService; | ||
|
||
@GetMapping("") | ||
public PagingResponse<QuestionResponse.Admin> getAllQuestionPaging( | ||
@AdminAuthenticate Long userId, | ||
@PageableDefault(page = 0, size = 10, sort = "id", direction = Sort.Direction.ASC) Pageable pageable | ||
) { | ||
Page<QuestionModel.Admin> models = questionService.getAllQuestionPaging(pageable); | ||
Page<QuestionResponse.Admin> response = models.map(QuestionResponse.Admin::from); | ||
return PagingResponse.from(response); | ||
} | ||
|
||
@PostMapping("") | ||
public GlobalResponse postCommonQuestion( | ||
@AdminAuthenticate Long userId, | ||
@RequestBody @Valid QuestionRequest.CommonCreate request | ||
) { | ||
questionService.createCommonQuestion(userId, request.toCommand()); | ||
return GlobalResponse.builder().message("질문이 등록되ㅐ었습니다.").build(); | ||
} | ||
} |
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
Oops, something went wrong.