Skip to content

Commit 7b8c0fa

Browse files
committedOct 27, 2024
Bug fix and added missing configs
1 parent 951932f commit 7b8c0fa

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed
 

‎src/main/java/com/bookwise/backend/config/MyDataRestConfig.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import org.springframework.web.servlet.config.annotation.CorsRegistry;
88

99
import com.bookwise.backend.entities.Book;
10+
import com.bookwise.backend.entities.Checkout;
1011
import com.bookwise.backend.entities.History;
1112
import com.bookwise.backend.entities.Message;
13+
import com.bookwise.backend.entities.Payment;
1214
import com.bookwise.backend.entities.Review;
1315

1416
@Configuration
@@ -21,11 +23,13 @@ public void configureRepositoryRestConfiguration(RepositoryRestConfiguration con
2123
CorsRegistry cors) {
2224
HttpMethod[] theUnsupportedActions = {HttpMethod.POST, HttpMethod.PATCH, HttpMethod.PUT, HttpMethod.DELETE};
2325

24-
config.exposeIdsFor(Book.class, Review.class, Message.class, History.class); //by default , spring boot not expose Primary Key of entities. Do this to expose the PK.
26+
config.exposeIdsFor(Book.class, Review.class, Message.class, History.class, Checkout.class, Payment.class); //by default , spring boot not expose Primary Key of entities. Do this to expose the PK.
2527
disableHttpMethods(Book.class, config, theUnsupportedActions);
2628
disableHttpMethods(Review.class, config, theUnsupportedActions);
2729
disableHttpMethods(Message.class, config, theUnsupportedActions);
2830
disableHttpMethods(History.class, config, theUnsupportedActions);
31+
disableHttpMethods(Checkout.class, config, theUnsupportedActions);
32+
disableHttpMethods(Payment.class, config, theUnsupportedActions);
2933

3034
/*Configure CORS Mapping*/
3135
cors.addMapping(config.getBasePath()+ "/**")

‎src/main/java/com/bookwise/backend/config/SecurityConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class SecurityConfig {
1616
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
1717
http.csrf(csrf -> csrf.disable())
1818
.authorizeHttpRequests(auth -> {
19-
auth.requestMatchers("/api/books/secure/**", "/api/reviews/secure/**","/api/messages/secure/**")
19+
auth.requestMatchers("/api/books/secure/**", "/api/reviews/secure/**","/api/messages/secure/**", "/api/payment/secure/**")
2020
.authenticated()
2121
.anyRequest().permitAll();
2222
}).oauth2ResourceServer().jwt();

‎src/main/java/com/bookwise/backend/service/BookService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void returnBook(String userEmail, Long bookId) throws Exception {
143143
LocalDate d2 = LocalDate.now();
144144
int diffInTime = d1.compareTo(d2);
145145
if(diffInTime < 0) {
146-
Payment payment = new Payment();
146+
Payment payment = paymentRepository.findByUserEmail(userEmail);
147147
payment.setAmount(payment.getAmount() + (diffInTime*-1));
148148
paymentRepository.save(payment);
149149
}

0 commit comments

Comments
 (0)
Please sign in to comment.