Commit 1c266988c5f925472396c2f57f8fb341ed407f50

Authored by jason
1 parent 4ba064d8

遗漏了测试类

yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java 0 → 100644
  1 +package cn.iocoder.yudao.adminserver;
  2 +
  3 +import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
  4 +import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;
  5 +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
  6 +import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
  7 +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  8 +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
  9 +import org.springframework.boot.test.context.SpringBootTest;
  10 +import org.springframework.context.annotation.Import;
  11 +import org.springframework.test.context.ActiveProfiles;
  12 +import org.springframework.test.context.jdbc.Sql;
  13 +
  14 +/**
  15 + * 依赖内存 DB 的单元测试
  16 + *
  17 + * 注意,Service 层同样适用。对于 Service 层的单元测试,我们针对自己模块的 Mapper 走的是 H2 内存数据库,针对别的模块的 Service 走的是 Mock 方法
  18 + *
  19 + * @author 芋道源码
  20 + */
  21 +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbUnitTest.Application.class)
  22 +@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件
  23 +@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB
  24 +public class BaseDbUnitTest {
  25 +
  26 + @Import({
  27 + // DB 配置类
  28 + YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类
  29 + DataSourceAutoConfiguration.class, // Spring DB 自动配置类
  30 + DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类
  31 + DruidDataSourceAutoConfigure.class, // Druid 自动配置类
  32 + // MyBatis 配置类
  33 + YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类
  34 + MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类
  35 + })
  36 + public static class Application {
  37 + }
  38 +
  39 +}
... ...
yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmFormServiceTest.java 0 → 100644
  1 +package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
  2 +
  3 +import cn.hutool.core.util.RandomUtil;
  4 +import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
  5 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.form.BpmFormCreateReqVO;
  6 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.form.BpmFormPageReqVO;
  7 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.form.BpmFormUpdateReqVO;
  8 +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmFormDO;
  9 +import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmFormMapper;
  10 +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmFormFieldRespDTO;
  11 +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl.BpmFormServiceImpl;
  12 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  13 +import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
  14 +import org.junit.jupiter.api.Test;
  15 +import org.springframework.context.annotation.Import;
  16 +
  17 +import javax.annotation.Resource;
  18 +import java.util.List;
  19 +import java.util.stream.Collectors;
  20 +import java.util.stream.Stream;
  21 +
  22 +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.FORM_NOT_EXISTS;
  23 +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
  24 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
  25 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
  26 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
  27 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
  28 +import static org.junit.jupiter.api.Assertions.*;
  29 +
  30 +/**
  31 + * {@link BpmFormServiceImpl} 的单元测试类
  32 + *
  33 + * @author 芋道源码
  34 + */
  35 +@Import(BpmFormServiceImpl.class)
  36 +public class BpmFormServiceTest extends BaseDbUnitTest {
  37 +
  38 + @Resource
  39 + private BpmFormServiceImpl formService;
  40 +
  41 + @Resource
  42 + private BpmFormMapper formMapper;
  43 +
  44 + @Test
  45 + public void testCreateForm_success() {
  46 + // 准备参数
  47 + BpmFormCreateReqVO reqVO = randomPojo(BpmFormCreateReqVO.class, o -> {
  48 + o.setConf("{}");
  49 + o.setFields(randomFields());
  50 + });
  51 +
  52 + // 调用
  53 + Long formId = formService.createForm(reqVO);
  54 + // 断言
  55 + assertNotNull(formId);
  56 + // 校验记录的属性是否正确
  57 + BpmFormDO form = formMapper.selectById(formId);
  58 + assertPojoEquals(reqVO, form);
  59 + }
  60 +
  61 + @Test
  62 + public void testUpdateForm_success() {
  63 + // mock 数据
  64 + BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> {
  65 + o.setConf("{}");
  66 + o.setFields(randomFields());
  67 + });
  68 + formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据
  69 + // 准备参数
  70 + BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class, o -> {
  71 + o.setId(dbForm.getId()); // 设置更新的 ID
  72 + o.setConf("{'yudao': 'yuanma'}");
  73 + o.setFields(randomFields());
  74 + });
  75 +
  76 + // 调用
  77 + formService.updateForm(reqVO);
  78 + // 校验是否更新正确
  79 + BpmFormDO form = formMapper.selectById(reqVO.getId()); // 获取最新的
  80 + assertPojoEquals(reqVO, form);
  81 + }
  82 +
  83 + @Test
  84 + public void testUpdateForm_notExists() {
  85 + // 准备参数
  86 + BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class, o -> {
  87 + o.setConf("{'yudao': 'yuanma'}");
  88 + o.setFields(randomFields());
  89 + });
  90 +
  91 + // 调用, 并断言异常
  92 + assertServiceException(() -> formService.updateForm(reqVO), FORM_NOT_EXISTS);
  93 + }
  94 +
  95 + @Test
  96 + public void testDeleteForm_success() {
  97 + // mock 数据
  98 + BpmFormDO dbForm = randomPojo(BpmFormDO.class);
  99 + formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据
  100 + // 准备参数
  101 + Long id = dbForm.getId();
  102 +
  103 + // 调用
  104 + formService.deleteForm(id);
  105 + // 校验数据不存在了
  106 + assertNull(formMapper.selectById(id));
  107 + }
  108 +
  109 + @Test
  110 + public void testDeleteForm_notExists() {
  111 + // 准备参数
  112 + Long id = randomLongId();
  113 +
  114 + // 调用, 并断言异常
  115 + assertServiceException(() -> formService.deleteForm(id), FORM_NOT_EXISTS);
  116 + }
  117 +
  118 + @Test
  119 + public void testGetFormPage() {
  120 + // mock 数据
  121 + BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { // 等会查询到
  122 + o.setName("芋道源码");
  123 + });
  124 + formMapper.insert(dbForm);
  125 + // 测试 name 不匹配
  126 + formMapper.insert(cloneIgnoreId(dbForm, o -> o.setName("源码")));
  127 + // 准备参数
  128 + BpmFormPageReqVO reqVO = new BpmFormPageReqVO();
  129 + reqVO.setName("芋道");
  130 +
  131 + // 调用
  132 + PageResult<BpmFormDO> pageResult = formService.getFormPage(reqVO);
  133 + // 断言
  134 + assertEquals(1, pageResult.getTotal());
  135 + assertEquals(1, pageResult.getList().size());
  136 + assertPojoEquals(dbForm, pageResult.getList().get(0));
  137 + }
  138 +
  139 + private List<String> randomFields() {
  140 + int size = RandomUtil.randomInt(1, 3);
  141 + return Stream.iterate(0, i -> i).limit(size)
  142 + .map(i -> JsonUtils.toJsonString(randomPojo(BpmFormFieldRespDTO.class)))
  143 + .collect(Collectors.toList());
  144 + }
  145 +
  146 +}
