Skip to content

Commit

Permalink
Merge pull request #5 from shenjingwaa/feature/proxy
Browse files Browse the repository at this point in the history
添加代理注解
  • Loading branch information
yan-haifeng authored Jan 16, 2024
2 parents 8cd5694 + e64462e commit 46a2fa2
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 171 deletions.
286 changes: 143 additions & 143 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
<name>relax-spring-boot-starter</name>
<description>
A Rapid Development Tool Based on Springboot.
Single table addition, deletion, modification, and querying can be quickly achieved through annotations, as well as entity reverse parsing into tables.
Single table addition, deletion, modification, and querying can be quickly achieved through annotations, as well
as entity reverse parsing into tables.
</description>
<url>https://github.com/shenjingwaa/relax</url>

<!-- <developers>-->
<!-- <developer>-->
<!-- <name>haifeng-yan</name>-->
<!-- <email>[email protected]</email>-->
<!-- <timezone>+8</timezone>-->
<!-- </developer>-->
<developers>
<developer>
<name>haifeng-yan</name>
<email>[email protected]</email>
<timezone>+8</timezone>
</developer>

<!-- <developer>-->
<!-- <name>shenjingwa</name>-->
<!-- <email>[email protected]</email>-->
<!-- <organization>https://github.com/shenjingwaa/</organization>-->
<!-- <timezone>+8</timezone>-->
<!-- </developer>-->
<!-- </developers>-->
<developer>
<name>shenjingwa</name>
<email>[email protected]</email>
<organization>https://github.com/shenjingwaa/</organization>
<timezone>+8</timezone>
</developer>
</developers>


<properties>
Expand Down Expand Up @@ -104,135 +105,134 @@

</dependencies>

<!-- <build>-->
<!--&lt;!&ndash; <pluginManagement>&ndash;&gt;-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <excludes>-->
<!-- <exclude>-->
<!-- <groupId>org.projectlombok</groupId>-->
<!-- <artifactId>lombok</artifactId>-->
<!-- </exclude>-->
<!-- </excludes>-->
<!-- </configuration>-->
<!-- </plugin>-->


<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>3.8.1</version>-->
<!-- <configuration>-->
<!-- <source>${java.version}</source>-->
<!-- <target>${java.version}</target>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- &lt;!&ndash; sonatype插件,发布使用&ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.sonatype.plugins</groupId>-->
<!-- <artifactId>nexus-staging-maven-plugin</artifactId>-->
<!-- <version>1.6.7</version>-->
<!-- <extensions>true</extensions>-->
<!-- <configuration>-->
<!-- <serverId>ossrh</serverId>-->
<!-- <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>-->
<!-- <autoReleaseAfterClose>true</autoReleaseAfterClose>-->
<!-- </configuration>-->
<!-- </plugin>-->

<!-- &lt;!&ndash; 生成java source.jar &ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-source-plugin</artifactId>-->
<!-- <version>2.2.1</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>attach-sources</id>-->
<!-- <goals>-->
<!-- <goal>jar-no-fork</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->

<!-- &lt;!&ndash; 生成java doc文档 &ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-javadoc-plugin</artifactId>-->
<!-- <version>2.9.1</version>-->
<!-- <configuration>-->
<!-- <show>private</show>-->
<!-- <nohelp>true</nohelp>-->
<!-- <charset>UTF-8</charset>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- <docencoding>UTF-8</docencoding>-->
<!-- <additionalparam>-Xdoclint:none</additionalparam>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>jar</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->

<!-- &lt;!&ndash; 工程文件自动签名&ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
<!-- <version>1.5</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>sign-artifacts</id>-->
<!-- <phase>verify</phase>-->
<!-- <goals>-->
<!-- <goal>sign</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->

<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-deploy-plugin</artifactId>-->
<!-- <version>2.8.2</version>-->
<!-- </plugin>-->
<!-- </plugins>-->

<!--&lt;!&ndash; </pluginManagement>&ndash;&gt;-->
<!-- </build>-->

