JPA

[JPA] 6. DELETE 방식의 이해

Song hyun 2024. 9. 27. 14:17
728x90
반응형

[JPA] 6. DELETE 방식의 이해

 

1. DELETE 방식의 특징

 

2. 시나리오 코드

package com.tenco.demo.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController // IoC 대상 (싱글톤 패턴으로 관리)
public class DeleteController {

    // 멀티 스레딩 환경!
    // http://localhost:8080/delete/100?acount=우리은행
    @DeleteMapping("/delete/{userId}")
    @GetMapping("/delete/{userId}")
    public ResponseEntity<?> delete(@PathVariable(name = "userId")String userId,
                                                             @RequestParam(name="account")String account){       
        System.out.println("userId : "+userId);
        System.out.println("account : "+account);
        return ResponseEntity.status(200).body("정상 삭제 되었습니다.");
    }
}
728x90
반응형