diff --git a/backend/pms/README.md b/backend/pms/README.md index 7668598..5ae4e66 100644 --- a/backend/pms/README.md +++ b/backend/pms/README.md @@ -43,7 +43,11 @@ CREATE DATABASE "pms-db";
-#### 5. Create Access Token +#### 5. Create Access / Refresh Token + +
+ +##### Access Token You can paste this in Postman or run in a terminal @@ -66,6 +70,26 @@ response: ```
+##### Refresh Token + +```shell +curl --location --request POST 'http://localhost:8080/api/v1/token/refresh' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer eyJhbGciOiJI...' + +``` + +response: + +```json +{ + "accessToken": "eyJhbGciOiJIUzUxMiJ9.eyJyb2xlcyI6W3sicm9sZSI6IkFkbWluIn1dLCJleHAiOjE3MDcwNzYxNjAsImlhdCI6MTcwNzA3NTU2MCwiZW1haWwiOiJhQGEuY29tIn0.rw0kPwa9Jpi8vNgBtej3X4QH0rDN69h1jg-sQtUY4w-sjnjYJSrpMq1S3CKOoiYL8ZWffrvX9b2uSDQNhP4GVw", + "refreshToken": "eyJhbGciOiJIUzUxMiJ9.eyJyb2xlcyI6W3sicm9sZSI6IkFkbWluIn1dLCJleHAiOjE3MDcwNzY3NjEsImlhdCI6MTcwNzA3NTU2MSwiZW1haWwiOiJhQGEuY29tIn0.HmEI79h6_IZBsZDv73kMd6XTcfz5PJBq2WrZPXNXBt1vco-osuq5PiEzDPIAn_KYTVvlb8CSlEybyJMqss8tKQ" +} +``` + +
+ ---
diff --git a/backend/pms/src/main/java/com/mini/pms/repo/FavoriteRepo.java b/backend/pms/src/main/java/com/mini/pms/repo/FavoriteRepo.java index a420b2c..5a012b7 100644 --- a/backend/pms/src/main/java/com/mini/pms/repo/FavoriteRepo.java +++ b/backend/pms/src/main/java/com/mini/pms/repo/FavoriteRepo.java @@ -19,7 +19,7 @@ public interface FavoriteRepo extends JpaRepository { boolean existsByMemberAndProperty(Member member, Property property); - void deleteByMemberAndProperty(Member member, Property property); + int deleteByMemberAndProperty(Member member, Property property); List findByMemberId(long memberId); diff --git a/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java b/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java index 3f418c5..46348a2 100644 --- a/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java +++ b/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java @@ -7,19 +7,14 @@ import com.mini.pms.service.MemberService; import com.mini.pms.util.Util; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import java.security.Principal; -import java.util.List; - -@CrossOrigin(origins = "http://localhost:3000") @RestController @RequestMapping("api/v1/users") @RequiredArgsConstructor diff --git a/backend/pms/src/main/java/com/mini/pms/service/impl/FavoriteServiceImpl.java b/backend/pms/src/main/java/com/mini/pms/service/impl/FavoriteServiceImpl.java index f43aaae..6eee851 100644 --- a/backend/pms/src/main/java/com/mini/pms/service/impl/FavoriteServiceImpl.java +++ b/backend/pms/src/main/java/com/mini/pms/service/impl/FavoriteServiceImpl.java @@ -53,7 +53,10 @@ public void addFavorite(long propertyId, long memberId) { public void removeFavorite(long propertyId, long memberId) { Member member = memberService.profile(memberId); Property property = propertyService.findById(propertyId); - favoriteRepo.deleteByMemberAndProperty(member, property); + int isDeleted = favoriteRepo.deleteByMemberAndProperty(member, property); + if (isDeleted == 0) { + throw new PlatformException("Favorite not found", HttpStatus.NOT_FOUND); + } } @Override diff --git a/backend/pms/src/main/resources/application.yml b/backend/pms/src/main/resources/application.yml index ff8732b..d8e8970 100644 --- a/backend/pms/src/main/resources/application.yml +++ b/backend/pms/src/main/resources/application.yml @@ -12,7 +12,7 @@ spring: properties: hibernate: dialect: org.hibernate.dialect.PostgreSQLDialect - format_sql: false + format_sql: true show-sql: true defer-datasource-initialization: true generate-ddl: true