From 1f0b2b69d7b600d426792d2421058467d83679e0 Mon Sep 17 00:00:00 2001 From: zhu-mingye <934230207@qq.com> Date: Thu, 16 Nov 2023 23:14:47 +0800 Subject: [PATCH] fix sql bug of h2 (#2534) --- .../org/dinky/controller/GitController.java | 16 ++-- .../dinky/controller/TenantController.java | 12 +-- .../org/dinky/controller/UserController.java | 16 ++-- .../AssignRoleDTO.java} | 6 +- .../AssignUserToTenantDTO.java} | 6 +- .../GitProjectSortJarDTO.java} | 8 +- .../org/dinky/service/GitProjectService.java | 6 +- .../java/org/dinky/service/TenantService.java | 6 +- .../java/org/dinky/service/UserService.java | 6 +- .../service/impl/GitProjectServiceImpl.java | 10 +-- .../dinky/service/impl/TenantServiceImpl.java | 8 +- .../dinky/service/impl/UserServiceImpl.java | 15 ++-- .../src/main/resources/db/db-h2-ddl.sql | 83 ++++++++++++++----- .../src/main/resources/db/db-h2-dml.sql | 69 ++++++++------- 14 files changed, 158 insertions(+), 109 deletions(-) rename dinky-admin/src/main/java/org/dinky/data/{params/AssignRoleParams.java => dto/AssignRoleDTO.java} (88%) rename dinky-admin/src/main/java/org/dinky/data/{params/AssignUserToTenantParams.java => dto/AssignUserToTenantDTO.java} (88%) rename dinky-admin/src/main/java/org/dinky/data/{params/GitProjectSortJarParams.java => dto/GitProjectSortJarDTO.java} (84%) diff --git a/dinky-admin/src/main/java/org/dinky/controller/GitController.java b/dinky-admin/src/main/java/org/dinky/controller/GitController.java index a66219ae2d..a523b2a5a0 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/GitController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/GitController.java @@ -22,11 +22,11 @@ import org.dinky.data.annotations.Log; import org.dinky.data.constant.PermissionConstants; import org.dinky.data.dto.GitProjectDTO; +import org.dinky.data.dto.GitProjectSortJarDTO; import org.dinky.data.dto.TreeNodeDTO; import org.dinky.data.enums.BusinessType; import org.dinky.data.enums.Status; import org.dinky.data.model.GitProject; -import org.dinky.data.params.GitProjectSortJarParams; import org.dinky.data.result.ProTableResult; import org.dinky.data.result.Result; import org.dinky.service.GitProjectService; @@ -129,26 +129,26 @@ public Result dragendSortProject(@RequestBody Map sortList) { /** * drag sort jar level * - * @param gitProjectSortJarParams + * @param gitProjectSortJarDTO * @return {@link Result}<{@link Void}> */ @PostMapping("/dragendSortJar") @Log(title = "GitProject Jar Sort", businessType = BusinessType.UPDATE) @ApiOperation("GitProject Jar Sort") @ApiImplicitParam( - name = "gitProjectSortJarParams", + name = "gitProjectSortJarDTO", value = "after sorter data", required = true, - dataType = "GitProjectSortJarParams", + dataType = "GitProjectSortJarDTO", paramType = "body", - dataTypeClass = GitProjectSortJarParams.class) + dataTypeClass = GitProjectSortJarDTO.class) @SaCheckPermission(PermissionConstants.REGISTRATION_GIT_PROJECT_EDIT) - public Result dragendSortJar(@RequestBody GitProjectSortJarParams gitProjectSortJarParams) { - GitProject gitProjectServiceById = gitProjectService.getById(gitProjectSortJarParams.getProjectId()); + public Result dragendSortJar(@RequestBody GitProjectSortJarDTO gitProjectSortJarDTO) { + GitProject gitProjectServiceById = gitProjectService.getById(gitProjectSortJarDTO.getProjectId()); if (gitProjectServiceById == null) { return Result.failed(Status.GIT_PROJECT_NOT_FOUND); } else { - if (gitProjectService.dragendSortJar(gitProjectSortJarParams)) { + if (gitProjectService.dragendSortJar(gitProjectSortJarDTO)) { return Result.succeed(Status.GIT_SORT_SUCCESS); } else { return Result.failed(Status.GIT_SORT_FAILED); diff --git a/dinky-admin/src/main/java/org/dinky/controller/TenantController.java b/dinky-admin/src/main/java/org/dinky/controller/TenantController.java index a16c31992b..7137e64279 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/TenantController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/TenantController.java @@ -21,10 +21,10 @@ import org.dinky.data.annotations.Log; import org.dinky.data.constant.PermissionConstants; +import org.dinky.data.dto.AssignUserToTenantDTO; import org.dinky.data.enums.BusinessType; import org.dinky.data.model.rbac.Tenant; import org.dinky.data.model.rbac.User; -import org.dinky.data.params.AssignUserToTenantParams; import org.dinky.data.result.ProTableResult; import org.dinky.data.result.Result; import org.dinky.service.TenantService; @@ -122,21 +122,21 @@ public ProTableResult listTenants(@RequestBody JsonNode para) { /** * assign user to tenant * - * @param assignUserToTenantParams {@link AssignUserToTenantParams} + * @param assignUserToTenantDTO {@link AssignUserToTenantDTO} * @return {@link Result} of {@link Void} */ @PutMapping(value = "/assignUserToTenant") @ApiOperation("Assign User To Tenant") @ApiImplicitParam( - name = "assignUserToTenantParams", + name = "assignUserToTenantDTO", value = "assign user to tenant params", required = true, - dataType = "AssignUserToTenantParams", + dataType = "AssignUserToTenantDTO", paramType = "body") @Log(title = "Assign User To Tenant", businessType = BusinessType.INSERT) @SaCheckPermission(value = PermissionConstants.AUTH_TENANT_ASSIGN_USER) - public Result assignUserToTenant(@RequestBody AssignUserToTenantParams assignUserToTenantParams) { - return tenantService.assignUserToTenant(assignUserToTenantParams); + public Result assignUserToTenant(@RequestBody AssignUserToTenantDTO assignUserToTenantDTO) { + return tenantService.assignUserToTenant(assignUserToTenantDTO); } /** diff --git a/dinky-admin/src/main/java/org/dinky/controller/UserController.java b/dinky-admin/src/main/java/org/dinky/controller/UserController.java index b7a06935e0..a521409353 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/UserController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/UserController.java @@ -22,11 +22,11 @@ import org.dinky.assertion.Asserts; import org.dinky.data.annotations.Log; import org.dinky.data.constant.PermissionConstants; +import org.dinky.data.dto.AssignRoleDTO; import org.dinky.data.dto.ModifyPasswordDTO; import org.dinky.data.enums.BusinessType; import org.dinky.data.enums.Status; import org.dinky.data.model.rbac.User; -import org.dinky.data.params.AssignRoleParams; import org.dinky.data.result.ProTableResult; import org.dinky.data.result.Result; import org.dinky.data.vo.UserVo; @@ -194,22 +194,22 @@ public Result modifyPassword(@RequestBody ModifyPasswordDTO modifyPassword /** * give user assign role * - * @param assignRoleParams {@link AssignRoleParams} + * @param assignRoleDTO {@link AssignRoleDTO} * @return {@link Result} with {@link Void} */ @PostMapping(value = "/assignRole") @ApiOperation("Assign Role") @Log(title = "Assign Role", businessType = BusinessType.UPDATE) @ApiImplicitParam( - name = "assignRoleParams", - value = "assignRoleParams", + name = "assignRoleDTO", + value = "assignRoleDTO", required = true, - dataType = "AssignRoleParams", + dataType = "AssignRoleDTO", paramType = "body", - dataTypeClass = AssignRoleParams.class) + dataTypeClass = AssignRoleDTO.class) @SaCheckPermission(PermissionConstants.AUTH_USER_ASSIGN_ROLE) - public Result assignRole(@RequestBody AssignRoleParams assignRoleParams) { - return userService.assignRole(assignRoleParams); + public Result assignRole(@RequestBody AssignRoleDTO assignRoleDTO) { + return userService.assignRole(assignRoleDTO); } /** diff --git a/dinky-admin/src/main/java/org/dinky/data/params/AssignRoleParams.java b/dinky-admin/src/main/java/org/dinky/data/dto/AssignRoleDTO.java similarity index 88% rename from dinky-admin/src/main/java/org/dinky/data/params/AssignRoleParams.java rename to dinky-admin/src/main/java/org/dinky/data/dto/AssignRoleDTO.java index 463d5cd261..4c0261ce23 100644 --- a/dinky-admin/src/main/java/org/dinky/data/params/AssignRoleParams.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/AssignRoleDTO.java @@ -17,7 +17,7 @@ * */ -package org.dinky.data.params; +package org.dinky.data.dto; import java.util.List; @@ -27,8 +27,8 @@ /** assign role params */ @Data -@ApiModel(value = "AssignRoleParams", description = "Parameters for Assigning Roles to a User") -public class AssignRoleParams { +@ApiModel(value = "AssignRoleDTO", description = "Parameters for Assigning Roles to a User") +public class AssignRoleDTO { @ApiModelProperty(value = "User ID", dataType = "Integer", notes = "ID of the user to assign roles to") private Integer userId; diff --git a/dinky-admin/src/main/java/org/dinky/data/params/AssignUserToTenantParams.java b/dinky-admin/src/main/java/org/dinky/data/dto/AssignUserToTenantDTO.java similarity index 88% rename from dinky-admin/src/main/java/org/dinky/data/params/AssignUserToTenantParams.java rename to dinky-admin/src/main/java/org/dinky/data/dto/AssignUserToTenantDTO.java index 21925fa1c0..14e6c841cf 100644 --- a/dinky-admin/src/main/java/org/dinky/data/params/AssignUserToTenantParams.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/AssignUserToTenantDTO.java @@ -17,7 +17,7 @@ * */ -package org.dinky.data.params; +package org.dinky.data.dto; import java.util.List; @@ -31,8 +31,8 @@ @Data @AllArgsConstructor @NoArgsConstructor -@ApiModel(value = "AssignUserToTenantParams", description = "Parameters for Assigning Users to a Tenant") -public class AssignUserToTenantParams { +@ApiModel(value = "AssignUserToTenantDTO", description = "Parameters for Assigning Users to a Tenant") +public class AssignUserToTenantDTO { @ApiModelProperty(value = "Tenant ID", dataType = "Integer", notes = "ID of the tenant to assign users to") private Integer tenantId; diff --git a/dinky-admin/src/main/java/org/dinky/data/params/GitProjectSortJarParams.java b/dinky-admin/src/main/java/org/dinky/data/dto/GitProjectSortJarDTO.java similarity index 84% rename from dinky-admin/src/main/java/org/dinky/data/params/GitProjectSortJarParams.java rename to dinky-admin/src/main/java/org/dinky/data/dto/GitProjectSortJarDTO.java index c0189835b9..f9a0a5c043 100644 --- a/dinky-admin/src/main/java/org/dinky/data/params/GitProjectSortJarParams.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/GitProjectSortJarDTO.java @@ -17,9 +17,7 @@ * */ -package org.dinky.data.params; - -import org.dinky.data.dto.GitAnalysisJarDTO; +package org.dinky.data.dto; import java.io.Serializable; import java.util.List; @@ -29,8 +27,8 @@ import lombok.Data; @Data -@ApiModel(value = "GitProjectSortJarParams", description = "Parameters for Sorting JARs in a Git Project") -public class GitProjectSortJarParams implements Serializable { +@ApiModel(value = "GitProjectSortJarDTO", description = "Parameters for Sorting JARs in a Git Project") +public class GitProjectSortJarDTO implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "Project ID", dataType = "Integer", notes = "ID of the Git project") diff --git a/dinky-admin/src/main/java/org/dinky/service/GitProjectService.java b/dinky-admin/src/main/java/org/dinky/service/GitProjectService.java index 24973239dd..9a1eebbe6a 100644 --- a/dinky-admin/src/main/java/org/dinky/service/GitProjectService.java +++ b/dinky-admin/src/main/java/org/dinky/service/GitProjectService.java @@ -20,9 +20,9 @@ package org.dinky.service; import org.dinky.data.dto.GitProjectDTO; +import org.dinky.data.dto.GitProjectSortJarDTO; import org.dinky.data.dto.TreeNodeDTO; import org.dinky.data.model.GitProject; -import org.dinky.data.params.GitProjectSortJarParams; import org.dinky.mybatis.service.ISuperService; import java.util.List; @@ -50,10 +50,10 @@ public interface GitProjectService extends ISuperService { /** * drag sort jar level * - * @param gitProjectSortJarParams + * @param gitProjectSortJarDTO * @return */ - Boolean dragendSortJar(GitProjectSortJarParams gitProjectSortJarParams); + Boolean dragendSortJar(GitProjectSortJarDTO gitProjectSortJarDTO); /** * Get the Git pool as a map of strings. diff --git a/dinky-admin/src/main/java/org/dinky/service/TenantService.java b/dinky-admin/src/main/java/org/dinky/service/TenantService.java index 302ced4b6d..a9b86eeef9 100644 --- a/dinky-admin/src/main/java/org/dinky/service/TenantService.java +++ b/dinky-admin/src/main/java/org/dinky/service/TenantService.java @@ -19,8 +19,8 @@ package org.dinky.service; +import org.dinky.data.dto.AssignUserToTenantDTO; import org.dinky.data.model.rbac.Tenant; -import org.dinky.data.params.AssignUserToTenantParams; import org.dinky.data.result.Result; import org.dinky.mybatis.service.ISuperService; @@ -78,8 +78,8 @@ public interface TenantService extends ISuperService { /** * assignUserToTenant users to tenant * - * @param assignUserToTenantParams {@link AssignUserToTenantParams} + * @param assignUserToTenantDTO {@link AssignUserToTenantDTO} * @return {@link Result} of {@link Void} */ - Result assignUserToTenant(AssignUserToTenantParams assignUserToTenantParams); + Result assignUserToTenant(AssignUserToTenantDTO assignUserToTenantDTO); } diff --git a/dinky-admin/src/main/java/org/dinky/service/UserService.java b/dinky-admin/src/main/java/org/dinky/service/UserService.java index de4a43505b..7d5c6749b9 100644 --- a/dinky-admin/src/main/java/org/dinky/service/UserService.java +++ b/dinky-admin/src/main/java/org/dinky/service/UserService.java @@ -19,6 +19,7 @@ package org.dinky.service; +import org.dinky.data.dto.AssignRoleDTO; import org.dinky.data.dto.LoginDTO; import org.dinky.data.dto.ModifyPasswordDTO; import org.dinky.data.dto.UserDTO; @@ -26,7 +27,6 @@ import org.dinky.data.model.rbac.RowPermissions; import org.dinky.data.model.rbac.Tenant; import org.dinky.data.model.rbac.User; -import org.dinky.data.params.AssignRoleParams; import org.dinky.data.result.Result; import org.dinky.data.vo.UserVo; import org.dinky.mybatis.service.ISuperService; @@ -91,10 +91,10 @@ public interface UserService extends ISuperService { /** * grant role * - * @param assignRoleParams {@link AssignRoleParams} + * @param assignRoleDTO {@link AssignRoleDTO} * @return {@link Result}<{@link Void}> */ - Result assignRole(AssignRoleParams assignRoleParams); + Result assignRole(AssignRoleDTO assignRoleDTO); /** * choose tenant diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/GitProjectServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/GitProjectServiceImpl.java index 2670344bae..37a2b2cefe 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/GitProjectServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/GitProjectServiceImpl.java @@ -21,10 +21,10 @@ import org.dinky.data.dto.GitAnalysisJarDTO; import org.dinky.data.dto.GitProjectDTO; +import org.dinky.data.dto.GitProjectSortJarDTO; import org.dinky.data.dto.TreeNodeDTO; import org.dinky.data.exception.DinkyException; import org.dinky.data.model.GitProject; -import org.dinky.data.params.GitProjectSortJarParams; import org.dinky.function.pool.UdfCodePool; import org.dinky.mapper.GitProjectMapper; import org.dinky.mybatis.service.impl.SuperServiceImpl; @@ -93,14 +93,14 @@ public void dragendSortProject(Map gitProjectDTOList) { } } - /** @param gitProjectSortJarParams */ + /** @param gitProjectSortJarDTO */ @Override - public Boolean dragendSortJar(GitProjectSortJarParams gitProjectSortJarParams) { - GitProject gitProject = getById(gitProjectSortJarParams.getProjectId()); + public Boolean dragendSortJar(GitProjectSortJarDTO gitProjectSortJarDTO) { + GitProject gitProject = getById(gitProjectSortJarDTO.getProjectId()); if (gitProject == null) { return false; } else { - String jarClasses = JSONUtil.toJsonStr(gitProjectSortJarParams.getJars()); + String jarClasses = JSONUtil.toJsonStr(gitProjectSortJarDTO.getJars()); gitProject.setUdfClassMapList(jarClasses); return updateById(gitProject); } diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/TenantServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/TenantServiceImpl.java index a518ddcbe4..be9864e5b5 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/TenantServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/TenantServiceImpl.java @@ -22,11 +22,11 @@ import org.dinky.assertion.Asserts; import org.dinky.context.TenantContextHolder; import org.dinky.data.constant.BaseConstant; +import org.dinky.data.dto.AssignUserToTenantDTO; import org.dinky.data.enums.Status; import org.dinky.data.model.rbac.Role; import org.dinky.data.model.rbac.Tenant; import org.dinky.data.model.rbac.UserTenant; -import org.dinky.data.params.AssignUserToTenantParams; import org.dinky.data.result.Result; import org.dinky.mapper.TenantMapper; import org.dinky.mybatis.service.impl.SuperServiceImpl; @@ -166,11 +166,11 @@ public Result removeTenantById(Integer tenantId) { @Override @Transactional(rollbackFor = Exception.class) - public Result assignUserToTenant(AssignUserToTenantParams assignUserToTenantParams) { + public Result assignUserToTenant(AssignUserToTenantDTO assignUserToTenantDTO) { List tenantUserList = new ArrayList<>(); - Integer tenantId = assignUserToTenantParams.getTenantId(); + Integer tenantId = assignUserToTenantDTO.getTenantId(); userTenantService.remove(new LambdaQueryWrapper().eq(UserTenant::getTenantId, tenantId)); - List userIds = assignUserToTenantParams.getUserIds(); + List userIds = assignUserToTenantDTO.getUserIds(); for (Integer userId : userIds) { UserTenant userTenant = new UserTenant(); userTenant.setTenantId(tenantId); diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java index a3b9f64b67..5c8bc20841 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java @@ -23,6 +23,8 @@ import org.dinky.context.RowLevelPermissionsContext; import org.dinky.context.TenantContextHolder; import org.dinky.context.UserInfoContextHolder; +import org.dinky.data.dto.AssignRoleDTO; +import org.dinky.data.dto.AssignUserToTenantDTO; import org.dinky.data.dto.LoginDTO; import org.dinky.data.dto.ModifyPasswordDTO; import org.dinky.data.dto.UserDTO; @@ -39,8 +41,6 @@ import org.dinky.data.model.rbac.User; import org.dinky.data.model.rbac.UserRole; import org.dinky.data.model.rbac.UserTenant; -import org.dinky.data.params.AssignRoleParams; -import org.dinky.data.params.AssignUserToTenantParams; import org.dinky.data.result.Result; import org.dinky.data.vo.UserVo; import org.dinky.mapper.TokenMapper; @@ -278,7 +278,7 @@ private User ldapLogin(LoginDTO loginDTO) throws AuthException { List userIds = getUserIdsByTenantId(tenant.getId()); User user = getUserByUsername(loginDTO.getUsername()); userIds.add(user.getId()); - tenantService.assignUserToTenant(new AssignUserToTenantParams(tenant.getId(), userIds)); + tenantService.assignUserToTenant(new AssignUserToTenantDTO(tenant.getId(), userIds)); return user; } else if (userFromLocal.getUserType() != UserType.LDAP.getCode()) { loginLogService.saveLoginLog(userFromLocal, Status.LDAP_LOGIN_FORBID); @@ -303,13 +303,12 @@ public User getUserByUsername(String username) { @Override @Transactional(rollbackFor = Exception.class) - public Result assignRole(AssignRoleParams assignRoleParams) { + public Result assignRole(AssignRoleDTO assignRoleDTO) { List userRoleList = new ArrayList<>(); - userRoleService.remove( - new LambdaQueryWrapper().eq(UserRole::getUserId, assignRoleParams.getUserId())); - for (Integer roleId : assignRoleParams.getRoleIds()) { + userRoleService.remove(new LambdaQueryWrapper().eq(UserRole::getUserId, assignRoleDTO.getUserId())); + for (Integer roleId : assignRoleDTO.getRoleIds()) { UserRole userRole = new UserRole(); - userRole.setUserId(assignRoleParams.getUserId()); + userRole.setUserId(assignRoleDTO.getUserId()); userRole.setRoleId(roleId); userRoleList.add(userRole); } diff --git a/dinky-admin/src/main/resources/db/db-h2-ddl.sql b/dinky-admin/src/main/resources/db/db-h2-ddl.sql index ebdf14d15e..d1763015d2 100644 --- a/dinky-admin/src/main/resources/db/db-h2-ddl.sql +++ b/dinky-admin/src/main/resources/db/db-h2-ddl.sql @@ -10,7 +10,10 @@ CREATE TABLE `dinky_alert_group` ( `note` varchar(255) null DEFAULT null COMMENT 'note', `enabled` tinyint(4) null DEFAULT 1 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' + ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_alert_history` ( @@ -34,7 +37,9 @@ CREATE TABLE `dinky_alert_instance` ( `params` text null COMMENT 'configuration', `enabled` tinyint(4) null DEFAULT 1 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update time', + `creator` int(11) null DEFAULT 1 COMMENT 'creator', + `updater` int(11) null DEFAULT 1 COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_catalogue` ( @@ -47,7 +52,9 @@ CREATE TABLE `dinky_catalogue` ( `enabled` tinyint(1) NOT null DEFAULT 1 COMMENT 'is enable', `is_leaf` tinyint(1) NOT null COMMENT 'is leaf node', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_cluster` ( @@ -66,7 +73,9 @@ CREATE TABLE `dinky_cluster` ( `task_id` int(11) null DEFAULT null COMMENT 'task ID', `enabled` tinyint(1) NOT null DEFAULT 1 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_cluster_configuration` ( @@ -79,7 +88,9 @@ CREATE TABLE `dinky_cluster_configuration` ( `note` varchar(255) null DEFAULT null COMMENT 'note', `enabled` tinyint(1) NOT null DEFAULT 1 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_database` ( @@ -102,7 +113,9 @@ CREATE TABLE `dinky_database` ( `heartbeat_time` datetime(0) null DEFAULT null COMMENT 'last heartbeat time', `enabled` tinyint(1) NOT null DEFAULT 1 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_flink_document` ( @@ -117,7 +130,9 @@ CREATE TABLE `dinky_flink_document` ( `like_num` int(11) null DEFAULT 0 COMMENT 'like number', `enabled` tinyint(1) NOT null DEFAULT 0 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update_time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update_time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; @@ -129,7 +144,9 @@ CREATE TABLE `dinky_fragment` ( `note` text null COMMENT 'note', `enabled` tinyint(4) null DEFAULT 1 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime(0) null DEFAULT null COMMENT 'update time' + `update_time` datetime(0) null DEFAULT null COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_history` ( @@ -184,6 +201,9 @@ CREATE TABLE `dinky_job_instance` ( `duration` bigint(20) null DEFAULT null COMMENT 'job duration', `error` text null COMMENT 'error logs', `failed_restart_count` int(11) null DEFAULT null COMMENT 'failed restart count', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater', + `operator` int(11) null DEFAULT null COMMENT 'operator', INDEX job_instance_task_id_idx13(`task_id`) ) ENGINE = InnoDB ROW_FORMAT = Dynamic; @@ -208,7 +228,8 @@ CREATE TABLE `dinky_savepoints` ( `name` varchar(255) NOT null COMMENT 'task name', `type` varchar(255) NOT null COMMENT 'savepoint type', `path` varchar(255) NOT null COMMENT 'savepoint path', - `create_time` datetime(0) null DEFAULT null COMMENT 'create time' + `create_time` datetime(0) null DEFAULT null COMMENT 'create time', + `creator` int(11) null DEFAULT null COMMENT 'creator' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; @@ -246,7 +267,10 @@ CREATE TABLE `dinky_task` ( `create_time` datetime(0) null DEFAULT null COMMENT 'create time', `update_time` datetime(0) null DEFAULT null COMMENT 'update time', `version_id` int(11) null DEFAULT null COMMENT 'version id', - `statement` text null DEFAULT null COMMENT 'statement' + `statement` text null DEFAULT null COMMENT 'statement', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater', + `operator` int(11) null DEFAULT null COMMENT 'operator' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; @@ -260,7 +284,8 @@ CREATE TABLE `dinky_task_version` ( `dialect` varchar(50) null DEFAULT null COMMENT 'dialect', `type` varchar(50) null DEFAULT null COMMENT 'type', `task_configure` text NOT null COMMENT 'task configuration', - `create_time` datetime(0) null DEFAULT null COMMENT 'create time' + `create_time` datetime(0) null DEFAULT null COMMENT 'create time', + `creator` int(11) null DEFAULT null COMMENT 'creator' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; CREATE TABLE `dinky_tenant` ( @@ -281,7 +306,9 @@ CREATE TABLE `dinky_udf_template` ( `template_code` longtext null COMMENT 'code', `enabled` tinyint(1) not null DEFAULT 1 COMMENT 'is enable', `create_time` datetime(0) null DEFAULT null COMMENT 'create time', - `update_time` datetime DEFAULT null ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time' + `update_time` datetime DEFAULT null ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = Dynamic; @@ -390,7 +417,9 @@ CREATE TABLE dinky_row_permissions ( table_name varchar(255) null COMMENT '表名', expression varchar(255) null COMMENT '表达式', create_time datetime null COMMENT '创建时间', - update_time datetime null COMMENT '更新时间' + update_time datetime null COMMENT '更新时间', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ); SET FOREIGN_KEY_CHECKS = 1; @@ -415,7 +444,11 @@ CREATE TABLE `dinky_git_project` ( `udf_class_map_list` text COMMENT 'scan udf class', `order_line` int(11) NOT null DEFAULT '1' COMMENT 'order', `create_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP COMMENT 'create time', - `update_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time' + `update_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater', + `operator` int(11) null DEFAULT null COMMENT 'operator' + ) ENGINE = InnoDB; @@ -445,7 +478,9 @@ CREATE TABLE `dinky_resources` ( `full_name` varchar(128) DEFAULT null, `is_directory` tinyint(4) DEFAULT null, `create_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP COMMENT 'create time', - `update_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time' + `update_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time', + `creator` int(11) null DEFAULT null COMMENT 'creator', + `updater` int(11) null DEFAULT null COMMENT 'updater' ) ENGINE = InnoDB; @@ -532,7 +567,7 @@ CREATE TABLE `dinky_sys_role_menu` ( -- ---------------------------- --- Table structure dinky_sys_token +-- Table structure updater -- ---------------------------- CREATE TABLE `dinky_sys_token` ( @@ -546,9 +581,9 @@ CREATE TABLE `dinky_sys_token` ( `expire_end_time` datetime DEFAULT NULL COMMENT 'expire end time ,when expire_type = 2,3 , it is the end time of the period', `create_time` datetime NOT NULL COMMENT 'create time', `update_time` datetime NOT NULL COMMENT 'modify time', - `creator` bigint DEFAULT NULL COMMENT '创建人', - `updator` bigint DEFAULT NULL COMMENT '修改人', `source` tinyint(2) DEFAULT NULL COMMENT '1:login 2:custom', + `creator` bigint DEFAULT NULL COMMENT 'creator', + `updater` bigint DEFAULT NULL COMMENT 'updater', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COMMENT='token management'; @@ -566,7 +601,9 @@ create table if not exists dinky_alert_template template_content text null COMMENT 'template content', enabled tinyint default 1 null COMMENT 'is enable', create_time datetime null COMMENT 'create time', - update_time datetime null COMMENT 'update time' + update_time datetime null COMMENT 'update time', + `creator` bigint DEFAULT NULL COMMENT 'creator', + `updater` bigint DEFAULT NULL COMMENT 'updater' ); @@ -582,7 +619,9 @@ create table if not exists dinky_alert_rules description text null comment 'description', enabled tinyint default 1 null comment 'is enable', create_time datetime null comment 'create time', - update_time datetime null comment 'update time' + update_time datetime null comment 'update time', + `creator` bigint DEFAULT NULL COMMENT 'creator', +`updater` bigint DEFAULT NULL COMMENT 'updater' ); @@ -596,5 +635,7 @@ CREATE TABLE IF NOT EXISTS `dinky_udf_manage` ( `resources_id` int(11) DEFAULT NULL COMMENT 'resources id', `enabled` tinyint(1) DEFAULT 1 COMMENT 'is enable', `create_time` datetime DEFAULT NULL COMMENT 'create time', - `update_time` datetime DEFAULT NULL COMMENT 'update time' + `update_time` datetime DEFAULT NULL COMMENT 'update time', + `creator` bigint DEFAULT NULL COMMENT 'creator', + `updater` bigint DEFAULT NULL COMMENT 'updater' ) ENGINE = InnoDB ROW_FORMAT = DYNAMIC; diff --git a/dinky-admin/src/main/resources/db/db-h2-dml.sql b/dinky-admin/src/main/resources/db/db-h2-dml.sql index f235d11e9d..c12457d4dd 100644 --- a/dinky-admin/src/main/resources/db/db-h2-dml.sql +++ b/dinky-admin/src/main/resources/db/db-h2-dml.sql @@ -512,7 +512,7 @@ VALUES (1, 'Default', ' - **End Time :** ${endTime} - **${(exceptions.rootException)?substring(0,20)}** [Go toTask Web](http://${taskUrl}) -', 1, null, null); +', 1, current_timestamp, current_timestamp,null,null); INSERT INTO `dinky_udf_template` VALUES ( 1, 'java_udf', 'Java', 'UDF', '${(package=='''')?string('''',''package ''+package+'';'')} @@ -524,7 +524,7 @@ public class ${className} extends ScalarFunction { return null; } }' - , 1, '2022-10-19 09:17:37', '2022-10-25 17:45:57'); + , 1, '2022-10-19 09:17:37', '2022-10-25 17:45:57',null,null); INSERT INTO `dinky_udf_template` VALUES ( 2, 'java_udtf', 'Java', 'UDTF', '${(package=='''')?string('''',''package ''+package+'';'')} @@ -540,7 +540,7 @@ public static class ${className} extends TableFunction { } } }' - , 1, '2022-10-19 09:22:58', '2022-10-25 17:49:30'); + , 1, '2022-10-19 09:22:58', '2022-10-25 17:49:30',null,null); INSERT INTO `dinky_udf_template` VALUES ( 3, 'scala_udf', 'Scala', 'UDF', '${(package=='''')?string('''',''package ''+package+'';'')} @@ -553,7 +553,7 @@ class ${className} extends ScalarFunction { "this is scala" } }' - , 1, '2022-10-25 09:21:32', '2022-10-25 17:49:46'); + , 1, '2022-10-25 09:21:32', '2022-10-25 17:49:46',null,null); INSERT INTO `dinky_udf_template` VALUES ( 4, 'python_udf_1', 'Python', 'UDF', 'from pyflink.table import ScalarFunction, DataTypes from pyflink.table.udf import udf @@ -567,7 +567,7 @@ class ${className}(ScalarFunction): ${attr!''f''} = udf(${className}(), result_type=DataTypes.STRING())' - , 1, '2022-10-25 09:23:07', '2022-10-25 09:34:01'); + , 1, '2022-10-25 09:23:07', '2022-10-25 09:34:01',null,null); INSERT INTO `dinky_udf_template` VALUES ( 5, 'python_udf_2', 'Python', 'UDF', 'from pyflink.table import DataTypes from pyflink.table.udf import udf @@ -575,7 +575,7 @@ from pyflink.table.udf import udf @udf(result_type=DataTypes.STRING()) def ${className}(variable1:str): return ''''' - , 1, '2022-10-25 09:25:13', '2022-10-25 09:34:47'); + , 1, '2022-10-25 09:25:13', '2022-10-25 09:34:47',null,null); INSERT INTO `dinky_flink_document` ( `id`, `category`, `type`, `subtype`, `name` , `description`, `fill_value`, `version`, `like_num`, `enabled` @@ -2691,7 +2691,11 @@ AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;', 'All Versions , '2023-10-31 16:41:46', '2023-10-31 16:43:29'); -INSERT INTO `dinky_flink_document` (id, category, type, subtype, name, description, fill_value, version, like_num, enabled, create_time, update_time) VALUES (244, 'Reference', '建表语句', 'Batch/Streaming', 'datagen job demo', 'datagen job demo', 'DROP TABLE IF EXISTS source_table3; +INSERT INTO `dinky_flink_document` (id, category, type, subtype, name + , description, fill_value, version, like_num, enabled + , create_time, update_time) +VALUES (244, 'Reference', '建表语句', 'Batch/Streaming', 'datagen job demo' + , 'datagen job demo', 'DROP TABLE IF EXISTS source_table3; CREATE TABLE IF NOT EXISTS source_table3( --订单id `order_id` BIGINT, @@ -2704,16 +2708,16 @@ CREATE TABLE IF NOT EXISTS source_table3( --支付时间 `order_time` as CAST(CURRENT_TIMESTAMP AS TIMESTAMP(3)), -- `在这里插入代码片` --WATERMARK -WATERMARK FOR order_time AS order_time - INTERVAL \'2\' SECOND +WATERMARK FOR order_time AS order_time - INTERVAL ''2'' SECOND ) WITH( -\'connector\' = \'datagen\', - \'rows-per-second\' = \'1\', - \'fields.order_id.min\' = \'1\', - \'fields.order_id.max\' = \'2\', - \'fields.amount.min\' = \'1\', - \'fields.amount.max\' = \'10\', - \'fields.product.min\' = \'1\', - \'fields.product.max\' = \'2\' +''connector'' = ''datagen'', + ''rows-per-second'' = ''1'', + ''fields.order_id.min'' = ''1'', + ''fields.order_id.max'' = ''2'', + ''fields.amount.min'' = ''1'', + ''fields.amount.max'' = ''10'', + ''fields.product.min'' = ''1'', + ''fields.product.max'' = ''2'' ); -- SELECT * FROM source_table3 LIMIT 10; @@ -2729,7 +2733,7 @@ CREATE TABLE IF NOT EXISTS sink_table5( --1分钟时间聚合总数 `one_minute_sum` BIGINT ) WITH( -\'connector\'=\'print\' +''connector''=''print'' ); INSERT INTO sink_table5 @@ -2741,18 +2745,25 @@ SUM(amount) OVER( PARTITION BY product ORDER BY order_time -- 标识统计范围是1个 product 的最近 1 分钟的数据 -RANGE BETWEEN INTERVAL \'1\' MINUTE PRECEDING AND CURRENT ROW +RANGE BETWEEN INTERVAL ''1'' MINUTE PRECEDING AND CURRENT ROW ) as one_minute_sum -FROM source_table3;', 'All Versions', 0, 1, '2023-11-15 15:42:16', '2023-11-15 15:42:16'); +FROM source_table3;', 'All Versions', 0, 1 + , '2023-11-15 15:42:16', '2023-11-15 15:42:16'); -INSERT INTO dinky_flink_document (id, category, type, subtype, name, description, fill_value, version, like_num, enabled, create_time, update_time) VALUES (245, 'Property', '优化参数', 'Streaming', 'checkpoint config', 'checkpoint config', '-- 声明一些调优参数 (checkpoint 等相关配置) -set \'execution.checkpointing.checkpoints-after-tasks-finish.enabled\' =\'true\'; -SET \'pipeline.operator-chaining\' = \'false\'; -set \'state.savepoints.dir\'=\'file:///opt/data/flink_cluster/savepoints\'; -- 目录自行修改 -set \'state.checkpoints.dir\'= \'file:///opt/data/flink_cluster/checkpoints\'; -- 目录自行修改 --- set state.checkpoint-storage=\'filesystem\'; -set \'state.backend.type\'=\'rocksdb\'; -set \'execution.checkpointing.interval\'=\'60 s\'; -set \'state.checkpoints.num-retained\'=\'100\'; + +INSERT INTO dinky_flink_document (id, category, type, subtype, name + , description, fill_value, version, like_num, enabled + , create_time, update_time) +VALUES (245, 'Property', '优化参数', 'Streaming', 'checkpoint config' + , 'checkpoint config', '-- 声明一些调优参数 (checkpoint 等相关配置) +set ''execution.checkpointing.checkpoints-after-tasks-finish.enabled'' =''true''; +SET ''pipeline.operator-chaining'' = ''false''; +set ''state.savepoints.dir''=''file:///opt/data/flink_cluster/savepoints''; -- 目录自行修改 +set ''state.checkpoints.dir''= ''file:///opt/data/flink_cluster/checkpoints''; -- 目录自行修改 +-- set state.checkpoint-storage=''filesystem''; +set ''state.backend.type''=''rocksdb''; +set ''execution.checkpointing.interval''=''60 s''; +set ''state.checkpoints.num-retained''=''100''; -- 使 solt 均匀分布在 各个 TM 上 -set \'cluster.evenly-spread-out-slots\'=\'true\';', 'All Versions', 0, 1, '2023-11-15 15:57:42', '2023-11-15 15:57:42'); +set ''cluster.evenly-spread-out-slots''=''true'';', 'All Versions', 0, 1 + , '2023-11-15 15:57:42', '2023-11-15 15:57:42');