Skip to content
Merged

Dev #193

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.39</version>
<version>3.4.41</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
16 changes: 8 additions & 8 deletions example/example-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
server.port=8090

application.version=@project.version@
#spring.datasource.driver-class-name=org.h2.Driver
#spring.datasource.url=jdbc:h2:file:./example.db
#spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:./example.db
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect


spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/flow?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=12345678
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://localhost:3306/flow?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
#spring.datasource.username=root
#spring.datasource.password=12345678
#spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
Expand Down
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.39</version>
<version>3.4.41</version>
</parent>

<name>springboot-starter-data-authorization</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-fast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.39</version>
<version>3.4.41</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private DynamicTableClassLoader() {
*/
public void registerClass(String className, Class<?> clazz) {
dynamicTableClassLoader.registerClass(className, clazz);
Thread.currentThread().setContextClassLoader(dynamicTableClassLoader);
}

/**
Expand All @@ -39,6 +40,7 @@ public void registerClass(String className, Class<?> clazz) {
*/
public void registerClass(Class<?> clazz) {
dynamicTableClassLoader.registerClass(clazz);
Thread.currentThread().setContextClassLoader(dynamicTableClassLoader);
}

/**
Expand Down Expand Up @@ -66,6 +68,7 @@ public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundExce
*/
public void cleanDynamicClass(String name) {
dynamicTableClassLoader.cleanClass(name);
Thread.currentThread().setContextClassLoader(dynamicTableClassLoader);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@AllArgsConstructor
public class JpaQueryContextRegister implements InitializingBean {

private JpaQuery jpaQuery;
private final JpaQuery jpaQuery;

@Override
public void afterPropertiesSet() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -146,6 +147,12 @@ private List<AnnotationDescription> buildFieldAnnotations(
TableEntityMetadata.ColumnMeta columnMeta) {
List<AnnotationDescription> annotations = new ArrayList<>();

if (columnMeta.getAnnotationClasses() != null) {
for(Class<? extends Annotation> annotaionClass: columnMeta.getAnnotationClasses()) {
annotations.add(AnnotationDescription.Builder.ofType(annotaionClass).build());
}
}

// @Id 注解
if (columnMeta.isPrimaryKey()) {
annotations.add(AnnotationDescription.Builder.ofType(Id.class).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import lombok.Getter;
import lombok.Setter;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
* 表实体元数据
Expand Down Expand Up @@ -64,6 +66,10 @@ public static class ColumnMeta {
* 主键自增策略
*/
private GeneratedValueMeta generatedValue;
/**
* 字段注解
*/
private Set<Class<? extends Annotation>> annotationClasses;
/**
* 备注
*/
Expand Down Expand Up @@ -149,8 +155,12 @@ public void setTable(String name) {
this.setTable(name, null, null, null);
}

public void addColumn(ColumnMeta column) {
this.columns.add(column);
}

public void addPrimaryKeyColumn(Class<?> type, String fieldName, String columnName, GenerationType strategy,
String generator, String comment, boolean isLob, boolean unique, boolean nullable,
String generator, Set<Class<? extends Annotation>> annotationClasses, String comment, boolean isLob, boolean unique, boolean nullable,
boolean insertable, boolean updatable, String columnDefinition,
int length, int precision, int scale) {
ColumnMeta column = new ColumnMeta();
Expand All @@ -161,6 +171,7 @@ public void addPrimaryKeyColumn(Class<?> type, String fieldName, String columnNa
GeneratedValueMeta generatedValueMeta = new GeneratedValueMeta();
generatedValueMeta.setGenerator(generator);
generatedValueMeta.setStrategy(strategy);
column.setAnnotationClasses(annotationClasses);
column.setGeneratedValue(generatedValueMeta);
column.setLob(isLob);
column.setComment(comment);
Expand All @@ -172,7 +183,7 @@ public void addPrimaryKeyColumn(Class<?> type, String fieldName, String columnNa
column.setLength(length);
column.setPrecision(precision);
column.setScale(scale);
this.columns.add(column);
this.addColumn(column);
}

public void addColumn(Class<?> type, String fieldName, String columnName, String comment, boolean isLob,
Expand All @@ -194,7 +205,7 @@ public void addColumn(Class<?> type, String fieldName, String columnName, String
column.setLength(length);
column.setPrecision(precision);
column.setScale(scale);
this.columns.add(column);
this.addColumn(column);
}

public void addColumn(Class<?> type, String name, String comment) {
Expand All @@ -214,15 +225,23 @@ public void addColumn(Class<?> type, String name) {
}

public void addPrimaryKeyColumn(Class<?> type, String name) {
this.addPrimaryKeyColumn(type, name, name, null, null, null, false, false, false, false, false, null, 255, 0, 0);
this.addPrimaryKeyColumn(type, name, name, null, null, null, null, false, false, false, false, false, null, 255, 0, 0);
}

public void addPrimaryKeyColumn(Class<?> type, String name, String comment) {
this.addPrimaryKeyColumn(type, name, name, null, null, null, comment, false, false, false, false, false, null, 255, 0, 0);
}

public void addPrimaryKeyColumn(Class<?> type, String name, GenerationType strategy) {
this.addPrimaryKeyColumn(type, name, name, strategy, null, null, false, false, false, false, false, null, 255, 0, 0);
this.addPrimaryKeyColumn(type, name, name, strategy, null, null, null, false, false, false, false, false, null, 255, 0, 0);
}

public void addPrimaryKeyColumn(Class<?> type, String name, GenerationType strategy, String comment) {
this.addPrimaryKeyColumn(type, name, name, strategy, null, comment, false, false, false, false, false, null, 255, 0, 0);
this.addPrimaryKeyColumn(type, name, name, strategy, null, null, comment, false, false, false, false, false, null, 255, 0, 0);
}

public void addPrimaryKeyColumn(Class<?> type, String name, Set<Class<? extends Annotation>> annotationClasses, String comment) {
this.addPrimaryKeyColumn(type, name, name, null, null, annotationClasses, comment, false, false, false, false, false, null, 255, 0, 0);
}

public void verify() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.codingapi.springboot.fast;

import com.codingapi.springboot.fast.entity.MyTest;
import com.codingapi.springboot.fast.repository.MyTestRepository;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@Slf4j
@SpringBootTest
public class MyTestRepositoryTest {

@Autowired
private MyTestRepository myTestRepository;

@Test
void test() {
MyTest demo = new MyTest();
demo.setName("123");
myTestRepository.save(demo);
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.codingapi.springboot.fast.annotation;

import com.codingapi.springboot.fast.strategy.MyIdGenerator;
import org.hibernate.annotations.IdGeneratorType;

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

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@IdGeneratorType(MyIdGenerator.class)
@Retention(RUNTIME)
@Target({METHOD,FIELD})
public @interface MyIdSequence {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.codingapi.springboot.fast.entity;

import com.codingapi.springboot.fast.annotation.MyIdSequence;
import jakarta.persistence.*;
import lombok.Data;


@Data
@Entity
@Table(name = "t_test")
public class MyTest {

@Id
@MyIdSequence
private Integer id;

private String name;
}
Loading