diff --git a/demo-one/README.md b/demo-one/README.md deleted file mode 100644 index b8fd6876..00000000 --- a/demo-one/README.md +++ /dev/null @@ -1,67 +0,0 @@ -![Muscle and Fitness Server Social Image](https://raw.githubusercontent.com/johnnymillergh/MaterialLibrary/master/muscle-and-fitness/muscle-and-fitness-server-social-image.png) -[![GitHub release](https://img.shields.io/github/release/johnnymillergh/muscle-and-fitness-server.svg)](https://github.com/johnnymillergh/muscle-and-fitness-server/releases) -[![Build Status](https://travis-ci.com/johnnymillergh/muscle-and-fitness-server.svg?branch=master)](https://travis-ci.com/johnnymillergh/muscle-and-fitness-server) -[![GitHub issues](https://img.shields.io/github/issues/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server/issues) -[![GitHub forks](https://img.shields.io/github/forks/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server/network) -[![GitHub stars](https://img.shields.io/github/stars/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server) -[![GitHub license](https://img.shields.io/github/license/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server/blob/master/LICENSE) -[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/johnnymillergh/muscle-and-fitness-server.svg?style=popout)](https://github.com/johnnymillergh/muscle-and-fitness-server) -[![GitHub repo size](https://img.shields.io/github/repo-size/johnnymillergh/muscle-and-fitness-server.svg)](https://github.com/johnnymillergh/muscle-and-fitness-server) -[![Twitter](https://img.shields.io/twitter/url/https/github.com/johnnymillergh/muscle-and-fitness-server?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fjohnnymillergh%2Fmuscle-and-fitness-server) - -# Demo One - -**Demo One** a sub mudule of Muscle and Fitness Server (M&F). - -[Official Docker Image](https://hub.docker.com/r/ijohnnymiller/demo-one-prod) - -## Features - -Here is the highlights of **Demo One**: - -1. Inherited from the most modern and newest Spring frameworks: - - `org.springframework.boot:spring-boot-starter-parent` - [![Spring Boot](https://maven-badges.herokuapp.com/maven-central/org.springframework.boot/spring-boot-starter-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.springframework.boot/spring-boot-starter-parent/) - `org.springframework.cloud:spring-cloud-dependencies` - [![Spring Cloud](https://maven-badges.herokuapp.com/maven-central/org.springframework.cloud/spring-cloud-dependencies/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.springframework.cloud/spring-cloud-dependencies/) - -2. Interact with Demo Two with Spring Cloud OpenFeign. - -## Usage - -1. Clone or download this project. - - ```shell - $ git clone https://github.com/johnnymillergh/exrx-net-crawler-server.git - ``` - -2. Build with newest Intellij IDEA. - -3. Click the green triangle to Run. - -## Maintainers - -[@johnnymillergh](https://github.com/johnnymillergh). - -## Contributing - -Feel free to dive in! [Open an issue](https://github.com/johnnymillergh/spring-cloud-tutorial/issues/new). - -### Contributors - -This project exists thanks to all the people who contribute. - -- Johnny Miller [[@johnnymillergh](https://github.com/johnnymillergh)] -- … - - -### Sponsors - -Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://become-a-sponsor.org)] - -## License - -[Apache License](https://github.com/johnnymillergh/exrx-net-crawler-server/blob/master/LICENSE) © Johnny Miller - -2020 - Present - - diff --git a/demo-one/pom.xml b/demo-one/pom.xml deleted file mode 100644 index 280f07d9..00000000 --- a/demo-one/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - 4.0.0 - - - demo-one - Demo 1 - Demo Project 1 for Spring Cloud microservice. - - 11 - 8770 - - - com.jmsoftware - muscle-and-fitness-server - 0.0.1-SNAPSHOT - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - com.google.cloud.tools - jib-maven-plugin - 2.0.0 - - - - compilingPhaseJib - compile - - dockerBuild - - - - - packagingPhaseJib - package - - build - - - - - - openjdk:11.0.5-slim - - - docker.io/ijohnnymiller/${project.artifactId}-${envAlias} - - ${project.version} - - - - - /${project.artifactId}-${envAlias} - - -Xmx256m - - - ${port} - - USE_CURRENT_TIMESTAMP - - - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - de.codecentric - spring-boot-admin-starter-client - ${spring-boot-admin.version} - - - org.springframework.cloud - spring-cloud-starter-zipkin - - - - com.jmsoftware - common - 0.0.1-SNAPSHOT - - - diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/DemoOneApplication.java b/demo-one/src/main/java/com/jmsoftware/demoone/DemoOneApplication.java deleted file mode 100644 index a7c7bc9c..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/DemoOneApplication.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.jmsoftware.demoone; - -import com.jmsoftware.demoone.universal.configuration.ProjectProperty; -import com.jmsoftware.demoone.universal.configuration.ServerConfiguration; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.cloud.openfeign.EnableFeignClients; - -import java.time.Duration; -import java.time.Instant; -import java.util.TimeZone; - -/** - *

DemoOneApplication

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/15/20 10:20 PM - **/ -@Slf4j -@EnableFeignClients -@EnableDiscoveryClient -@SpringBootApplication -public class DemoOneApplication { - private static final String LINE_SEPARATOR = System.lineSeparator(); - private static ProjectProperty projectProperty; - private static ServerConfiguration serverConfiguration; - - public DemoOneApplication(ProjectProperty projectProperty, ServerConfiguration serverConfiguration) { - DemoOneApplication.projectProperty = projectProperty; - DemoOneApplication.serverConfiguration = serverConfiguration; - } - - public static void main(String[] args) { - var startInstant = Instant.now(); - SpringApplication.run(DemoOneApplication.class, args); - var endInstant = Instant.now(); - var duration = Duration.between(startInstant, endInstant); - log.info("🥳 Congratulations! 🎉"); - log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion()); - log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias()); - log.info("⏳ Deployment duration: {} seconds ({} ms)", duration.getSeconds(), duration.toMillis()); - log.info("⏰ App started at {} (timezone - {})", endInstant, TimeZone.getDefault().getDisplayName()); - log.info("{} App running at{} - Local: http://localhost:{}{}/{} - Network: {}/", - LINE_SEPARATOR, LINE_SEPARATOR, serverConfiguration.getServerPort(), projectProperty.getContextPath(), - LINE_SEPARATOR, serverConfiguration.getBaseUrl()); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/math/MathController.java b/demo-one/src/main/java/com/jmsoftware/demoone/math/MathController.java deleted file mode 100644 index f7480bc5..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/math/MathController.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.jmsoftware.demoone.math; - -import com.jmsoftware.common.bean.ResponseBodyBean; -import com.jmsoftware.demoone.math.domain.AddPayload; -import com.jmsoftware.demoone.math.domain.SubtractPayload; -import com.jmsoftware.demoone.math.service.MathService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -/** - *

MathController

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:19 AM - **/ -@RestController -@RequestMapping("/math") -@RequiredArgsConstructor -@Api(tags = {"Math Controller"}) -public class MathController { - private final MathService mathService; - - @GetMapping("/add") - @ApiOperation(value = "/add", notes = "Addition operation") - public ResponseBodyBean add(AddPayload payload) { - return ResponseBodyBean.ofDataAndMessage(mathService.add(payload.getParameterList()), "Done"); - } - - @GetMapping("/subtract") - @ApiOperation(value = "/subtract", notes = "Subtraction operation") - public ResponseBodyBean subtract(@Valid SubtractPayload payload) { - return ResponseBodyBean.ofDataAndMessage(mathService.subtract(payload.getParameter1(), payload.getParameter2()), - "Done"); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/math/domain/AddPayload.java b/demo-one/src/main/java/com/jmsoftware/demoone/math/domain/AddPayload.java deleted file mode 100644 index cc8ab21b..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/math/domain/AddPayload.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.jmsoftware.demoone.math.domain; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -/** - *

AddPayload

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:21 AM - **/ -@Data -public class AddPayload { - @NotEmpty - private List parameterList; -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/math/domain/SubtractPayload.java b/demo-one/src/main/java/com/jmsoftware/demoone/math/domain/SubtractPayload.java deleted file mode 100644 index d79f1f82..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/math/domain/SubtractPayload.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.jmsoftware.demoone.math.domain; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - *

SubtractPayload

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:46 AM - **/ -@Data -public class SubtractPayload { - @NotNull - private Double parameter1; - @NotNull - private Double parameter2; -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/math/service/MathService.java b/demo-one/src/main/java/com/jmsoftware/demoone/math/service/MathService.java deleted file mode 100644 index 346dcf0a..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/math/service/MathService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.jmsoftware.demoone.math.service; - -import java.util.List; - -/** - *

MathService

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:23 AM - */ -public interface MathService { - /** - * Add double. - * - * @param parameterList the parameter list - * @return the double - */ - Double add(List parameterList); - - /** - * Subtract double. - * - * @param parameter1 the parameter 1 - * @param parameter2 the parameter 2 - * @return the double - */ - Double subtract(Double parameter1, Double parameter2); -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/math/service/impl/MathServiceImpl.java b/demo-one/src/main/java/com/jmsoftware/demoone/math/service/impl/MathServiceImpl.java deleted file mode 100644 index a84f9146..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/math/service/impl/MathServiceImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.jmsoftware.demoone.math.service.impl; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjectUtil; -import com.jmsoftware.common.exception.BusinessException; -import com.jmsoftware.demoone.math.service.MathService; -import com.jmsoftware.demoone.remote.DemoTwoService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.List; - -/** - *

MathServiceImpl

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:32 AM - **/ -@Slf4j -@Service -@RequiredArgsConstructor -public class MathServiceImpl implements MathService { - private final DemoTwoService demoTwoService; - - @Override - public Double add(List parameterList) { - if (CollectionUtil.isEmpty(parameterList)) { - throw new BusinessException("parameterList is empty!"); - } - var result = parameterList.stream().mapToDouble(parameter -> parameter).sum(); - log.info("Addition operation done. parameterList: {}, result: {}", parameterList, result); - this.callRemote(); - return result; - } - - @Override - public Double subtract(Double parameter1, Double parameter2) { - if (!ObjectUtil.isAllNotEmpty(parameter1, parameter2)) { - throw new BusinessException( - String.format("Subtraction parameter is invalid! parameter1: %s, parameter2: %s", - parameter1, parameter2)); - } - return NumberUtil.sub(parameter1, parameter2); - } - - private void callRemote() { - var params1 = new HashMap(4); - params1.put("parameter1", 1D); - params1.put("parameter2", 2D); - var response1 = demoTwoService.divide(params1); - log.info("Called demo-two remote service. response: {}", response1); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/remote/DemoTwoService.java b/demo-one/src/main/java/com/jmsoftware/demoone/remote/DemoTwoService.java deleted file mode 100644 index 54d64da0..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/remote/DemoTwoService.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.jmsoftware.demoone.remote; - -import com.jmsoftware.common.bean.ResponseBodyBean; -import feign.Headers; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.Map; - -import static org.springframework.web.bind.annotation.RequestMethod.GET; - -/** - *

DemoTwoService

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 9:42 AM - */ -@FeignClient(name = "demo-two") -//@Qualifier(value = "demoTwoService") -public interface DemoTwoService { - /** - * Multiply response body bean. - * - * @param params the params - * @return the response body bean - */ - @RequestMapping(value = "/math/multiply", method = GET) - @Headers("Content-Type: application/json") - ResponseBodyBean multiply(@RequestParam Map params); - - /** - * Divide response body bean. - * - * @param params the params - * @return the response body bean - */ - @RequestMapping(value = "/math/divide", method = GET) - @Headers("Content-Type: application/json") - ResponseBodyBean divide(@RequestParam Map params); -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/ExceptionControllerAdvice.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/ExceptionControllerAdvice.java deleted file mode 100644 index 62f968b6..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/ExceptionControllerAdvice.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.jmsoftware.demoone.universal.aspect; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.json.JSONUtil; -import com.jmsoftware.common.bean.ResponseBodyBean; -import com.jmsoftware.common.constant.HttpStatus; -import com.jmsoftware.common.exception.BaseException; -import com.jmsoftware.common.util.RequestUtil; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.support.DefaultMessageSourceResolvable; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.validation.BindException; -import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; -import org.springframework.web.servlet.NoHandlerFoundException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.validation.ConstraintViolationException; -import java.util.Objects; - -/** - *

ExceptionControllerAdvice

- *

- * Exception advice for global controllers. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-03-02 17:39 - **/ -@Slf4j -@ControllerAdvice -public class ExceptionControllerAdvice { - /** - *

Exception handler.

- *

ATTENTION: In this method, cannot throw any exception.

- * - * @param request HTTP request - * @param exception any kinds of exception occurred in controller - * @return custom exception info - */ - @ResponseBody - @ExceptionHandler(value = Exception.class) - public ResponseBodyBean handleException(HttpServletRequest request, - HttpServletResponse response, - Exception exception) { - log.error("Exception occurred when [{}] requested access. URL: {}", - RequestUtil.getRequestIpAndPort(request), - request.getServletPath()); - - // FIXME: THIS IS NOT A PROBLEM - // ATTENTION: Use only ResponseBodyBean.ofStatus() in handleException() method and DON'T throw any exception - if (exception instanceof NoHandlerFoundException) { - log.error("[GlobalExceptionCapture] NoHandlerFoundException: Request URL = {}, HTTP method = {}", - ((NoHandlerFoundException) exception).getRequestURL(), - ((NoHandlerFoundException) exception).getHttpMethod()); - response.setStatus(HttpStatus.NOT_FOUND.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.NOT_FOUND); - } else if (exception instanceof HttpRequestMethodNotSupportedException) { - log.error("[GlobalExceptionCapture] HttpRequestMethodNotSupportedException: " + - "Current method is {}, Support HTTP method = {}", - ((HttpRequestMethodNotSupportedException) exception).getMethod(), - JSONUtil.toJsonStr( - ((HttpRequestMethodNotSupportedException) exception).getSupportedHttpMethods())); - response.setStatus(HttpStatus.METHOD_NOT_ALLOWED.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.METHOD_NOT_ALLOWED); - } else if (exception instanceof MethodArgumentNotValidException) { - log.error("[GlobalExceptionCapture] MethodArgumentNotValidException: {}", exception.getMessage()); - response.setStatus(HttpStatus.BAD_REQUEST.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.BAD_REQUEST.getCode(), - getFieldErrorMessageFromException((MethodArgumentNotValidException) exception), - null); - } else if (exception instanceof ConstraintViolationException) { - log.error("[GlobalExceptionCapture] ConstraintViolationException: {}", exception.getMessage()); - response.setStatus(HttpStatus.BAD_REQUEST.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.BAD_REQUEST.getCode(), - CollUtil.getFirst(((ConstraintViolationException) exception) - .getConstraintViolations()) - .getMessage(), null); - } else if (exception instanceof MethodArgumentTypeMismatchException) { - log.error("[GlobalExceptionCapture] MethodArgumentTypeMismatchException: " + - "Parameter name = {}, Exception information: {}", - ((MethodArgumentTypeMismatchException) exception).getName(), - ((MethodArgumentTypeMismatchException) exception).getMessage()); - response.setStatus(HttpStatus.PARAM_NOT_MATCH.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.PARAM_NOT_MATCH); - } else if (exception instanceof HttpMessageNotReadableException) { - log.error("[GlobalExceptionCapture] HttpMessageNotReadableException: {}", - ((HttpMessageNotReadableException) exception).getMessage()); - response.setStatus(HttpStatus.PARAM_NOT_NULL.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.PARAM_NOT_NULL); - } else if (exception instanceof BaseException) { - log.error("[GlobalExceptionCapture] BaseException: Status code: {}, message: {}, data: {}", - ((BaseException) exception).getCode(), - exception.getMessage(), - ((BaseException) exception).getData()); - response.setStatus(((BaseException) exception).getCode()); - return ResponseBodyBean.ofStatus(((BaseException) exception).getCode(), - exception.getMessage(), - ((BaseException) exception).getData()); - } else if (exception instanceof BindException) { - log.error("[GlobalExceptionCapture]: Exception information: {} ", exception.getMessage()); - response.setStatus(HttpStatus.INVALID_PARAM.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.INVALID_PARAM); - } - log.error("[GlobalExceptionCapture]: Exception information: {} ", exception.getMessage(), exception); - response.setStatus(HttpStatus.ERROR.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.ERROR.getCode(), HttpStatus.ERROR.getMessage(), null); - } - - /** - * Get field error message from exception. If two or more fields do not pass Spring Validation check, then will - * return the 1st error message of the error field. - * - * @param exception MethodArgumentNotValidException - * @return field error message - */ - private String getFieldErrorMessageFromException(MethodArgumentNotValidException exception) { - try { - DefaultMessageSourceResolvable firstErrorField = - (DefaultMessageSourceResolvable) Objects.requireNonNull(exception.getBindingResult() - .getAllErrors() - .get(0) - .getArguments())[0]; - String firstErrorFieldName = firstErrorField.getDefaultMessage(); - String firstErrorFieldMessage = exception.getBindingResult().getAllErrors().get(0).getDefaultMessage(); - return firstErrorFieldName + " " + firstErrorFieldMessage; - } catch (Exception e) { - log.error("Exception occurred when get field error message from exception. Exception message: {}", - e.getMessage(), - e); - return HttpStatus.INVALID_PARAM.getMessage(); - } - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/MethodArgumentValidationAspect.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/MethodArgumentValidationAspect.java deleted file mode 100644 index 66eefcb5..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/MethodArgumentValidationAspect.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.jmsoftware.demoone.universal.aspect; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.ArrayUtil; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.*; -import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.stereotype.Component; - -import javax.validation.*; -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - *

MethodArgumentValidationAspect

- *

This class is an aspect class that validates method's argument(s).

- *

USAGE (Must Do's)

- *
    - *
  1. Annotate the method which argument we need to validate by @ValidateArgument
  2. - *
  3. Annotate the argument(s) that we need to validate by @javax.validation.Valid
  4. - *
  5. The field(s) of the argument(s) could be annotated by the constraint annotation provided by Spring - * Security
  6. - *
- *

ATTENTION

- *

If the argument doesn't pass validation, an IllegalArgumentException will be thrown, and not proceed - * the target method.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-07-06 12:17 - **/ -@Slf4j -@Aspect -@Component -public class MethodArgumentValidationAspect { - private final Validator validator; - - public MethodArgumentValidationAspect() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - this.validator = factory.getValidator(); - } - - /** - * Define pointcut. Pointcut is a predicate or expression that matches join points. In - * ValidateMethodArgumentAspect, we need to cut any method annotated with `@ValidateArgument` only. - *

- * More detail at: Spring aop aspectJ - * pointcut expression examples - */ - @Pointcut("@annotation(com.jmsoftware.demoone.universal.aspect.ValidateArgument)") - public void validateMethodArgumentPointcut() { - } - - /** - * Before handle method's argument. This method will be executed after called `proceedingJoinPoint.proceed()`. In - * this phrase, we're going to take some logs. - *

- * `@Before` annotated methods run exactly before the all methods matching with pointcut expression. - * - * @param joinPoint a point of execution of the program - */ - @Before("validateMethodArgumentPointcut()") - public void beforeMethodHandleArgument(JoinPoint joinPoint) { - log.info("Method : {}#{}", - joinPoint.getSignature().getDeclaringTypeName(), - joinPoint.getSignature().getName()); - log.info("Argument : {}", joinPoint.getArgs()); - } - - /** - * Around annotated method processes argument. Around advice can perform custom behavior before and after the - * method invocation. - * - * @param proceedingJoinPoint the object can perform method invocation - * @return any value (may be void) that annotated method returned - */ - @Around("validateMethodArgumentPointcut()") - public Object aroundMethodHandleArgument(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - log.info("======= METHOD'S ARGUMENT VALIDATION START ======="); - Object[] args = proceedingJoinPoint.getArgs(); - MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature(); - Annotation[][] parameterAnnotations = signature.getMethod().getParameterAnnotations(); - // argumentIndexes is the array list that stores the index of argument we need to validate (the argument - // annotated by `@Valid`) - List argumentIndexes = new ArrayList<>(); - for (Annotation[] parameterAnnotation : parameterAnnotations) { - int paramIndex = ArrayUtil.indexOf(parameterAnnotations, parameterAnnotation); - for (Annotation annotation : parameterAnnotation) { - if (annotation instanceof Valid) { - argumentIndexes.add(paramIndex); - } - } - } - - for (Integer index : argumentIndexes) { - Set> validates = validator.validate(args[index]); - if (CollectionUtil.isNotEmpty(validates)) { - String message = String.format("Argument validation failed: %s", validates); - log.info("Method : {}#{}", - proceedingJoinPoint.getSignature().getDeclaringTypeName(), - proceedingJoinPoint.getSignature().getName()); - log.info("Argument : {}", args); - log.error("Validation result: {}", message); - // If the argument doesn't pass validation, an IllegalArgumentException will be thrown, and not - // proceed the target method - throw new IllegalArgumentException(message); - } - } - - log.info("Validation result: Validation passed"); - return proceedingJoinPoint.proceed(); - } - - /** - * `@After` annotated methods run exactly after the all methods matching with pointcut expression. - */ - @After("validateMethodArgumentPointcut()") - public void afterMethodHandleArgument() { - log.info("======== METHOD'S ARGUMENT VALIDATION END ========"); - } - - /** - * `@AfterThrowing` annotated methods run after the method (matching with pointcut expression) exits by throwing an - * exception. - * - * @param joinPoint a point of execution of the program - * @param e exception that controller's method throws - */ - @AfterThrowing(pointcut = "validateMethodArgumentPointcut()", throwing = "e") - public void afterThrowingException(JoinPoint joinPoint, Exception e) { - log.info("Signature : {}", joinPoint.getSignature().toShortString()); - log.error("Exception message: {}", e.toString()); - log.error("== METHOD'S ARGUMENT VALIDATION END WITH EXCEPTION =="); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/ValidateArgument.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/ValidateArgument.java deleted file mode 100644 index 8e55e7bb..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/ValidateArgument.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.jmsoftware.demoone.universal.aspect; - -import java.lang.annotation.*; - -/** - *

ValidateArgument

- *

Annotation for validating method's argument.

- *

ATTENTION

- *

If the argument doesn't pass validation, an IllegalArgumentException will be thrown, and not proceed - * the target method.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-07-06 12:08 - **/ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD}) -@Documented -public @interface ValidateArgument { -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/WebRequestLogAspect.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/WebRequestLogAspect.java deleted file mode 100644 index dccc6f9c..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/aspect/WebRequestLogAspect.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.jmsoftware.demoone.universal.aspect; - -import cn.hutool.core.util.NumberUtil; -import cn.hutool.json.JSONUtil; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.jmsoftware.common.util.RequestUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.*; -import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; - -/** - *

RequestLogAspect

- *

Description:

- *

RequestLogAspect is an AOP for logging URL, HTTP method, client IP and other information when web resource was - * accessed.

- *

Feature:

- *

No methods in controller need to be decorated with annotation. This aspect would automatically cut the method - * decorated with `@GetMapping` or `@PostMapping`.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-05-05 19:55 - **/ -@Slf4j -@Aspect -@Component -@RequiredArgsConstructor -public class WebRequestLogAspect { - private static final String LINE_SEPARATOR = System.lineSeparator(); - private final ObjectMapper mapper = new ObjectMapper(); - - /** - * Define pointcut. Pointcut is a predicate or expression that matches join points. In WebRequestLogAspect, we need - * to cut any method annotated with `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`, `@PatchMapping`, `@RequestMapping`. - *

- * More detail at: Spring aop aspectJ - * pointcut expression examples - */ - @Pointcut("@annotation(org.springframework.web.bind.annotation.GetMapping)" + - " || @annotation(org.springframework.web.bind.annotation.PostMapping)" + - " || @annotation(org.springframework.web.bind.annotation.PutMapping)" + - " || @annotation(org.springframework.web.bind.annotation.DeleteMapping)" + - " || @annotation(org.springframework.web.bind.annotation.PatchMapping)" + - " || @annotation(org.springframework.web.bind.annotation.RequestMapping)") - public void requestLogPointcut() { - } - - /** - * Before controller handle client request (on client sent a request). - *

- * `@Before` annotated methods run exactly before the all methods matching with pointcut expression. - * - * @param joinPoint a point of execution of the program - */ - @Before("requestLogPointcut()") - public void beforeHandleRequest(JoinPoint joinPoint) { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - assert attributes != null; - HttpServletRequest request = attributes.getRequest(); - log.info("============ WEB REQUEST LOG START ============"); - log.info("URL : {}", request.getRequestURL().toString()); - log.info("HTTP Method : {}", request.getMethod()); - log.info("Client IP:Port : {}", RequestUtil.getRequestIpAndPort(request)); - log.info("Class Method : {}#{}", - joinPoint.getSignature().getDeclaringTypeName(), - joinPoint.getSignature().getName()); - log.info("Request Params :{}{}", LINE_SEPARATOR, JSONUtil.toJsonPrettyStr(joinPoint.getArgs())); - } - - /** - * Around controller's method processes client request. Around advice can perform custom behavior before and after - * the method invocation. - * - * @param proceedingJoinPoint the object can perform method invocation - * @return any value (may be void) that controller's method returned - * @throws Throwable any exceptions that controller's method may throw - */ - @Around("requestLogPointcut()") - public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Object result = proceedingJoinPoint.proceed(); - long elapsedTime = System.currentTimeMillis() - startTime; - try { - var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result)); - if (formattedStringifiedJson.length() > 500) { - formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…"); - } - log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson); - } catch (JsonProcessingException e) { - log.info("Response (non-JSON): {}", result); - } - log.info("Elapsed time : {} s ({} ms)", - NumberUtil.decimalFormat("0.00", elapsedTime / 1000D), - elapsedTime); - return result; - } - - /** - * `@After` annotated methods run exactly after the all methods matching with pointcut expression. - */ - @After("requestLogPointcut()") - public void afterHandleRequest() { - log.info("============= WEB REQUEST LOG END ============="); - } - - /** - * `@AfterThrowing` annotated methods run after the method (matching with pointcut expression) exits by throwing an - * exception. - * - * @param joinPoint a point of execution of the program - * @param e exception that controller's method throws - */ - @AfterThrowing(pointcut = "requestLogPointcut()", throwing = "e") - public void afterThrowingException(JoinPoint joinPoint, Exception e) { - log.info("Signature : {}", joinPoint.getSignature().toShortString()); - log.error("Exception message : {}, message: {}", e.toString(), e.getMessage()); - log.error("====== WEB REQUEST LOG END WITH EXCEPTION ====="); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/ProjectProperty.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/ProjectProperty.java deleted file mode 100644 index 4a901ba2..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/ProjectProperty.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jmsoftware.demoone.universal.configuration; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - *

ProjectProperty

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-04-18 13:01 - **/ -@Slf4j -@Data -@Component -@ConfigurationProperties(prefix = "project.property") -public class ProjectProperty { - private String basePackage; - private String contextPath; - private String groupId; - private String artifactId; - private String projectArtifactId; - private String version; - private String description; - private String jdkVersion; - private String environment; - private String environmentAlias; - private String url; - private String inceptionYear; - private String organizationName; - private String organizationUrl; - private String issueManagementSystem; - private String issueManagementUrl; - private String developerName; - private String developerEmail; - private String developerUrl; -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/ServerConfiguration.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/ServerConfiguration.java deleted file mode 100644 index e118d6c1..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/ServerConfiguration.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.jmsoftware.demoone.universal.configuration; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.web.context.WebServerInitializedEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.Inet4Address; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.URL; -import java.util.Enumeration; - -/** - *

ServerConfiguration

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-04-26 16:02 - **/ -@Slf4j -@Getter -@Component -@RequiredArgsConstructor -public class ServerConfiguration implements ApplicationListener { - public static final String DEVELOPMENT_ENVIRONMENT_ALIAS = "dev"; - private final ProjectProperty projectProperty; - private int serverPort; - - @Override - public void onApplicationEvent(WebServerInitializedEvent event) { - this.serverPort = event.getWebServer().getPort(); - } - - /** - *

Get base URL of backend server.

- *

The result will be like:

- *
    - *
  1. http://[serverIp]:[serverPort]/[contextPath]
  2. - *
  3. https://[serverIp]/[contextPath]
  4. - *
- * - * @return base URL - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-05-03 16:05 - */ - public String getBaseUrl() { - return "http://" + this.getPublicIp() + ":" + serverPort + projectProperty.getContextPath(); - } - - /** - * Find public IP address. - * - * @return public IP - */ - public String getPublicIp() { - if (projectProperty.getEnvironmentAlias().contains(DEVELOPMENT_ENVIRONMENT_ALIAS)) { - return this.getInternetIp(); - } - try { - // An API provided by https://whatismyipaddress.com/api - URL url = new URL("https://ipv4bot.whatismyipaddress.com/"); - BufferedReader sc = new BufferedReader(new InputStreamReader(url.openStream())); - // Read system IP Address - return sc.readLine().trim(); - } catch (Exception e) { - log.error("Cannot execute properly to get IP address from https://whatismyipaddress.com/api", e); - } - return this.getInternetIp(); - } - - /** - * Get internet IP. - * - * @return internet IP - */ - private String getInternetIp() { - String intranetIp = this.getIntranetIp(); - try { - Enumeration networks = NetworkInterface.getNetworkInterfaces(); - InetAddress ip; - Enumeration addresses; - while (networks.hasMoreElements()) { - addresses = networks.nextElement().getInetAddresses(); - while (addresses.hasMoreElements()) { - ip = addresses.nextElement(); - if (ip instanceof Inet4Address - && ip.isSiteLocalAddress() - && !ip.getHostAddress().equals(intranetIp)) { - return ip.getHostAddress(); - } - } - } - return intranetIp; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Get intranet IP. - * - * @return intranet IP - */ - private String getIntranetIp() { - try { - return InetAddress.getLocalHost().getHostAddress(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/Swagger2Configuration.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/Swagger2Configuration.java deleted file mode 100644 index 2d81e3cd..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/Swagger2Configuration.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.jmsoftware.demoone.universal.configuration; - -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - *

Swagger2Configuration

- *

- * Swagger 2 Configuration - * Click me to view - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-02-07 16:15 - **/ -@Configuration -@EnableSwagger2 -@RequiredArgsConstructor -public class Swagger2Configuration { - private final ProjectProperty projectProperty; - private static final String LINE_SEPARATOR = System.lineSeparator(); - - @Bean - public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.basePackage(projectProperty.getBasePackage())) - .paths(PathSelectors.any()) - .build(); - } - - private ApiInfo apiInfo() { - var projectArtifactId = projectProperty.getProjectArtifactId(); - var version = projectProperty.getVersion(); - var developerEmail = projectProperty.getDeveloperEmail(); - var developerUrl = projectProperty.getDeveloperUrl(); - var environmentAlias = projectProperty.getEnvironmentAlias(); - return new ApiInfoBuilder() - .title(String.format("API for %s@%s (%s)", - projectArtifactId, - version, - environmentAlias)) - .description(String.format("%s %sArtifact ID: %s%sEnvironment: %s (%s)", - projectProperty.getDescription(), - LINE_SEPARATOR, - projectArtifactId, - LINE_SEPARATOR, - projectProperty.getEnvironment(), - environmentAlias)) - .contact(new Contact(String.format("%s, email: %s%sHome page: %s", - projectProperty.getDeveloperName(), - developerEmail, - LINE_SEPARATOR, - developerUrl), - developerUrl, developerEmail)) - .version(version) - .build(); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/WebMvcConfiguration.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/WebMvcConfiguration.java deleted file mode 100644 index 725d3c5d..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/configuration/WebMvcConfiguration.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jmsoftware.demoone.universal.configuration; - -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - *

WebMvcConfiguration

- *

- * Spring MVC Configurations. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 1/23/20 9:02 AM - **/ -@Configuration -@RequiredArgsConstructor -public class WebMvcConfiguration implements WebMvcConfigurer { - private static final long MAX_AGE_SECS = 3600; - - /** - * 1. Config static path pattern - * 2. Config static resource location - * - * @param registry static resources register - */ - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); - } - - /** - * Configure cross origin requests processing. - * - * @param registry CORS registry - */ - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("*") - .allowedMethods("HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE") - .maxAge(MAX_AGE_SECS); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/CommonController.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/CommonController.java deleted file mode 100644 index cbb86b09..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/CommonController.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jmsoftware.demoone.universal.controller; - -import com.jmsoftware.common.bean.ResponseBodyBean; -import com.jmsoftware.demoone.universal.domain.ValidationTestPayload; -import com.jmsoftware.demoone.universal.service.CommonService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import java.util.Map; - -/** - *

CommonController

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/4/20 10:29 AM - **/ -@RestController -@RequiredArgsConstructor -@RequestMapping("/common") -@Api(tags = {"Common Controller"}) -public class CommonController { - private final CommonService commonService; - - @GetMapping("/app-info") - @ApiOperation(value = "/app-info", notes = "Retrieve application information") - public ResponseBodyBean> applicationInformation() { - var data = commonService.getApplicationInfo(); - return ResponseBodyBean.ofDataAndMessage(data, "Succeed to retrieve app info."); - } - - @PostMapping("/validation-test") - @ApiOperation(value = "/validation-test", notes = "Validation of request payload test") - public ResponseBodyBean validationTest(@RequestBody ValidationTestPayload payload) { - commonService.validateObject(payload); - return ResponseBodyBean.ofDataAndMessage(payload.getName(), "validationTest()"); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/ErrorController.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/ErrorController.java deleted file mode 100644 index fcbb3812..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/ErrorController.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jmsoftware.demoone.universal.controller; - -import io.swagger.annotations.Api; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.autoconfigure.web.ServerProperties; -import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; -import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; -import org.springframework.boot.web.servlet.error.ErrorAttributes; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.util.List; -import java.util.Map; - -/** - *

ErrorController

- *

- * Error controller. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-03-02 16:56 - **/ -@Slf4j -@RestController -@Api(tags = {"Error Controller"}) -public class ErrorController extends BasicErrorController { - public ErrorController(ErrorAttributes errorAttributes, - ServerProperties serverProperties, - List errorViewResolvers) { - super(errorAttributes, serverProperties.getError(), errorViewResolvers); - } - - @Override - public ResponseEntity> error(HttpServletRequest request) { - HttpStatus httpStatus = getStatus(request); - Map body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL)); - body.put("message", httpStatus.getReasonPhrase()); - log.error("Captured HTTP request error. Response body = {}", body); - return new ResponseEntity<>(body, httpStatus); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/RedirectController.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/RedirectController.java deleted file mode 100644 index 91d28d5e..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/controller/RedirectController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.jmsoftware.demoone.universal.controller; - -import com.jmsoftware.demoone.universal.configuration.ProjectProperty; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.PostConstruct; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

RedirectController

- *

- * HTTP Redirect Controller - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 1/21/20 1:18 PM - **/ -@Slf4j -@RestController -@RequiredArgsConstructor -@Api(tags = {"Redirect Controller"}) -public class RedirectController { - private final ProjectProperty projectProperty; - - @PostConstruct - public void postConstruct() { - log.info("URL redirect service initialized."); - } - - @GetMapping("/home") - @ApiOperation(value = "/home", notes = "Home page") - public void handleHomeRequest(HttpServletResponse response) throws IOException { - // Redirect to home page - response.sendRedirect(projectProperty.getContextPath() + "static/home.html"); - } - - @GetMapping("/doc") - @ApiOperation(value = "/doc", notes = "Swagger API Documentation") - public void handleDocRequest(HttpServletResponse response) throws IOException { - // Redirect to Bootstrap Swagger API documentation - response.sendRedirect(projectProperty.getContextPath() + "/doc.html?cache=1&lang=en"); - } - - @GetMapping("/webjars/bycdao-ui/images/api.ico") - @ApiOperation(value = "/webjars/bycdao-ui/images/api.ico", notes = "Favicon redirection") - public void handleFaviconRequest(HttpServletResponse response) throws IOException { - // Redirect to a customized favicon - response.sendRedirect(projectProperty.getContextPath() + "/static/icon/favicon.ico"); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/domain/ValidationTestPayload.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/domain/ValidationTestPayload.java deleted file mode 100644 index c6545cfe..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/domain/ValidationTestPayload.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.jmsoftware.demoone.universal.domain; - -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - *

ValidationTestPayload

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/14/20 11:34 AM - **/ -@Data -public class ValidationTestPayload { - @NotNull - @Min(value = 1L) - private Long id; - @NotEmpty - private String name; -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/filter/RequestFilter.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/filter/RequestFilter.java deleted file mode 100644 index 1184b88e..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/filter/RequestFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jmsoftware.demoone.universal.filter; - -import com.jmsoftware.common.util.RequestUtil; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; -import org.springframework.web.filter.OncePerRequestFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

RequestFilter

- *

Request filter.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-03-23 14:24 - **/ -@Slf4j -@Component -public class RequestFilter extends OncePerRequestFilter { - @Override - @SuppressWarnings("NullableProblems") - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws IOException, ServletException { - log.info("[{}] Client requested access. Method: {}, URL: {}", - RequestUtil.getRequestIpAndPort(request), - request.getMethod(), - request.getRequestURL()); - filterChain.doFilter(request, response); - } -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/service/CommonService.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/service/CommonService.java deleted file mode 100644 index 101ab40f..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/service/CommonService.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.jmsoftware.demoone.universal.service; - -import com.jmsoftware.demoone.universal.domain.ValidationTestPayload; - -import java.util.Map; - -/** - *

CommonService

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/4/20 11:15 AM - */ -public interface CommonService { - /** - * Gets application info. - * - * @return the application info. - */ - Map getApplicationInfo(); - - /** - * Validate object. - * - * @param payload the payload - */ - void validateObject(ValidationTestPayload payload); -} diff --git a/demo-one/src/main/java/com/jmsoftware/demoone/universal/service/impl/CommonServiceImpl.java b/demo-one/src/main/java/com/jmsoftware/demoone/universal/service/impl/CommonServiceImpl.java deleted file mode 100644 index 222536cc..00000000 --- a/demo-one/src/main/java/com/jmsoftware/demoone/universal/service/impl/CommonServiceImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.jmsoftware.demoone.universal.service.impl; - -import com.jmsoftware.demoone.universal.aspect.ValidateArgument; -import com.jmsoftware.demoone.universal.configuration.ProjectProperty; -import com.jmsoftware.demoone.universal.domain.ValidationTestPayload; -import com.jmsoftware.demoone.universal.service.CommonService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import javax.validation.Valid; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - *

CommonServiceImpl

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/4/20 11:16 AM - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class CommonServiceImpl implements CommonService { - private final ProjectProperty projectProperty; - - @Override - public Map getApplicationInfo() { - var map = new HashMap(16); - var fieldsInfo = getFieldsInfo(projectProperty); - fieldsInfo.forEach(fieldInfo -> { - var type = fieldInfo.get("type"); - if ("class java.lang.String".equals(type)) { - map.put((String) fieldInfo.get("name"), fieldInfo.get("value")); - } - }); - return map; - } - - @Override - @ValidateArgument - public void validateObject(@Valid ValidationTestPayload payload) { - log.info("Validation passed! {}", payload); - } - - /** - * Gets field value by name. - * - * @param fieldName the field name - * @param object the object - * @return the field value by name - * @see Java 中遍历一个对象的所有属性 - */ - private Object getFieldValueByName(String fieldName, Object object) { - try { - String firstLetter = fieldName.substring(0, 1).toUpperCase(); - String getter = "get" + firstLetter + fieldName.substring(1); - Method method = object.getClass().getMethod(getter); - return method.invoke(object); - } catch (Exception e) { - log.error("Can't get field's value by name! Cause: {}", e.getMessage()); - return null; - } - } - - /** - * Get filed name string [ ]. - * - * @param o the o - * @return the string [ ] - * @see Java 中遍历一个对象的所有属性 - */ - private String[] getFiledName(Object o) { - Field[] fields = o.getClass().getDeclaredFields(); - String[] fieldNames = new String[fields.length]; - for (int i = 0; i < fields.length; i++) { - log.info("fields[i].getType(): {}", fields[i].getType()); - fieldNames[i] = fields[i].getName(); - } - return fieldNames; - } - - /** - * Get Fields Info - * - * @param o the o - * @return the fields info - * @see Java 中遍历一个对象的所有属性 - */ - private List> getFieldsInfo(Object o) { - Field[] fields = o.getClass().getDeclaredFields(); - var arrayList = new ArrayList>(); - for (Field field : fields) { - var infoMap = new HashMap(16); - infoMap.put("type", field.getType().toString()); - infoMap.put("name", field.getName()); - infoMap.put("value", getFieldValueByName(field.getName(), o)); - arrayList.add(infoMap); - } - return arrayList; - } - - /** - * Get Filed Values - * - * @param o the o - * @return the object [ ] - * @see Java 中遍历一个对象的所有属性 - */ - public Object[] getFiledValues(Object o) { - String[] fieldNames = this.getFiledName(o); - Object[] value = new Object[fieldNames.length]; - for (int i = 0; i < fieldNames.length; i++) { - value[i] = this.getFieldValueByName(fieldNames[i], o); - } - return value; - } -} diff --git a/demo-one/src/main/resources/application-development-docker.yml b/demo-one/src/main/resources/application-development-docker.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-one/src/main/resources/application-development-docker.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-one/src/main/resources/application-development-local.yml b/demo-one/src/main/resources/application-development-local.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-one/src/main/resources/application-development-local.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-one/src/main/resources/application-production.yml b/demo-one/src/main/resources/application-production.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-one/src/main/resources/application-production.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-one/src/main/resources/application-stage.yml b/demo-one/src/main/resources/application-stage.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-one/src/main/resources/application-stage.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-one/src/main/resources/application-test.yml b/demo-one/src/main/resources/application-test.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-one/src/main/resources/application-test.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-one/src/main/resources/application.yml b/demo-one/src/main/resources/application.yml deleted file mode 100644 index d9cc1272..00000000 --- a/demo-one/src/main/resources/application.yml +++ /dev/null @@ -1,64 +0,0 @@ -server: - port: @port@ - # servlet: - # context-path: /@project.artifactId@-@envAlias@ - tomcat: - uri-encoding: @project.build.sourceEncoding@ - -spring: - application: - name: @project.artifactId@ - profiles: - active: @env@ - mvc: - throw-exception-if-no-handler-found: true - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 - sleuth: - sampler: - probability: 1.0 - -feign: - client: - config: - default: - connectTimeout: 5000 - readTimeout: 10000 - -management: - endpoints: - web: - exposure: - include: "*" - endpoint: - health: - show-details: ALWAYS - -logging: - config: classpath:configuration/logback/logback-@env@.xml - # Configure logging level of project as DEBUG to enable SQL logging and other logging. - level: - com.jmsoftware: DEBUG - -project: - property: - base-package: com.jmsoftware.demoone - context-path: - group-id: @project.groupId@ - artifact-id: @project.artifactId@ - project-artifact-id: @project.artifactId@ - version: @project.version@ - description: @project.description@ - jdk-version: @java.version@ - environment: @env@ - environment-alias: @envAlias@ - url: @project.url@ - inception-year: @inceptionYear@ - organization-name: @project.organization.name@ - organization-url: @project.organization.url@ - issue-management-system: @project.issueManagement.system@ - issue-management-url: @project.issueManagement.url@ - developer-name: @developerName@ - developer-email: @developerEmail@ - developer-url: @developerUrl@ diff --git a/demo-one/src/main/resources/banner.txt b/demo-one/src/main/resources/banner.txt deleted file mode 100644 index b00fc47e..00000000 --- a/demo-one/src/main/resources/banner.txt +++ /dev/null @@ -1,26 +0,0 @@ -${AnsiStyle.BOLD}${AnsiColor.BRIGHT_GREEN} - ____ ____ - / __ \___ ____ ___ ____ / __ \____ ___ - / / / / _ \/ __ `__ \/ __ \ / / / / __ \/ _ \ - / /_/ / __/ / / / / / /_/ / / /_/ / / / / __/ -/_____/\___/_/ /_/ /_/\____/ \____/_/ /_/\___/ -${AnsiStyle.BOLD}Demo One :: Powered by Spring Boot ::${spring-boot.formatted-version} -${AnsiColor.CYAN}Author: Johnny Miller (鍾俊), email: johnnysviva@outlook.com -${AnsiStyle.NORMAL}${AnsiColor.MAGENTA}http://patorjk.com/software/taag/#p=display&f=Slant&t=Demo%20One -${AnsiColor.BRIGHT_BLACK} --------------------------------------------Font Info------------------------------------------- -Slant by Glenn Chappell 3/93 -- based on Standard -Includes ISO Latin-1 -figlet release 2.1 -- 12 Aug 1994 -Permission is hereby given to modify this font, as long as the -modifier's name is placed on a comment line. - -Modified by Paul Burton 12/96 to include new parameter -supported by FIGlet and FIGWin. May also be slightly modified for better use -of new full-width/kern/smush alternatives, but default output is NOT changed. - -------------------------------------------Banner Info------------------------------------------ -Banner generated by Text ASCII Art Generator. -A web app that lets you type in large ASCII Art text lettering. -This can create art you can put in your email signature, on your webpage, etc etc. -More at http://patorjk.com/software/taag/ diff --git a/demo-one/src/main/resources/configuration/.empty b/demo-one/src/main/resources/configuration/.empty deleted file mode 100644 index e69de29b..00000000 diff --git a/demo-one/src/main/resources/configuration/logback/logback-base.xml b/demo-one/src/main/resources/configuration/logback/logback-base.xml deleted file mode 100644 index 31a1f820..00000000 --- a/demo-one/src/main/resources/configuration/logback/logback-base.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${CONSOLE_LOG_PATTERN} - UTF-8 - - - - - - - ALL - ACCEPT - ACCEPT - - - - ${FILE_LOG_PATTERN} - UTF-8 - - - - - - - ${LOG_HOME}/${PROJECT_ARTIFACT_Id}.%d{yyyy-MM-dd}.%i.log.gz - - 5MB - 7 - 1GB - - - diff --git a/demo-one/src/main/resources/configuration/logback/logback-development-docker.xml b/demo-one/src/main/resources/configuration/logback/logback-development-docker.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-one/src/main/resources/configuration/logback/logback-development-docker.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-one/src/main/resources/configuration/logback/logback-development-local.xml b/demo-one/src/main/resources/configuration/logback/logback-development-local.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-one/src/main/resources/configuration/logback/logback-development-local.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-one/src/main/resources/configuration/logback/logback-production.xml b/demo-one/src/main/resources/configuration/logback/logback-production.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-one/src/main/resources/configuration/logback/logback-production.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-one/src/main/resources/configuration/logback/logback-stage.xml b/demo-one/src/main/resources/configuration/logback/logback-stage.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-one/src/main/resources/configuration/logback/logback-stage.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-one/src/main/resources/configuration/logback/logback-test.xml b/demo-one/src/main/resources/configuration/logback/logback-test.xml deleted file mode 100644 index f1916a0f..00000000 --- a/demo-one/src/main/resources/configuration/logback/logback-test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-one/src/main/resources/static/home.html b/demo-one/src/main/resources/static/home.html deleted file mode 100644 index e7599316..00000000 --- a/demo-one/src/main/resources/static/home.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - UNSET - - - - -

-
- Hello, World! - - Welcome to {{ projectArtifactId }}@{{ version }}! - - - - {{ applicationName }} - -
-
- Create New Person -
- - -
-
- - -
-
- - -
-
- - -
-
- - - - - - - - - - - - - - - - - -
NameAgeSexDelete
{{ person.name }}{{ person.age }}{{ person.sex }} - -
- This page is provided by - keepfool. - -
- - - - diff --git a/demo-one/src/main/resources/static/icon/favicon.ico b/demo-one/src/main/resources/static/icon/favicon.ico deleted file mode 100644 index 0798d38f..00000000 Binary files a/demo-one/src/main/resources/static/icon/favicon.ico and /dev/null differ diff --git a/demo-one/src/main/resources/static/image/muscle-and-fitness-server-social-image.png b/demo-one/src/main/resources/static/image/muscle-and-fitness-server-social-image.png deleted file mode 100644 index 83786ad8..00000000 Binary files a/demo-one/src/main/resources/static/image/muscle-and-fitness-server-social-image.png and /dev/null differ diff --git a/demo-one/src/main/resources/static/script/404.js b/demo-one/src/main/resources/static/script/404.js deleted file mode 100644 index 5401ce54..00000000 --- a/demo-one/src/main/resources/static/script/404.js +++ /dev/null @@ -1,12 +0,0 @@ -// noinspection JSUnusedGlobalSymbols -const vm = new Vue({ - el: '#app', - data: {}, - methods: { - handleClickGoToHome: function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - window.location.href = `${split[0]}//${split[2]}/${split[3]}`; - } - } -}); diff --git a/demo-one/src/main/resources/static/script/home.js b/demo-one/src/main/resources/static/script/home.js deleted file mode 100644 index a191d8c5..00000000 --- a/demo-one/src/main/resources/static/script/home.js +++ /dev/null @@ -1,72 +0,0 @@ -// noinspection JSUnusedGlobalSymbols -const vm = new Vue({ - el: '#app', - data: { - projectArtifactId: null, - version: null, - applicationName: null, - newPerson: { - name: '', - age: 0, - sex: 'Male' - }, - people: [{ - name: 'Jack', - age: 30, - sex: 'Male' - }, { - name: 'Bill', - age: 26, - sex: 'Male' - }, { - name: 'Tracy', - age: 22, - sex: 'Female' - }, { - name: 'Chris', - age: 36, - sex: 'Male' - }] - }, - methods: { - /** - * Create a person - */ - createPerson: function () { - this.people.push(this.newPerson); - this.newPerson = {name: '', age: 0, sex: 'Male'} - - }, - /** - * delete a person - * @param index - */ - deletePerson: function (index) { - this.people.splice(index, 1); - }, - handleClickSwaggerApiDocumentation: function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - window.location.href = `${split[0]}//${split[2]}/doc`; - }, - handleClickVideoDemo: function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - window.location.href = `${split[0]}//${split[2]}/${split[3]}/video.html`; - }, - getAppInfo: async function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - const baseUrl = `${split[0]}//${split[2]}`; - const response = await fetch(`${baseUrl}/common/app-info`); - const responseJson = await response.json(); - this.projectArtifactId = responseJson.data.projectArtifactId; - this.version = responseJson.data.version; - this.applicationName = this.projectArtifactId.toUpperCase(); - window.document.title = this.applicationName; - } - }, - mounted: async function () { - this.getAppInfo(); - } -}); diff --git a/demo-one/src/main/resources/static/script/video.js b/demo-one/src/main/resources/static/script/video.js deleted file mode 100644 index 3a155900..00000000 --- a/demo-one/src/main/resources/static/script/video.js +++ /dev/null @@ -1,17 +0,0 @@ -// noinspection JSUnusedGlobalSymbols -const vm = new Vue({ - el: '#app', - data: { - appInfo: null, - videoSource: '' - }, - async mounted() { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - this.videoSource = `${split[0]}//${split[2]}/${split[3]}/test-table/demo-video`; - const baseUrl = `${split[0]}//${split[2]}`; - const response = await fetch(`${baseUrl}/common/app-info`); - const responseJson = await response.json(); - this.appInfo = responseJson.data; - } -}); diff --git a/demo-one/src/main/resources/static/styles/404.css b/demo-one/src/main/resources/static/styles/404.css deleted file mode 100644 index 09a4e9bc..00000000 --- a/demo-one/src/main/resources/static/styles/404.css +++ /dev/null @@ -1,89 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box -} - -html { - font-size: 12px; - font-family: Ubuntu, simHei, sans-serif; - font-weight: 400 -} - -body { - font-size: 1rem -} - -button { - outline: none; - padding: 5px 8px; - color: #fff; - border: 1px solid #BCBCBC; - border-radius: 3px; - background-color: #009A61; - cursor: pointer; -} - -button:hover { - opacity: 0.8; -} - -#app { - margin: 48px auto 0; - max-width: 640px; - -webkit-perspective: 500px; -} - -.text-center { - text-align: center; -} - -.message-box { - background-color: firebrick; - max-width: 700px; - padding: 20px; - border-radius: 8px; - margin: 48px auto 20px; -} - -.slide-in-bck-center { - animation: slide-in-bck-center 1.2s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; -} - -@keyframes slide-in-bck-center { - 0% { - transform: translateZ(600px); - opacity: 0; - } - 100% { - transform: translateZ(0); - opacity: 1; - } -} - -.message-text { - font-size: xx-large; - text-align: center; - color: ivory; -} - -.social-image { - width: 600px; - border-radius: 8px; -} - -.message-title { - text-align: center; - display: block; - font-size: 48px; - text-shadow: black 2px 2px 6px; -} - -.server-name { - color: gold; -} - -.go-to { - display: inline-block; - margin-bottom: 6px; -} diff --git a/demo-one/src/main/resources/static/styles/home.css b/demo-one/src/main/resources/static/styles/home.css deleted file mode 100644 index 62ebe0c2..00000000 --- a/demo-one/src/main/resources/static/styles/home.css +++ /dev/null @@ -1,222 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box -} - -html { - font-size: 12px; - font-family: Ubuntu, simHei, sans-serif; - font-weight: 400 -} - -body { - font-size: 1rem -} - -table, -td, -th { - border-collapse: collapse; - border-spacing: 0 -} - -table { - width: 100% -} - -td, -th { - border: 1px solid #bcbcbc; - padding: 5px 10px -} - -th { - background: #42b983; - font-size: 1.2rem; - font-weight: 400; - color: #fff; - cursor: pointer -} - -tr:nth-of-type(odd) { - background: #fff -} - -tr:nth-of-type(even) { - background: #eee -} - -fieldset { - border: 1px solid #BCBCBC; - padding: 15px; -} - -input { - outline: none -} - -input[type=text] { - border: 1px solid #ccc; - padding: .5rem .3rem; -} - -input[type=text]:focus { - border-color: #42b983; -} - -button { - outline: none; - padding: 5px 8px; - color: #fff; - border: 1px solid #BCBCBC; - border-radius: 3px; - background-color: #009A61; - cursor: pointer; -} - -button:hover { - opacity: 0.8; -} - -#app { - margin: 0 auto; - max-width: 640px; - -webkit-perspective: 500px; -} - -.form-group { - margin: 10px; -} - -.form-group > label { - display: inline-block; - width: 10rem; - text-align: right; -} - -.form-group > input, -.form-group > select { - display: inline-block; - height: 2.5rem; - line-height: 2.5rem; -} - -.text-center { - text-align: center; -} - -.pagination { - display: inline-block; - padding-left: 0; - margin: 21px 0; - border-radius: 3px; -} - -.pagination > li { - display: inline; -} - -.pagination > li > a { - position: relative; - float: left; - padding: 6px 12px; - line-height: 1.5; - text-decoration: none; - color: #009a61; - background-color: #fff; - border: 1px solid #ddd; - margin-left: -1px; - list-style: none; -} - -.pagination > li > a:hover { - background-color: #eee; -} - -.pagination .active { - color: #fff; - background-color: #009a61; - border-left: none; - border-right: none; -} - -.pagination .active:hover { - background: #009a61; - cursor: default; -} - -.pagination > li:first-child > a .p { - border-bottom-left-radius: 3px; - border-top-left-radius: 3px; -} - -.pagination > li:last-child > a { - border-bottom-right-radius: 3px; - border-top-right-radius: 3px; -} - -.greeting-box { - background-color: firebrick; - max-width: 700px; - padding: 20px; - border-radius: 8px; - margin: 48px auto 20px; -} - -.slide-in-bck-center { - animation: slide-in-bck-center 1.2s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; -} - -@keyframes slide-in-bck-center { - 0% { - transform: translateZ(600px); - opacity: 0; - } - 100% { - transform: translateZ(0); - opacity: 1; - } -} - -.greeting-text { - font-size: xx-large; - text-align: center; - color: ivory; - display: block; -} - -.application-name { - display: inline-block; - font-weight: bold; - width: auto; - font-size: 48px; - color: rgb(7, 156, 58); - position: relative; - left: 60px; - top: 200px; - cursor: default; -} - -.social-image { - width: 600px; - border-radius: 8px; -} - -.greeting-title { - text-align: center; - display: block; - font-size: 48px; - font-weight: bold; - color: ivory; - text-shadow: black 2px 2px 6px; -} - -.server-name { - color: gold; -} - -.go-to { - display: inline-block; - margin-bottom: 6px; -} diff --git a/demo-one/src/main/resources/static/styles/video.css b/demo-one/src/main/resources/static/styles/video.css deleted file mode 100644 index 341a63f5..00000000 --- a/demo-one/src/main/resources/static/styles/video.css +++ /dev/null @@ -1,136 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box -} - -html { - font-size: 12px; - font-family: Ubuntu, simHei, sans-serif; - font-weight: 400 -} - -body { - font-size: 1rem -} - -table, -td, -th { - border-collapse: collapse; - border-spacing: 0 -} - -table { - width: 100% -} - -td, -th { - border: 1px solid #bcbcbc; - padding: 5px 10px -} - -th { - background: #42b983; - font-size: 1.2rem; - font-weight: 400; - color: #fff; - cursor: pointer -} - -tr:nth-of-type(odd) { - background: #fff -} - -tr:nth-of-type(even) { - background: #eee -} - -fieldset { - border: 1px solid #BCBCBC; - padding: 15px; -} - -input { - outline: none -} - -input[type=text] { - border: 1px solid #ccc; - padding: .5rem .3rem; -} - -input[type=text]:focus { - border-color: #42b983; -} - -button { - outline: none; - padding: 5px 8px; - color: #fff; - border: 1px solid #BCBCBC; - border-radius: 3px; - background-color: #009A61; - cursor: pointer; -} - -button:hover { - opacity: 0.8; -} - -#app { - margin: 0 auto; - max-width: 640px; - -webkit-perspective: 500px; -} - -.greeting-box { - background-color: firebrick; - max-width: 700px; - padding: 20px; - border-radius: 8px; - margin: 48px auto 20px; -} - -.slide-in-bck-center { - animation: slide-in-bck-center 1.2s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; -} - -@keyframes slide-in-bck-center { - 0% { - transform: translateZ(600px); - opacity: 0; - } - 100% { - transform: translateZ(0); - opacity: 1; - } -} - -.greeting-text { - font-size: xx-large; - text-align: center; - color: ivory; -} - -.social-image { - width: 600px; - border-radius: 8px; -} - -.greeting-title { - text-align: center; - display: block; - font-size: 48px; - text-shadow: black 2px 2px 6px; -} - -.server-name { - color: gold; -} - -.go-to { - display: inline-block; - margin-bottom: 6px; -} diff --git a/demo-one/src/main/resources/static/video.html b/demo-one/src/main/resources/static/video.html deleted file mode 100644 index 9a186caa..00000000 --- a/demo-one/src/main/resources/static/video.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - ExRx.net Crawler Server - - - - -
-
- - Hello, World! - Welcome to {{ appInfo.projectArtifactId }}@{{ appInfo.version }}! - - -
-
- - - - diff --git a/demo-one/src/test/java/com/jmsoftware/demoone/DemoOneApplicationTests.java b/demo-one/src/test/java/com/jmsoftware/demoone/DemoOneApplicationTests.java deleted file mode 100644 index e005c513..00000000 --- a/demo-one/src/test/java/com/jmsoftware/demoone/DemoOneApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jmsoftware.demoone; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class DemoOneApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/demo-two/README.md b/demo-two/README.md deleted file mode 100644 index 3c75dcd9..00000000 --- a/demo-two/README.md +++ /dev/null @@ -1,67 +0,0 @@ -![Muscle and Fitness Server Social Image](https://raw.githubusercontent.com/johnnymillergh/MaterialLibrary/master/muscle-and-fitness/muscle-and-fitness-server-social-image.png) -[![GitHub release](https://img.shields.io/github/release/johnnymillergh/muscle-and-fitness-server.svg)](https://github.com/johnnymillergh/muscle-and-fitness-server/releases) -[![Build Status](https://travis-ci.com/johnnymillergh/muscle-and-fitness-server.svg?branch=master)](https://travis-ci.com/johnnymillergh/muscle-and-fitness-server) -[![GitHub issues](https://img.shields.io/github/issues/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server/issues) -[![GitHub forks](https://img.shields.io/github/forks/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server/network) -[![GitHub stars](https://img.shields.io/github/stars/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server) -[![GitHub license](https://img.shields.io/github/license/johnnymillergh/muscle-and-fitness-server)](https://github.com/johnnymillergh/muscle-and-fitness-server/blob/master/LICENSE) -[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/johnnymillergh/muscle-and-fitness-server.svg?style=popout)](https://github.com/johnnymillergh/muscle-and-fitness-server) -[![GitHub repo size](https://img.shields.io/github/repo-size/johnnymillergh/muscle-and-fitness-server.svg)](https://github.com/johnnymillergh/muscle-and-fitness-server) -[![Twitter](https://img.shields.io/twitter/url/https/github.com/johnnymillergh/muscle-and-fitness-server?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fjohnnymillergh%2Fmuscle-and-fitness-server) - -# Demo Two - -**Demo Two** a sub mudule of Muscle and Fitness Server (M&F). - -[Official Docker Image](https://hub.docker.com/r/ijohnnymiller/demo-two-prod) - -## Features - -Here is the highlights of **Demo Two**: - -1. Inherited from the most modern and newest Spring frameworks: - - `org.springframework.boot:spring-boot-starter-parent` - [![Spring Boot](https://maven-badges.herokuapp.com/maven-central/org.springframework.boot/spring-boot-starter-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.springframework.boot/spring-boot-starter-parent/) - `org.springframework.cloud:spring-cloud-dependencies` - [![Spring Cloud](https://maven-badges.herokuapp.com/maven-central/org.springframework.cloud/spring-cloud-dependencies/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.springframework.cloud/spring-cloud-dependencies/) - -2. Interact with Demo One with Spring Cloud OpenFeign. - -## Usage - -1. Clone or download this project. - - ```shell - $ git clone https://github.com/johnnymillergh/exrx-net-crawler-server.git - ``` - -2. Build with newest Intellij IDEA. - -3. Click the green triangle to Run. - -## Maintainers - -[@johnnymillergh](https://github.com/johnnymillergh). - -## Contributing - -Feel free to dive in! [Open an issue](https://github.com/johnnymillergh/spring-cloud-tutorial/issues/new). - -### Contributors - -This project exists thanks to all the people who contribute. - -- Johnny Miller [[@johnnymillergh](https://github.com/johnnymillergh)] -- … - - -### Sponsors - -Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://become-a-sponsor.org)] - -## License - -[Apache License](https://github.com/johnnymillergh/exrx-net-crawler-server/blob/master/LICENSE) © Johnny Miller - -2020 - Present - - diff --git a/demo-two/pom.xml b/demo-two/pom.xml deleted file mode 100644 index a7a94c7c..00000000 --- a/demo-two/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - 4.0.0 - - - demo-two - Demo 2 - Demo Project 2 for Spring Cloud microservice. - - 11 - 8771 - - - com.jmsoftware - muscle-and-fitness-server - 0.0.1-SNAPSHOT - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - com.google.cloud.tools - jib-maven-plugin - 2.0.0 - - - - compilingPhaseJib - compile - - dockerBuild - - - - - packagingPhaseJib - package - - build - - - - - - openjdk:11.0.5-slim - - - docker.io/ijohnnymiller/${project.artifactId}-${envAlias} - - ${project.version} - - - - - /${project.artifactId}-${envAlias} - - -Xmx256m - - - ${port} - - USE_CURRENT_TIMESTAMP - - - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - de.codecentric - spring-boot-admin-starter-client - ${spring-boot-admin.version} - - - org.springframework.cloud - spring-cloud-starter-zipkin - - - - com.jmsoftware - common - 0.0.1-SNAPSHOT - - - diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/DemoTwoApplication.java b/demo-two/src/main/java/com/jmsoftware/demotwo/DemoTwoApplication.java deleted file mode 100644 index dbd6c341..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/DemoTwoApplication.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jmsoftware.demotwo; - -import com.jmsoftware.demotwo.universal.configuration.ProjectProperty; -import com.jmsoftware.demotwo.universal.configuration.ServerConfiguration; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.cloud.openfeign.EnableFeignClients; - -import java.time.Duration; -import java.time.Instant; -import java.util.TimeZone; - - -/** - *

DemoTwoApplication

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/15/20 10:32 PM - **/ -@Slf4j -@EnableFeignClients -@EnableDiscoveryClient -@SpringBootApplication -public class DemoTwoApplication { - private static final String LINE_SEPARATOR = System.lineSeparator(); - private static ProjectProperty projectProperty; - private static ServerConfiguration serverConfiguration; - - public DemoTwoApplication(ProjectProperty projectProperty, ServerConfiguration serverConfiguration) { - DemoTwoApplication.projectProperty = projectProperty; - DemoTwoApplication.serverConfiguration = serverConfiguration; - } - - public static void main(String[] args) { - var startInstant = Instant.now(); - SpringApplication.run(DemoTwoApplication.class, args); - var endInstant = Instant.now(); - var duration = Duration.between(startInstant, endInstant); - log.info("🥳 Congratulations! 🎉"); - log.info("🖥 {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion()); - log.info("⚙️ Environment: {} ({})", projectProperty.getEnvironment(), projectProperty.getEnvironmentAlias()); - log.info("⏳ Deployment duration: {} seconds ({} ms)", duration.getSeconds(), duration.toMillis()); - log.info("⏰ App started at {} (timezone - {})", endInstant, TimeZone.getDefault().getDisplayName()); - log.info("{} App running at{} - Local: http://localhost:{}{}/{} - Network: {}/", - LINE_SEPARATOR, LINE_SEPARATOR, serverConfiguration.getServerPort(), projectProperty.getContextPath(), - LINE_SEPARATOR, serverConfiguration.getBaseUrl()); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/math/MathController.java b/demo-two/src/main/java/com/jmsoftware/demotwo/math/MathController.java deleted file mode 100644 index 978e94a2..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/math/MathController.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.jmsoftware.demotwo.math; - -import com.jmsoftware.common.bean.ResponseBodyBean; -import com.jmsoftware.demotwo.math.domain.DividePayload; -import com.jmsoftware.demotwo.math.domain.MultiplyPayload; -import com.jmsoftware.demotwo.math.service.MathService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -/** - *

MathController

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:19 AM - **/ -@RestController -@RequestMapping("/math") -@RequiredArgsConstructor -@Api(tags = {"Math Controller"}) -public class MathController { - private final MathService mathService; - - @GetMapping("/multiply") - @ApiOperation(value = "/multiply", notes = "Multiplication operation") - public ResponseBodyBean multiply(@Valid MultiplyPayload payload) { - return ResponseBodyBean.ofDataAndMessage(mathService.multiply(payload.getParameterList()), "Done"); - } - - @GetMapping("/divide") - @ApiOperation(value = "/divide", notes = "Division operation") - public ResponseBodyBean divide(@Valid DividePayload payload) { - return ResponseBodyBean.ofDataAndMessage(mathService.divide(payload.getParameter1(), payload.getParameter2()), - "Done"); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/math/domain/DividePayload.java b/demo-two/src/main/java/com/jmsoftware/demotwo/math/domain/DividePayload.java deleted file mode 100644 index c2c126df..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/math/domain/DividePayload.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.jmsoftware.demotwo.math.domain; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - *

DividePayload

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:46 AM - **/ -@Data -public class DividePayload { - @NotNull - private Double parameter1; - @NotNull - private Double parameter2; -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/math/domain/MultiplyPayload.java b/demo-two/src/main/java/com/jmsoftware/demotwo/math/domain/MultiplyPayload.java deleted file mode 100644 index e2f836d9..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/math/domain/MultiplyPayload.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.jmsoftware.demotwo.math.domain; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -/** - *

MultiplyPayload

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:21 AM - **/ -@Data -public class MultiplyPayload { - @NotEmpty - private List parameterList; -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/math/service/MathService.java b/demo-two/src/main/java/com/jmsoftware/demotwo/math/service/MathService.java deleted file mode 100644 index 5ad3b0ae..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/math/service/MathService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.jmsoftware.demotwo.math.service; - -import java.util.List; - -/** - *

MathService

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:23 AM - */ -public interface MathService { - /** - * Multiply double. - * - * @param parameterList the parameter list - * @return the double - */ - Double multiply(List parameterList); - - /** - * Divide double. - * - * @param parameter1 the parameter 1 - * @param parameter2 the parameter 2 - * @return the double - */ - Double divide(Double parameter1, Double parameter2); -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/math/service/impl/MathServiceImpl.java b/demo-two/src/main/java/com/jmsoftware/demotwo/math/service/impl/MathServiceImpl.java deleted file mode 100644 index db661a8c..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/math/service/impl/MathServiceImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jmsoftware.demotwo.math.service.impl; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.NumberUtil; -import cn.hutool.core.util.ObjectUtil; -import com.jmsoftware.common.exception.BusinessException; -import com.jmsoftware.demotwo.math.service.MathService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

MathServiceImpl

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/17/20 8:32 AM - **/ -@Slf4j -@Service -public class MathServiceImpl implements MathService { - @Override - public Double multiply(List parameterList) { - if (CollectionUtil.isEmpty(parameterList)) { - throw new BusinessException("Multiplication's parameterList is empty!"); - } - var result = parameterList.stream().mapToDouble(parameter -> parameter).reduce(1, (a, b) -> a * b); - log.info("Multiplication operation done. parameterList: {}, result: {}", parameterList, result); - return result; - } - - @Override - public Double divide(Double parameter1, Double parameter2) { - if (!ObjectUtil.isAllNotEmpty(parameter1, parameter2)) { - throw new BusinessException( - String.format("Division parameter(s) is invalid! parameter1: %s, parameter2: %s", - parameter1, parameter2)); - } - var result = NumberUtil.div(parameter1, parameter2); - log.info("Division operation done. parameter1: {}, parameter2: {}, result: {}", parameter1, parameter2, result); - return result; - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/ExceptionControllerAdvice.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/ExceptionControllerAdvice.java deleted file mode 100644 index 0729b7dc..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/ExceptionControllerAdvice.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.jmsoftware.demotwo.universal.aspect; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.json.JSONUtil; -import com.jmsoftware.common.bean.ResponseBodyBean; -import com.jmsoftware.common.constant.HttpStatus; -import com.jmsoftware.common.exception.BaseException; -import com.jmsoftware.common.util.RequestUtil; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.support.DefaultMessageSourceResolvable; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.validation.BindException; -import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; -import org.springframework.web.servlet.NoHandlerFoundException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.validation.ConstraintViolationException; -import java.util.Objects; - -/** - *

ExceptionControllerAdvice

- *

- * Exception advice for global controllers. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-03-02 17:39 - **/ -@Slf4j -@ControllerAdvice -public class ExceptionControllerAdvice { - /** - *

Exception handler.

- *

ATTENTION: In this method, cannot throw any exception.

- * - * @param request HTTP request - * @param exception any kinds of exception occurred in controller - * @return custom exception info - */ - @ResponseBody - @ExceptionHandler(value = Exception.class) - public ResponseBodyBean handleException(HttpServletRequest request, - HttpServletResponse response, - Exception exception) { - log.error("Exception occurred when [{}] requested access. URL: {}", - RequestUtil.getRequestIpAndPort(request), - request.getServletPath()); - - // FIXME: THIS IS NOT A PROBLEM - // ATTENTION: Use only ResponseBodyBean.ofStatus() in handleException() method and DON'T throw any exception - if (exception instanceof NoHandlerFoundException) { - log.error("[GlobalExceptionCapture] NoHandlerFoundException: Request URL = {}, HTTP method = {}", - ((NoHandlerFoundException) exception).getRequestURL(), - ((NoHandlerFoundException) exception).getHttpMethod()); - response.setStatus(HttpStatus.NOT_FOUND.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.NOT_FOUND); - } else if (exception instanceof HttpRequestMethodNotSupportedException) { - log.error("[GlobalExceptionCapture] HttpRequestMethodNotSupportedException: " + - "Current method is {}, Support HTTP method = {}", - ((HttpRequestMethodNotSupportedException) exception).getMethod(), - JSONUtil.toJsonStr( - ((HttpRequestMethodNotSupportedException) exception).getSupportedHttpMethods())); - response.setStatus(HttpStatus.METHOD_NOT_ALLOWED.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.METHOD_NOT_ALLOWED); - } else if (exception instanceof MethodArgumentNotValidException) { - log.error("[GlobalExceptionCapture] MethodArgumentNotValidException: {}", exception.getMessage()); - response.setStatus(HttpStatus.BAD_REQUEST.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.BAD_REQUEST.getCode(), - getFieldErrorMessageFromException((MethodArgumentNotValidException) exception), - null); - } else if (exception instanceof ConstraintViolationException) { - log.error("[GlobalExceptionCapture] ConstraintViolationException: {}", exception.getMessage()); - response.setStatus(HttpStatus.BAD_REQUEST.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.BAD_REQUEST.getCode(), - CollUtil.getFirst(((ConstraintViolationException) exception) - .getConstraintViolations()) - .getMessage(), null); - } else if (exception instanceof MethodArgumentTypeMismatchException) { - log.error("[GlobalExceptionCapture] MethodArgumentTypeMismatchException: " + - "Parameter name = {}, Exception information: {}", - ((MethodArgumentTypeMismatchException) exception).getName(), - ((MethodArgumentTypeMismatchException) exception).getMessage()); - response.setStatus(HttpStatus.PARAM_NOT_MATCH.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.PARAM_NOT_MATCH); - } else if (exception instanceof HttpMessageNotReadableException) { - log.error("[GlobalExceptionCapture] HttpMessageNotReadableException: {}", - ((HttpMessageNotReadableException) exception).getMessage()); - response.setStatus(HttpStatus.PARAM_NOT_NULL.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.PARAM_NOT_NULL); - } else if (exception instanceof BaseException) { - log.error("[GlobalExceptionCapture] BaseException: Status code: {}, message: {}, data: {}", - ((BaseException) exception).getCode(), - exception.getMessage(), - ((BaseException) exception).getData()); - response.setStatus(((BaseException) exception).getCode()); - return ResponseBodyBean.ofStatus(((BaseException) exception).getCode(), - exception.getMessage(), - ((BaseException) exception).getData()); - } else if (exception instanceof BindException) { - log.error("[GlobalExceptionCapture]: Exception information: {} ", exception.getMessage()); - response.setStatus(HttpStatus.INVALID_PARAM.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.INVALID_PARAM); - } - log.error("[GlobalExceptionCapture]: Exception information: {} ", exception.getMessage(), exception); - response.setStatus(HttpStatus.ERROR.getCode()); - return ResponseBodyBean.ofStatus(HttpStatus.ERROR.getCode(), HttpStatus.ERROR.getMessage(), null); - } - - /** - * Get field error message from exception. If two or more fields do not pass Spring Validation check, then will - * return the 1st error message of the error field. - * - * @param exception MethodArgumentNotValidException - * @return field error message - */ - private String getFieldErrorMessageFromException(MethodArgumentNotValidException exception) { - try { - DefaultMessageSourceResolvable firstErrorField = - (DefaultMessageSourceResolvable) Objects.requireNonNull(exception.getBindingResult() - .getAllErrors() - .get(0) - .getArguments())[0]; - String firstErrorFieldName = firstErrorField.getDefaultMessage(); - String firstErrorFieldMessage = exception.getBindingResult().getAllErrors().get(0).getDefaultMessage(); - return firstErrorFieldName + " " + firstErrorFieldMessage; - } catch (Exception e) { - log.error("Exception occurred when get field error message from exception. Exception message: {}", - e.getMessage(), - e); - return HttpStatus.INVALID_PARAM.getMessage(); - } - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/MethodArgumentValidationAspect.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/MethodArgumentValidationAspect.java deleted file mode 100644 index a86619d8..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/MethodArgumentValidationAspect.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.jmsoftware.demotwo.universal.aspect; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.ArrayUtil; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.*; -import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.stereotype.Component; - -import javax.validation.*; -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - *

MethodArgumentValidationAspect

- *

This class is an aspect class that validates method's argument(s).

- *

USAGE (Must Do's)

- *
    - *
  1. Annotate the method which argument we need to validate by @ValidateArgument
  2. - *
  3. Annotate the argument(s) that we need to validate by @javax.validation.Valid
  4. - *
  5. The field(s) of the argument(s) could be annotated by the constraint annotation provided by Spring - * Security
  6. - *
- *

ATTENTION

- *

If the argument doesn't pass validation, an IllegalArgumentException will be thrown, and not proceed - * the target method.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-07-06 12:17 - **/ -@Slf4j -@Aspect -@Component -public class MethodArgumentValidationAspect { - private final Validator validator; - - public MethodArgumentValidationAspect() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - this.validator = factory.getValidator(); - } - - /** - * Define pointcut. Pointcut is a predicate or expression that matches join points. In - * ValidateMethodArgumentAspect, we need to cut any method annotated with `@ValidateArgument` only. - *

- * More detail at: Spring aop aspectJ - * pointcut expression examples - */ - @Pointcut("@annotation(com.jmsoftware.demotwo.universal.aspect.ValidateArgument)") - public void validateMethodArgumentPointcut() { - } - - /** - * Before handle method's argument. This method will be executed after called `proceedingJoinPoint.proceed()`. In - * this phrase, we're going to take some logs. - *

- * `@Before` annotated methods run exactly before the all methods matching with pointcut expression. - * - * @param joinPoint a point of execution of the program - */ - @Before("validateMethodArgumentPointcut()") - public void beforeMethodHandleArgument(JoinPoint joinPoint) { - log.info("Method : {}#{}", - joinPoint.getSignature().getDeclaringTypeName(), - joinPoint.getSignature().getName()); - log.info("Argument : {}", joinPoint.getArgs()); - } - - /** - * Around annotated method processes argument. Around advice can perform custom behavior before and after the - * method invocation. - * - * @param proceedingJoinPoint the object can perform method invocation - * @return any value (may be void) that annotated method returned - */ - @Around("validateMethodArgumentPointcut()") - public Object aroundMethodHandleArgument(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - log.info("======= METHOD'S ARGUMENT VALIDATION START ======="); - Object[] args = proceedingJoinPoint.getArgs(); - MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature(); - Annotation[][] parameterAnnotations = signature.getMethod().getParameterAnnotations(); - // argumentIndexes is the array list that stores the index of argument we need to validate (the argument - // annotated by `@Valid`) - List argumentIndexes = new ArrayList<>(); - for (Annotation[] parameterAnnotation : parameterAnnotations) { - int paramIndex = ArrayUtil.indexOf(parameterAnnotations, parameterAnnotation); - for (Annotation annotation : parameterAnnotation) { - if (annotation instanceof Valid) { - argumentIndexes.add(paramIndex); - } - } - } - - for (Integer index : argumentIndexes) { - Set> validates = validator.validate(args[index]); - if (CollectionUtil.isNotEmpty(validates)) { - String message = String.format("Argument validation failed: %s", validates); - log.info("Method : {}#{}", - proceedingJoinPoint.getSignature().getDeclaringTypeName(), - proceedingJoinPoint.getSignature().getName()); - log.info("Argument : {}", args); - log.error("Validation result: {}", message); - // If the argument doesn't pass validation, an IllegalArgumentException will be thrown, and not - // proceed the target method - throw new IllegalArgumentException(message); - } - } - - log.info("Validation result: Validation passed"); - return proceedingJoinPoint.proceed(); - } - - /** - * `@After` annotated methods run exactly after the all methods matching with pointcut expression. - */ - @After("validateMethodArgumentPointcut()") - public void afterMethodHandleArgument() { - log.info("======== METHOD'S ARGUMENT VALIDATION END ========"); - } - - /** - * `@AfterThrowing` annotated methods run after the method (matching with pointcut expression) exits by throwing an - * exception. - * - * @param joinPoint a point of execution of the program - * @param e exception that controller's method throws - */ - @AfterThrowing(pointcut = "validateMethodArgumentPointcut()", throwing = "e") - public void afterThrowingException(JoinPoint joinPoint, Exception e) { - log.info("Signature : {}", joinPoint.getSignature().toShortString()); - log.error("Exception message: {}", e.toString()); - log.error("== METHOD'S ARGUMENT VALIDATION END WITH EXCEPTION =="); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/ValidateArgument.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/ValidateArgument.java deleted file mode 100644 index 631fdbe0..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/ValidateArgument.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.jmsoftware.demotwo.universal.aspect; - -import java.lang.annotation.*; - -/** - *

ValidateArgument

- *

Annotation for validating method's argument.

- *

ATTENTION

- *

If the argument doesn't pass validation, an IllegalArgumentException will be thrown, and not proceed - * the target method.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-07-06 12:08 - **/ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD}) -@Documented -public @interface ValidateArgument { -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/WebRequestLogAspect.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/WebRequestLogAspect.java deleted file mode 100644 index b7b1ab05..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/aspect/WebRequestLogAspect.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.jmsoftware.demotwo.universal.aspect; - -import cn.hutool.core.util.NumberUtil; -import cn.hutool.json.JSONUtil; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.jmsoftware.common.util.RequestUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.*; -import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; - -/** - *

RequestLogAspect

- *

Description:

- *

RequestLogAspect is an AOP for logging URL, HTTP method, client IP and other information when web resource was - * accessed.

- *

Feature:

- *

No methods in controller need to be decorated with annotation. This aspect would automatically cut the method - * decorated with `@GetMapping` or `@PostMapping`.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-05-05 19:55 - **/ -@Slf4j -@Aspect -@Component -@RequiredArgsConstructor -public class WebRequestLogAspect { - private static final String LINE_SEPARATOR = System.lineSeparator(); - private final ObjectMapper mapper = new ObjectMapper(); - - /** - * Define pointcut. Pointcut is a predicate or expression that matches join points. In WebRequestLogAspect, we need - * to cut any method annotated with `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`, `@PatchMapping`, `@RequestMapping`. - *

- * More detail at: Spring aop aspectJ - * pointcut expression examples - */ - @Pointcut("@annotation(org.springframework.web.bind.annotation.GetMapping)" + - " || @annotation(org.springframework.web.bind.annotation.PostMapping)" + - " || @annotation(org.springframework.web.bind.annotation.PutMapping)" + - " || @annotation(org.springframework.web.bind.annotation.DeleteMapping)" + - " || @annotation(org.springframework.web.bind.annotation.PatchMapping)" + - " || @annotation(org.springframework.web.bind.annotation.RequestMapping)") - public void requestLogPointcut() { - } - - /** - * Before controller handle client request (on client sent a request). - *

- * `@Before` annotated methods run exactly before the all methods matching with pointcut expression. - * - * @param joinPoint a point of execution of the program - */ - @Before("requestLogPointcut()") - public void beforeHandleRequest(JoinPoint joinPoint) { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - assert attributes != null; - HttpServletRequest request = attributes.getRequest(); - log.info("============ WEB REQUEST LOG START ============"); - log.info("URL : {}", request.getRequestURL().toString()); - log.info("HTTP Method : {}", request.getMethod()); - log.info("Client IP:Port : {}", RequestUtil.getRequestIpAndPort(request)); - log.info("Class Method : {}#{}", - joinPoint.getSignature().getDeclaringTypeName(), - joinPoint.getSignature().getName()); - log.info("Request Params :{}{}", LINE_SEPARATOR, JSONUtil.toJsonPrettyStr(joinPoint.getArgs())); - } - - /** - * Around controller's method processes client request. Around advice can perform custom behavior before and after - * the method invocation. - * - * @param proceedingJoinPoint the object can perform method invocation - * @return any value (may be void) that controller's method returned - * @throws Throwable any exceptions that controller's method may throw - */ - @Around("requestLogPointcut()") - public Object aroundHandleRequest(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Object result = proceedingJoinPoint.proceed(); - long elapsedTime = System.currentTimeMillis() - startTime; - try { - var formattedStringifiedJson = JSONUtil.formatJsonStr(mapper.writeValueAsString(result)); - if (formattedStringifiedJson.length() > 500) { - formattedStringifiedJson = formattedStringifiedJson.substring(0, 499).concat("…"); - } - log.info("Response :{}{}", LINE_SEPARATOR, formattedStringifiedJson); - } catch (JsonProcessingException e) { - log.info("Response (non-JSON): {}", result); - } - log.info("Elapsed time : {} s ({} ms)", - NumberUtil.decimalFormat("0.00", elapsedTime / 1000D), - elapsedTime); - return result; - } - - /** - * `@After` annotated methods run exactly after the all methods matching with pointcut expression. - */ - @After("requestLogPointcut()") - public void afterHandleRequest() { - log.info("============= WEB REQUEST LOG END ============="); - } - - /** - * `@AfterThrowing` annotated methods run after the method (matching with pointcut expression) exits by throwing an - * exception. - * - * @param joinPoint a point of execution of the program - * @param e exception that controller's method throws - */ - @AfterThrowing(pointcut = "requestLogPointcut()", throwing = "e") - public void afterThrowingException(JoinPoint joinPoint, Exception e) { - log.info("Signature : {}", joinPoint.getSignature().toShortString()); - log.error("Exception message : {}, message: {}", e.toString(), e.getMessage()); - log.error("====== WEB REQUEST LOG END WITH EXCEPTION ====="); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/ProjectProperty.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/ProjectProperty.java deleted file mode 100644 index 541f1f84..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/ProjectProperty.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jmsoftware.demotwo.universal.configuration; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - *

ProjectProperty

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-04-18 13:01 - **/ -@Slf4j -@Data -@Component -@ConfigurationProperties(prefix = "project.property") -public class ProjectProperty { - private String basePackage; - private String contextPath; - private String groupId; - private String artifactId; - private String projectArtifactId; - private String version; - private String description; - private String jdkVersion; - private String environment; - private String environmentAlias; - private String url; - private String inceptionYear; - private String organizationName; - private String organizationUrl; - private String issueManagementSystem; - private String issueManagementUrl; - private String developerName; - private String developerEmail; - private String developerUrl; -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/ServerConfiguration.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/ServerConfiguration.java deleted file mode 100644 index e0d689e0..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/ServerConfiguration.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.jmsoftware.demotwo.universal.configuration; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.web.context.WebServerInitializedEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.Inet4Address; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.URL; -import java.util.Enumeration; - -/** - *

ServerConfiguration

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-04-26 16:02 - **/ -@Slf4j -@Getter -@Component -@RequiredArgsConstructor -public class ServerConfiguration implements ApplicationListener { - public static final String DEVELOPMENT_ENVIRONMENT_ALIAS = "dev"; - private final ProjectProperty projectProperty; - private int serverPort; - - @Override - public void onApplicationEvent(WebServerInitializedEvent event) { - this.serverPort = event.getWebServer().getPort(); - } - - /** - *

Get base URL of backend server.

- *

The result will be like:

- *
    - *
  1. http://[serverIp]:[serverPort]/[contextPath]
  2. - *
  3. https://[serverIp]/[contextPath]
  4. - *
- * - * @return base URL - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-05-03 16:05 - */ - public String getBaseUrl() { - return "http://" + this.getPublicIp() + ":" + serverPort + projectProperty.getContextPath(); - } - - /** - * Find public IP address. - * - * @return public IP - */ - public String getPublicIp() { - if (projectProperty.getEnvironmentAlias().contains(DEVELOPMENT_ENVIRONMENT_ALIAS)) { - return this.getInternetIp(); - } - try { - // An API provided by https://whatismyipaddress.com/api - URL url = new URL("https://ipv4bot.whatismyipaddress.com/"); - BufferedReader sc = new BufferedReader(new InputStreamReader(url.openStream())); - // Read system IP Address - return sc.readLine().trim(); - } catch (Exception e) { - log.error("Cannot execute properly to get IP address from https://whatismyipaddress.com/api", e); - } - return this.getInternetIp(); - } - - /** - * Get internet IP. - * - * @return internet IP - */ - private String getInternetIp() { - String intranetIp = this.getIntranetIp(); - try { - Enumeration networks = NetworkInterface.getNetworkInterfaces(); - InetAddress ip; - Enumeration addresses; - while (networks.hasMoreElements()) { - addresses = networks.nextElement().getInetAddresses(); - while (addresses.hasMoreElements()) { - ip = addresses.nextElement(); - if (ip instanceof Inet4Address - && ip.isSiteLocalAddress() - && !ip.getHostAddress().equals(intranetIp)) { - return ip.getHostAddress(); - } - } - } - return intranetIp; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Get intranet IP. - * - * @return intranet IP - */ - private String getIntranetIp() { - try { - return InetAddress.getLocalHost().getHostAddress(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/Swagger2Configuration.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/Swagger2Configuration.java deleted file mode 100644 index 780fec6b..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/Swagger2Configuration.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.jmsoftware.demotwo.universal.configuration; - -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - *

Swagger2Configuration

- *

- * Swagger 2 Configuration - * Click me to view - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-02-07 16:15 - **/ -@Configuration -@EnableSwagger2 -@RequiredArgsConstructor -public class Swagger2Configuration { - private final ProjectProperty projectProperty; - private static final String LINE_SEPARATOR = System.lineSeparator(); - - @Bean - public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.basePackage(projectProperty.getBasePackage())) - .paths(PathSelectors.any()) - .build(); - } - - private ApiInfo apiInfo() { - var projectArtifactId = projectProperty.getProjectArtifactId(); - var version = projectProperty.getVersion(); - var developerEmail = projectProperty.getDeveloperEmail(); - var developerUrl = projectProperty.getDeveloperUrl(); - var environmentAlias = projectProperty.getEnvironmentAlias(); - return new ApiInfoBuilder() - .title(String.format("API for %s@%s (%s)", - projectArtifactId, - version, - environmentAlias)) - .description(String.format("%s %sArtifact ID: %s%sEnvironment: %s (%s)", - projectProperty.getDescription(), - LINE_SEPARATOR, - projectArtifactId, - LINE_SEPARATOR, - projectProperty.getEnvironment(), - environmentAlias)) - .contact(new Contact(String.format("%s, email: %s%sHome page: %s", - projectProperty.getDeveloperName(), - developerEmail, - LINE_SEPARATOR, - developerUrl), - developerUrl, developerEmail)) - .version(version) - .build(); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/WebMvcConfiguration.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/WebMvcConfiguration.java deleted file mode 100644 index 39596523..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/configuration/WebMvcConfiguration.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jmsoftware.demotwo.universal.configuration; - -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - *

WebMvcConfiguration

- *

- * Spring MVC Configurations. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 1/23/20 9:02 AM - **/ -@Configuration -@RequiredArgsConstructor -public class WebMvcConfiguration implements WebMvcConfigurer { - private static final long MAX_AGE_SECS = 3600; - - /** - * 1. Config static path pattern - * 2. Config static resource location - * - * @param registry static resources register - */ - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); - } - - /** - * Configure cross origin requests processing. - * - * @param registry CORS registry - */ - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("*") - .allowedMethods("HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE") - .maxAge(MAX_AGE_SECS); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/CommonController.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/CommonController.java deleted file mode 100644 index 597dc57c..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/CommonController.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jmsoftware.demotwo.universal.controller; - -import com.jmsoftware.common.bean.ResponseBodyBean; -import com.jmsoftware.demotwo.universal.domain.ValidationTestPayload; -import com.jmsoftware.demotwo.universal.service.CommonService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; - -import java.util.Map; - -/** - *

CommonController

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/4/20 10:29 AM - **/ -@RestController -@RequiredArgsConstructor -@RequestMapping("/common") -@Api(tags = {"Common Controller"}) -public class CommonController { - private final CommonService commonService; - - @GetMapping("/app-info") - @ApiOperation(value = "/app-info", notes = "Retrieve application information") - public ResponseBodyBean> applicationInformation() { - var data = commonService.getApplicationInfo(); - return ResponseBodyBean.ofDataAndMessage(data, "Succeed to retrieve app info."); - } - - @PostMapping("/validation-test") - @ApiOperation(value = "/validation-test", notes = "Validation of request payload test") - public ResponseBodyBean validationTest(@RequestBody ValidationTestPayload payload) { - commonService.validateObject(payload); - return ResponseBodyBean.ofDataAndMessage(payload.getName(), "validationTest()"); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/ErrorController.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/ErrorController.java deleted file mode 100644 index b2dc1ffb..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/ErrorController.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jmsoftware.demotwo.universal.controller; - -import io.swagger.annotations.Api; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.autoconfigure.web.ServerProperties; -import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; -import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; -import org.springframework.boot.web.servlet.error.ErrorAttributes; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.util.List; -import java.util.Map; - -/** - *

ErrorController

- *

- * Error controller. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-03-02 16:56 - **/ -@Slf4j -@RestController -@Api(tags = {"Error Controller"}) -public class ErrorController extends BasicErrorController { - public ErrorController(ErrorAttributes errorAttributes, - ServerProperties serverProperties, - List errorViewResolvers) { - super(errorAttributes, serverProperties.getError(), errorViewResolvers); - } - - @Override - public ResponseEntity> error(HttpServletRequest request) { - HttpStatus httpStatus = getStatus(request); - Map body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL)); - body.put("message", httpStatus.getReasonPhrase()); - log.error("Captured HTTP request error. Response body = {}", body); - return new ResponseEntity<>(body, httpStatus); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/RedirectController.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/RedirectController.java deleted file mode 100644 index d4b66802..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/controller/RedirectController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.jmsoftware.demotwo.universal.controller; - -import com.jmsoftware.demotwo.universal.configuration.ProjectProperty; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.PostConstruct; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

RedirectController

- *

- * HTTP Redirect Controller - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 1/21/20 1:18 PM - **/ -@Slf4j -@RestController -@RequiredArgsConstructor -@Api(tags = {"Redirect Controller"}) -public class RedirectController { - private final ProjectProperty projectProperty; - - @PostConstruct - public void postConstruct() { - log.info("URL redirect service initialized."); - } - - @GetMapping("/home") - @ApiOperation(value = "/home", notes = "Home page") - public void handleHomeRequest(HttpServletResponse response) throws IOException { - // Redirect to home page - response.sendRedirect(projectProperty.getContextPath() + "/static/home.html"); - } - - @GetMapping("/doc") - @ApiOperation(value = "/doc", notes = "Swagger API Documentation") - public void handleDocRequest(HttpServletResponse response) throws IOException { - // Redirect to Bootstrap Swagger API documentation - response.sendRedirect(projectProperty.getContextPath() + "/doc.html?cache=1&lang=en"); - } - - @GetMapping("/webjars/bycdao-ui/images/api.ico") - @ApiOperation(value = "/webjars/bycdao-ui/images/api.ico", notes = "Favicon redirection") - public void handleFaviconRequest(HttpServletResponse response) throws IOException { - // Redirect to a customized favicon - response.sendRedirect(projectProperty.getContextPath() + "/static/icon/favicon.ico"); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/domain/ValidationTestPayload.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/domain/ValidationTestPayload.java deleted file mode 100644 index 02178c17..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/domain/ValidationTestPayload.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.jmsoftware.demotwo.universal.domain; - -import lombok.Data; - -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - *

ValidationTestPayload

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/14/20 11:34 AM - **/ -@Data -public class ValidationTestPayload { - @NotNull - @Min(value = 1L) - private Long id; - @NotEmpty - private String name; -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/filter/RequestFilter.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/filter/RequestFilter.java deleted file mode 100644 index e8eadf09..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/filter/RequestFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jmsoftware.demotwo.universal.filter; - -import com.jmsoftware.common.util.RequestUtil; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; -import org.springframework.web.filter.OncePerRequestFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - *

RequestFilter

- *

Request filter.

- * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2019-03-23 14:24 - **/ -@Slf4j -@Component -public class RequestFilter extends OncePerRequestFilter { - @Override - @SuppressWarnings("NullableProblems") - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws IOException, ServletException { - log.info("[{}] Client requested access. Method: {}, URL: {}", - RequestUtil.getRequestIpAndPort(request), - request.getMethod(), - request.getRequestURL()); - filterChain.doFilter(request, response); - } -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/service/CommonService.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/service/CommonService.java deleted file mode 100644 index 127ffb28..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/service/CommonService.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.jmsoftware.demotwo.universal.service; - -import com.jmsoftware.demotwo.universal.domain.ValidationTestPayload; - -import java.util.Map; - -/** - *

CommonService

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/4/20 11:15 AM - */ -public interface CommonService { - /** - * Gets application info. - * - * @return the application info. - */ - Map getApplicationInfo(); - - /** - * Validate object. - * - * @param payload the payload - */ - void validateObject(ValidationTestPayload payload); -} diff --git a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/service/impl/CommonServiceImpl.java b/demo-two/src/main/java/com/jmsoftware/demotwo/universal/service/impl/CommonServiceImpl.java deleted file mode 100644 index de74209a..00000000 --- a/demo-two/src/main/java/com/jmsoftware/demotwo/universal/service/impl/CommonServiceImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.jmsoftware.demotwo.universal.service.impl; - -import com.jmsoftware.demotwo.universal.aspect.ValidateArgument; -import com.jmsoftware.demotwo.universal.configuration.ProjectProperty; -import com.jmsoftware.demotwo.universal.domain.ValidationTestPayload; -import com.jmsoftware.demotwo.universal.service.CommonService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import javax.validation.Valid; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - *

CommonServiceImpl

- *

- * Change description here. - * - * @author Johnny Miller (鍾俊), email: johnnysviva@outlook.com - * @date 2/4/20 11:16 AM - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class CommonServiceImpl implements CommonService { - private final ProjectProperty projectProperty; - - @Override - public Map getApplicationInfo() { - var map = new HashMap(16); - var fieldsInfo = getFieldsInfo(projectProperty); - fieldsInfo.forEach(fieldInfo -> { - var type = fieldInfo.get("type"); - if ("class java.lang.String".equals(type)) { - map.put((String) fieldInfo.get("name"), fieldInfo.get("value")); - } - }); - return map; - } - - @Override - @ValidateArgument - public void validateObject(@Valid ValidationTestPayload payload) { - log.info("Validation passed! {}", payload); - } - - /** - * Gets field value by name. - * - * @param fieldName the field name - * @param object the object - * @return the field value by name - * @see Java 中遍历一个对象的所有属性 - */ - private Object getFieldValueByName(String fieldName, Object object) { - try { - String firstLetter = fieldName.substring(0, 1).toUpperCase(); - String getter = "get" + firstLetter + fieldName.substring(1); - Method method = object.getClass().getMethod(getter); - return method.invoke(object); - } catch (Exception e) { - log.error("Can't get field's value by name! Cause: {}", e.getMessage()); - return null; - } - } - - /** - * Get filed name string [ ]. - * - * @param o the o - * @return the string [ ] - * @see Java 中遍历一个对象的所有属性 - */ - private String[] getFiledName(Object o) { - Field[] fields = o.getClass().getDeclaredFields(); - String[] fieldNames = new String[fields.length]; - for (int i = 0; i < fields.length; i++) { - log.info("fields[i].getType(): {}", fields[i].getType()); - fieldNames[i] = fields[i].getName(); - } - return fieldNames; - } - - /** - * Get Fields Info - * - * @param o the o - * @return the fields info - * @see Java 中遍历一个对象的所有属性 - */ - private List> getFieldsInfo(Object o) { - Field[] fields = o.getClass().getDeclaredFields(); - var arrayList = new ArrayList>(); - for (Field field : fields) { - var infoMap = new HashMap(16); - infoMap.put("type", field.getType().toString()); - infoMap.put("name", field.getName()); - infoMap.put("value", getFieldValueByName(field.getName(), o)); - arrayList.add(infoMap); - } - return arrayList; - } - - /** - * Get Filed Values - * - * @param o the o - * @return the object [ ] - * @see Java 中遍历一个对象的所有属性 - */ - public Object[] getFiledValues(Object o) { - String[] fieldNames = this.getFiledName(o); - Object[] value = new Object[fieldNames.length]; - for (int i = 0; i < fieldNames.length; i++) { - value[i] = this.getFieldValueByName(fieldNames[i], o); - } - return value; - } -} diff --git a/demo-two/src/main/resources/application-development-docker.yml b/demo-two/src/main/resources/application-development-docker.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-two/src/main/resources/application-development-docker.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-two/src/main/resources/application-development-local.yml b/demo-two/src/main/resources/application-development-local.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-two/src/main/resources/application-development-local.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-two/src/main/resources/application-production.yml b/demo-two/src/main/resources/application-production.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-two/src/main/resources/application-production.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-two/src/main/resources/application-stage.yml b/demo-two/src/main/resources/application-stage.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-two/src/main/resources/application-stage.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-two/src/main/resources/application-test.yml b/demo-two/src/main/resources/application-test.yml deleted file mode 100644 index f513aad3..00000000 --- a/demo-two/src/main/resources/application-test.yml +++ /dev/null @@ -1,15 +0,0 @@ -eureka: - instance: - leaseRenewalIntervalInSeconds: 10 - health-check-url-path: /actuator/health - metadata-map: - # needed to trigger info and endpoint update after restart - startup: ${random.int} - client: - registryFetchIntervalSeconds: 5 - serviceUrl: - defaultZone: http://localhost:8760/eureka/ - -spring: - zipkin: - base-url: http://localhost:9411 diff --git a/demo-two/src/main/resources/application.yml b/demo-two/src/main/resources/application.yml deleted file mode 100644 index 34cc4cd0..00000000 --- a/demo-two/src/main/resources/application.yml +++ /dev/null @@ -1,57 +0,0 @@ -server: - port: @port@ -# servlet: -# context-path: /@project.artifactId@-@envAlias@ - tomcat: - uri-encoding: @project.build.sourceEncoding@ - -spring: - application: - name: @project.artifactId@ - profiles: - active: @env@ - mvc: - throw-exception-if-no-handler-found: true - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 - sleuth: - sampler: - probability: 1.0 - -management: - endpoints: - web: - exposure: - include: "*" - endpoint: - health: - show-details: ALWAYS - -logging: - config: classpath:configuration/logback/logback-@env@.xml - # Configure logging level of project as DEBUG to enable SQL logging and other logging. - level: - com.jmsoftware: DEBUG - -project: - property: - base-package: com.jmsoftware.demotwo - context-path: - group-id: @project.groupId@ - artifact-id: @project.artifactId@ - project-artifact-id: @project.artifactId@ - version: @project.version@ - description: @project.description@ - jdk-version: @java.version@ - environment: @env@ - environment-alias: @envAlias@ - url: @project.url@ - inception-year: @inceptionYear@ - organization-name: @project.organization.name@ - organization-url: @project.organization.url@ - issue-management-system: @project.issueManagement.system@ - issue-management-url: @project.issueManagement.url@ - developer-name: @developerName@ - developer-email: @developerEmail@ - developer-url: @developerUrl@ diff --git a/demo-two/src/main/resources/banner.txt b/demo-two/src/main/resources/banner.txt deleted file mode 100644 index a15e397d..00000000 --- a/demo-two/src/main/resources/banner.txt +++ /dev/null @@ -1,26 +0,0 @@ -${AnsiStyle.BOLD}${AnsiColor.BRIGHT_GREEN} - ____ ______ - / __ \___ ____ ___ ____ /_ __/ ______ - / / / / _ \/ __ `__ \/ __ \ / / | | /| / / __ \ - / /_/ / __/ / / / / / /_/ / / / | |/ |/ / /_/ / -/_____/\___/_/ /_/ /_/\____/ /_/ |__/|__/\____/ -${AnsiStyle.BOLD}Demo Two :: Powered by Spring Boot ::${spring-boot.formatted-version} -${AnsiColor.CYAN}Author: Johnny Miller (鍾俊), email: johnnysviva@outlook.com -${AnsiStyle.NORMAL}${AnsiColor.MAGENTA}http://patorjk.com/software/taag/#p=display&f=Slant&t=Spring%20Boot%20Admin -${AnsiColor.BRIGHT_BLACK} --------------------------------------------Font Info------------------------------------------- -Slant by Glenn Chappell 3/93 -- based on Standard -Includes ISO Latin-1 -figlet release 2.1 -- 12 Aug 1994 -Permission is hereby given to modify this font, as long as the -modifier's name is placed on a comment line. - -Modified by Paul Burton 12/96 to include new parameter -supported by FIGlet and FIGWin. May also be slightly modified for better use -of new full-width/kern/smush alternatives, but default output is NOT changed. - -------------------------------------------Banner Info------------------------------------------ -Banner generated by Text ASCII Art Generator. -A web app that lets you type in large ASCII Art text lettering. -This can create art you can put in your email signature, on your webpage, etc etc. -More at http://patorjk.com/software/taag/ diff --git a/demo-two/src/main/resources/configuration/.empty b/demo-two/src/main/resources/configuration/.empty deleted file mode 100644 index e69de29b..00000000 diff --git a/demo-two/src/main/resources/configuration/logback/logback-base.xml b/demo-two/src/main/resources/configuration/logback/logback-base.xml deleted file mode 100644 index 6cac9cea..00000000 --- a/demo-two/src/main/resources/configuration/logback/logback-base.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${CONSOLE_LOG_PATTERN} - UTF-8 - - - - - - - ALL - ACCEPT - ACCEPT - - - - ${FILE_LOG_PATTERN} - UTF-8 - - - - - - - ${LOG_HOME}/${PROJECT_ARTIFACT_Id}.%d{yyyy-MM-dd}.%i.log.gz - - 5MB - 7 - 1GB - - - diff --git a/demo-two/src/main/resources/configuration/logback/logback-development-docker.xml b/demo-two/src/main/resources/configuration/logback/logback-development-docker.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-two/src/main/resources/configuration/logback/logback-development-docker.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-two/src/main/resources/configuration/logback/logback-development-local.xml b/demo-two/src/main/resources/configuration/logback/logback-development-local.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-two/src/main/resources/configuration/logback/logback-development-local.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-two/src/main/resources/configuration/logback/logback-production.xml b/demo-two/src/main/resources/configuration/logback/logback-production.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-two/src/main/resources/configuration/logback/logback-production.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-two/src/main/resources/configuration/logback/logback-stage.xml b/demo-two/src/main/resources/configuration/logback/logback-stage.xml deleted file mode 100644 index f38e6c2d..00000000 --- a/demo-two/src/main/resources/configuration/logback/logback-stage.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-two/src/main/resources/configuration/logback/logback-test.xml b/demo-two/src/main/resources/configuration/logback/logback-test.xml deleted file mode 100644 index f1916a0f..00000000 --- a/demo-two/src/main/resources/configuration/logback/logback-test.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/demo-two/src/main/resources/static/home.html b/demo-two/src/main/resources/static/home.html deleted file mode 100644 index e7599316..00000000 --- a/demo-two/src/main/resources/static/home.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - UNSET - - - - -

-
- Hello, World! - - Welcome to {{ projectArtifactId }}@{{ version }}! - - - - {{ applicationName }} - -
-
- Create New Person -
- - -
-
- - -
-
- - -
-
- - -
-
- - - - - - - - - - - - - - - - - -
NameAgeSexDelete
{{ person.name }}{{ person.age }}{{ person.sex }} - -
- This page is provided by - keepfool. - -
- - - - diff --git a/demo-two/src/main/resources/static/icon/favicon.ico b/demo-two/src/main/resources/static/icon/favicon.ico deleted file mode 100644 index 0798d38f..00000000 Binary files a/demo-two/src/main/resources/static/icon/favicon.ico and /dev/null differ diff --git a/demo-two/src/main/resources/static/image/muscle-and-fitness-server-social-image.png b/demo-two/src/main/resources/static/image/muscle-and-fitness-server-social-image.png deleted file mode 100644 index 83786ad8..00000000 Binary files a/demo-two/src/main/resources/static/image/muscle-and-fitness-server-social-image.png and /dev/null differ diff --git a/demo-two/src/main/resources/static/script/404.js b/demo-two/src/main/resources/static/script/404.js deleted file mode 100644 index 5401ce54..00000000 --- a/demo-two/src/main/resources/static/script/404.js +++ /dev/null @@ -1,12 +0,0 @@ -// noinspection JSUnusedGlobalSymbols -const vm = new Vue({ - el: '#app', - data: {}, - methods: { - handleClickGoToHome: function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - window.location.href = `${split[0]}//${split[2]}/${split[3]}`; - } - } -}); diff --git a/demo-two/src/main/resources/static/script/home.js b/demo-two/src/main/resources/static/script/home.js deleted file mode 100644 index a191d8c5..00000000 --- a/demo-two/src/main/resources/static/script/home.js +++ /dev/null @@ -1,72 +0,0 @@ -// noinspection JSUnusedGlobalSymbols -const vm = new Vue({ - el: '#app', - data: { - projectArtifactId: null, - version: null, - applicationName: null, - newPerson: { - name: '', - age: 0, - sex: 'Male' - }, - people: [{ - name: 'Jack', - age: 30, - sex: 'Male' - }, { - name: 'Bill', - age: 26, - sex: 'Male' - }, { - name: 'Tracy', - age: 22, - sex: 'Female' - }, { - name: 'Chris', - age: 36, - sex: 'Male' - }] - }, - methods: { - /** - * Create a person - */ - createPerson: function () { - this.people.push(this.newPerson); - this.newPerson = {name: '', age: 0, sex: 'Male'} - - }, - /** - * delete a person - * @param index - */ - deletePerson: function (index) { - this.people.splice(index, 1); - }, - handleClickSwaggerApiDocumentation: function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - window.location.href = `${split[0]}//${split[2]}/doc`; - }, - handleClickVideoDemo: function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - window.location.href = `${split[0]}//${split[2]}/${split[3]}/video.html`; - }, - getAppInfo: async function () { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - const baseUrl = `${split[0]}//${split[2]}`; - const response = await fetch(`${baseUrl}/common/app-info`); - const responseJson = await response.json(); - this.projectArtifactId = responseJson.data.projectArtifactId; - this.version = responseJson.data.version; - this.applicationName = this.projectArtifactId.toUpperCase(); - window.document.title = this.applicationName; - } - }, - mounted: async function () { - this.getAppInfo(); - } -}); diff --git a/demo-two/src/main/resources/static/script/video.js b/demo-two/src/main/resources/static/script/video.js deleted file mode 100644 index 3a155900..00000000 --- a/demo-two/src/main/resources/static/script/video.js +++ /dev/null @@ -1,17 +0,0 @@ -// noinspection JSUnusedGlobalSymbols -const vm = new Vue({ - el: '#app', - data: { - appInfo: null, - videoSource: '' - }, - async mounted() { - const currentUrl = window.location.href; - const split = currentUrl.split('/'); - this.videoSource = `${split[0]}//${split[2]}/${split[3]}/test-table/demo-video`; - const baseUrl = `${split[0]}//${split[2]}`; - const response = await fetch(`${baseUrl}/common/app-info`); - const responseJson = await response.json(); - this.appInfo = responseJson.data; - } -}); diff --git a/demo-two/src/main/resources/static/styles/404.css b/demo-two/src/main/resources/static/styles/404.css deleted file mode 100644 index 09a4e9bc..00000000 --- a/demo-two/src/main/resources/static/styles/404.css +++ /dev/null @@ -1,89 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box -} - -html { - font-size: 12px; - font-family: Ubuntu, simHei, sans-serif; - font-weight: 400 -} - -body { - font-size: 1rem -} - -button { - outline: none; - padding: 5px 8px; - color: #fff; - border: 1px solid #BCBCBC; - border-radius: 3px; - background-color: #009A61; - cursor: pointer; -} - -button:hover { - opacity: 0.8; -} - -#app { - margin: 48px auto 0; - max-width: 640px; - -webkit-perspective: 500px; -} - -.text-center { - text-align: center; -} - -.message-box { - background-color: firebrick; - max-width: 700px; - padding: 20px; - border-radius: 8px; - margin: 48px auto 20px; -} - -.slide-in-bck-center { - animation: slide-in-bck-center 1.2s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; -} - -@keyframes slide-in-bck-center { - 0% { - transform: translateZ(600px); - opacity: 0; - } - 100% { - transform: translateZ(0); - opacity: 1; - } -} - -.message-text { - font-size: xx-large; - text-align: center; - color: ivory; -} - -.social-image { - width: 600px; - border-radius: 8px; -} - -.message-title { - text-align: center; - display: block; - font-size: 48px; - text-shadow: black 2px 2px 6px; -} - -.server-name { - color: gold; -} - -.go-to { - display: inline-block; - margin-bottom: 6px; -} diff --git a/demo-two/src/main/resources/static/styles/home.css b/demo-two/src/main/resources/static/styles/home.css deleted file mode 100644 index 62ebe0c2..00000000 --- a/demo-two/src/main/resources/static/styles/home.css +++ /dev/null @@ -1,222 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box -} - -html { - font-size: 12px; - font-family: Ubuntu, simHei, sans-serif; - font-weight: 400 -} - -body { - font-size: 1rem -} - -table, -td, -th { - border-collapse: collapse; - border-spacing: 0 -} - -table { - width: 100% -} - -td, -th { - border: 1px solid #bcbcbc; - padding: 5px 10px -} - -th { - background: #42b983; - font-size: 1.2rem; - font-weight: 400; - color: #fff; - cursor: pointer -} - -tr:nth-of-type(odd) { - background: #fff -} - -tr:nth-of-type(even) { - background: #eee -} - -fieldset { - border: 1px solid #BCBCBC; - padding: 15px; -} - -input { - outline: none -} - -input[type=text] { - border: 1px solid #ccc; - padding: .5rem .3rem; -} - -input[type=text]:focus { - border-color: #42b983; -} - -button { - outline: none; - padding: 5px 8px; - color: #fff; - border: 1px solid #BCBCBC; - border-radius: 3px; - background-color: #009A61; - cursor: pointer; -} - -button:hover { - opacity: 0.8; -} - -#app { - margin: 0 auto; - max-width: 640px; - -webkit-perspective: 500px; -} - -.form-group { - margin: 10px; -} - -.form-group > label { - display: inline-block; - width: 10rem; - text-align: right; -} - -.form-group > input, -.form-group > select { - display: inline-block; - height: 2.5rem; - line-height: 2.5rem; -} - -.text-center { - text-align: center; -} - -.pagination { - display: inline-block; - padding-left: 0; - margin: 21px 0; - border-radius: 3px; -} - -.pagination > li { - display: inline; -} - -.pagination > li > a { - position: relative; - float: left; - padding: 6px 12px; - line-height: 1.5; - text-decoration: none; - color: #009a61; - background-color: #fff; - border: 1px solid #ddd; - margin-left: -1px; - list-style: none; -} - -.pagination > li > a:hover { - background-color: #eee; -} - -.pagination .active { - color: #fff; - background-color: #009a61; - border-left: none; - border-right: none; -} - -.pagination .active:hover { - background: #009a61; - cursor: default; -} - -.pagination > li:first-child > a .p { - border-bottom-left-radius: 3px; - border-top-left-radius: 3px; -} - -.pagination > li:last-child > a { - border-bottom-right-radius: 3px; - border-top-right-radius: 3px; -} - -.greeting-box { - background-color: firebrick; - max-width: 700px; - padding: 20px; - border-radius: 8px; - margin: 48px auto 20px; -} - -.slide-in-bck-center { - animation: slide-in-bck-center 1.2s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; -} - -@keyframes slide-in-bck-center { - 0% { - transform: translateZ(600px); - opacity: 0; - } - 100% { - transform: translateZ(0); - opacity: 1; - } -} - -.greeting-text { - font-size: xx-large; - text-align: center; - color: ivory; - display: block; -} - -.application-name { - display: inline-block; - font-weight: bold; - width: auto; - font-size: 48px; - color: rgb(7, 156, 58); - position: relative; - left: 60px; - top: 200px; - cursor: default; -} - -.social-image { - width: 600px; - border-radius: 8px; -} - -.greeting-title { - text-align: center; - display: block; - font-size: 48px; - font-weight: bold; - color: ivory; - text-shadow: black 2px 2px 6px; -} - -.server-name { - color: gold; -} - -.go-to { - display: inline-block; - margin-bottom: 6px; -} diff --git a/demo-two/src/main/resources/static/styles/video.css b/demo-two/src/main/resources/static/styles/video.css deleted file mode 100644 index 341a63f5..00000000 --- a/demo-two/src/main/resources/static/styles/video.css +++ /dev/null @@ -1,136 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box -} - -html { - font-size: 12px; - font-family: Ubuntu, simHei, sans-serif; - font-weight: 400 -} - -body { - font-size: 1rem -} - -table, -td, -th { - border-collapse: collapse; - border-spacing: 0 -} - -table { - width: 100% -} - -td, -th { - border: 1px solid #bcbcbc; - padding: 5px 10px -} - -th { - background: #42b983; - font-size: 1.2rem; - font-weight: 400; - color: #fff; - cursor: pointer -} - -tr:nth-of-type(odd) { - background: #fff -} - -tr:nth-of-type(even) { - background: #eee -} - -fieldset { - border: 1px solid #BCBCBC; - padding: 15px; -} - -input { - outline: none -} - -input[type=text] { - border: 1px solid #ccc; - padding: .5rem .3rem; -} - -input[type=text]:focus { - border-color: #42b983; -} - -button { - outline: none; - padding: 5px 8px; - color: #fff; - border: 1px solid #BCBCBC; - border-radius: 3px; - background-color: #009A61; - cursor: pointer; -} - -button:hover { - opacity: 0.8; -} - -#app { - margin: 0 auto; - max-width: 640px; - -webkit-perspective: 500px; -} - -.greeting-box { - background-color: firebrick; - max-width: 700px; - padding: 20px; - border-radius: 8px; - margin: 48px auto 20px; -} - -.slide-in-bck-center { - animation: slide-in-bck-center 1.2s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; -} - -@keyframes slide-in-bck-center { - 0% { - transform: translateZ(600px); - opacity: 0; - } - 100% { - transform: translateZ(0); - opacity: 1; - } -} - -.greeting-text { - font-size: xx-large; - text-align: center; - color: ivory; -} - -.social-image { - width: 600px; - border-radius: 8px; -} - -.greeting-title { - text-align: center; - display: block; - font-size: 48px; - text-shadow: black 2px 2px 6px; -} - -.server-name { - color: gold; -} - -.go-to { - display: inline-block; - margin-bottom: 6px; -} diff --git a/demo-two/src/main/resources/static/video.html b/demo-two/src/main/resources/static/video.html deleted file mode 100644 index 9a186caa..00000000 --- a/demo-two/src/main/resources/static/video.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - ExRx.net Crawler Server - - - - -
-
- - Hello, World! - Welcome to {{ appInfo.projectArtifactId }}@{{ appInfo.version }}! - - -
-
- - - - diff --git a/demo-two/src/test/java/com/jmsoftware/demotwo/DemoTwoApplicationTests.java b/demo-two/src/test/java/com/jmsoftware/demotwo/DemoTwoApplicationTests.java deleted file mode 100644 index fdb2e16d..00000000 --- a/demo-two/src/test/java/com/jmsoftware/demotwo/DemoTwoApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jmsoftware.demotwo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class DemoTwoApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/docker-compose.development-docker.yml b/docker-compose.development-docker.yml index f1292629..e725cdac 100644 --- a/docker-compose.development-docker.yml +++ b/docker-compose.development-docker.yml @@ -77,7 +77,7 @@ services: container_name: exercise-mis-dev_dkr image: "ijohnnymiller/exercise-mis-dev_dkr:${TAG}" ports: - - "8772:8772" + - "8770:8770" volumes: - /Users/johnny/docker-file-mapping/exercise-mis:/log-dev_dkr networks: @@ -88,7 +88,7 @@ services: container_name: muscle-mis-dev_dkr image: "ijohnnymiller/muscle-mis-dev_dkr:${TAG}" ports: - - "8773:8773" + - "8771:8771" volumes: - /Users/johnny/docker-file-mapping/muscle-mis:/log-dev_dkr networks: diff --git a/exercise-mis/pom.xml b/exercise-mis/pom.xml index d71185f6..95b8e3b6 100644 --- a/exercise-mis/pom.xml +++ b/exercise-mis/pom.xml @@ -10,7 +10,7 @@ Exercise Management Information Service. 11 - 8772 + 8770 com.jmsoftware diff --git a/muscle-mis/pom.xml b/muscle-mis/pom.xml index de34ff8c..2b62d277 100644 --- a/muscle-mis/pom.xml +++ b/muscle-mis/pom.xml @@ -9,7 +9,7 @@ Muscle Management Information Service. 11 - 8773 + 8771 com.jmsoftware diff --git a/pom.xml b/pom.xml index c42de2ad..55bf4437 100644 --- a/pom.xml +++ b/pom.xml @@ -32,8 +32,6 @@ service-registry spring-boot-admin gateway - demo-one - demo-two exercise-mis muscle-mis @@ -69,16 +67,6 @@ gateway 0.0.1-SNAPSHOT - - com.jmsoftware - demo-one - 0.0.1-SNAPSHOT - - - com.jmsoftware - demo-two - 0.0.1-SNAPSHOT - com.jmsoftware exercise-mis