Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
javamxd committed May 10, 2023
2 parents 20e31ae + d05b7da commit b316c7f
Show file tree
Hide file tree
Showing 42 changed files with 161 additions and 110 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ magic-api 是一个基于Java的接口快速开发框架,编写接口将通过
<dependency>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-spring-boot-starter</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</dependency>
```
## 修改application.properties
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-cluster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-cluster</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.ssssssss.magicapi.core.config.MagicAPIProperties;
Expand All @@ -19,9 +15,10 @@
import org.ssssssss.magicapi.core.model.Plugin;
import org.ssssssss.magicapi.core.service.MagicAPIService;
import org.ssssssss.magicapi.core.service.MagicNotifyService;
import org.ssssssss.magicapi.redis.RedisModule;
import org.ssssssss.magicapi.utils.JsonUtils;

import java.util.Objects;
import java.util.Arrays;


@EnableConfigurationProperties(ClusterConfig.class)
Expand All @@ -32,14 +29,11 @@ public class MagicClusterConfiguration implements MagicPluginConfiguration {

private final MagicAPIProperties properties;

private final StringRedisTemplate stringRedisTemplate;

private final Logger logger = LoggerFactory.getLogger(MagicClusterConfiguration.class);

public MagicClusterConfiguration(MagicAPIProperties properties, ClusterConfig config, ObjectProvider<StringRedisTemplate> stringRedisTemplateProvider) {
public MagicClusterConfiguration(MagicAPIProperties properties, ClusterConfig config) {
this.properties = properties;
this.config = config;
this.stringRedisTemplate = stringRedisTemplateProvider.getIfAvailable();
}

@Override
Expand All @@ -52,8 +46,8 @@ public Plugin plugin() {
*/
@Bean
@ConditionalOnMissingBean
public MagicNotifyService magicNotifyService() {
return magicNotify -> stringRedisTemplate.convertAndSend(config.getChannel(), Objects.requireNonNull(JsonUtils.toJsonString(magicNotify)));
public MagicNotifyService magicNotifyService(RedisModule redisModule) {
return magicNotify -> redisModule.execute("publish", Arrays.asList(config.getChannel(), JsonUtils.toJsonString(magicNotify)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-component/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-component</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-elasticsearch</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-git/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-git</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-mongo</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-redis</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-springdoc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-springdoc</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-swagger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-swagger</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-plugins/magic-api-plugin-task/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugin-task</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "magic-test",
"name": "magic-task",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down
4 changes: 2 additions & 2 deletions magic-api-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-parent</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-plugins</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<packaging>pom</packaging>
<name>magic-api-plugins</name>
<description>auto generate http api</description>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-servlet/magic-api-servlet-jakarta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-servlet</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-servlet-jakarta</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public String getValue() {
return cookie.getValue();
}

public Cookie getOriginCookie(){
return cookie;
@Override
public <T> T getCookie() {
return (T) cookie;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public Principal getUserPrincipal() {
return request.getUserPrincipal();
}

@Override
public <T> T getRequest() {
return (T) request;
}


public static class ArgumentsResolver implements HandlerMethodArgumentResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@ public void sendRedirect(String location) throws IOException {

@Override
public void addCookie(MagicCookie cookie) {
MagicJakartaCookie javaEECookie = (MagicJakartaCookie) cookie;
response.addCookie(javaEECookie.getOriginCookie());
response.addCookie(cookie.getCookie());
}

@Override
public void setContentType(String contentType) {
response.setContentType(contentType);
}

@Override
public void setCharacterEncoding(String characterEncoding) {
response.setCharacterEncoding(characterEncoding);
}

@Override
Expand All @@ -53,6 +62,11 @@ public Collection<String> getHeaderNames() {
return response.getHeaderNames();
}

@Override
public <T> T getResponse() {
return (T) response;
}

public static class ArgumentsResolver implements HandlerMethodArgumentResolver {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class MagicJakartaHttpSession implements MagicHttpSession {

private HttpSession session;
private final HttpSession session;

public MagicJakartaHttpSession(HttpSession session) {
this.session = session;
Expand All @@ -21,4 +21,9 @@ public Object getAttribute(String key) {
public void setAttribute(String key, Object value) {
session.setAttribute(key, value);
}

@Override
public <T> T getSession() {
return (T) session;
}
}
2 changes: 1 addition & 1 deletion magic-api-servlet/magic-api-servlet-javaee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-servlet</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-servlet-javaee</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public String getValue() {
return cookie.getValue();
}

public Cookie getOriginCookie() {
return cookie;
@Override
public <T> T getCookie() {
return (T) cookie;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public Principal getUserPrincipal() {
return request.getUserPrincipal();
}

@Override
public <T> T getRequest() {
return (T) request;
}

public static class ArgumentsResolver implements HandlerMethodArgumentResolver {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@ public void sendRedirect(String location) throws IOException {

@Override
public void addCookie(MagicCookie cookie) {
MagicJavaEECookie javaEECookie = (MagicJavaEECookie) cookie;
response.addCookie(javaEECookie.getOriginCookie());
response.addCookie(cookie.getCookie());
}

@Override
public void setContentType(String contentType) {
response.setContentType(contentType);
}

@Override
public void setCharacterEncoding(String characterEncoding) {
response.setCharacterEncoding(characterEncoding);
}

@Override
Expand All @@ -53,6 +62,11 @@ public Collection<String> getHeaderNames() {
return response.getHeaderNames();
}

@Override
public <T> T getResponse() {
return (T) response;
}


public static class ArgumentsResolver implements HandlerMethodArgumentResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class MagicJavaEEHttpSession implements MagicHttpSession {

private HttpSession session;
private final HttpSession session;

public MagicJavaEEHttpSession(HttpSession session) {
this.session = session;
Expand All @@ -21,4 +21,9 @@ public Object getAttribute(String key) {
public void setAttribute(String key, Object value) {
session.setAttribute(key, value);
}

@Override
public <T> T getSession() {
return (T) session;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public void addInterceptors(InterceptorRegistry registry) {

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new MagicJavaEEHttpServletRequest.ArgumentsResolver());
resolvers.add(new MagicJavaEEHttpServletResponse.ArgumentsResolver());
resolvers.add(0, new MagicJavaEEHttpServletRequest.ArgumentsResolver());
resolvers.add(0, new MagicJavaEEHttpServletResponse.ArgumentsResolver());
}

@Bean
Expand Down
2 changes: 1 addition & 1 deletion magic-api-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-parent</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-servlet</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-parent</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api-spring-boot-starter</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion magic-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ssssssss</groupId>
<artifactId>magic-api-parent</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>magic-api</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ public interface MagicCookie {
String getName();

String getValue();

<T> T getCookie();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public interface MagicHttpServletRequest {
MultipartRequest resolveMultipart();

Principal getUserPrincipal();

<T> T getRequest();
}


Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ public interface MagicHttpServletResponse {

public void addCookie(MagicCookie cookie);

public void setContentType(String contentType);

public void setCharacterEncoding(String characterEncoding);

public OutputStream getOutputStream() throws IOException;

public Collection<String> getHeaderNames();

public <T> T getResponse();
}
Loading

0 comments on commit b316c7f

Please sign in to comment.