... ...
yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java 0 → 100644
  1 +package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
  2 +
  3 +import cn.hutool.core.date.DateUtil;
  4 +import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
  5 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupCreateReqVO;
  6 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupPageReqVO;
  7 +import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupUpdateReqVO;
  8 +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO;
  9 +import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmUserGroupMapper;
  10 +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl.BpmUserGroupServiceImpl;
  11 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  12 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  13 +import cn.iocoder.yudao.framework.common.util.date.DateUtils;
  14 +import org.junit.jupiter.api.Test;
  15 +import org.springframework.context.annotation.Import;
  16 +
  17 +import javax.annotation.Resource;
  18 +
  19 +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.USER_GROUP_NOT_EXISTS;
  20 +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
  21 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
  22 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
  23 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
  24 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
  25 +import static org.junit.jupiter.api.Assertions.*;
  26 +
  27 +/**
  28 +* {@link BpmUserGroupServiceImpl} 的单元测试类
  29 +*
  30 +* @author 芋道源码
  31 +*/
  32 +@Import(BpmUserGroupServiceImpl.class)
  33 +public class BpmUserGroupServiceTest extends BaseDbUnitTest {
  34 +
  35 + @Resource
  36 + private BpmUserGroupServiceImpl userGroupService;
  37 +
  38 + @Resource
  39 + private BpmUserGroupMapper userGroupMapper;
  40 +
  41 + @Test
  42 + public void testCreateUserGroup_success() {
  43 + // 准备参数
  44 + BpmUserGroupCreateReqVO reqVO = randomPojo(BpmUserGroupCreateReqVO.class);
  45 +
  46 + // 调用
  47 + Long userGroupId = userGroupService.createUserGroup(reqVO);
  48 + // 断言
  49 + assertNotNull(userGroupId);
  50 + // 校验记录的属性是否正确
  51 + BpmUserGroupDO userGroup = userGroupMapper.selectById(userGroupId);
  52 + assertPojoEquals(reqVO, userGroup);
  53 + }
  54 +
  55 + @Test
  56 + public void testUpdateUserGroup_success() {
  57 + // mock 数据
  58 + BpmUserGroupDO dbUserGroup = randomPojo(BpmUserGroupDO.class);
  59 + userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据
  60 + // 准备参数
  61 + BpmUserGroupUpdateReqVO reqVO = randomPojo(BpmUserGroupUpdateReqVO.class, o -> {
  62 + o.setId(dbUserGroup.getId()); // 设置更新的 ID
  63 + });
  64 +
  65 + // 调用
  66 + userGroupService.updateUserGroup(reqVO);
  67 + // 校验是否更新正确
  68 + BpmUserGroupDO userGroup = userGroupMapper.selectById(reqVO.getId()); // 获取最新的
  69 + assertPojoEquals(reqVO, userGroup);
  70 + }
  71 +
  72 + @Test
  73 + public void testUpdateUserGroup_notExists() {
  74 + // 准备参数
  75 + BpmUserGroupUpdateReqVO reqVO = randomPojo(BpmUserGroupUpdateReqVO.class);
  76 +
  77 + // 调用, 并断言异常
  78 + assertServiceException(() -> userGroupService.updateUserGroup(reqVO), USER_GROUP_NOT_EXISTS);
  79 + }
  80 +
  81 + @Test
  82 + public void testDeleteUserGroup_success() {
  83 + // mock 数据
  84 + BpmUserGroupDO dbUserGroup = randomPojo(BpmUserGroupDO.class);
  85 + userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据
  86 + // 准备参数
  87 + Long id = dbUserGroup.getId();
  88 +
  89 + // 调用
  90 + userGroupService.deleteUserGroup(id);
  91 + // 校验数据不存在了
  92 + assertNull(userGroupMapper.selectById(id));
  93 + }
  94 +
  95 + @Test
  96 + public void testDeleteUserGroup_notExists() {
  97 + // 准备参数
  98 + Long id = randomLongId();
  99 +
  100 + // 调用, 并断言异常
  101 + assertServiceException(() -> userGroupService.deleteUserGroup(id), USER_GROUP_NOT_EXISTS);
  102 + }
  103 +
  104 + @Test
  105 + public void testGetUserGroupPage() {
  106 + // mock 数据
  107 + BpmUserGroupDO dbUserGroup = randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到
  108 + o.setName("芋道源码");
  109 + o.setStatus(CommonStatusEnum.ENABLE.getStatus());
  110 + o.setCreateTime(DateUtils.buildTime(2021, 11, 11));
  111 + });
  112 + userGroupMapper.insert(dbUserGroup);
  113 + // 测试 name 不匹配
  114 + userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setName("芋道")));
  115 + // 测试 status 不匹配
  116 + userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
  117 + // 测试 createTime 不匹配
  118 + userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setCreateTime(DateUtils.buildTime(2021, 12, 12))));
  119 + // 准备参数
  120 + BpmUserGroupPageReqVO reqVO = new BpmUserGroupPageReqVO();
  121 + reqVO.setName("源码");
  122 + reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
  123 + reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 11, 10));
  124 + reqVO.setEndCreateTime(DateUtils.buildTime(2021, 11, 12));
  125 +
  126 + // 调用
  127 + PageResult<BpmUserGroupDO> pageResult = userGroupService.getUserGroupPage(reqVO);
  128 + // 断言
  129 + assertEquals(1, pageResult.getTotal());
  130 + assertEquals(1, pageResult.getList().size());
  131 + assertPojoEquals(dbUserGroup, pageResult.getList().get(0));
  132 + }
  133 +
  134 +}
