Skip to content

Commit

Permalink
合并拉取请求 #47
Browse files Browse the repository at this point in the history
dev Update documentation
  • Loading branch information
vnobo authored Jan 22, 2025
2 parents 182859a + 3c30f4e commit f67e2b9
Show file tree
Hide file tree
Showing 38 changed files with 1,487 additions and 1,450 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
5 changes: 3 additions & 2 deletions boot/platform/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ plugins {
}

dependencies {
implementation 'org.springframework.modulith:spring-modulith-starter-core'

implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.session:spring-session-data-redis")

implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-data-redis-reactive")

//implementation("org.springframework.boot:spring-boot-starter-jooq")
//implementation("org.jooq:jooq")
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("org.postgresql:r2dbc-postgresql")

Expand All @@ -24,6 +24,7 @@ dependencies {

testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.springframework.modulith:spring-modulith-starter-test'

}

Expand Down
55 changes: 0 additions & 55 deletions boot/platform/src/main/java/com/plate/boot/BootApplication.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.plate.boot;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.r2dbc.core.DatabaseClient;

/**
* @author <a href="https://github.com/vnobo">Alex Bob</a>
Expand All @@ -14,56 +11,4 @@ public class BootApplication {
public static void main(String[] args) {
SpringApplication.run(BootApplication.class, args);
}

//@Component
static class AppRunner implements ApplicationRunner {

private final DatabaseClient databaseClient;

AppRunner(DatabaseClient databaseClient) {
this.databaseClient = databaseClient;
}

@Override
public void run(ApplicationArguments args) {
String sql = """
do $$
declare
v_code text;
v_phone text;
batch_size int := 100; -- 每批提交的记录数
commit_count int := 0; -- 记录已提交的批次数
begin
for i in 1..100
loop
-- 生成用户代码
if i < 1000 then
v_code := 'U' || lpad(i::text, 4, '0');
else
v_code := 'U' || (i + 3)::text;
end if;
-- 生成手机号码
v_phone := '1708911826' || lpad(i::text, 2, '0');
-- 插入用户数据
insert into se_users(code, username, password, name, phone, email, bio, creator, updater)
values (v_code, 'user' || i,
'{pbkdf2}7d8a68bc5d507bd19bc153ff10bcdef66f5a5f3d0c1ab2438630e50b5c65894bccc2c7e4404c5afa',
'普通用户' || i, v_phone, 'user' || i || '@qq.com', null, 'U1000', 'U1000');
-- 每插入 batch_size 条记录后提交事务
commit_count := commit_count + 1;
if commit_count % batch_size = 0 then
commit;
end if;
end loop;
-- 提交剩余的记录
commit;
end $$;
""";
databaseClient.sql(() -> sql).fetch().rowsUpdated().subscribe();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public abstract class AbstractEntity<T> implements BaseEntity<T> {

/**
* Data entity create operator
* use User.class code property
* use User. Class code property
*/
@CreatedBy
@InsertOnlyProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/**
* Represents the base entity contract for entities that require common functionality
* such as having a unique code, being serializable, and persistable with a generic type identifier.
* such as having a unique code, being serializable, and perishable with a generic type identifier.
* Implementing classes should provide concrete behavior for these base operations.
*/
public interface BaseEntity<T> extends Serializable, Persistable<T> {
Expand Down
Loading

0 comments on commit f67e2b9

Please sign in to comment.