Skip to content

Commit

Permalink
chage: add regex and modify some
Browse files Browse the repository at this point in the history
  • Loading branch information
DuyTC1811 committed Jul 19, 2023
1 parent 4482037 commit 9da2bdc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.stereotype.Component;

@Component
public class CommandController<RESPONSE, REQUEST extends ICommand<RESPONSE>> {
public abstract class CommandController<RESPONSE, REQUEST extends ICommand<RESPONSE>> {
@Autowired
private ISpringBus springBus;

Expand Down
2 changes: 1 addition & 1 deletion cqrs/src/main/java/io/cqrs/controller/PageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.springframework.stereotype.Component;

@Component
public class PageController<RESPONSE, REQUEST extends IPage<RESPONSE>> {
public abstract class PageController<RESPONSE, REQUEST extends IPage<RESPONSE>> {
@Autowired
private ISpringBus springBus;

Expand Down
2 changes: 1 addition & 1 deletion cqrs/src/main/java/io/cqrs/controller/QueryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.stereotype.Component;

@Component
public class QueryController<RESPONSE, REQUEST extends IQuery<RESPONSE>> {
public abstract class QueryController<RESPONSE, REQUEST extends IQuery<RESPONSE>> {
@Autowired
private ISpringBus springBus;

Expand Down
6 changes: 3 additions & 3 deletions cqrs/src/main/java/io/cqrs/dispascher/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public class Registry {

public Registry(ApplicationContext applicationContext) {
// Register ICommandHandler
Arrays.stream(applicationContext.getBeanNamesForType(ICommandHandler.class))
Arrays.stream(applicationContext.getBeanNamesForType(ICommandHandler.class)).parallel()
.forEach(name -> registerCommand(applicationContext, name));

// Register IQueryHandler
Arrays.stream(applicationContext.getBeanNamesForType(IQueryHandler.class))
Arrays.stream(applicationContext.getBeanNamesForType(IQueryHandler.class)).parallel()
.forEach(name -> registerQuery(applicationContext, name));

// Register IPageHandler
Arrays.stream(applicationContext.getBeanNamesForType(IPageHandler.class))
Arrays.stream(applicationContext.getBeanNamesForType(IPageHandler.class)).parallel()
.forEach(name -> registerPage(applicationContext, name));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package io.exceptions.handlers;

import io.exceptions.models.BaseException;
import io.exceptions.models.ResponseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@ControllerAdvice
@RestControllerAdvice
public class ExceptionHandlers extends ResponseEntityExceptionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionHandlers.class);

@ExceptionHandler(Exception.class)
public ResponseEntity<ResponseException> handlerException(BaseException exception) {
public ResponseEntity<ResponseException> handlerException(Exception exception) {
LOGGER.error("Info Exception {}", exception.getMessage());
return ResponseEntity.badRequest().body(new ResponseException(exception.getMessage()));
}
Expand Down
9 changes: 9 additions & 0 deletions utilities/src/main/java/io/utilities/regexs/RegexUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.utilities.regexs;

import java.util.regex.Pattern;

public class RegexUtils {
public static boolean validateRegex(String value, String regex) {
return Pattern.matches(regex, value);
}
}

0 comments on commit 9da2bdc

Please sign in to comment.