forked from zhou-hao/hsweb4-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
**/pom.xml.versionsBackup | ||
**/target/ | ||
**/out/ | ||
*.class | ||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
.idea/ | ||
/nbproject | ||
*.ipr | ||
*.iws | ||
*.iml | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
*.log | ||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
**/transaction-logs/ | ||
!/.mvn/wrapper/maven-wrapper.jar | ||
/data/ | ||
*.db | ||
/static/ | ||
/upload | ||
/ui/upload/ | ||
docker/data | ||
./dev/** | ||
/dist/data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# hsweb4-examples | ||
hsweb4 响应式后台管理框架用例 | ||
|
||
|
||
* [ ] [增删改查](hsweb4-crud-example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM openjdk:8 as builder | ||
WORKDIR application | ||
ARG JAR_FILE=target/hsweb4-crud-example.jar | ||
COPY ${JAR_FILE} application.jar | ||
RUN java -Djarmode=layertools -jar application.jar extract | ||
|
||
FROM openjdk:8 | ||
WORKDIR application | ||
COPY --from=builder application/dependencies/ ./ | ||
COPY --from=builder application/snapshot-dependencies/ ./ | ||
COPY --from=builder application/spring-boot-loader/ ./ | ||
COPY --from=builder application/application/ ./ | ||
COPY docker-entrypoint.sh ./ | ||
RUN chmod +x docker-entrypoint.sh | ||
ENTRYPOINT ["./docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 增删改查例子 | ||
|
||
1. 启动 | ||
|
||
```bash | ||
$ mvn spring-boot:run | ||
``` | ||
|
||
2. 访问接口文档 http://127.0.0.1:8080/doc.html | ||
|
||
3. 进入对应接口CRUD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
java $JAVA_OPTS -server \ | ||
-XX:+UnlockExperimentalVMOptions \ | ||
-XX:+UseCGroupMemoryLimitForHeap \ | ||
-XX:-OmitStackTraceInFastThrow \ | ||
-Djava.security.egd=file:/dev/./urandom \ | ||
org.springframework.boot.loader.JarLauncher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>hsweb4-crud-example</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.build.locales>zh_CN</project.build.locales> | ||
<java.version>1.8</java.version> | ||
<project.build.jdk>${java.version}</project.build.jdk> | ||
<hsweb.framework.version>4.0.8</hsweb.framework.version> | ||
<spring.boot.version>2.3.7.RELEASE</spring.boot.version> | ||
<r2dbc.version>Arabba-SR7</r2dbc.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>${project.build.jdk}</source> | ||
<target>${project.build.jdk}</target> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.4</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<configuration> | ||
<mainClass>org.hswebframework.example.crud.CrudApplication</mainClass> | ||
<layout>ZIP</layout> | ||
<layers> | ||
<enabled>true</enabled> | ||
</layers> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.12</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-webflux</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hswebframework.web</groupId> | ||
<artifactId>hsweb-commons-crud</artifactId> | ||
<version>${hsweb.framework.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hswebframework.web</groupId> | ||
<artifactId>hsweb-starter</artifactId> | ||
<version>${hsweb.framework.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-r2dbc</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.r2dbc</groupId> | ||
<artifactId>r2dbc-h2</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>dev.miku</groupId> | ||
<artifactId>r2dbc-mysql</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.r2dbc</groupId> | ||
<artifactId>r2dbc-postgresql</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.projectreactor</groupId> | ||
<artifactId>reactor-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-annotations</artifactId> | ||
<version>2.1.4</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-webflux-ui</artifactId> | ||
<version>1.4.5</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.github.xiaoymin</groupId> | ||
<artifactId>knife4j-springdoc-ui</artifactId> | ||
<version>2.0.5</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.r2dbc</groupId> | ||
<artifactId>r2dbc-bom</artifactId> | ||
<version>${r2dbc.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<repositories> | ||
<repository> | ||
<id>aliyun-nexus</id> | ||
<name>aliyun</name> | ||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url> | ||
</repository> | ||
|
||
<repository> | ||
<id>hsweb-nexus</id> | ||
<name>Nexus Release Repository</name> | ||
<url>http://nexus.hsweb.me/content/groups/public/</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
<updatePolicy>always</updatePolicy> | ||
</snapshots> | ||
</repository> | ||
|
||
</repositories> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>aliyun-nexus</id> | ||
<name>aliyun</name> | ||
<url>https://maven.aliyun.com/nexus/content/groups/public/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
</project> |
34 changes: 34 additions & 0 deletions
34
hsweb4-crud-example/src/main/java/org/hswebframework/example/crud/CrudApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.hswebframework.example.crud; | ||
|
||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.info.Contact; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import org.hswebframework.web.crud.annotation.EnableEasyormRepository; | ||
import org.springdoc.webflux.core.SpringDocWebFluxConfiguration; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@SpringBootApplication | ||
@EnableEasyormRepository("org.hswebframework.example.**.entity") | ||
public class CrudApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(CrudApplication.class, args); | ||
} | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@OpenAPIDefinition( | ||
info = @Info( | ||
title = "hsweb4 curd example", | ||
description = "hsweb4 增删改查例子", | ||
contact = @Contact(name = "admin"), | ||
version = "1.0.0-SNAPSHOT" | ||
) | ||
) | ||
@AutoConfigureBefore(SpringDocWebFluxConfiguration.class) | ||
static class SwaggerConfiguration { | ||
|
||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
hsweb4-crud-example/src/main/java/org/hswebframework/example/crud/entity/TestEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.hswebframework.example.crud.entity; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hswebframework.example.crud.enums.TestEnum; | ||
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType; | ||
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue; | ||
import org.hswebframework.ezorm.rdb.mapping.annotation.EnumCodec; | ||
import org.hswebframework.ezorm.rdb.mapping.annotation.JsonCodec; | ||
import org.hswebframework.web.api.crud.entity.GenericEntity; | ||
import org.hswebframework.web.crud.generator.Generators; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Table; | ||
import javax.validation.constraints.NotBlank; | ||
import java.sql.JDBCType; | ||
import java.util.Date; | ||
import java.util.Map; | ||
|
||
@Table(name = "t_test") | ||
@Getter | ||
@Setter | ||
public class TestEntity extends GenericEntity<String> { | ||
|
||
@Column(length = 64, nullable = false) | ||
@NotBlank | ||
@Schema(description = "名称") | ||
private String name; | ||
|
||
//枚举 | ||
@Column(length = 32) | ||
@EnumCodec | ||
@ColumnType(javaType = String.class) | ||
private TestEnum enumTest; | ||
|
||
@Column | ||
@JsonCodec | ||
@ColumnType(javaType = String.class, jdbcType = JDBCType.CLOB) | ||
private Map<String, Object> jsonValue; | ||
|
||
@Column(updatable = false) | ||
@Schema(description = "创建时间", accessMode = Schema.AccessMode.READ_ONLY) | ||
@DefaultValue(generator = Generators.CURRENT_TIME)//逻辑默认值 | ||
private Date createTime; | ||
} |
Oops, something went wrong.