Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/najasin/na-jasin-be into…
Browse files Browse the repository at this point in the history
… feature/#21

# Conflicts:
#	src/main/java/com/najasin/domain/user/controller/UserController.java
  • Loading branch information
adoo24 committed Aug 20, 2023
2 parents 0473900 + e8dca3f commit 8685301
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/najasin/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ private Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationMa
new AntPathRequestMatcher("/success/**"),
new AntPathRequestMatcher("/api/auth"),
new AntPathRequestMatcher("/auth2/**"),
new AntPathRequestMatcher("/login/**")
new AntPathRequestMatcher("/login/**"),
new AntPathRequestMatcher("/api/*/my-manual", "GET")
).permitAll()
.requestMatchers(new AntPathRequestMatcher("/api/**")).hasAnyRole("ADMIN", "MEMBER")
.anyRequest().authenticated();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.najasin.domain.user.controller;

import static java.util.Objects.*;

import com.najasin.domain.answer.service.AnswerService;
import com.najasin.domain.answer.dto.AnswerDTO;
import com.najasin.domain.character.CharacterService;
Expand Down Expand Up @@ -32,8 +34,6 @@
import java.util.ArrayList;
import java.util.List;

import static com.najasin.domain.user.entity.QUser.user;

@RequiredArgsConstructor
@RestController
@RequestMapping("/api")
Expand Down Expand Up @@ -152,14 +152,19 @@ public ResponseEntity<ApiResponse<?>> getMyManual(
@AuthorizeUser User user

) {
// User user = userService.findById(userId);
Manual manual = new Manual();
String userId = user.getId();
manual.setNickname(user.getNickname());
manual.setBaseImage("https://picsum.photos/200/300?random=1");
CharacterItems characterInfoDTO = userUserTypeService.getCharacter(userId, userTypeName);
manual.setCharacterItems(characterService.getAllCharacterItems().getCharacterItems());
manual.setExampleKeywords(keywordService.getAllKeywords());

if(!isNull(user)) {
manual.setNickname(user.getId());
}
manual.setBaseImage("https://picsum.photos/200/300?random=1");
manual.setCharacterItems(characterService.getAllCharacterItems().getCharacterItems());
manual.setQuestions(questionService.getQuestionByQuestionTypeAndUserType(QuestionType.FOR_USER, userTypeName));
return new ResponseEntity<>(
ApiResponse.createSuccessWithData(UserResponse.SUCCESS_GET_PAGE.getMessage(), manual),
Expand Down Expand Up @@ -220,10 +225,8 @@ public ResponseEntity<ApiResponse<?>> getMyPage(
);
}

@GetMapping("/{userTypeName}/characterItems")
public ResponseEntity<ApiResponse<?>> getCharacterItems(
@PathVariable String userTypeName
){
@GetMapping("/characterItems")
public ResponseEntity<ApiResponse<?>> getCharacterItems(){
AllCharacterItems allCharacterItems = characterService.getAllCharacterItems();
return new ResponseEntity<>(
ApiResponse.createSuccessWithData(UserResponse.SUCCESS_GET_PAGE.getMessage(), allCharacterItems),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.najasin.global.resovler;

import static java.util.Objects.*;

import org.springframework.core.MethodParameter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
Expand Down Expand Up @@ -30,7 +33,11 @@ public boolean supportsParameter(MethodParameter parameter) {
@Override
public User resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
String authentication = SecurityContextHolder.getContext().getAuthentication().getName();
SecurityContext securityContext = SecurityContextHolder.getContext();
if(isNull(securityContext)) {
return null;
}
String authentication = securityContext.getAuthentication().getName();

return userService.findById(authentication);
}
Expand Down

0 comments on commit 8685301

Please sign in to comment.