Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sql bug of h2 #2534

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -129,26 +129,26 @@ public Result<Void> 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<Void> dragendSortJar(@RequestBody GitProjectSortJarParams gitProjectSortJarParams) {
GitProject gitProjectServiceById = gitProjectService.getById(gitProjectSortJarParams.getProjectId());
public Result<Void> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,21 +122,21 @@ public ProTableResult<Tenant> 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<Void> assignUserToTenant(@RequestBody AssignUserToTenantParams assignUserToTenantParams) {
return tenantService.assignUserToTenant(assignUserToTenantParams);
public Result<Void> assignUserToTenant(@RequestBody AssignUserToTenantDTO assignUserToTenantDTO) {
return tenantService.assignUserToTenant(assignUserToTenantDTO);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -194,22 +194,22 @@ public Result<Void> 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<Void> assignRole(@RequestBody AssignRoleParams assignRoleParams) {
return userService.assignRole(assignRoleParams);
public Result<Void> assignRole(@RequestBody AssignRoleDTO assignRoleDTO) {
return userService.assignRole(assignRoleDTO);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

package org.dinky.data.params;
package org.dinky.data.dto;

import java.util.List;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

package org.dinky.data.params;
package org.dinky.data.dto;

import java.util.List;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,10 +50,10 @@ public interface GitProjectService extends ISuperService<GitProject> {
/**
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -78,8 +78,8 @@ public interface TenantService extends ISuperService<Tenant> {
/**
* assignUserToTenant users to tenant
*
* @param assignUserToTenantParams {@link AssignUserToTenantParams}
* @param assignUserToTenantDTO {@link AssignUserToTenantDTO}
* @return {@link Result} of {@link Void}
*/
Result<Void> assignUserToTenant(AssignUserToTenantParams assignUserToTenantParams);
Result<Void> assignUserToTenant(AssignUserToTenantDTO assignUserToTenantDTO);
}
6 changes: 3 additions & 3 deletions dinky-admin/src/main/java/org/dinky/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

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;
import org.dinky.data.model.rbac.Role;
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;
Expand Down Expand Up @@ -91,10 +91,10 @@ public interface UserService extends ISuperService<User> {
/**
* grant role
*
* @param assignRoleParams {@link AssignRoleParams}
* @param assignRoleDTO {@link AssignRoleDTO}
* @return {@link Result}<{@link Void}>
*/
Result<Void> assignRole(AssignRoleParams assignRoleParams);
Result<Void> assignRole(AssignRoleDTO assignRoleDTO);

/**
* choose tenant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -166,11 +166,11 @@ public Result<Void> removeTenantById(Integer tenantId) {

@Override
@Transactional(rollbackFor = Exception.class)
public Result<Void> assignUserToTenant(AssignUserToTenantParams assignUserToTenantParams) {
public Result<Void> assignUserToTenant(AssignUserToTenantDTO assignUserToTenantDTO) {
List<UserTenant> tenantUserList = new ArrayList<>();
Integer tenantId = assignUserToTenantParams.getTenantId();
Integer tenantId = assignUserToTenantDTO.getTenantId();
userTenantService.remove(new LambdaQueryWrapper<UserTenant>().eq(UserTenant::getTenantId, tenantId));
List<Integer> userIds = assignUserToTenantParams.getUserIds();
List<Integer> userIds = assignUserToTenantDTO.getUserIds();
for (Integer userId : userIds) {
UserTenant userTenant = new UserTenant();
userTenant.setTenantId(tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -278,7 +278,7 @@ private User ldapLogin(LoginDTO loginDTO) throws AuthException {
List<Integer> 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);
Expand All @@ -303,13 +303,12 @@ public User getUserByUsername(String username) {

@Override
@Transactional(rollbackFor = Exception.class)
public Result<Void> assignRole(AssignRoleParams assignRoleParams) {
public Result<Void> assignRole(AssignRoleDTO assignRoleDTO) {
List<UserRole> userRoleList = new ArrayList<>();
userRoleService.remove(
new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, assignRoleParams.getUserId()));
for (Integer roleId : assignRoleParams.getRoleIds()) {
userRoleService.remove(new LambdaQueryWrapper<UserRole>().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);
}
Expand Down
Loading
Loading