<!-- <distributionManagement>-->
<!-- <snapshotRepository>-->
<!-- <id>ossrh</id>-->
<!-- <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>-->
<!-- </snapshotRepository>-->
<!-- <repository>-->
<!-- <id>ossrh</id>-->
<!-- <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>-->
<!-- </repository>-->
<!-- </distributionManagement>-->


<!-- <licenses>-->
<!-- <license>-->
<!-- <name>The Apache Software License, Version 2.0</name>-->
<!-- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>-->
<!-- <distribution>repo</distribution>-->
<!-- </license>-->
<!-- </licenses>-->

<!-- <scm>-->
<!-- <url>https://github.com/shenjingwaa/relax</url>-->
<!-- <connection>scm:[email protected]/shenjingwaa/relax.git</connection>-->
<!-- <developerConnection>scm:[email protected]/shenjingwaa/relax.git</developerConnection>-->
<!-- </scm>-->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- sonatype插件,发布使用-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

<!-- 生成java source.jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- 生成java doc文档 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- 工程文件自动签名-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>


<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>https://github.com/shenjingwaa/relax</url>
<connection>scm:[email protected]/shenjingwaa/relax.git</connection>
<developerConnection>scm:[email protected]/shenjingwaa/relax.git</developerConnection>
</scm>


</project>
19 changes: 19 additions & 0 deletions src/main/java/com/relax/relax/common/annotation/RelaxProxy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.relax.relax.common.annotation;

import com.relax.relax.common.enums.ProxyType;
import com.relax.relax.common.proxy.RelaxViewProxy;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface RelaxProxy {
Class<?> relaxClass();

Class<? extends RelaxViewProxy> afterClass() default RelaxViewProxy.class;

ProxyType proxyType();
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
package com.relax.relax.common.controller;

import com.alibaba.fastjson2.JSON;
import com.relax.relax.common.annotation.MappingType;
import com.relax.relax.common.container.EntityHandleContainer;
import com.relax.relax.common.domain.RelaxResult;
import com.relax.relax.common.constants.ValidationGroup;
import com.relax.relax.common.enums.CrudOperationType;
import com.relax.relax.common.enums.ProxyMethodType;
import com.relax.relax.common.enums.SqlType;
import com.relax.relax.common.executor.SqlOperationExecutor;
import com.relax.relax.common.utils.BeanUtil;
import com.relax.relax.common.utils.RelaxProxyUtil;
import com.relax.relax.common.utils.SpringUtil;
import com.relax.relax.common.utils.ValidationUtil;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class BaseController<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public abstract class ProxyExecutor {
List<RelaxViewProxy> proxyContainer = new ArrayList<>();
Expand All @@ -24,7 +23,7 @@ public abstract class ProxyExecutor {

public void addProxyBefore(Class<? extends RelaxViewProxy> clazz, RelaxViewProxy proxy) {
proxy.setExecutor(this);

if (proxyContainer.contains(proxy)) return;
int index = getProxyIndex(clazz);
if (index >= 0) {
proxyContainer.add(index, proxy);
Expand All @@ -35,7 +34,7 @@ public void addProxyBefore(Class<? extends RelaxViewProxy> clazz, RelaxViewProxy

public void addProxyAfter(Class<? extends RelaxViewProxy> clazz, RelaxViewProxy proxy) {
proxy.setExecutor(this);

if (proxyContainer.contains(proxy)) return;
int index = getProxyIndex(clazz);
if (index >= 0) {
proxyContainer.add(index + 1, proxy);
Expand All @@ -46,7 +45,7 @@ public void addProxyAfter(Class<? extends RelaxViewProxy> clazz, RelaxViewProxy

public void addProxy(RelaxViewProxy proxy) {
proxy.setExecutor(this);

if (proxyContainer.contains(proxy)) return;
proxyContainer.add(proxy);
}

Expand Down
Loading

0 comments on commit 46a2fa2

Please sign in to comment.