Browse Source

优化索引

zhou-hao 6 years ago
parent
commit
9240be3954

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserService.java

@@ -137,7 +137,7 @@ public class SimpleUserService extends AbstractService<UserEntity, String>
         //用户名合法性验证
         tryValidateProperty(usernameValidator, UserEntity.username, userEntity.getUsername());
         //判断用户是否已经存在
-        tryValidateProperty(null == selectByUsername(userEntity.getUsername()), UserEntity.username, "{username_exists}");
+        tryValidateProperty(null == selectByUsername(userEntity.getUsername()), UserEntity.username, "用户名已存在");
         //密码强度验证
         tryValidateProperty(passwordStrengthValidator, UserEntity.password, userEntity.getPassword());
         userEntity.setCreateTime(System.currentTimeMillis());

+ 18 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/hsweb-starter.js

@@ -51,6 +51,8 @@ function install(context) {
         .addColumn().name("last_login_time").number(32).comment("上一次登录时间").commit()
         .addColumn().name("creator_id").varchar(32).comment("创建者ID").commit()
         .addColumn().name("create_time").number(32).notNull().comment("创建时间").commit()
+        //用户名唯一索引
+        .index().name("idx_user_username").column("username").unique().commit()
         .comment("用户表").commit();
 
     database.createOrAlter("s_role")
@@ -82,6 +84,9 @@ function install(context) {
     database.createOrAlter("s_user_role")
         .addColumn().name("role_id").varchar(32).notNull().comment("角色ID").commit()
         .addColumn().name("user_id").varchar(32).notNull().comment("用户ID").commit()
+        .index().name("idx_ur_user_id").column("user_id").commit()
+        .index().name("idx_ur_role_id").column("role_id").commit()
+
         .comment("用户与角色关联表").commit();
 
     //权限设置
@@ -91,6 +96,8 @@ function install(context) {
         .addColumn().name("setting_for").varchar(64).notNull().comment("设置给谁").commit()
         .addColumn().name("describe").varchar(256).comment("备注").commit()
         .addColumn().name("status").number(4, 0).comment("设置给谁").commit()
+
+        .index().name("idx_as_type_setting_for").column("type").column("setting_for").commit()
         .comment("权限设置表").commit();
 
     database.createOrAlter("s_autz_detail")
@@ -102,6 +109,8 @@ function install(context) {
         .addColumn().name("status").number(4, 0).comment("状态").commit()
         .addColumn().name("priority").number(32, 0).comment("优先级").commit()
         .addColumn().name("is_merge").number(4, 0).comment("是否合并").commit()
+        .index().name("idx_ad_setting_id").column("setting_id").commit()
+
         .comment("权限设置详情表").commit();
 
     database.createOrAlter("s_autz_menu")
@@ -114,6 +123,9 @@ function install(context) {
         .addColumn().name("status").number(4, 0).comment("状态").commit()
         .addColumn().name("level").number(32, 0).comment("树深度").commit()
         .addColumn().name("config").clob().comment("其他配置").commit()
+        .index().name("idx_ame_setting_id").column("setting_id").commit()
+        .index().name("idx_ame_parent_id").column("parent_id").commit()
+        .index().name("idx_ame_path").column("path").commit()
         .comment("权限设置菜单表").commit();
 
     // 菜单
@@ -128,6 +140,9 @@ function install(context) {
         .addColumn().name("url").varchar(2000).comment("URL").commit()
         .addColumn().name("icon").varchar(512).comment("图标").commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
+        .index().name("idx_menu_path").column("path").commit()
+        .index().name("idx_menu_parent_id").column("parent_id").commit()
+
         .comment("系统菜单表").commit()
 
     database.createOrAlter("s_menu_group")
@@ -164,6 +179,9 @@ function install(context) {
         .addColumn().name("setting_id").varchar(32).notNull().comment("自定义配置id").commit()
         .addColumn().name("create_time").datetime().notNull().comment("创建时间").commit()
         .addColumn().name("update_time").datetime().comment("创建时间").commit()
+        .index().name("idx_uset_user_id").column("user_id").commit()
+        .index().name("idx_uset_user_id_key").column("user_id").column("key").commit()
+        .index().name("idx_uset_user_id_key_setting").column("user_id").column("key").column("setting_id").commit()
         .comment("用户设置表").commit();
 }
 

+ 4 - 0
hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/hsweb-starter.js

@@ -56,6 +56,8 @@ function install(context) {
         .addColumn().name("dict_config").alias("dictConfig").comment("字典配置").jdbcType(java.sql.JDBCType.CLOB).commit()
         .addColumn().name("sort_index").alias("sortIndex").comment("排序序号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
         .addColumn().name("validator").alias("validator").comment("验证器配置").jdbcType(java.sql.JDBCType.CLOB).commit()
+        .index().name("idx_dynf_form_id").column("form_id").commit()
+
         .comment("动态表单列").commit();
 
     database.createOrAlter("s_dyn_form_log")
@@ -65,6 +67,8 @@ function install(context) {
         .addColumn().name("deploy_time").alias("deployTime").comment("发布时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
         .addColumn().name("meta_data").alias("metaData").comment("部署的元数据").jdbcType(java.sql.JDBCType.CLOB).commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.NUMERIC).length(4, 0).commit()
+        .index().name("idx_dynfl_form_id").column("form_id").commit()
+        .index().name("idx_dynfl_form_id_ver").column("form_id").column("version").commit()
         .comment("表单发布日志").commit();
 }
 //设置依赖

+ 3 - 0
hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/hsweb-starter.js

@@ -31,6 +31,9 @@ function install(context) {
         .addColumn().name("classified").alias("classified").comment("分类").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
         .addColumn().name("create_time").alias("create_time").comment("创建时间").jdbcType(java.sql.JDBCType.NUMERIC).length(32,0).commit()
         .addColumn().name("creator_id").alias("creatorId").comment("创建人").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit()
+        .index().name("idx_file_md5").column("md5").commit()
+        .index().name("idx_file_creator_id").column("creator_id").commit()
+
         .comment("文件信息").commit();
 }
 //设置依赖

+ 5 - 0
hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/hsweb-starter.js

@@ -64,6 +64,11 @@ function install(context) {
         .addColumn().name("create_time").alias("createTime").comment("创建时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
         .addColumn().name("update_time").alias("updateTime").comment("更新时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
         .addColumn().name("grant_type").alias("grant_type").comment("授权方式").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit()
+        .index().name("idx_oauth_cli_c_user_id").column("client_user_id").commit()
+        .index().name("idx_oauth_cli_s_user_id").column("server_user_id").commit()
+        .index().name("idx_oauth_cli_access_token").column("access_token").commit()
+        .index().name("idx_oauth_cli_refresh_token").column("refresh_token").commit()
+
         .comment("OAuth2用户授权信息").commit();
 }
 

+ 4 - 0
hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/hsweb-starter.js

@@ -64,6 +64,10 @@ function install(context) {
         .addColumn().name("update_time").number(32).comment("更新时间").commit()
         .addColumn().name("scope").clob().comment("授权范围").commit()
         .addColumn().name("grant_type").varchar(32).comment("授权类型").commit()
+        .index().name("idx_oauth_ser_client_id").column("client_id").commit()
+        .index().name("idx_oauth_ser_owner_id").column("owner_id").commit()
+        .index().name("idx_oauth_ser_access_token").column("access_token").commit()
+        .index().name("idx_oauth_ser_refresh_token").column("refresh_token").commit()
         .comment("OAuth2授权认证信息").commit();
 
     database.createOrAlter("s_oauth2_auth_code")

+ 30 - 1
hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/hsweb-starter.js

@@ -48,6 +48,9 @@ function install(context) {
         .addColumn().name("describe").alias("describe").comment("说明").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
         .addColumn().name("sort_index").alias("sortIndex").comment("排序索引").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
+        .index().name("idx_district_parent_id").column("parent_id").commit()
+        .index().name("idx_district_path").column("path").commit()
+
         .comment("行政区域").commit();
 
     database.createOrAlter("s_organization")
@@ -62,7 +65,11 @@ function install(context) {
         .addColumn().name("sort_index").alias("sortIndex").comment("树结构编码").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
         .addColumn().name("level").alias("level").comment("级别").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
-        .comment("组织").commit();
+        .index().name("idx_org_parent_id").column("parent_id").commit()
+        .index().name("idx_org_path").column("path").commit()
+        .index().name("idx_org_district_id").column("district_id").commit()
+
+        .comment("组织,公司").commit();
 
     database.createOrAlter("s_department")
         .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit()
@@ -74,6 +81,10 @@ function install(context) {
         .addColumn().name("sort_index").alias("sortIndex").comment("排序序号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
         .addColumn().name("level").alias("level").comment("级别").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
+        .index().name("idx_dept_parent_id").column("parent_id").commit()
+        .index().name("idx_dept_path").column("path").commit()
+        .index().name("idx_dept_org_id").column("org_id").commit()
+
         .comment("部门").commit();
 
     database.createOrAlter("s_position")
@@ -86,6 +97,10 @@ function install(context) {
         .addColumn().name("path").alias("path").comment("树结构编码").jdbcType(java.sql.JDBCType.VARCHAR).length(4000).commit()
         .addColumn().name("sort_index").alias("sortIndex").comment("排序索引").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
         .addColumn().name("level").alias("level").comment("级别").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
+        .index().name("idx_position_parent_id").column("parent_id").commit()
+        .index().name("idx_position_path").column("path").commit()
+        .index().name("idx_position_dept_id").column("department_id").commit()
+
         .comment("职位").commit();
 
     database.createOrAlter("s_person")
@@ -98,11 +113,17 @@ function install(context) {
         .addColumn().name("user_id").alias("userId").comment("关联用户id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
         .addColumn().name("remark").alias("remark").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit()
+        .index().name("idx_person_parent_id").column("parent_id").commit()
+        .index().name("idx_person_path").column("path").commit()
+
         .comment("人员").commit();
 
     database.createOrAlter("s_person_position")
         .addColumn().name("person_id").alias("personId").comment("人员id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
         .addColumn().name("position_id").alias("positionId").comment("职位id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .index().name("idx_person_pos_person_id").column("person_id").commit()
+        .index().name("idx_person_pos_position_id").column("position_id").commit()
+
         .comment("人员职位关联").commit();
 
     database.createOrAlter("s_relation_def")
@@ -110,6 +131,8 @@ function install(context) {
         .addColumn().name("name").alias("name").comment("关系名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
         .addColumn().name("type_id").alias("typeId").comment("关系类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.NUMERIC).length(4,0).commit()
+        .index().name("idx_relation_def_type").column("type_id").commit()
+
         .comment("关系定义").commit();
 
     database.createOrAlter("s_relation_info")
@@ -120,6 +143,12 @@ function install(context) {
         .addColumn().name("relation_type_from").alias("relationTypeFrom").comment("关系类型从,如:人员").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit()
         .addColumn().name("relation_type_to").alias("relationTypeTo").comment("关系类型至,如:部门").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.NUMERIC).length(4,0).commit()
+        .index().name("idx_relation_r_id").column("relation_id").commit()
+        .index().name("idx_relation_rt_from").column("relation_type_from").commit()
+        .index().name("idx_relation_rt_to").column("relation_type_to").commit()
+        .index().name("idx_relation_r_to").column("relation_to").commit()
+        .index().name("idx_relation_r_from").column("relation_from").commit()
+
         .comment("关系信息").commit();
 
 }

+ 9 - 0
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/hsweb-starter.js

@@ -32,6 +32,9 @@ function install(context) {
         .addColumn().name("update_time").alias("updateTime").comment("修改时间").datetime().commit()
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.TINYINT).commit()
         .addColumn().name("listeners").alias("listeners").comment("监听器配置").jdbcType(java.sql.JDBCType.CLOB).commit()
+        .index().name("idx_proc_def_key").column("proc_def_key").commit()
+        .index().name("idx_proc_def_id").column("proc_def_id").commit()
+
         .comment("工作流流程自定义配置")
         .commit();
 
@@ -47,6 +50,9 @@ function install(context) {
         .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.TINYINT).commit()
         .addColumn().name("properties").alias("properties").comment("其他配置").jdbcType(java.sql.JDBCType.CLOB).commit()
         .addColumn().name("listeners").alias("listeners").comment("监听器配置").jdbcType(java.sql.JDBCType.CLOB).commit()
+        .index().name("idx_act_proc_def_id").column("proc_def_id").commit()
+        .index().name("idx_act_proc_def_key").column("proc_def_key").commit()
+
         .comment("工作流环节自定义配置")
         .commit();
 
@@ -64,6 +70,9 @@ function install(context) {
         .addColumn().name("create_time").alias("createTime").notNull().comment("创建时间").datetime().commit()
         .addColumn().name("creator_id").alias("creatorId").length(32).notNull().comment("创建人ID").jdbcType(java.sql.JDBCType.VARCHAR).commit()
         .addColumn().name("creator_name").alias("creatorName").length(32).notNull().comment("创建人姓名").jdbcType(java.sql.JDBCType.VARCHAR).commit()
+        .index().name("idx_proc_his_def_id").column("proc_def_id").commit()
+        .index().name("idx_proc_his_ins_id").column("proc_ins_id").commit()
+        .index().name("idx_proc_his_task_id").column("task_id").commit()
         .comment("工作流流程历史")
         .commit();
 }