... ...
yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/application-unit-test.yaml 0 → 100644
  1 +spring:
  2 + main:
  3 + lazy-initialization: true # 开启懒加载,加快速度
  4 + banner-mode: off # 单元测试,禁用 Banner
  5 +
  6 +--- #################### 数据库相关配置 ####################
  7 +
  8 +spring:
  9 + # 数据源配置项
  10 + datasource:
  11 + name: ruoyi-vue-pro
  12 + url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写
  13 + driver-class-name: org.h2.Driver
  14 + username: sa
  15 + password:
  16 + schema: classpath:sql/create_tables.sql # MySQL 转 H2 的语句,使用 https://www.jooq.org/translate/ 工具
  17 + druid:
  18 + async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度
  19 + initial-size: 1 # 单元测试,配置为 1,提升启动速度
  20 +
  21 +mybatis:
  22 + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试
  23 +
  24 +--- #################### 定时任务相关配置 ####################
  25 +
  26 +--- #################### 配置中心相关配置 ####################
  27 +
  28 +--- #################### 服务保障相关配置 ####################
  29 +
  30 +# Lock4j 配置项(单元测试,禁用 Lock4j)
  31 +
  32 +# Resilience4j 配置项
  33 +
  34 +--- #################### 监控相关配置 ####################
  35 +
  36 +--- #################### 芋道相关配置 ####################
  37 +
  38 +# 芋道配置项,设置当前项目所有自定义的配置
