API ๊ตฌ๋ถ | ๊ธฐ๋ฅ |
---|---|
ํ์๊ฐ์ | - ํ์๋ช
, ๋น๋ฐ๋ฒํธ Client์์ ์ ๋ฌ๋ฐ๊ธฐ - username : 4 ~ 10์, ์ํ๋ฒณ์๋ฌธ์(a ~ z), ์ซ์(0 ~ 9) ๊ตฌ์ฑ - password : 8 ~ 15์, ์ํ๋ฒณ๋์๋ฌธ์(a ~ z, A ~ Z), ์ซ์(0 ~ 9) ๊ตฌ์ฑ - ํ์ DB ์ค๋ณตํ์ธ ํ, ์ ์ฅ - ํ์๊ฐ์ ์ฑ๊ณต ์, Client๋ก ์ฑ๊ณต๋ฉ์์ง + ์ํ์ฝ๋ ๋ฐํ |
๋ก๊ทธ์ธ | - ํ์๋ช
, ๋น๋ฐ๋ฒํธ Client์์ ์ ๋ฌ๋ฐ๊ธฐ - ํ์ DB์์ username์ ์ฌ์ฉํด ์กฐํ โ password ์ ํจ์ฑ๊ฒ์ฌ - ๋ก๊ทธ์ธ์ฑ๊ณต โ username๊ณผ JWT ํตํด Token ๋ฐ๊ธ - Token โ Response Header์ ์ถ๊ฐ, ์ฑ๊ณต๋ฉ์์ง + ์ํ์ฝ๋ Client ๋ฐํ |
๊ฒ์๊ธ ์์ฑ | - Client Token ์ ํจ์ฑ๊ฒ์ฌ โ ๊ฒ์๊ธ์์ฑ ๊ฐ๋ฅ - ์ ๋ชฉ, ํ์๋ช , ์์ฑ๋ด์ฉ ์ ์ฅ - ์ ์ฅ๋๊ฒ์๊ธ Client ๋ฐํ |
์ ์ฒด๊ฒ์๊ธ ๋ชฉ๋ก์กฐํ | - ์ ๋ชฉ, ํ์๋ช
, ์์ฑ๋ด์ฉ, ์์ฑ๋ ์ง ์กฐํ - ์์ฑ๋ ์ง ๊ธฐ์ค ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ |
์ ํํ๊ฒ์๊ธ ์กฐํ | - ์ ํํ๊ฒ์๊ธ ์ ๋ชฉ, ํ์๋ช , ์์ฑ๋ ์ง, ์์ฑ๋ด์ฉ ์กฐํ |
์ ํํ๊ฒ์๊ธ ์์ | - ์์ ์์ฒญ ์, Client Token ์ ํจ์ฑ๊ฒ์ฌ + ๋์ผ ํ์์ผ ๊ฒฝ์ฐ์๋ง ๊ฒ์๊ธ ์์ ๊ฐ๋ฅ - ์ ๋ชฉ, ์์ฑ๋ด์ฉ ์์ - ์์ ๋๊ฒ์๊ธ Client ๋ฐํ |
์ ํํ๊ฒ์๊ธ ์ญ์ | - ์ญ์ ์์ฒญ ์, Client Token ์ ํจ์ฑ๊ฒ์ฌ + ๋์ผ ํ์์ผ ๊ฒฝ์ฐ์๋ง ๊ฒ์๊ธ ์ญ์ ๊ฐ๋ฅ - ์ฑ๊ณต๋ฉ์์ง + ์ํ์ฝ๋ Client ๋ฐํ |
๊ธฐ๋ฅ | URL | Method | RequestHeader | Request | ResponseHeader | Response |
---|---|---|---|---|---|---|
ํ์๊ฐ์ | /auth/signup | POST | - | { ย ย "username" : String, ย ย "password" : String } | - | { ย ย "status" : 200, ย ย "message" : "You have successfully signed up" } |
๋ก๊ทธ์ธ | /auth/login | POST | - | { ย ย "username" : String, ย ย "password" : String } | Authorization: Bearer <JWT> | { ย ย "status" : 200, ย ย "message" : "You have successfully logged in" } |
๊ฒ์๊ธ์์ฑ | /post | POST | Authorization: Bearer <JWT> | { ย ย "title" : String, ย ย "content" : String } | - | { ย ย "id" : Long, ย ย "username" : String, ย ย "title" : String, ย ย "content" : String, ย ย "createAt" : String, ย ย "modifiedAt" : String } |
์ ์ฒด๊ฒ์๊ธ๋ชฉ๋ก์กฐํ | /posts | GET | - | - | - | [ { ย ย "id" : Long, ย ย "username" : String, ย ย "title" : String, ย ย "content" : String, ย ย "createdAt" : String, ย ย "modifiedAt" : String }, { ย ย "id" : Long, ย ย "username" : String, ย ย "title" : String, ย ย "content" : String, ย ย "createdAt" : String, ย ย "modifiedAt" : String }, โขโขโข ] |
์ ํํ๊ฒ์๊ธ์กฐํ | /post/{post-id} | GET | - | - | - | { ย ย "id" : Long, ย ย "username" : String, ย ย "title" : String, ย ย "content" : String, ย ย "createdAt" : String, ย ย "modifiedAt" : String } |
์ ํํ๊ฒ์๊ธ์์ | /post/{post-id} | PUT | Authorization: Bearer <JWT> | { ย ย "title" : String, ย ย "content" : String } | - | { ย ย "id" : Long, ย ย "username" : String, ย ย "title" : String, ย ย "content" : String, ย ย "createdAt" : String, ย ย "modifiedAt" : String } |
์ ํํ๊ฒ์๊ธ์ญ์ | /post/{post-id} | DELETE | Authorization: Bearer <JWT> | - | - | { ย ย "status" : 200, ย ย "message" : "Your post has been deleted successfully" } |
@Entity(name = "users")
@NoArgsConstructor
@Getter
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, unique = true)
private String username;
@Column(nullable = false)
private String password;
// ์์ฑ์
@Builder
private User(String username, String password) {
this.username = username;
this.password = password;
}
// ์ ์ ํฉํ ๋ฆฌ๋ฉ์๋
public static User of(String username, String password) {
return User.builder()
.username(username)
.password(password)
.build();
}
}
public interface UserRepository extends JpaRepository<User, Long> {
}
@Getter
public class SignupRequestDto {
// build.gradle -> validation ์์กด์ฑ์ถ๊ฐ
@Size(min = 4, max = 10, message = "์ต์ 4์, ์ต๋ 10์๊น์ง ์ค์ ๊ฐ๋ฅํฉ๋๋ค")
@Pattern(regexp = "[a-z0-9]*$", message = "์ํ๋ฒณ์๋ฌธ์ ๋ฐ ์ซ์๋ก๋ง ์ค์ ๊ฐ๋ฅํฉ๋๋ค")
private String username;
@Size(min = 8, max = 15, message = "์ต์ 8์, ์ต๋ 15์๊น์ง ์ค์ ๊ฐ๋ฅํฉ๋๋ค")
@Pattern(regexp = "[a-zA-Z0-9]*$", message = "์ํ๋ฒณ๋์๋ฌธ์ ๋ฐ ์ซ์๋ก๋ง ์ค์ ๊ฐ๋ฅํฉ๋๋ค")
private String password;
}
/*build.gradle -> validation ์์กด์ฑ์ถ๊ฐ*/
// ์ ๊ทํํ์ @Size, @Pattern
implementation 'org.springframework.boot:spring-boot-starter-validation'
@Getter
public class LoginRequestDto {
private String username;
private String password;
}
@Entity
@Getter
@NoArgsConstructor // ํ๋ผ๋ฏธํฐ์๋ ๊ธฐ๋ณธ์์ฑ์
public class Post extends Timestamped {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String content;
// User Entity -> Post Entity ; ๋จ๋ฐฉํฅ์ฐ๊ด๊ด๊ณ
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_Id")
private User user;
// Client Request ๊ฐ -> Dto์์ ๋ฐ์์์ -> ๋ฎ์ด์์
@Builder // ๋น๋ํจํด : ์์ฑ์๋ฅผ ํตํด ๊ฐ์ ๋ฐ์ (-> ์ ์ ํฉํ ๋ฆฌ๋ฉ์๋)
private Post(String title, String content, User user) {
this.title = title;
this.content = content;
this.user = user;
}
// ์ ์ ํฉํ ๋ฆฌ๋ฉ์๋
public static Post of(PostRequestDto postRequestDto, User user) {
return Post.builder()
.title(postRequestDto.getTitle())
.content(postRequestDto.getContent())
.user(user)
.build();
}
// Post ์์ (Service -> RequestDto -> update ๋ฉ์๋)
public void update(PostRequestDto postRequestDto) {
this.title = postRequestDto.getTitle();
this.content = postRequestDto.getContent();
}
}
username
, password
โ ์ปฌ๋ผ ์ญ์
์์ฑ์ ๋ฐ ์ ์ ํฉํ ๋ฆฌ๋ฉ์๋ User ๋ถ๋ถ ์ถ๊ฐ
๋จ๋ฐฉํฅ์ฐ๊ด๊ด๊ณ ์ค์
@ManyToOne
์ค์ @Getter
public class PostRequestDto {
private String title;
private String content;
}
username
, password
โ ์ญ์ @Getter
public class PostResponseDto {
private Long id;
private String title;
private String username;
private String content;
private LocalDateTime createdAt;
private LocalDateTime modifiedAt;
// ์์ฑ์
@Builder
private PostResponseDto(Long id,
String title, String username, String content,
LocalDateTime createdAt, LocalDateTime modifiedAt) {
this.id = id;
this.title = title;
this.username = username;
this.content = content;
this.createdAt = createdAt;
this.modifiedAt = modifiedAt;
}
// ์ ์ ํฉํ ๋ฆฌ๋ฉ์๋
public static PostResponseDto of(Post post) {
return PostResponseDto.builder()
.id(post.getId())
.title(post.getTitle())
.username(post.getUser().getUsername())
.content(post.getContent())
.createdAt(post.getCreatedAt())
.modifiedAt(post.getModifiedAt())
.build();
}
}
// JWT
compileOnly group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2'
# JWT SecretKey
jwt.secret.key=<์ํธํ์ฝ๋>
@Slf4j
@Component
@RequiredArgsConstructor
public class JwtUtil {
/* JWT Token ์์ฑ ํ์๊ฐ */
// Header key
public static final String AUTHORIZATION_HEADER = "Authorization";
// ์ฌ์ฉ์ ๊ถํ๊ฐ key
public static final String AUTHORIZATION_KEY = "auth";
// JWT Token ์ธ์ฆ๋ฐฉ์ (Bearer + JWT Token ๊ฐ์ด ์ ์ก)
private static final String BEARER_PREFIX = "Bearer ";
// JWT Token ๋ง๋ฃ์๊ฐ (1h)
private static final long TOKEN_TIME = 60 * 60 * 1000L;
// WT SecretKey ๋ถ๋ฌ์ค๊ธฐ
@Value("${jwt.secret.key}")
private String secretKey;
// JWT Token ์๋ช
๋ฐ ๊ฒ์ฆ์ฉ๋
private Key key;
// JWT Token ์์ฑ(์๋ช
) ์๊ณ ๋ฆฌ์ฆ
private final SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
// SecretKey ๋์ฝ๋ฉ ํ, ์๋ช
๋ฐ ๊ฒ์ฆ์ ํ์ํ key ์์ฑ
@PostConstruct
public void init() {
// secretKey -> ๋์ฝ๋ฉ -> byte๋ฐฐ์ด์ ๋ด์
byte[] bytes = Base64.getDecoder().decode(secretKey);
// ๋์ฝ๋ฉ ํ byte๋ฐฐ์ด -> JWT Token ์๋ช
๋ฐ ๊ฒ์ฆ์ ํ์ํ key ์์ฑ
key = Keys.hmacShaKeyFor(bytes);
}
/* 1. Client Request Header -> JWT Token ๊ฐ์ ธ์ค๊ธฐ */
public String getToken(HttpServletRequest httpServletRequest) {
// Header์ ์๋ JWT Token -> clientToken์ ๋ด์
String clientToken = httpServletRequest.getHeader(AUTHORIZATION_HEADER);
// clientToken ์กด์ฌ + Bearer๋ก ์์ -> JWT Token ๊ฐ๋ง ์ถ์ถ
if (StringUtils.hasText(clientToken) && clientToken.startsWith(BEARER_PREFIX)) {
return clientToken.substring(7);
}
return null;
}
/* 2. JWT Token ์์ฑ */
public String createToken(String username) {
Date date = new Date();
return BEARER_PREFIX +
Jwts.builder()
.setSubject(username)
.setExpiration(new Date(date.getTime() + TOKEN_TIME))
.setIssuedAt(date)
.signWith(key, signatureAlgorithm)
.compact();
}
/* 3. JWT Token ๊ฒ์ฆ */
public boolean validateToken(String token) {
try {
Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token);
return true;
} catch (SecurityException | MalformedJwtException exception) {
log.info("Invalid JWT signature, ์ ํจํ์ง ์๋ JWT ์๋ช
์
๋๋ค");
} catch (ExpiredJwtException exception) {
log.info("Expired JWT Token, ๋ง๋ฃ๋ JWT Token ์
๋๋ค");
} catch (UnsupportedJwtException exception) {
log.info("Unsupported JWT Token, ์ง์๋์ง ์๋ JWT Token ์
๋๋ค");
} catch (IllegalArgumentException exception) {
log.info("JWT claims is empty, ์๋ชป๋ JWT Token ์
๋๋ค");
}
return false;
}
/* 4. JWT Token -> ํ์์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ */
public Claims getUserInfoFromToken(String token) {
return Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token).getBody();
}
}
@Getter
public class StatusMessageResponseDto {
private Integer status;
private String message;
// ์์ฑ์
@Builder
private StatusMessageResponseDto(Integer status, String message) {
this.status = status;
this.message = message;
}
// ์ ์ ํฉํ ๋ฆฌ๋ฉ์๋
public static StatusMessageResponseDto of(Integer status, String message) {
return StatusMessageResponseDto.builder()
.status(status)
.message(message)
.build();
}
}
@RestController
@RequiredArgsConstructor
@RequestMapping("/auth")
public class UserController {
private final UserService userService;
// ํ์๊ฐ์
@PostMapping("/signup")
public ResponseEntity<StatusMessageResponseDto> signup(@Valid @RequestBody SignupRequestDto signupRequestDto) {
return userService.signup(signupRequestDto);
}
}
@Service
@RequiredArgsConstructor
public class UserService {
private final UserRepository userRepository;
private final JwtUtil jwtUtil;
// ํ์๊ฐ์
@Transactional
public ResponseEntity<StatusMessageResponseDto> signup(SignupRequestDto signupRequestDto) {
// id/pw ๊ฐ์ ธ์ค๊ธฐ
String username = signupRequestDto.getUsername();
String password = signupRequestDto.getPassword();
// ํ์์ค๋ณตํ์ธ (Optional -> ๊ฒฐ๊ณผ๊ฐ Null ํ์ฉ)
Optional<User> duplicationTest = userRepository.findByUsername(username);
if (duplicationTest.isPresent()) {
throw new IllegalArgumentException("A Duplicate user already exists");
}
// ํ์์ ๋ณด -> Entity ์ด๊ธฐํ
User user = User.of(username, password);
// Entity -> DB ์ ์ฅ
userRepository.save(user);
// ํ์๊ฐ์
์ฑ๊ณต ์, Client๋ก ์ฑ๊ณต๋ฉ์์ง + ์ํ์ฝ๋ ๋ฐํ
return ResponseEntity.ok(StatusMessageResponseDto.of(200, "You have successfully signed up"));
}
}
public interface UserRepository extends JpaRepository<User, Long> {
// ํ์๊ฐ์
-> ์ค๋ณต๊ฒ์ฌ
Optional<User> findByUsername(String username);
}
/* ์๋ถ๋ถ ์๋ต */
// ๋ก๊ทธ์ธ
@PostMapping("/login")
public ResponseEntity<StatusMessageResponseDto> login(@RequestBody LoginRequestDto loginRequestDto,
HttpServletResponse httpServletResponse) {
return userService.login(loginRequestDto, httpServletResponse);
}
/* ๋ท๋ถ๋ถ ์๋ต */
/* ์๋ถ๋ถ ์๋ต */
// ๋ก๊ทธ์ธ
@Transactional(readOnly = true)
public ResponseEntity<StatusMessageResponseDto> login(LoginRequestDto loginRequestDto,
HttpServletResponse httpServletResponse) {
// id/pw ๊ฐ์ ธ์ค๊ธฐ
String username = loginRequestDto.getUsername();
String password = loginRequestDto.getPassword();
// ํ์์ ํจ์ฑ๊ฒ์ฌ
User user = userRepository.findByUsername(username).orElseThrow(
() -> new IllegalArgumentException("This account does not exist")
);
// ๋น๋ฐ๋ฒํธ์ ํจ์ฑ๊ฒ์ฌ
if (! user.getPassword().equals(password)) {
throw new IllegalArgumentException("This password is invalid");
}
// ๋ก๊ทธ์ธ์ฑ๊ณต -> ResponseHeader์ JWT Token ๋ณด๋
httpServletResponse.addHeader(JwtUtil.AUTHORIZATION_HEADER, jwtUtil.createToken(user.getUsername()));
// ๋ก๊ทธ์ธ ์ฑ๊ณต ์, Client๋ก ์ฑ๊ณต๋ฉ์์ง + ์ํ์ฝ๋ ๋ฐํ
return ResponseEntity.ok(StatusMessageResponseDto.of(200, "You have successfully logged in"));
}
/* ๋ท๋ถ๋ถ ์๋ต */
/* ์๋ถ๋ถ ์๋ต */
// Post ์์ฑ
@PostMapping("/post")
public PostResponseDto createPost(@RequestBody PostRequestDto postRequestDto,
HttpServletRequest httpServletRequest) {
return postService.createPost(postRequestDto, httpServletRequest);
}
/* ๋ท๋ถ๋ถ ์๋ต */
/* ์๋ถ๋ถ ์๋ต */
private final PostRepository postRepository;
private final UserRepository userRepository;
private final JwtUtil jwtUtil;
// Post ์์ฑ
@Transactional // DB์ฒ๋ฆฌ ์์
์ค ์ค๋ฅ -> ๋ชจ๋ ์์
์์ํ๋ก ๋ณต๊ตฌ
public PostResponseDto createPost(PostRequestDto postRequestDto,
HttpServletRequest httpServletRequest) {
// 1. HTTP Request Header -> JWT Token ๊ฐ์ ธ์ค๊ธฐ
String token = jwtUtil.getToken(httpServletRequest);
Claims claims;
// 2. JWT Token ์ ํจ -> Post ์์ฑ ๊ฐ๋ฅ
if (token != null) {
// 2-1. JWT Token ๊ฒ์ฆ
if (jwtUtil.validateToken(token)) {
// JWT Token ์์ ์ฌ์ฉ์์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
claims = jwtUtil.getUserInfoFromToken(token);
} else {
throw new IllegalArgumentException("Token Error");
}
// 2-2. Token์์ ๊ฐ์ ธ์จ ์ฌ์ฉ์ ์ ๋ณด -> DB ์กฐํ
User user = userRepository.findByUsername(claims.getSubject()).orElseThrow(
() -> new IllegalArgumentException("This account does not exist")
);
// 2-3. ์์ฒญ๋ฐ์ DTO -> DB์ ์ ์ฅํ ๊ฐ์ฒด์์ฑ
Post post = postRepository.saveAndFlush(Post.of(postRequestDto, user));
// 2-4. ResponseDto์ ๊ฐ์ฒด๋ด์ ๋ฐํ
return PostResponseDto.of(post);
} else {
return null;
}
}
/* ๋ท๋ถ๋ถ ์๋ต */
/* ์๋ถ๋ถ ์๋ต */
// Post ์์
@PutMapping("/post/{post-id}")
public PostResponseDto updatePost(@PathVariable(name="post-id") Long postId,
@RequestBody PostRequestDto postRequestDto,
HttpServletRequest httpServletRequest) {
return postService.updatePost(postId, postRequestDto, httpServletRequest);
}
/* ๋ท๋ถ๋ถ ์๋ต */
/* ์๋ถ๋ถ ์๋ต */
// Post ์์
@Transactional
public PostResponseDto updatePost(Long postId, PostRequestDto postRequestDto,
HttpServletRequest httpServletRequest) {
// 1. HTTP Request Header -> JWT Token ๊ฐ์ ธ์ค๊ธฐ
String token = jwtUtil.getToken(httpServletRequest);
Claims claims;
// 2. JWT Token ์ ํจ -> Post ์์ ๊ฐ๋ฅ
if (token != null) {
// 2-1. JWT Token ๊ฒ์ฆ
if (jwtUtil.validateToken(token)) {
// JWT Token ์์ ์ฌ์ฉ์์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
claims = jwtUtil.getUserInfoFromToken(token);
} else {
throw new IllegalArgumentException("Token Error");
}
// 2-2. User ์ ํจ์ฑ๊ฒ์ฌ
User user = userRepository.findByUsername(claims.getSubject()).orElseThrow(
() -> new IllegalArgumentException("This account does not exist")
);
// 2-3. Post ์ ํจ์ฑ๊ฒ์ฌ
Post updatePost = postRepository.findById(postId).orElseThrow(
() -> new IllegalArgumentException("The Post does not exist")
);
// 2-4. ํ์์์ ์ ํจ์ฑ๊ฒ์ฌ
if (! updatePost.getUser().getUsername().equals(user.getUsername())) {
throw new IllegalArgumentException("You are not authorized to update this post");
}
// 2-5. Post ์์
updatePost.update(postRequestDto);
// 2-6. update ๋ Post ๋ฐํ
return PostResponseDto.of(updatePost);
} else {
return null;
}
}
/* ๋ท๋ถ๋ถ ์๋ต */
/* ์๋ถ๋ถ ์๋ต */
// Post ์ญ์
@DeleteMapping("/post/{post-id}")
public ResponseEntity<StatusMessageResponseDto> deletePost(@PathVariable(name="post-id") Long postId,
HttpServletRequest httpServletRequest) {
return postService.deletePost(postId, httpServletRequest);
}
/* ๋ท๋ถ๋ถ ์๋ต */
/* ์๋ถ๋ถ ์๋ต */
// Post ์ญ์
@Transactional
public ResponseEntity<StatusMessageResponseDto> deletePost(Long postId,
HttpServletRequest httpServletRequest) {
// 1. HTTP Request Header -> JWT Token ๊ฐ์ ธ์ค๊ธฐ
String token = jwtUtil.getToken(httpServletRequest);
Claims claims;
// 2. JWT Token ์ ํจ -> Post ์์ ๊ฐ๋ฅ
if (token != null) {
// 2-1. JWT Token ๊ฒ์ฆ
if (jwtUtil.validateToken(token)) {
// JWT Token ์์ ์ฌ์ฉ์์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
claims = jwtUtil.getUserInfoFromToken(token);
} else {
throw new IllegalArgumentException("Token Error");
}
// 2-2. User ์ ํจ์ฑ๊ฒ์ฌ
User user = userRepository.findByUsername(claims.getSubject()).orElseThrow(
() -> new IllegalArgumentException("This account does not exist")
);
// 2-3. Post ์ ํจ์ฑ๊ฒ์ฌ
Post deletePost = postRepository.findById(postId).orElseThrow(
() -> new IllegalArgumentException("The Post does not exist")
);
// 2-4. ํ์์์ ์ ํจ์ฑ๊ฒ์ฌ
if (!deletePost.getUser().getUsername().equals(user.getUsername())) {
throw new IllegalArgumentException("You are not authorized to delete this post");
}
// 2-5. Post ์ญ์
postRepository.delete(deletePost);
// 2-6. Post์ญ์ ์ฑ๊ณต ์, Client๋ก ์ฑ๊ณต๋ฉ์์ง + ์ํ์ฝ๋ ๋ฐํ
return ResponseEntity.ok(StatusMessageResponseDto.of(200, "Your Post has been deleted successfully"));
} else {
return null;
}
}
/* ๋ท๋ถ๋ถ ์๋ต */