优化
This commit is contained in:
@@ -31,8 +31,9 @@ INSERT INTO iam_tenant (
|
||||
'91310000ITTEST0001', 'IT 测试客户管理员', '13800000000', 'it-test@example.com',
|
||||
NOW(3), 1000001, 1000001, 0, 0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
tenant_name = VALUES(tenant_name), tenant_type = VALUES(tenant_type),
|
||||
tenant_code = VALUES(tenant_code), tenant_name = VALUES(tenant_name), tenant_type = VALUES(tenant_type),
|
||||
status = 'ACTIVE', legal_name = VALUES(legal_name),
|
||||
unified_social_credit_code = VALUES(unified_social_credit_code),
|
||||
contact_name = VALUES(contact_name), contact_phone = VALUES(contact_phone),
|
||||
contact_email = VALUES(contact_email), approved_at = COALESCE(approved_at, NOW(3)),
|
||||
approved_by = VALUES(approved_by), deleted = 0;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.baiyue.iam.repository;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class InitialIdentitySeedSqlContractTest {
|
||||
@Test
|
||||
void initializesPlatformAndItTestCustomerIdentitiesWithStableIds() throws Exception {
|
||||
assertIdentitySeed(new ClassPathResource("db/phase1-admin-rbac.sql")
|
||||
.getContentAsString(StandardCharsets.UTF_8));
|
||||
assertIdentitySeed(Files.readString(unifiedSql(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private static void assertIdentitySeed(String sql) {
|
||||
assertThat(sql)
|
||||
.contains("(0, 'PLATFORM', '虫虫出海平台'")
|
||||
.contains("(10001, 'IT_TEST', 'IT 测试客户'")
|
||||
.contains("(2000001, 1000001, 'INTERNAL', '平台系统管理员'")
|
||||
.contains("(2000002, 1000002, 'ENTERPRISE', 'IT 测试客户管理员'")
|
||||
.contains("(3000001, 0, 2000001, 'EMPLOYEE'")
|
||||
.contains("(3000002, 10001, 2000002, 'OWNER'")
|
||||
.contains("tenant_code = VALUES(tenant_code)")
|
||||
.doesNotContain("PHASE1_DEMO")
|
||||
.doesNotContain("一期演示企业");
|
||||
}
|
||||
|
||||
private static Path unifiedSql() {
|
||||
Path path = Path.of("deploy", "sql", "头程数据库统一增量-MySQL8.sql");
|
||||
return Files.exists(path) ? path : Path.of("..", "deploy", "sql", "头程数据库统一增量-MySQL8.sql");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user