-
Notifications
You must be signed in to change notification settings - Fork 2
๐ [fix/#456] note update ๋น ๊ฐ ์ฒ๋ฆฌ #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package umc.th.juinjang.api.limjang.controller.request; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import umc.th.juinjang.domain.limjang.model.Address; | ||
| import umc.th.juinjang.domain.limjang.model.LimjangPrice; | ||
| import umc.th.juinjang.domain.limjang.model.LimjangPriceType; | ||
| import umc.th.juinjang.domain.limjang.model.LimjangPurpose; | ||
| import umc.th.juinjang.domain.limjang.repository.NotePriceFactory; | ||
|
|
||
| public record NotePatchRequestV2( | ||
| @NotNull | ||
| LimjangPriceType priceType, | ||
|
|
||
| @Pattern(regexp = "^[0-9]+$", message = "๊ฐ๊ฒฉ์ ์ซ์๋ง ์ ๋ ฅํด์ผ ํฉ๋๋ค.") | ||
| String price, | ||
| @Pattern(regexp = "^[0-9]+$", message = "๊ฐ๊ฒฉ์ ์ซ์๋ง ์ ๋ ฅํด์ผ ํฉ๋๋ค.") | ||
| String monthlyRent, | ||
|
|
||
| String roadAddress, | ||
| String addressDetail, | ||
|
|
||
| String bcode, | ||
|
|
||
| String nickname, | ||
|
|
||
| String floor, | ||
| Integer pyong, //null ์ฒ๋ฆฌ๋ฅผ ์ํด Integer๋ก ๋ณ๊ฒฝ | ||
| String sido, | ||
| String sigungu, | ||
| String bname1, | ||
| String bname2 | ||
| ) { | ||
|
|
||
| public LimjangPrice toUpdatedPrice(LimjangPurpose purpose) { | ||
| if (price == null && monthlyRent == null) { | ||
| return LimjangPrice.empty(); | ||
| } | ||
| return NotePriceFactory.create(purpose, priceType, price, monthlyRent); | ||
| } | ||
|
|
||
| public Address toUpdatedAddress() { | ||
| if (isAddressAllEmpty()) { | ||
| return Address.empty(); | ||
| } | ||
| return Address.create(roadAddress, addressDetail, bcode, sido, sigungu, bname1, bname2); | ||
| } | ||
|
|
||
| private boolean isAddressAllEmpty() { | ||
| return isBlank(roadAddress) | ||
| && isBlank(addressDetail) | ||
| && isBlank(bcode) | ||
| && isBlank(sido) | ||
| && isBlank(sigungu) | ||
| && isBlank(bname1) | ||
| && isBlank(bname2); | ||
| } | ||
|
|
||
| private boolean isBlank(String s) { | ||
| return s == null || s.isBlank(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,67 +1,68 @@ | ||
| package umc.th.juinjang.auth.jwt; | ||
|
|
||
| import java.io.IOException; | ||
| import java.time.LocalDateTime; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.filter.OncePerRequestFilter; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.SerializationFeature; | ||
| import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
|
|
||
| import io.jsonwebtoken.ExpiredJwtException; | ||
| import jakarta.servlet.FilterChain; | ||
| import jakarta.servlet.ServletException; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.filter.OncePerRequestFilter; | ||
| import umc.th.juinjang.common.ExceptionHandler; | ||
| import umc.th.juinjang.common.code.status.ErrorStatus; | ||
|
|
||
| import java.io.IOException; | ||
| import java.time.LocalDateTime; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class JwtExceptionFilter extends OncePerRequestFilter { | ||
|
|
||
| @Override | ||
| protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { | ||
| try{ | ||
| log.info("exception filter"); | ||
| doFilter(request,response,filterChain); | ||
| log.info("jwt success"); | ||
| } catch (NullPointerException e) { | ||
| final Map<String, Object> body = new HashMap<>(); | ||
| final ObjectMapper mapper = new ObjectMapper(); | ||
| mapper.registerModule(new JavaTimeModule()); | ||
| mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
| response.setStatus(HttpServletResponse.SC_BAD_REQUEST); // ์์ธ์ ๋ง๋ HTTP ์ํ ์ฝ๋ ์ค์ | ||
| response.setContentType("application/json"); | ||
| body.put("timestamp", LocalDateTime.now()); | ||
| body.put("code", ErrorStatus.TOKEN_EMPTY.getCode()); | ||
| body.put("error", "Bad Request"); | ||
| body.put("message", ErrorStatus.TOKEN_EMPTY.getMessage()); // ์์ธ์ ๋ง๋ ๋ฉ์์ง ์ค์ | ||
| body.put("path", request.getRequestURI()); | ||
| @Override | ||
| protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, | ||
| FilterChain filterChain) throws ServletException, IOException { | ||
| try { | ||
| log.info("exception filter"); | ||
| filterChain.doFilter(request, response); | ||
| log.info("jwt success"); | ||
| } catch (NullPointerException e) { | ||
| final Map<String, Object> body = new HashMap<>(); | ||
| final ObjectMapper mapper = new ObjectMapper(); | ||
| mapper.registerModule(new JavaTimeModule()); | ||
| mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
| response.setStatus(HttpServletResponse.SC_BAD_REQUEST); // ์์ธ์ ๋ง๋ HTTP ์ํ ์ฝ๋ ์ค์ | ||
| response.setContentType("application/json"); | ||
| body.put("timestamp", LocalDateTime.now()); | ||
| body.put("code", ErrorStatus.TOKEN_EMPTY.getCode()); | ||
| body.put("error", "Bad Request"); | ||
| body.put("message", ErrorStatus.TOKEN_EMPTY.getMessage()); // ์์ธ์ ๋ง๋ ๋ฉ์์ง ์ค์ | ||
| body.put("path", request.getRequestURI()); | ||
|
|
||
| mapper.writeValue(response.getOutputStream(), body); | ||
| logger.info("jwt exception nullpointer"); | ||
| throw new ExceptionHandler(ErrorStatus.TOKEN_EMPTY); | ||
| } | ||
| catch (ExpiredJwtException e) { | ||
| final Map<String, Object> body = new HashMap<>(); | ||
| final ObjectMapper mapper = new ObjectMapper(); | ||
| mapper.registerModule(new JavaTimeModule()); | ||
| mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
| response.setStatus(419); | ||
| response.setContentType("application/json"); | ||
| body.put("timestamp", LocalDateTime.now()); | ||
| body.put("code", ErrorStatus.TOKEN_UNAUTHORIZED.getCode()); | ||
| body.put("error", "Unauthorized"); | ||
| body.put("message", ErrorStatus.TOKEN_UNAUTHORIZED.getMessage()); | ||
| body.put("path", request.getRequestURI()); | ||
| mapper.writeValue(response.getOutputStream(), body); | ||
| logger.info("jwt exception nullpointer"); | ||
| // throw new ExceptionHandler(ErrorStatus.TOKEN_EMPTY); | ||
| } catch (ExpiredJwtException e) { | ||
| final Map<String, Object> body = new HashMap<>(); | ||
| final ObjectMapper mapper = new ObjectMapper(); | ||
| mapper.registerModule(new JavaTimeModule()); | ||
| mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
| response.setStatus(419); | ||
| response.setContentType("application/json"); | ||
| body.put("timestamp", LocalDateTime.now()); | ||
| body.put("code", ErrorStatus.TOKEN_UNAUTHORIZED.getCode()); | ||
| body.put("error", "Unauthorized"); | ||
| body.put("message", ErrorStatus.TOKEN_UNAUTHORIZED.getMessage()); | ||
| body.put("path", request.getRequestURI()); | ||
|
|
||
| mapper.writeValue(response.getOutputStream(), body); | ||
| } | ||
| } | ||
| mapper.writeValue(response.getOutputStream(), body); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| package umc.th.juinjang.domain.limjang.model; | ||
|
|
||
| import java.util.Objects; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
|
|
@@ -87,4 +86,22 @@ public void update(Address newAddress) { | |
| public String getFullAddress() { | ||
| return this.roadAddress + " " + this.getAddressDetail(); | ||
| } | ||
|
|
||
| public static Address empty() { | ||
| return Address.builder().build(); // ๋ชจ๋ ํ๋ null | ||
| } | ||
|
|
||
| public boolean isEmpty() { | ||
| return isBlank(roadAddress) | ||
| && isBlank(addressDetail) | ||
| && isBlank(bcode) | ||
| && isBlank(sido) | ||
| && isBlank(sigungo) | ||
| && isBlank(bname1) | ||
| && isBlank(bname2); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๊ถ๊ธํ ๋ถ๋ถ์ด ์๊ฒผ์ต๋๋ค. isEmpty() ์กฐ๊ฑด์ด ๋ชจ๋ && ์ฐ์ฐ์๋ก ๋ค์ด๊ฐ ์๋๋ฐ, ํ๋ก ํธ์์ , addressDetail ๋ง ๋ณด๋ด๋ ๊ฒฝ์ฐ์๋ ์ ์ฅ์ด ๋ ์ ์๋ ๊ฑธ๊น์?? ํ๋ก ํธ์์ ์ ํจ์ฑ ๊ฒ์ฌ ์ฒ๋ฆฌํด์ addressDetail ๋ง ๋ณด๋ด์ฃผ๋ ๊ฒฝ์ฐ๋ ์์ง ์์๊น ํ๊ธด ํฉ๋๋ค๋ง...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ .. ์ด ๋ถ๋ถ ๋น์ฐํ ์์ธ ์ฃผ์๋ง ์ค๋ ๊ฒฝ์ฐ๋ ์์๊ฑฐ๋ผ๊ณ ์๊ฐํด์ ์ ๋ฐ์์ผ๋ก ์ฝ๋๋ฅผ ์์ฑํ๋๋ฐ, ์ด ๋ถ๋ถ PMํ์๊ฒ ํ๋ฒ ์ฌ์ญค๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค :) ๊ฐ์ฌํฉ๋๋ค. (์ถ๊ฐ๋ก ์์ธ ์ฃผ์๋ง null๋ก ์ค๋ ๊ฒฝ์ฐ๋ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง๋ ์ฌ์ญค๋ณด๊ฒ ์ต๋๋ค.) |
||
| } | ||
|
|
||
| private boolean isBlank(String s) { | ||
| return s == null || s.isBlank(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํด๋น ๋ถ๋ถ์ด 500์๋ฌ ๋ด๋ฟ๋ ๋ถ๋ถ ์์ ํ์ ๊ฑธ๊น์? ํน์ ์ ๊ทธ๋ฐ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๊ณ , ์ด๋ป๊ฒ ๊ณ ์น๊ฑด์ง ๊ฐ๋จํ๊ฒ ์ด์ผ๊ธฐ ํด์ฃผ์ค ์ ์๋์?