... ...
yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/application.yaml 0 → 100644
  1 +spring:
  2 + application:
  3 + name: yudao-module-bpm-service
  4 +
  5 + # Jackson 配置项
  6 + jackson:
  7 + serialization:
  8 + write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳
  9 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
  10 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
  11 + fail-on-empty-beans: false # 允许序列化无属性的 Bean
  12 +
  13 +# MyBatis Plus 的配置项
  14 +mybatis-plus:
  15 + configuration:
  16 + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
  17 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志
  18 + global-config:
  19 + db-config:
  20 + id-type: AUTO # 自增 ID
  21 + logic-delete-value: 1 # 逻辑已删除值(默认为 1)
  22 + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
  23 + mapper-locations: classpath*:mapper/*.xml
  24 + type-aliases-package: ${yudao.core-service.base-package}.modules.*.dal.dataobject
  25 +
  26 +--- #################### 芋道相关配置 ####################
  27 +
  28 +yudao:
  29 + info:
  30 + version: 1.0.0
  31 + base-package: cn.iocoder.yudao.adminserver
  32 + core-service:
  33 + base-package: cn.iocoder.yudao.coreservice
  34 +
  35 +debug: false
... ...
yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/logback-spring.xml 0 → 100644
  1 +<configuration>
  2 + <!-- 引用 Spring Boot 的 logback 基础配置 -->
  3 + <include resource="org/springframework/boot/logging/logback/defaults.xml" />
  4 +</configuration>
... ...
yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/clean.sql 0 → 100644
  1 +-- inf 开头的 DB
  2 +DELETE FROM "inf_config";
  3 +DELETE FROM "inf_file";
  4 +DELETE FROM "inf_job";
  5 +DELETE FROM "inf_job_log";
  6 +DELETE FROM "inf_api_access_log";
  7 +DELETE FROM "inf_api_error_log";
  8 +
  9 +-- sys 开头的 DB
  10 +DELETE FROM "sys_dept";
  11 +DELETE FROM "sys_dict_data";
  12 +DELETE FROM "sys_role";
  13 +DELETE FROM "sys_role_menu";
  14 +DELETE FROM "sys_menu";
  15 +DELETE FROM "sys_user_role";
  16 +DELETE FROM "sys_dict_type";
  17 +DELETE FROM "sys_user_session";
  18 +DELETE FROM "sys_post";
  19 +DELETE FROM "sys_login_log";
  20 +DELETE FROM "sys_operate_log";
  21 +DELETE FROM "sys_user";
  22 +DELETE FROM "sys_sms_channel";
  23 +DELETE FROM "sys_sms_template";
  24 +DELETE FROM "sys_sms_log";
  25 +DELETE FROM "sys_error_code";
  26 +DELETE FROM "sys_social_user";
  27 +DELETE FROM "sys_tenant";
  28 +
  29 +-- pay 开头的 DB
  30 +DELETE FROM pay_merchant;
  31 +DELETE FROM pay_app;
  32 +DELETE FROM pay_channel;
  33 +DELETE FROM pay_order;
  34 +DELETE FROM pay_refund;
  35 +
  36 +-- bpm 开头的 DB
  37 +DELETE FROM "bpm_form";
  38 +DELETE FROM "bpm_user_group";
... ...
yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql 0 → 100644
  1 +-- inf 开头的 DB
  2 +
  3 +CREATE TABLE IF NOT EXISTS "inf_config" (
  4 + "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  5 + "group" varchar(50) NOT NULL,
  6 + "type" tinyint NOT NULL,
  7 + "name" varchar(100) NOT NULL DEFAULT '',
  8 + "key" varchar(100) NOT NULL DEFAULT '',
  9 + "value" varchar(500) NOT NULL DEFAULT '',
  10 + "sensitive" bit NOT NULL,
  11 + "remark" varchar(500) DEFAULT NULL,
  12 + "creator" varchar(64) DEFAULT '',
  13 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  14 + "updater" varchar(64) DEFAULT '',
  15 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  16 + "deleted" bit NOT NULL DEFAULT FALSE,
  17 + PRIMARY KEY ("id")
  18 +) COMMENT '参数配置表';
  19 +
  20 +CREATE TABLE IF NOT EXISTS "inf_file" (
  21 + "id" varchar(188) NOT NULL,
  22 + "type" varchar(63) DEFAULT NULL,
  23 + "content" blob NOT NULL,
  24 + "creator" varchar(64) DEFAULT '',
  25 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  26 + "updater" varchar(64) DEFAULT '',
  27 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  28 + "deleted" bit NOT NULL DEFAULT FALSE,
  29 + "tenant_id" bigint not null default '0',
  30 + PRIMARY KEY ("id")
  31 +) COMMENT '文件表';
  32 +
  33 +CREATE TABLE IF NOT EXISTS "inf_job" (
  34 + "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '任务编号',
  35 + "name" varchar(32) NOT NULL COMMENT '任务名称',
  36 + "status" tinyint(4) NOT NULL COMMENT '任务状态',
  37 + "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字',
  38 + "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数',
  39 + "cron_expression" varchar(32) NOT NULL COMMENT 'CRON 表达式',
  40 + "retry_count" int(11) NOT NULL DEFAULT '0' COMMENT '重试次数',
  41 + "retry_interval" int(11) NOT NULL DEFAULT '0' COMMENT '重试间隔',
  42 + "monitor_timeout" int(11) NOT NULL DEFAULT '0' COMMENT '监控超时时间',
  43 + "creator" varchar(64) DEFAULT '' COMMENT '创建者',
  44 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  45 + "updater" varchar(64) DEFAULT '' COMMENT '更新者',
  46 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  47 + "deleted" bit NOT NULL DEFAULT FALSE COMMENT '是否删除',
  48 + PRIMARY KEY ("id")
  49 +) COMMENT='定时任务表';
  50 +
  51 +CREATE TABLE IF NOT EXISTS "inf_job_log" (
  52 + "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '日志编号',
  53 + "job_id" bigint(20) NOT NULL COMMENT '任务编号',
  54 + "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字',
  55 + "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数',
  56 + "execute_index" tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几次执行',
  57 + "begin_time" datetime NOT NULL COMMENT '开始执行时间',
  58 + "end_time" datetime DEFAULT NULL COMMENT '结束执行时间',
  59 + "duration" int(11) DEFAULT NULL COMMENT '执行时长',
  60 + "status" tinyint(4) NOT NULL COMMENT '任务状态',
  61 + "result" varchar(4000) DEFAULT '' COMMENT '结果数据',
  62 + "creator" varchar(64) DEFAULT '' COMMENT '创建者',
  63 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  64 + "updater" varchar(64) DEFAULT '' COMMENT '更新者',
  65 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  66 + "deleted" bit(1) NOT NULL DEFAULT FALSE COMMENT '是否删除',
  67 + PRIMARY KEY ("id")
  68 +)COMMENT='定时任务日志表';
  69 +
  70 +-- sys 开头的 DB
  71 +
  72 +CREATE TABLE IF NOT EXISTS "sys_dept" (
  73 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  74 + "name" varchar(30) NOT NULL DEFAULT '',
  75 + "parent_id" bigint NOT NULL DEFAULT '0',
  76 + "sort" int NOT NULL DEFAULT '0',
  77 + "leader_user_id" bigint DEFAULT NULL,
  78 + "phone" varchar(11) DEFAULT NULL,
  79 + "email" varchar(50) DEFAULT NULL,
  80 + "status" tinyint NOT NULL,
  81 + "creator" varchar(64) DEFAULT '',
  82 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  83 + "updater" varchar(64) DEFAULT '',
  84 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  85 + "deleted" bit NOT NULL DEFAULT FALSE,
  86 + "tenant_id" bigint not null default '0',
  87 + PRIMARY KEY ("id")
  88 +) COMMENT '部门表';
  89 +
  90 +CREATE TABLE IF NOT EXISTS "sys_dict_data" (
  91 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  92 + "sort" int NOT NULL DEFAULT '0',
  93 + "label" varchar(100) NOT NULL DEFAULT '',
  94 + "value" varchar(100) NOT NULL DEFAULT '',
  95 + "dict_type" varchar(100) NOT NULL DEFAULT '',
  96 + "status" tinyint NOT NULL DEFAULT '0',
  97 + "remark" varchar(500) DEFAULT NULL,
  98 + "creator" varchar(64) DEFAULT '',
  99 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  100 + "updater" varchar(64) DEFAULT '',
  101 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  102 + "deleted" bit NOT NULL DEFAULT FALSE,
  103 + PRIMARY KEY ("id")
  104 +) COMMENT '字典数据表';
  105 +
  106 +CREATE TABLE IF NOT EXISTS "sys_role" (
  107 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  108 + "name" varchar(30) NOT NULL,
  109 + "code" varchar(100) NOT NULL,
  110 + "sort" int NOT NULL,
  111 + "data_scope" tinyint NOT NULL DEFAULT '1',
  112 + "data_scope_dept_ids" varchar(500) NOT NULL DEFAULT '',
  113 + "status" tinyint NOT NULL,
  114 + "type" tinyint NOT NULL,
  115 + "remark" varchar(500) DEFAULT NULL,
  116 + "creator" varchar(64) DEFAULT '',
  117 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  118 + "updater" varchar(64) DEFAULT '',
  119 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  120 + "deleted" bit NOT NULL DEFAULT FALSE,
  121 + PRIMARY KEY ("id")
  122 +) COMMENT '角色信息表';
  123 +
  124 +CREATE TABLE IF NOT EXISTS "sys_role_menu" (
  125 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  126 + "role_id" bigint NOT NULL,
  127 + "menu_id" bigint NOT NULL,
  128 + "creator" varchar(64) DEFAULT '',
  129 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  130 + "updater" varchar(64) DEFAULT '',
  131 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  132 + "deleted" bit NOT NULL DEFAULT FALSE,
  133 + PRIMARY KEY ("id")
  134 +) COMMENT '角色和菜单关联表';
  135 +
  136 +CREATE TABLE IF NOT EXISTS "sys_menu" (
  137 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  138 + "name" varchar(50) NOT NULL,
  139 + "permission" varchar(100) NOT NULL DEFAULT '',
  140 + "menu_type" tinyint NOT NULL,
  141 + "sort" int NOT NULL DEFAULT '0',
  142 + "parent_id" bigint NOT NULL DEFAULT '0',
  143 + "path" varchar(200) DEFAULT '',
  144 + "icon" varchar(100) DEFAULT '#',
  145 + "component" varchar(255) DEFAULT NULL,
  146 + "status" tinyint NOT NULL DEFAULT '0',
  147 + "creator" varchar(64) DEFAULT '',
  148 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  149 + "updater" varchar(64) DEFAULT '',
  150 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  151 + "deleted" bit NOT NULL DEFAULT FALSE,
  152 + PRIMARY KEY ("id")
  153 +) COMMENT '菜单权限表';
  154 +
  155 +CREATE TABLE IF NOT EXISTS "sys_user_role" (
  156 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  157 + "user_id" bigint NOT NULL,
  158 + "role_id" bigint NOT NULL,
  159 + "creator" varchar(64) DEFAULT '',
  160 + "create_time" timestamp DEFAULT NULL,
  161 + "updater" varchar(64) DEFAULT '',
  162 + "update_time" timestamp DEFAULT NULL,
  163 + "deleted" bit DEFAULT FALSE,
  164 + PRIMARY KEY ("id")
  165 +) COMMENT '用户和角色关联表';
  166 +
  167 +CREATE TABLE IF NOT EXISTS "sys_dict_type" (
  168 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  169 + "name" varchar(100) NOT NULL DEFAULT '',
  170 + "type" varchar(100) NOT NULL DEFAULT '',
  171 + "status" tinyint NOT NULL DEFAULT '0',
  172 + "remark" varchar(500) DEFAULT NULL,
  173 + "creator" varchar(64) DEFAULT '',
  174 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  175 + "updater" varchar(64) DEFAULT '',
  176 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  177 + "deleted" bit NOT NULL DEFAULT FALSE,
  178 + PRIMARY KEY ("id")
  179 +) COMMENT '字典类型表';
  180 +
  181 +CREATE TABLE IF NOT EXISTS `sys_user_session` (
  182 + `id` varchar(32) NOT NULL,
  183 + `user_id` bigint DEFAULT NULL,
  184 + "user_type" tinyint NOT NULL,
  185 + `username` varchar(50) NOT NULL DEFAULT '',
  186 + `user_ip` varchar(50) DEFAULT NULL,
  187 + `user_agent` varchar(512) DEFAULT NULL,
  188 + `session_timeout` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  189 + "creator" varchar(64) DEFAULT '',
  190 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  191 + `updater` varchar(64) DEFAULT '' ,
  192 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  193 + "deleted" bit NOT NULL DEFAULT FALSE,
  194 + "tenant_id" bigint not null default '0',
  195 + PRIMARY KEY (`id`)
  196 +) COMMENT '用户在线 Session';
  197 +
  198 +CREATE TABLE IF NOT EXISTS "sys_post" (
  199 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  200 + "code" varchar(64) NOT NULL,
  201 + "name" varchar(50) NOT NULL,
  202 + "sort" integer NOT NULL,
  203 + "status" tinyint NOT NULL,
  204 + "remark" varchar(500) DEFAULT NULL,
  205 + "creator" varchar(64) DEFAULT '',
  206 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  207 + "updater" varchar(64) DEFAULT '',
  208 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  209 + "deleted" bit NOT NULL DEFAULT FALSE,
  210 + "tenant_id" bigint not null default '0',
  211 + PRIMARY KEY ("id")
  212 +) COMMENT '岗位信息表';
  213 +
  214 +CREATE TABLE IF NOT EXISTS "sys_notice" (
  215 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  216 + "title" varchar(50) NOT NULL COMMENT '公告标题',
  217 + "content" text NOT NULL COMMENT '公告内容',
  218 + "notice_type" tinyint NOT NULL COMMENT '公告类型(1通知 2公告)',
  219 + "status" tinyint NOT NULL DEFAULT '0' COMMENT '公告状态(0正常 1关闭)',
  220 + "creator" varchar(64) DEFAULT '' COMMENT '创建者',
  221 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  222 + "updater" varchar(64) DEFAULT '' COMMENT '更新者',
  223 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  224 + "deleted" bit NOT NULL DEFAULT 0 COMMENT '是否删除',
  225 + "tenant_id" bigint not null default '0',
  226 + PRIMARY KEY("id")
  227 +) COMMENT '通知公告表';
  228 +
  229 +CREATE TABLE IF NOT EXISTS `sys_login_log` (
  230 + `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  231 + `log_type` bigint(4) NOT NULL,
  232 + "user_id" bigint not null default '0',
  233 + "user_type" tinyint NOT NULL,
  234 + `trace_id` varchar(64) NOT NULL DEFAULT '',
  235 + `username` varchar(50) NOT NULL DEFAULT '',
  236 + `result` tinyint(4) NOT NULL,
  237 + `user_ip` varchar(50) NOT NULL,
  238 + `user_agent` varchar(512) NOT NULL,
  239 + `creator` varchar(64) DEFAULT '',
  240 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  241 + `updater` varchar(64) DEFAULT '',
  242 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  243 + `deleted` bit(1) NOT NULL DEFAULT '0',
  244 + PRIMARY KEY (`id`)
  245 +) COMMENT ='系统访问记录';
  246 +
  247 +CREATE TABLE IF NOT EXISTS `sys_operate_log` (
  248 + `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  249 + `trace_id` varchar(64) NOT NULL DEFAULT '',
  250 + `user_id` bigint(20) NOT NULL,
  251 + `module` varchar(50) NOT NULL,
  252 + `name` varchar(50) NOT NULL,
  253 + `operate_type` bigint(4) NOT NULL DEFAULT '0',
  254 + `content` varchar(2000) NOT NULL DEFAULT '',
  255 + `exts` varchar(512) NOT NULL DEFAULT '',
  256 + `request_method` varchar(16) DEFAULT '',
  257 + `request_url` varchar(255) DEFAULT '',
  258 + `user_ip` varchar(50) DEFAULT NULL,
  259 + `user_agent` varchar(200) DEFAULT NULL,
  260 + `java_method` varchar(512) NOT NULL DEFAULT '',
  261 + `java_method_args` varchar(8000) DEFAULT '',
  262 + `start_time` datetime NOT NULL,
  263 + `duration` int(11) NOT NULL,
  264 + `result_code` int(11) NOT NULL DEFAULT '0',
  265 + `result_msg` varchar(512) DEFAULT '',
  266 + `result_data` varchar(4000) DEFAULT '',
  267 + `creator` varchar(64) DEFAULT '',
  268 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  269 + `updater` varchar(64) DEFAULT '',
  270 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  271 + `deleted` bit(1) NOT NULL DEFAULT '0',
  272 + "tenant_id" bigint not null default '0',
  273 + PRIMARY KEY (`id`)
  274 +) COMMENT ='操作日志记录';
  275 +
  276 +CREATE TABLE IF NOT EXISTS "sys_user" (
  277 + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
  278 + "username" varchar(30) not null,
  279 + "password" varchar(100) not null default '',
  280 + "nickname" varchar(30) not null,
  281 + "remark" varchar(500) default null,
  282 + "dept_id" bigint default null,
  283 + "post_ids" varchar(255) default null,
  284 + "email" varchar(50) default '',
  285 + "mobile" varchar(11) default '',
  286 + "sex" tinyint default '0',
  287 + "avatar" varchar(100) default '',
  288 + "status" tinyint not null default '0',
  289 + "login_ip" varchar(50) default '',
  290 + "login_date" timestamp default null,
  291 + "creator" varchar(64) default '',
  292 + "create_time" timestamp not null default current_timestamp,
  293 + "updater" varchar(64) default '',
  294 + "update_time" timestamp not null default current_timestamp,
  295 + "deleted" bit not null default false,
  296 + "tenant_id" bigint not null default '0',
  297 + primary key ("id")
  298 +) comment '用户信息表';
  299 +
  300 +CREATE TABLE IF NOT EXISTS "inf_api_access_log" (
  301 + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
  302 + "trace_id" varchar(64) not null default '',
  303 + "user_id" bigint not null default '0',
  304 + "user_type" tinyint not null default '0',
  305 + "application_name" varchar(50) not null,
  306 + "request_method" varchar(16) not null default '',
  307 + "request_url" varchar(255) not null default '',
  308 + "request_params" varchar(8000) not null default '',
  309 + "user_ip" varchar(50) not null,
  310 + "user_agent" varchar(512) not null,
  311 + "begin_time" timestamp not null,
  312 + "end_time" timestamp not null,
  313 + "duration" integer not null,
  314 + "result_code" integer not null default '0',
  315 + "result_msg" varchar(512) default '',
  316 + "creator" varchar(64) default '',
  317 + "create_time" timestamp not null default current_timestamp,
  318 + "updater" varchar(64) default '',
  319 + "update_time" timestamp not null default current_timestamp,
  320 + "deleted" bit not null default false,
  321 + "tenant_id" bigint not null default '0',
  322 + primary key ("id")
  323 +) COMMENT 'API 访问日志表';
  324 +
  325 +CREATE TABLE IF NOT EXISTS "inf_api_error_log" (
  326 + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
  327 + "trace_id" varchar(64) not null,
  328 + "user_id" bigint not null default '0',
  329 + "user_type" tinyint not null default '0',
  330 + "application_name" varchar(50) not null,
  331 + "request_method" varchar(16) not null,
  332 + "request_url" varchar(255) not null,
  333 + "request_params" varchar(8000) not null,
  334 + "user_ip" varchar(50) not null,
  335 + "user_agent" varchar(512) not null,
  336 + "exception_time" timestamp not null,
  337 + "exception_name" varchar(128) not null default '',
  338 + "exception_message" clob not null,
  339 + "exception_root_cause_message" clob not null,
  340 + "exception_stack_trace" clob not null,
  341 + "exception_class_name" varchar(512) not null,
  342 + "exception_file_name" varchar(512) not null,
  343 + "exception_method_name" varchar(512) not null,
  344 + "exception_line_number" integer not null,
  345 + "process_status" tinyint not null,
  346 + "process_time" timestamp default null,
  347 + "process_user_id" bigint default '0',
  348 + "creator" varchar(64) default '',
  349 + "create_time" timestamp not null default current_timestamp,
  350 + "updater" varchar(64) default '',
  351 + "update_time" timestamp not null default current_timestamp,
  352 + "deleted" bit not null default false,
  353 + "tenant_id" bigint not null default '0',
  354 + primary key ("id")
  355 +) COMMENT '系统异常日志';
  356 +
  357 +CREATE TABLE IF NOT EXISTS "sys_sms_channel" (
  358 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  359 + "signature" varchar(10) NOT NULL,
  360 + "code" varchar(63) NOT NULL,
  361 + "status" tinyint NOT NULL,
  362 + "remark" varchar(255) DEFAULT NULL,
  363 + "api_key" varchar(63) NOT NULL,
  364 + "api_secret" varchar(63) DEFAULT NULL,
  365 + "callback_url" varchar(255) DEFAULT NULL,
  366 + "creator" varchar(64) DEFAULT '',
  367 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  368 + "updater" varchar(64) DEFAULT '',
  369 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  370 + "deleted" bit NOT NULL DEFAULT FALSE,
  371 + PRIMARY KEY ("id")
  372 +) COMMENT '短信渠道';
  373 +
  374 +CREATE TABLE IF NOT EXISTS "sys_sms_template" (
  375 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  376 + "type" tinyint NOT NULL,
  377 + "status" tinyint NOT NULL,
  378 + "code" varchar(63) NOT NULL,
  379 + "name" varchar(63) NOT NULL,
  380 + "content" varchar(255) NOT NULL,
  381 + "params" varchar(255) NOT NULL,
  382 + "remark" varchar(255) DEFAULT NULL,
  383 + "api_template_id" varchar(63) NOT NULL,
  384 + "channel_id" bigint NOT NULL,
  385 + "channel_code" varchar(63) NOT NULL,
  386 + "creator" varchar(64) DEFAULT '',
  387 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  388 + "updater" varchar(64) DEFAULT '',
  389 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  390 + "deleted" bit NOT NULL DEFAULT FALSE,
  391 + PRIMARY KEY ("id")
  392 +) COMMENT '短信模板';
  393 +
  394 +CREATE TABLE IF NOT EXISTS "sys_sms_log" (
  395 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  396 + "channel_id" bigint NOT NULL,
  397 + "channel_code" varchar(63) NOT NULL,
  398 + "template_id" bigint NOT NULL,
  399 + "template_code" varchar(63) NOT NULL,
  400 + "template_type" tinyint NOT NULL,
  401 + "template_content" varchar(255) NOT NULL,
  402 + "template_params" varchar(255) NOT NULL,
  403 + "api_template_id" varchar(63) NOT NULL,
  404 + "mobile" varchar(11) NOT NULL,
  405 + "user_id" bigint DEFAULT '0',
  406 + "user_type" tinyint DEFAULT '0',
  407 + "send_status" tinyint NOT NULL DEFAULT '0',
  408 + "send_time" timestamp DEFAULT NULL,
  409 + "send_code" int DEFAULT NULL,
  410 + "send_msg" varchar(255) DEFAULT NULL,
  411 + "api_send_code" varchar(63) DEFAULT NULL,
  412 + "api_send_msg" varchar(255) DEFAULT NULL,
  413 + "api_request_id" varchar(255) DEFAULT NULL,
  414 + "api_serial_no" varchar(255) DEFAULT NULL,
  415 + "receive_status" tinyint NOT NULL DEFAULT '0',
  416 + "receive_time" timestamp DEFAULT NULL,
  417 + "api_receive_code" varchar(63) DEFAULT NULL,
  418 + "api_receive_msg" varchar(255) DEFAULT NULL,
  419 + "creator" varchar(64) DEFAULT '',
  420 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  421 + "updater" varchar(64) DEFAULT '',
  422 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  423 + "deleted" bit NOT NULL DEFAULT FALSE,
  424 + PRIMARY KEY ("id")
  425 +) COMMENT '短信日志';
  426 +
  427 +CREATE TABLE IF NOT EXISTS "sys_error_code" (
  428 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  429 + "type" tinyint NOT NULL DEFAULT '0',
  430 + "application_name" varchar(50) NOT NULL,
  431 + "code" int NOT NULL DEFAULT '0',
  432 + "message" varchar(512) NOT NULL DEFAULT '',
  433 + "memo" varchar(512) DEFAULT '',
  434 + "creator" varchar(64) DEFAULT '',
  435 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  436 + "updater" varchar(64) DEFAULT '',
  437 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  438 + "deleted" bit NOT NULL DEFAULT FALSE,
  439 + PRIMARY KEY ("id")
  440 +) COMMENT '错误码表';
  441 +
  442 +CREATE TABLE IF NOT EXISTS "sys_social_user" (
  443 + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  444 + "user_id" bigint NOT NULL,
  445 + "user_type" tinyint NOT NULL DEFAULT '0',
  446 + "type" tinyint NOT NULL,
  447 + "openid" varchar(32) NOT NULL,
  448 + "token" varchar(256) DEFAULT NULL,
  449 + "union_id" varchar(32) NOT NULL,
  450 + "raw_token_info" varchar(1024) NOT NULL,
  451 + "nickname" varchar(32) NOT NULL,
  452 + "avatar" varchar(255) DEFAULT NULL,
  453 + "raw_user_info" varchar(1024) NOT NULL,
  454 + "creator" varchar(64) DEFAULT '',
  455 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  456 + "updater" varchar(64) DEFAULT '',
  457 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  458 + "deleted" bit NOT NULL DEFAULT FALSE,
  459 + PRIMARY KEY ("id")
  460 +) COMMENT '社交用户';
  461 +
  462 +CREATE TABLE IF NOT EXISTS "sys_tenant" (
  463 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  464 + "name" varchar(63) NOT NULL,
  465 + "contact_name" varchar(255) NOT NULL,
  466 + "contact_mobile" varchar(255),
  467 + "status" tinyint NOT NULL,
  468 + "creator" varchar(64) DEFAULT '',
  469 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  470 + "updater" varchar(64) DEFAULT '',
  471 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  472 + "deleted" bit NOT NULL DEFAULT FALSE,
  473 + PRIMARY KEY ("id")
  474 +) COMMENT '租户';
  475 +
  476 +
  477 +CREATE TABLE IF NOT EXISTS "pay_merchant"
  478 +(
  479 + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  480 + "no" varchar(32) NOT NULL,
  481 + "name" varchar(64) NOT NULL,
  482 + "short_name" varchar(64) NOT NULL,
  483 + "status" tinyint NOT NULL,
  484 + "remark" varchar(255) DEFAULT NULL,
  485 + "creator" varchar(64) DEFAULT '',
  486 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  487 + "updater" varchar(64) DEFAULT '',
  488 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  489 + "deleted" bit(1) NOT NULL DEFAULT FALSE,
  490 + PRIMARY KEY ("id")
  491 +) COMMENT '支付商户信息';
  492 +
  493 +-- bpm 开头的 DB
  494 +
  495 +CREATE TABLE IF NOT EXISTS "pay_app" (
  496 + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  497 + "name" varchar(64) NOT NULL,
  498 + "status" tinyint NOT NULL,
  499 + "remark" varchar(255) DEFAULT NULL,
  500 + `pay_notify_url` varchar(1024) NOT NULL,
  501 + `refund_notify_url` varchar(1024) NOT NULL,
  502 + `merchant_id` bigint(20) NOT NULL,
  503 + "creator" varchar(64) DEFAULT '',
  504 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  505 + "updater" varchar(64) DEFAULT '',
  506 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  507 + "deleted" bit(1) NOT NULL DEFAULT FALSE,
  508 + PRIMARY KEY ("id")
  509 +) COMMENT = '支付应用信息';
  510 +
  511 +CREATE TABLE IF NOT EXISTS "pay_channel" (
  512 + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  513 + "code" varchar(32) NOT NULL,
  514 + "status" tinyint(4) NOT NULL,
  515 + "remark" varchar(255) DEFAULT NULL,
  516 + "fee_rate" double NOT NULL DEFAULT 0,
  517 + "merchant_id" bigint(20) NOT NULL,
  518 + "app_id" bigint(20) NOT NULL,
  519 + "config" varchar(10240) NOT NULL,
  520 + "creator" varchar(64) NULL DEFAULT '',
  521 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  522 + "updater" varchar(64) NULL DEFAULT '',
  523 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  524 + "deleted" bit(1) NOT NULL DEFAULT FALSE,
  525 + PRIMARY KEY ("id")
  526 +) COMMENT = '支付渠道';
  527 +
  528 +CREATE TABLE IF NOT EXISTS `pay_order` (
  529 + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  530 + `merchant_id` bigint(20) NOT NULL,
  531 + `app_id` bigint(20) NOT NULL,
  532 + `channel_id` bigint(20) DEFAULT NULL,
  533 + `channel_code` varchar(32) DEFAULT NULL,
  534 + `merchant_order_id` varchar(64) NOT NULL,
  535 + `subject` varchar(32) NOT NULL,
  536 + `body` varchar(128) NOT NULL,
  537 + `notify_url` varchar(1024) NOT NULL,
  538 + `notify_status` tinyint(4) NOT NULL,
  539 + `amount` bigint(20) NOT NULL,
  540 + `channel_fee_rate` double DEFAULT 0,
  541 + `channel_fee_amount` bigint(20) DEFAULT 0,
  542 + `status` tinyint(4) NOT NULL,
  543 + `user_ip` varchar(50) NOT NULL,
  544 + `expire_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  545 + `success_time` datetime(0) DEFAULT CURRENT_TIMESTAMP,
  546 + `notify_time` datetime(0) DEFAULT CURRENT_TIMESTAMP,
  547 + `success_extension_id` bigint(20) DEFAULT NULL COMMENT '支付成功的订单拓展单编号',
  548 + `refund_status` tinyint(4) NOT NULL,
  549 + `refund_times` tinyint(4) NOT NULL,
  550 + `refund_amount` bigint(20) NOT NULL,
  551 + `channel_user_id` varchar(255) DEFAULT NULL,
  552 + `channel_order_no` varchar(64) DEFAULT NULL,
  553 + `creator` varchar(64) DEFAULT '',
  554 + `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  555 + `updater` varchar(64) DEFAULT '',
  556 + `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  557 + `deleted` bit(1) NOT NULL DEFAULT FALSE,
  558 + PRIMARY KEY ("id")
  559 +) COMMENT = '支付订单';
  560 +
  561 +CREATE TABLE IF NOT EXISTS `pay_refund` (
  562 + "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  563 + `merchant_id` bigint(20) NOT NULL,
  564 + `app_id` bigint(20) NOT NULL,
  565 + `channel_id` bigint(20) NOT NULL,
  566 + `channel_code` varchar(32) NOT NULL,
  567 + `order_id` bigint(20) NOT NULL,
  568 + `trade_no` varchar(64) NOT NULL,
  569 + `merchant_order_id` varchar(64) NOT NULL,
  570 + `merchant_refund_no` varchar(64) NOT NULL,
  571 + `notify_url` varchar(1024) NOT NULL,
  572 + `notify_status` tinyint(4) NOT NULL,
  573 + `status` tinyint(4) NOT NULL,
  574 + `type` tinyint(4) NOT NULL,
  575 + `pay_amount` bigint(20) NOT NULL,
  576 + `refund_amount` bigint(20) NOT NULL,
  577 + `reason` varchar(256) NOT NULL,
  578 + `user_ip` varchar(50) NULL DEFAULT NULL,
  579 + `channel_order_no` varchar(64) NOT NULL,
  580 + `channel_refund_no` varchar(64) NULL DEFAULT NULL,
  581 + `channel_error_code` varchar(128) NULL DEFAULT NULL,
  582 + `channel_error_msg` varchar(256) NULL DEFAULT NULL,
  583 + `channel_extras` varchar(1024) NULL DEFAULT NULL,
  584 + `expire_time` datetime(0) NULL DEFAULT NULL,
  585 + `success_time` datetime(0) NULL DEFAULT NULL,
  586 + `notify_time` datetime(0) NULL DEFAULT NULL,
  587 + `creator` varchar(64) NULL DEFAULT '',
  588 + `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  589 + `updater` varchar(64) NULL DEFAULT '',
  590 + `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  591 + `deleted` bit(1) NOT NULL DEFAULT FALSE,
  592 + PRIMARY KEY ("id")
  593 +) COMMENT = '退款订单';
  594 +
  595 +-- bpm 开头的 DB
  596 +
  597 +CREATE TABLE IF NOT EXISTS "bpm_form" (
  598 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  599 + "name" varchar(63) NOT NULL,
  600 + "status" tinyint NOT NULL,
  601 + "fields" varchar(255) NOT NULL,
  602 + "conf" varchar(255) NOT NULL,
  603 + "remark" varchar(255),
  604 + "creator" varchar(64) DEFAULT '',
  605 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  606 + "updater" varchar(64) DEFAULT '',
  607 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  608 + "deleted" bit NOT NULL DEFAULT FALSE,
  609 + PRIMARY KEY ("id")
  610 +) COMMENT '动态表单';
  611 +
  612 +CREATE TABLE IF NOT EXISTS "bpm_user_group" (
  613 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  614 + "name" varchar(63) NOT NULL,
  615 + "description" varchar(255) NOT NULL,
  616 + "status" tinyint NOT NULL,
  617 + "member_user_ids" varchar(255) NOT NULL,
  618 + "creator" varchar(64) DEFAULT '',
  619 + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  620 + "updater" varchar(64) DEFAULT '',
  621 + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  622 + "deleted" bit NOT NULL DEFAULT FALSE,
  623 + PRIMARY KEY ("id")
  624 + ) COMMENT '用户组';
... ...