Skip to content

Commit b9a63fd

Browse files
committed
docker-compose
1 parent 9340066 commit b9a63fd

File tree

26 files changed

+32
-17
lines changed

26 files changed

+32
-17
lines changed

api-gateway/src/main/resources/application.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ spring:
2121
- Path=/api/inventory/**
2222

2323
# NOTIFY-SERVICE
24-
- id: notification-service
24+
- id: notification-service-notifications
2525
uri: lb://NOTIFICATION-SERVICE
2626
predicates:
2727
- Path=/api/email/**
2828

29+
- id: notification-service-payments
30+
uri: lb://NOTIFICATION-SERVICE
31+
predicates:
32+
- Path=/api/payments/**
33+
2934
# ORDER-SERVICE
3035
- id: order-service-carts
3136
uri: lb://ORDER-SERVICE

favourite-service/src/main/java/com/hoangtien2k3qx1/favouriteservice/FavouriteServiceApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class FavouriteServiceApplication {
1313
public static void main(String[] args) {
1414
TimeZone.setDefault(TimeZone.getTimeZone("GMT +0:00"));
1515
SpringApplication.run(FavouriteServiceApplication.class, args);
16+
17+
1618
}
1719

1820
}

notification-service/src/main/java/com/hoangtien2k3/notificationservice/api/PaymentController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ public Mono<List<Payment>> getAllPayments() {
3939
public Mono<Void> deletePayment(@PathVariable Integer paymentId) {
4040
return paymentService.deletePayment(paymentId);
4141
}
42+
4243
}

notification-service/src/main/java/com/hoangtien2k3/notificationservice/entity/Notification.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import lombok.AllArgsConstructor;
44
import lombok.Getter;
5-
import lombok.NoArgsConstructor;
65
import lombok.Setter;
76
import org.springframework.data.annotation.Id;
87
import org.springframework.data.mongodb.core.mapping.Document;

notification-service/src/main/java/com/hoangtien2k3/notificationservice/service/impl/EmailServiceImpl.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public Mono<String> sendMailWithAttachment(EmailDetails details) {
7171
});
7272
}
7373

74-
7574
@Override
7675
public Mono<String> sendMail(MultipartFile[] files, String to, String[] cc, String subject, String body) {
7776
return Mono.fromCallable(() -> {
@@ -98,5 +97,4 @@ public Mono<String> sendMail(MultipartFile[] files, String to, String[] cc, Stri
9897
});
9998
}
10099

101-
102100
}

order-service/src/main/java/com/hoangtien2k3/orderservice/api/CartController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class CartController {
4141
@ApiResponse(code = 204, message = "No content", response = ResponseEntity.class)
4242
})
4343
@GetMapping
44-
@PreAuthorize("hasAuthority('ADMIN') and hasAuthority('USER')")
44+
@PreAuthorize("hasAuthority('ADMIN') or hasAuthority('USER')")
4545
public Mono<ResponseEntity<List<CartDto>>> findAll() {
4646
log.info("*** CartDto List, controller; fetch all categories *");
4747
return cartService.findAll()
@@ -55,7 +55,7 @@ public Mono<ResponseEntity<List<CartDto>>> findAll() {
5555
@ApiResponse(code = 204, message = "No content", response = ResponseEntity.class)
5656
})
5757
@GetMapping("/all")
58-
@PreAuthorize("hasAuthority('ADMIN') and hasAuthority('USER')")
58+
@PreAuthorize("hasAuthority('ADMIN') or hasAuthority('USER')")
5959
public Mono<ResponseEntity<Page<CartDto>>> findAll(@RequestParam(defaultValue = "0") int page,
6060
@RequestParam(defaultValue = "10") int size,
6161
@RequestParam(defaultValue = "cartId") String sortBy,

payment-service/src/main/java/com/hoangtien2k3/paymentservice/config/swagger/Swagger2Config.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
@Configuration
3030
@EnableSwagger2
3131
public class Swagger2Config {
32+
3233
@Bean
3334
public Docket api() {
3435
return new Docket(DocumentationType.SWAGGER_2)

payment-service/src/main/java/com/hoangtien2k3/paymentservice/exception/ApiExceptionHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@ public <T extends RuntimeException> ResponseEntity<ExceptionMessage> handleApiRe
5454
.now(ZoneId.systemDefault()))
5555
.build(), badRequest);
5656
}
57-
5857
}

payment-service/src/main/java/com/hoangtien2k3/paymentservice/security/JwtTokenFilter.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import io.jsonwebtoken.MalformedJwtException;
55
import io.jsonwebtoken.SignatureException;
66
import io.jsonwebtoken.UnsupportedJwtException;
7+
import org.json.HTTP;
78
import org.slf4j.Logger;
89
import org.slf4j.LoggerFactory;
910
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.http.HttpStatus;
1012
import org.springframework.security.core.Authentication;
1113
import org.springframework.security.core.context.SecurityContextHolder;
1214
import org.springframework.web.context.request.RequestContextHolder;
@@ -33,7 +35,10 @@ protected void doFilterInternal(HttpServletRequest request,
3335

3436
String token = extractToken(request);
3537

38+
39+
3640
try {
41+
3742
if (token != null && jwtProvider.validateToken(token)) {
3843
Authentication authentication = jwtProvider.getAuthentication(token);
3944
SecurityContextHolder.getContext().setAuthentication(authentication);
@@ -46,9 +51,13 @@ protected void doFilterInternal(HttpServletRequest request,
4651
}
4752
} catch (ExpiredJwtException e) {
4853
logger.error("Token has expired for request: {}", request.getRequestURI());
49-
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Token has expired");
54+
response.setStatus(HttpStatus.UNAUTHORIZED.value());
55+
response.getWriter().write("Token has expired for request");
56+
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Token has expired");
5057
} catch (MalformedJwtException | SignatureException | UnsupportedJwtException | IllegalArgumentException e) {
51-
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid token");
58+
response.setStatus(HttpStatus.UNAUTHORIZED.value());
59+
60+
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid token");
5261
}
5362
}
5463

payment-service/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://localhost:8761/eureka}
4545

4646
# swagger-ui custom path
4747
springdoc.swagger-ui.path=/swagger-ui.html
48-
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
48+
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
4949

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

user-service/src/main/java/com/hoangtien2k3/userservice/config/Swagger2Config.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@Configuration
2727
@EnableSwagger2
2828
public class Swagger2Config {
29+
2930
@Bean
3031
public Docket api() {
3132
return new Docket(DocumentationType.SWAGGER_2)

user-service/src/main/java/com/hoangtien2k3/userservice/repository/UserRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@Repository
1313
public interface UserRepository extends JpaRepository<User, Long> {
1414

15-
@Query("SELECT u FROM User u WHERE u.username = :username")
15+
@Query("SELECT u FROM User u WHERE u.username = :username") // JPQL
1616
Optional<User> findByUsername(@Param("username") String username);
1717

1818
@Query("SELECT u FROM User u WHERE u.email = :email")

user-service/src/main/java/com/hoangtien2k3/userservice/service/EmailService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ public String sendMail(EmailDetails emailDetails) {
2626
.bodyToMono(String.class)
2727
.block();
2828
}
29+
2930
}
3031

user-service/src/main/resources/application.properties

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# port
22
server.port=8088
33

4-
# name local
4+
# kafka
5+
kafka.bootstrap.servers=localhost:9092
6+
spring.kafka.producer.retries=3
7+
spring.kafka.producer.batch-size=16384
8+
spring.kafka.producer.buffer-memory=32MB
59
spring.application.name=USER-SERVICE
610

711
# diagram
@@ -18,11 +22,6 @@ spring.jpa.properties.hibernate.format_sql=false
1822
spring.jpa.generate-ddl=false
1923
spring.jpa.hibernate.ddl-auto=update
2024

21-
# kafka
22-
kafka.bootstrap.servers=localhost:9092
23-
spring.kafka.producer.retries=3
24-
spring.kafka.producer.batch-size=16384
25-
spring.kafka.producer.buffer-memory=33554432
2625
payment.kafka.consumer-group-id=userService-groupId
2726

2827
# validation

user-service/src/main/resources/application.yaml

Whitespace-only changes.

0 commit comments

Comments
 (0)