Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Godfunc committed Aug 10, 2021
1 parent f42b4f7 commit fd60534
Show file tree
Hide file tree
Showing 279 changed files with 3,151 additions and 2,140 deletions.
201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

8 changes: 0 additions & 8 deletions api/Dockerfile

This file was deleted.

54 changes: 54 additions & 0 deletions api/notify/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api</artifactId>
<groupId>com.godfunc</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>notify</artifactId>

<dependencies>
<dependency>
<groupId>com.godfunc</groupId>
<artifactId>common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- spring cloud alibaba -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- 支持返回xml -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
19 changes: 19 additions & 0 deletions api/notify/src/main/java/com/godfunc/NotifyApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.godfunc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author Godfunc
* @email [email protected]
*/
@SpringBootApplication
@EnableTransactionManagement
@EnableDiscoveryClient
public class NotifyApplication {

public static void main(String[] args) {
SpringApplication.run(NotifyApplication.class, args);
}
}
48 changes: 48 additions & 0 deletions api/notify/src/main/java/com/godfunc/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.godfunc.config;

import io.swagger.annotations.ApiOperation;
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.oas.annotations.EnableOpenApi;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;



/**
* Swagger配置
*
* @author godfunc
* @email [email protected]
*/
@Configuration
@EnableOpenApi
public class SwaggerConfig {

@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo())
.select()
//加了ApiOperation注解的类,生成接口文档
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//包下的类,生成接口文档
//.apis(RequestHandlerSelectors.basePackage("com.godfunc.controller"))
.paths(PathSelectors.any())
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Godfunc-Notify")
.description("Godfunc-Notify文档")
.termsOfServiceUrl("https://godfunc.fun")
.version("1.0.0")
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import com.godfunc.constant.CommonConstant;
import com.godfunc.interceptor.AuthorizationInterceptor;
import com.godfunc.resolver.LoginUserHandlerMethodArgumentResolver;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
* @author godfunc
Expand All @@ -32,26 +27,10 @@
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

private final AuthorizationInterceptor authorizationInterceptor;
private final LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;

public WebMvcConfig(AuthorizationInterceptor authorizationInterceptor, LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver) {
this.authorizationInterceptor = authorizationInterceptor;
this.loginUserHandlerMethodArgumentResolver = loginUserHandlerMethodArgumentResolver;
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**");
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
// .allowedOriginPatterns("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
Expand Down
10 changes: 10 additions & 0 deletions api/notify/src/main/java/com/godfunc/constant/ApiConstant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.godfunc.constant;

/**
* @author godfunc
* @email [email protected]
*/
public interface ApiConstant {

String NOTIFY_SERVICE_PREFIX = "notify_service_";
}
Loading

0 comments on commit fd60534

Please sign in to comment.