完善基础代码
This commit is contained in:
parent
b693d3472c
commit
1c361deef3
@ -10,5 +10,5 @@ package ink.wgink.interfaces.role;
|
||||
* @Date: 2021/1/24 12:57
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IRoleService {
|
||||
public interface IRoleBaseService {
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
package ink.wgink.pojo.dtos.department;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName: DepartmentUserDTO
|
||||
* @Description: 部门用户
|
||||
* @Author: wenc
|
||||
* @Date: 2019/1/10 10:39 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public class DepartmentUserDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2899875759045646539L;
|
||||
private String userId;
|
||||
private String departmentId;
|
||||
private String userUsername;
|
||||
private String userName;
|
||||
private String userPhone;
|
||||
private String userEmail;
|
||||
private String userUKey;
|
||||
private String userUKeyElectronicSecretKey;
|
||||
private Integer loginType;
|
||||
private String departmentName;
|
||||
private Integer userType;
|
||||
private Integer userState;
|
||||
private String userAvatar;
|
||||
private String userSort;
|
||||
|
||||
public String getUserId() {
|
||||
return userId == null ? "" : userId.trim();
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getDepartmentId() {
|
||||
return departmentId == null ? "" : departmentId.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentId(String departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getUserUsername() {
|
||||
return userUsername == null ? "" : userUsername.trim();
|
||||
}
|
||||
|
||||
public void setUserUsername(String userUsername) {
|
||||
this.userUsername = userUsername;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName == null ? "" : userName.trim();
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return userPhone == null ? "" : userPhone.trim();
|
||||
}
|
||||
|
||||
public void setUserPhone(String userPhone) {
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
public String getUserEmail() {
|
||||
return userEmail == null ? "" : userEmail.trim();
|
||||
}
|
||||
|
||||
public void setUserEmail(String userEmail) {
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
|
||||
public String getUserUKey() {
|
||||
return userUKey == null ? "" : userUKey;
|
||||
}
|
||||
|
||||
public void setUserUKey(String userUKey) {
|
||||
this.userUKey = userUKey;
|
||||
}
|
||||
|
||||
public String getUserUKeyElectronicSecretKey() {
|
||||
return userUKeyElectronicSecretKey == null ? "" : userUKeyElectronicSecretKey.trim();
|
||||
}
|
||||
|
||||
public void setUserUKeyElectronicSecretKey(String userUKeyElectronicSecretKey) {
|
||||
this.userUKeyElectronicSecretKey = userUKeyElectronicSecretKey;
|
||||
}
|
||||
|
||||
public Integer getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(Integer loginType) {
|
||||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
public String getDepartmentName() {
|
||||
return departmentName == null ? "" : departmentName.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentName(String departmentName) {
|
||||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public Integer getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(Integer userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public Integer getUserState() {
|
||||
return userState;
|
||||
}
|
||||
|
||||
public void setUserState(Integer userState) {
|
||||
this.userState = userState;
|
||||
}
|
||||
|
||||
public String getUserAvatar() {
|
||||
return userAvatar == null ? "" : userAvatar.trim();
|
||||
}
|
||||
|
||||
public void setUserAvatar(String userAvatar) {
|
||||
this.userAvatar = userAvatar;
|
||||
}
|
||||
|
||||
public String getUserSort() {
|
||||
return userSort == null ? "" : userSort.trim();
|
||||
}
|
||||
|
||||
public void setUserSort(String userSort) {
|
||||
this.userSort = userSort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"userId\":")
|
||||
.append("\"").append(userId).append("\"");
|
||||
sb.append(",\"departmentId\":")
|
||||
.append("\"").append(departmentId).append("\"");
|
||||
sb.append(",\"userUsername\":")
|
||||
.append("\"").append(userUsername).append("\"");
|
||||
sb.append(",\"userName\":")
|
||||
.append("\"").append(userName).append("\"");
|
||||
sb.append(",\"userPhone\":")
|
||||
.append("\"").append(userPhone).append("\"");
|
||||
sb.append(",\"userEmail\":")
|
||||
.append("\"").append(userEmail).append("\"");
|
||||
sb.append(",\"userUKey\":")
|
||||
.append("\"").append(userUKey).append("\"");
|
||||
sb.append(",\"userUKeyElectronicSecretKey\":")
|
||||
.append("\"").append(userUKeyElectronicSecretKey).append("\"");
|
||||
sb.append(",\"loginType\":")
|
||||
.append(loginType);
|
||||
sb.append(",\"departmentName\":")
|
||||
.append("\"").append(departmentName).append("\"");
|
||||
sb.append(",\"userType\":")
|
||||
.append(userType);
|
||||
sb.append(",\"userState\":")
|
||||
.append(userState);
|
||||
sb.append(",\"userAvatar\":")
|
||||
.append("\"").append(userAvatar).append("\"");
|
||||
sb.append(",\"userSort\":")
|
||||
.append("\"").append(userSort).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package ink.wgink.pojo.dtos.permission;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: PermissionDTO
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class PermissionDTO {
|
||||
|
||||
@ApiModelProperty(name = "permissionId", value = "主键")
|
||||
private String permissionId;
|
||||
@ApiModelProperty(name = "permissionTitle", value = "权限名称")
|
||||
private String permissionTitle;
|
||||
@ApiModelProperty(name = "permissionType", value = "权限类型")
|
||||
private String permissionType;
|
||||
@ApiModelProperty(name = "permissionUrl", value = "权限路径")
|
||||
private String permissionUrl;
|
||||
@ApiModelProperty(name = "permissionClientId", value = "客户端")
|
||||
private String permissionClientId;
|
||||
@ApiModelProperty(name = "permissionClientName", value = "客户端字典名称")
|
||||
private String permissionClientName;
|
||||
@ApiModelProperty(name = "isPublic", value = "是否公共")
|
||||
private Integer isPublic;
|
||||
|
||||
public String getPermissionId() {
|
||||
return permissionId == null ? "" : permissionId;
|
||||
}
|
||||
|
||||
public void setPermissionId(String permissionId) {
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
|
||||
public String getPermissionTitle() {
|
||||
return permissionTitle == null ? "" : permissionTitle.trim();
|
||||
}
|
||||
|
||||
public void setPermissionTitle(String permissionTitle) {
|
||||
this.permissionTitle = permissionTitle;
|
||||
}
|
||||
|
||||
public String getPermissionType() {
|
||||
return permissionType == null ? "" : permissionType;
|
||||
}
|
||||
|
||||
public void setPermissionType(String permissionType) {
|
||||
this.permissionType = permissionType;
|
||||
}
|
||||
|
||||
public String getPermissionUrl() {
|
||||
return permissionUrl == null ? "" : permissionUrl;
|
||||
}
|
||||
|
||||
public void setPermissionUrl(String permissionUrl) {
|
||||
this.permissionUrl = permissionUrl;
|
||||
}
|
||||
|
||||
public String getPermissionClientId() {
|
||||
return permissionClientId == null ? "" : permissionClientId;
|
||||
}
|
||||
|
||||
public void setPermissionClientId(String permissionClientId) {
|
||||
this.permissionClientId = permissionClientId;
|
||||
}
|
||||
|
||||
public String getPermissionClientName() {
|
||||
return permissionClientName == null ? "" : permissionClientName.trim();
|
||||
}
|
||||
|
||||
public void setPermissionClientName(String permissionClientName) {
|
||||
this.permissionClientName = permissionClientName;
|
||||
}
|
||||
|
||||
public Integer getIsPublic() {
|
||||
return isPublic == null ? 0 : isPublic;
|
||||
}
|
||||
|
||||
public void setIsPublic(Integer isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"permissionId\":")
|
||||
.append("\"").append(permissionId).append("\"");
|
||||
sb.append(",\"permissionTitle\":")
|
||||
.append("\"").append(permissionTitle).append("\"");
|
||||
sb.append(",\"permissionType\":")
|
||||
.append("\"").append(permissionType).append("\"");
|
||||
sb.append(",\"permissionUrl\":")
|
||||
.append("\"").append(permissionUrl).append("\"");
|
||||
sb.append(",\"permissionClientId\":")
|
||||
.append("\"").append(permissionClientId).append("\"");
|
||||
sb.append(",\"permissionClientName\":")
|
||||
.append("\"").append(permissionClientName).append("\"");
|
||||
sb.append(",\"isPublic\":")
|
||||
.append(isPublic);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
135
basic-pojo/src/main/java/ink/wgink/pojo/dtos/role/RoleDTO.java
Normal file
135
basic-pojo/src/main/java/ink/wgink/pojo/dtos/role/RoleDTO.java
Normal file
@ -0,0 +1,135 @@
|
||||
package ink.wgink.pojo.dtos.role;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleDTO
|
||||
* @Description: 角色
|
||||
* @Author: wenc
|
||||
* @Date: 2019/1/6 3:50 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RoleDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7751365464386221023L;
|
||||
@ApiModelProperty(name = "departmentId", value = "角色ID")
|
||||
private String roleId;
|
||||
@ApiModelProperty(name = "roleParentId", value = "上级角色ID")
|
||||
private String roleParentId;
|
||||
@ApiModelProperty(name = "roleParentName", value = "上级角色名称")
|
||||
private String roleParentName;
|
||||
@ApiModelProperty(name = "isParent", value = "是否是上级")
|
||||
private Boolean isParent;
|
||||
@ApiModelProperty(name = "roleName", value = "角色名称")
|
||||
private String roleName;
|
||||
@ApiModelProperty(name = "roleSummary", value = "角色说明")
|
||||
private String roleSummary;
|
||||
@ApiModelProperty(name = "roleCode", value = "角色编码")
|
||||
private String roleCode;
|
||||
@ApiModelProperty(name = "roleDataAuthority", value = "角色数据类型")
|
||||
private String roleDataAuthority;
|
||||
@ApiModelProperty(name = "subRoles", value = "子角色列表")
|
||||
private List<RoleDTO> subRoles;
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId == null ? "" : roleId.trim();
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleParentId() {
|
||||
return roleParentId == null ? "" : roleParentId.trim();
|
||||
}
|
||||
|
||||
public void setRoleParentId(String roleParentId) {
|
||||
this.roleParentId = roleParentId;
|
||||
}
|
||||
|
||||
public String getRoleParentName() {
|
||||
return roleParentName == null ? "" : roleParentName.trim();
|
||||
}
|
||||
|
||||
public void setRoleParentName(String roleParentName) {
|
||||
this.roleParentName = roleParentName;
|
||||
}
|
||||
|
||||
public Boolean getParent() {
|
||||
return isParent;
|
||||
}
|
||||
|
||||
public void setParent(Boolean parent) {
|
||||
isParent = parent;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName == null ? "" : roleName.trim();
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getRoleSummary() {
|
||||
return roleSummary == null ? "" : roleSummary.trim();
|
||||
}
|
||||
|
||||
public void setRoleSummary(String roleSummary) {
|
||||
this.roleSummary = roleSummary;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return roleCode == null ? "" : roleCode.trim();
|
||||
}
|
||||
|
||||
public void setRoleCode(String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public String getRoleDataAuthority() {
|
||||
return roleDataAuthority == null ? "" : roleDataAuthority.trim();
|
||||
}
|
||||
|
||||
public void setRoleDataAuthority(String roleDataAuthority) {
|
||||
this.roleDataAuthority = roleDataAuthority;
|
||||
}
|
||||
|
||||
public List<RoleDTO> getSubRoles() {
|
||||
return subRoles;
|
||||
}
|
||||
|
||||
public void setSubRoles(List<RoleDTO> subRoles) {
|
||||
this.subRoles = subRoles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"roleId\":")
|
||||
.append("\"").append(roleId).append("\"");
|
||||
sb.append(",\"roleParentId\":")
|
||||
.append("\"").append(roleParentId).append("\"");
|
||||
sb.append(",\"roleParentName\":")
|
||||
.append("\"").append(roleParentName).append("\"");
|
||||
sb.append(",\"isParent\":")
|
||||
.append(isParent);
|
||||
sb.append(",\"roleName\":")
|
||||
.append("\"").append(roleName).append("\"");
|
||||
sb.append(",\"roleSummary\":")
|
||||
.append("\"").append(roleSummary).append("\"");
|
||||
sb.append(",\"roleCode\":")
|
||||
.append("\"").append(roleCode).append("\"");
|
||||
sb.append(",\"roleDataAuthority\":")
|
||||
.append("\"").append(roleDataAuthority).append("\"");
|
||||
sb.append(",\"subRoles\":")
|
||||
.append(subRoles);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package ink.wgink.pojo.dtos.role;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RoleDataAuthority
|
||||
* @Description: 角色数据权限
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/25 5:42 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RoleDataAuthorityDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -537349124664914120L;
|
||||
@ApiModelProperty(name = "roleId", value = "角色ID")
|
||||
private String roleId;
|
||||
@ApiModelProperty(name = "departmentId", value = "部门ID")
|
||||
private String departmentId;
|
||||
@ApiModelProperty(name = "userId", value = "人员ID")
|
||||
private String userId;
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId == null ? "" : roleId.trim();
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getDepartmentId() {
|
||||
return departmentId == null ? "" : departmentId.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentId(String departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId == null ? "" : userId.trim();
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"roleId\":")
|
||||
.append("\"").append(roleId).append("\"");
|
||||
sb.append(",\"departmentId\":")
|
||||
.append("\"").append(departmentId).append("\"");
|
||||
sb.append(",\"userId\":")
|
||||
.append("\"").append(userId).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package ink.wgink.pojo.dtos.role;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RoleDataAuthorityTypeDTO
|
||||
* @Description: 权限类型
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/25 6:02 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RoleDataAuthorityTypeDTO {
|
||||
|
||||
@ApiModelProperty(name = "roleDataAuthorityType", value = "数据权限类型")
|
||||
private String roleDataAuthorityType;
|
||||
@ApiModelProperty(name = "roleDataAuthority", value = "数据权限")
|
||||
private String roleDataAuthority;
|
||||
|
||||
public String getRoleDataAuthorityType() {
|
||||
return roleDataAuthorityType == null ? "" : roleDataAuthorityType.trim();
|
||||
}
|
||||
|
||||
public void setRoleDataAuthorityType(String roleDataAuthorityType) {
|
||||
this.roleDataAuthorityType = roleDataAuthorityType;
|
||||
}
|
||||
|
||||
public String getRoleDataAuthority() {
|
||||
return roleDataAuthority == null ? "" : roleDataAuthority.trim();
|
||||
}
|
||||
|
||||
public void setRoleDataAuthority(String roleDataAuthority) {
|
||||
this.roleDataAuthority = roleDataAuthority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"roleDataAuthorityType\":")
|
||||
.append("\"").append(roleDataAuthorityType).append("\"");
|
||||
sb.append(",\"roleDataAuthority\":")
|
||||
.append("\"").append(roleDataAuthority).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package ink.wgink.pojo.dtos.role;
|
||||
|
||||
import ink.wgink.pojo.dtos.permission.PermissionDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: PermissionDTO
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RolePermissionDTO extends PermissionDTO {
|
||||
|
||||
@ApiModelProperty(name = "roleId", value = "角色ID")
|
||||
private String roleId;
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId == null ? "" : roleId.trim();
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"roleId\":")
|
||||
.append("\"").append(roleId).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -9,8 +9,7 @@ import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.bos.UserInfoBO;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.util.date.DateUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -26,9 +25,9 @@ import java.util.*;
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DefaultBaseService {
|
||||
|
||||
protected static Logger LOG = LoggerFactory.getLogger(DefaultBaseService.class);
|
||||
@Autowired
|
||||
protected SecurityComponent securityComponent;
|
||||
@Autowired
|
||||
@ -254,7 +253,7 @@ public class DefaultBaseService {
|
||||
} else if (org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.DEPARTMENT.getDataAuthorityType(), dataAuthority)
|
||||
|| org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.CUSTOM.getDataAuthorityType(), dataAuthority)) {
|
||||
if (Objects.isNull(dataAuthorityUserIds) || dataAuthorityUserIds.isEmpty()) {
|
||||
LOG.debug("权限列表为空,设置查看个人");
|
||||
log.debug("权限列表为空,设置查看个人");
|
||||
params.put(ISystemConstant.DATA_AUTHORITY, RoleDataAuthorityEnum.SELF.getDataAuthorityType());
|
||||
params.put(ISystemConstant.DATA_CREATOR, currentUser.getUserId());
|
||||
} else {
|
||||
|
23
module-permission/pom.xml
Normal file
23
module-permission/pom.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>wg-basic</artifactId>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>module-permission</artifactId>
|
||||
<description>权限模块</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,118 @@
|
||||
package ink.wgink.service.permission.controller.api;
|
||||
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.common.component.SecurityComponent;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.CurrentUserIdInfoDTO;
|
||||
import ink.wgink.pojo.dtos.permission.PermissionDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultData;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.permission.pojo.vos.PermissionVO;
|
||||
import ink.wgink.service.permission.service.IPermissionService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: PermissionController
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "权限接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/permission")
|
||||
public class PermissionController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private IPermissionService permissionService;
|
||||
@Autowired
|
||||
private SecurityComponent securityComponent;
|
||||
private AntPathMatcher antPathMatcher = new AntPathMatcher();
|
||||
|
||||
@ApiOperation(value = "新增权限", notes = "新增权限接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult save(@RequestBody PermissionVO permissionVO) {
|
||||
permissionService.save(permissionVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除权限(id列表)", notes = "删除权限(id列表)接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@DeleteMapping("remove/{ids}")
|
||||
public SuccessResult remove(@PathVariable("ids") String ids) {
|
||||
permissionService.remove(Arrays.asList(ids.split("\\_")));
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改权限", notes = "修改权限接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "permissionId", value = "权限ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update/{permissionId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult update(@PathVariable("permissionId") String permissionId, @RequestBody PermissionVO permissionVO) {
|
||||
permissionService.update(permissionId, permissionVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "权限详情(通过ID)", notes = "权限详情(通过ID)接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "permissionId", value = "权限ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("get/{permissionId}")
|
||||
public PermissionDTO get(@PathVariable("permissionId") String permissionId) {
|
||||
return permissionService.get(permissionId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "权限列表", notes = "权限列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list")
|
||||
public List<PermissionDTO> list() {
|
||||
Map<String, Object> params = requestParams();
|
||||
return permissionService.list(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "权限分页列表", notes = "权限分页列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "permissionType", value = "权限类型", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage")
|
||||
public SuccessResultList<List<PermissionDTO>> listPage(ListPage page) {
|
||||
Map<String, Object> params = requestParams();
|
||||
page.setParams(params);
|
||||
return permissionService.listPage(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "权限统计", notes = "权限统计接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("count")
|
||||
SuccessResultData<Integer> count() {
|
||||
Map<String, Object> params = requestParams();
|
||||
return permissionService.count(params);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package ink.wgink.service.permission.dao;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.pojo.dtos.permission.PermissionDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: IPermissionDao
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IPermissionDao {
|
||||
|
||||
/**
|
||||
* 新增权限
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除权限
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void remove(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 删除权限(物理)
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void delete(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 修改权限
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void update(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 权限详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
PermissionDTO get(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<PermissionDTO> list(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 权限统计
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer count(Map<String, Object> params) throws SearchException;
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package ink.wgink.service.permission.pojo.vos;
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import ink.wgink.annotation.CheckNumberAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: PermissionVO
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class PermissionVO {
|
||||
|
||||
@ApiModelProperty(name = "permissionTitle", value = "权限名称")
|
||||
@CheckEmptyAnnotation(name = "权限名称")
|
||||
private String permissionTitle;
|
||||
@ApiModelProperty(name = "permissionType", value = "权限类型")
|
||||
@CheckEmptyAnnotation(name = "权限类型", types = {"permissionInsert", "permissionDelete", "permissionUpdate", "permissionQuery"})
|
||||
private String permissionType;
|
||||
@ApiModelProperty(name = "permissionUrl", value = "权限路径")
|
||||
private String permissionUrl;
|
||||
@ApiModelProperty(name = "permissionClientId", value = "客户端")
|
||||
private String permissionClientId;
|
||||
@ApiModelProperty(name = "isPublic", value = "是否公共")
|
||||
@CheckNumberAnnotation(name = "是否公共", types = {"0", "1"})
|
||||
private Integer isPublic;
|
||||
|
||||
public String getPermissionTitle() {
|
||||
return permissionTitle == null ? "" : permissionTitle;
|
||||
}
|
||||
|
||||
public void setPermissionTitle(String permissionTitle) {
|
||||
this.permissionTitle = permissionTitle;
|
||||
}
|
||||
|
||||
public String getPermissionType() {
|
||||
return permissionType == null ? "" : permissionType;
|
||||
}
|
||||
|
||||
public void setPermissionType(String permissionType) {
|
||||
this.permissionType = permissionType;
|
||||
}
|
||||
|
||||
public String getPermissionUrl() {
|
||||
return permissionUrl == null ? "" : permissionUrl;
|
||||
}
|
||||
|
||||
public void setPermissionUrl(String permissionUrl) {
|
||||
this.permissionUrl = permissionUrl;
|
||||
}
|
||||
|
||||
public String getPermissionClientId() {
|
||||
return permissionClientId == null ? "" : permissionClientId;
|
||||
}
|
||||
|
||||
public void setPermissionClientId(String permissionClientId) {
|
||||
this.permissionClientId = permissionClientId;
|
||||
}
|
||||
|
||||
public Integer getIsPublic() {
|
||||
return isPublic == null ? 0 : isPublic;
|
||||
}
|
||||
|
||||
public void setIsPublic(Integer isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"permissionTitle\":\"")
|
||||
.append(permissionTitle).append('\"');
|
||||
sb.append(",\"permissionType\":\"")
|
||||
.append(permissionType).append('\"');
|
||||
sb.append(",\"permissionUrl\":\"")
|
||||
.append(permissionUrl).append('\"');
|
||||
sb.append(",\"permissionClientId\":\"")
|
||||
.append(permissionClientId).append('\"');
|
||||
sb.append(",\"isPublic\":")
|
||||
.append(isPublic);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package ink.wgink.service.permission.service;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.permission.PermissionDTO;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultData;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.permission.pojo.vos.PermissionVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: IPermissionService
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IPermissionService {
|
||||
|
||||
/**
|
||||
* 新增权限
|
||||
*
|
||||
* @param permissionVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
void save(PermissionVO permissionVO);
|
||||
|
||||
/**
|
||||
* 新增权限
|
||||
*
|
||||
* @param permissionVO
|
||||
* @return permissionId
|
||||
*/
|
||||
String savePermissionReturnId(PermissionVO permissionVO);
|
||||
|
||||
/**
|
||||
* 删除权限
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void remove(List<String> ids);
|
||||
|
||||
/**
|
||||
* 删除权限(物理删除)
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void deletePermission(List<String> ids);
|
||||
|
||||
/**
|
||||
* 修改权限
|
||||
*
|
||||
* @param permissionId
|
||||
* @param permissionVO
|
||||
* @return
|
||||
*/
|
||||
void update(String permissionId, PermissionVO permissionVO);
|
||||
|
||||
/**
|
||||
* 权限详情(通过ID)
|
||||
*
|
||||
* @param permissionId
|
||||
* @return
|
||||
*/
|
||||
PermissionDTO get(String permissionId);
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<PermissionDTO> list(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 权限分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<PermissionDTO>> listPage(ListPage page);
|
||||
|
||||
/**
|
||||
* 权限统计
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Integer countNumberPermission(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 权限统计
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
SuccessResultData<Integer> count(Map<String, Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package ink.wgink.service.permission.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.permission.PermissionDTO;
|
||||
import ink.wgink.pojo.result.SuccessResultData;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.permission.dao.IPermissionDao;
|
||||
import ink.wgink.service.permission.pojo.vos.PermissionVO;
|
||||
import ink.wgink.service.permission.service.IPermissionService;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: PermissionServiceImpl
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
public class PermissionServiceImpl extends DefaultBaseService implements IPermissionService {
|
||||
|
||||
@Autowired
|
||||
private IPermissionDao permissionDao;
|
||||
|
||||
@Override
|
||||
public void save(PermissionVO permissionVO) {
|
||||
savePermissionReturnId(permissionVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String savePermissionReturnId(PermissionVO permissionVO) {
|
||||
String permissionId = UUIDUtil.getUUID();
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(permissionVO);
|
||||
params.put("permissionId", permissionId);
|
||||
setSaveInfo(params);
|
||||
permissionDao.save(params);
|
||||
return permissionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(List<String> ids) {
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
params.put("permissionIds", ids);
|
||||
setUpdateInfo(params);
|
||||
permissionDao.remove(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePermission(List<String> ids) {
|
||||
Map<String, Object> params = getHashMap(3);
|
||||
params.put("permissionIds", ids);
|
||||
permissionDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String permissionId, PermissionVO permissionVO) {
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(permissionVO);
|
||||
params.put("permissionId", permissionId);
|
||||
setUpdateInfo(params);
|
||||
permissionDao.update(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionDTO get(String permissionId) {
|
||||
Map<String, Object> params = super.getHashMap(1);
|
||||
params.put("permissionId", permissionId);
|
||||
return permissionDao.get(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionDTO> list(Map<String, Object> params) {
|
||||
return permissionDao.list(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<PermissionDTO>> listPage(ListPage page) {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<PermissionDTO> permissionDTOs = permissionDao.list(page.getParams());
|
||||
PageInfo<PermissionDTO> pageInfo = new PageInfo<>(permissionDTOs);
|
||||
return new SuccessResultList<>(permissionDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countNumberPermission(Map<String, Object> params) {
|
||||
Integer count = permissionDao.count(params);
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultData<Integer> count(Map<String, Object> params) {
|
||||
return new SuccessResultData<>(countNumberPermission(params));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ink.wgink.service.permission.dao.IPermissionDao">
|
||||
|
||||
<resultMap id="permissionDTO" type="ink.wgink.pojo.dtos.permission.PermissionDTO">
|
||||
<id column="permission_id" property="permissionId"/>
|
||||
<result column="permission_title" property="permissionTitle"/>
|
||||
<result column="permission_type" property="permissionType"/>
|
||||
<result column="permission_url" property="permissionUrl"/>
|
||||
<result column="permission_client_id" property="permissionClientId"/>
|
||||
<result column="permission_client_name" property="permissionClientName"/>
|
||||
<result column="is_public" property="isPublic"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 新增权限 -->
|
||||
<insert id="save" parameterType="map">
|
||||
INSERT INTO sys_permission(
|
||||
permission_id,
|
||||
permission_title,
|
||||
permission_type,
|
||||
permission_url,
|
||||
permission_client_id,
|
||||
is_public,
|
||||
creator,
|
||||
gmt_create,
|
||||
modifier,
|
||||
gmt_modified,
|
||||
is_delete
|
||||
) VALUES(
|
||||
#{permissionId},
|
||||
#{permissionTitle},
|
||||
#{permissionType},
|
||||
#{permissionUrl},
|
||||
#{permissionClientId},
|
||||
#{isPublic},
|
||||
#{creator},
|
||||
#{gmtCreate},
|
||||
#{modifier},
|
||||
#{gmtModified},
|
||||
#{isDelete}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除权限 -->
|
||||
<update id="remove" parameterType="map">
|
||||
UPDATE
|
||||
sys_permission
|
||||
SET
|
||||
is_delete = 1,
|
||||
modifier = #{modifier},
|
||||
gmt_modified = #{gmtModified}
|
||||
WHERE
|
||||
permission_id IN
|
||||
<foreach collection="permissionIds" index="index" open="(" separator="," close=")">
|
||||
#{permissionIds[${index}]}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 删除权限(物理) -->
|
||||
<update id="delete" parameterType="map">
|
||||
DELETE FROM
|
||||
sys_permission
|
||||
WHERE
|
||||
permission_id IN
|
||||
<foreach collection="permissionIds" index="index" open="(" separator="," close=")">
|
||||
#{permissionIds[${index}]}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 修改权限 -->
|
||||
<update id="update" parameterType="map">
|
||||
UPDATE
|
||||
sys_permission
|
||||
SET
|
||||
<if test="permissionTitle != null and permissionTitle != ''">
|
||||
permission_title = #{permissionTitle},
|
||||
</if>
|
||||
<if test="permissionType != null and permissionType != ''">
|
||||
permission_type = #{permissionType},
|
||||
</if>
|
||||
<if test="permissionUrl != null and permissionUrl != ''">
|
||||
permission_url = #{permissionUrl},
|
||||
</if>
|
||||
<if test="permissionClientId != null and permissionClientId != ''">
|
||||
permission_client_id = #{permissionClientId},
|
||||
</if>
|
||||
<if test="isPublic != null">
|
||||
is_public = #{isPublic},
|
||||
</if>
|
||||
modifier = #{modifier},
|
||||
gmt_modified = #{gmtModified}
|
||||
WHERE
|
||||
permission_id = #{permissionId}
|
||||
</update>
|
||||
|
||||
<!-- 权限详情 -->
|
||||
<select id="get" parameterType="map" resultMap="permissionDTO">
|
||||
SELECT
|
||||
t1.permission_title,
|
||||
t1.permission_type,
|
||||
t1.permission_url,
|
||||
t1.permission_client_id,
|
||||
t1.is_public,
|
||||
t1.permission_id
|
||||
FROM
|
||||
sys_permission t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
<if test="permissionId != null and permissionId != ''">
|
||||
AND
|
||||
t1.permission_id = #{permissionId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 权限列表 -->
|
||||
<select id="list" parameterType="map" resultMap="permissionDTO">
|
||||
SELECT
|
||||
t1.permission_title,
|
||||
t1.permission_type,
|
||||
t1.permission_url,
|
||||
t1.permission_client_id,
|
||||
jt1.client_name permission_client_name,
|
||||
t1.is_public,
|
||||
t1.permission_id
|
||||
FROM
|
||||
sys_permission t1
|
||||
LEFT JOIN
|
||||
oauth_client_details jt1
|
||||
ON
|
||||
jt1.client_id = t1.permission_client_id
|
||||
AND
|
||||
jt1.is_delete = 0
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
t1.permission_title LIKE CONCAT('%', #{keywords}, '%')
|
||||
OR
|
||||
jt1.client_name LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="permissionType != null and permissionType != ''">
|
||||
AND
|
||||
t1.permission_type = #{permissionType}
|
||||
</if>
|
||||
<if test="permissionClientId != null and permissionClientId != ''">
|
||||
AND
|
||||
t1.permission_client_id = #{permissionClientId}
|
||||
</if>
|
||||
<if test="isPublic != null">
|
||||
AND
|
||||
t1.is_public = #{isPublic}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND
|
||||
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND
|
||||
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||||
</if>
|
||||
<if test="permissionIds != null and permissionIds.size > 0">
|
||||
AND
|
||||
t1.permission_id IN
|
||||
<foreach collection="permissionIds" index="index" open="(" separator="," close=")">
|
||||
#{permissionIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY
|
||||
t1.permission_url
|
||||
</select>
|
||||
|
||||
<!-- 权限统计 -->
|
||||
<select id="count" parameterType="map" resultType="Integer">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
sys_permission t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,247 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/usercenter/">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="permissionType" name="permissionType">
|
||||
<option value="">选择权限</option>
|
||||
<option value="permissionInsert">新增权限</option>
|
||||
<option value="permissionDelete">删除权限</option>
|
||||
<option value="permissionUpdate">修改权限</option>
|
||||
<option value="permissionQuery">查询权限</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="isPublic" name="isPublic">
|
||||
<option value="">公开类型</option>
|
||||
<option value="1">是</option>
|
||||
<option value="0">否</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item" id="permissionClientIdSelectTemplateBox" lay-filter="permissionClientIdSelectTemplateBox"></div>
|
||||
<script id="permissionClientIdSelectTemplate" type="text/html">
|
||||
<select id="permissionClientId" name="permissionClientId">
|
||||
<option value="">客户端</option>
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<option value="{{item.clientId}}">{{item.clientName}}</option>
|
||||
{{# } }}
|
||||
</select>
|
||||
</script>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
var admin = layui.admin;
|
||||
var laydate = layui.laydate;
|
||||
var common = layui.common;
|
||||
var resizeTimeout = null;
|
||||
var roleId = top.restAjax.params(window.location.href).roleId;
|
||||
var tableUrl = 'api/permission/listpagepermissionwithroleid/'+ roleId;
|
||||
|
||||
// 初始化客户端下拉选择
|
||||
function initPermissionClientIdSelect() {
|
||||
top.restAjax.get(top.restAjax.path('api/oauthclient/listoauthclient', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('permissionClientIdSelectTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('permissionClientIdSelectTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('select', 'permissionClientIdSelectTemplateBox');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
initPermissionClientIdSelect();
|
||||
|
||||
// 初始化表格
|
||||
var tableData;
|
||||
function initTable() {
|
||||
$.extend(table, {config: {checkName: 'checked'}});
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 60,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field: 'permissionUrl', width: 300, title: '权限路径', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field:'permissionTitle', width:200, title: '权限名称', align:'center'},
|
||||
{field: 'permissionType', width: 100, title: '权限类型', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
if(rowData == 'permissionInsert') {
|
||||
return '新增权限';
|
||||
} else if(rowData == 'permissionDelete') {
|
||||
return '删除权限';
|
||||
} else if(rowData == 'permissionUpdate') {
|
||||
return '更新权限';
|
||||
} else if(rowData == 'permissionQuery') {
|
||||
return '查询权限';
|
||||
}
|
||||
return '错误';
|
||||
}
|
||||
},
|
||||
{field: 'permissionClientName', width: 180, title: '客户端名称', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'isPublic', width: 100, title: '公共接口', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(rowData == '0') {
|
||||
return '否';
|
||||
} else if(rowData == '1') {
|
||||
return '是';
|
||||
}
|
||||
return '错误';
|
||||
}
|
||||
},
|
||||
]],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
for(var i = 0, item; item = data.rows[i++];) {
|
||||
if(item.roleId) {
|
||||
item.checked = true;
|
||||
} else {
|
||||
item.checked = false;
|
||||
}
|
||||
}
|
||||
tableData = data.rows;
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateCheckStatus(checked, dataArray) {
|
||||
var permissionIdArray = [];
|
||||
for(var i = 0, item; item = dataArray[i++];) {
|
||||
permissionIdArray.push(item.permissionId);
|
||||
}
|
||||
top.restAjax.put(top.restAjax.path('api/permission/updatepermissionbyroleId/{roleId}', [roleId]), {
|
||||
checked: checked,
|
||||
permissionIdArray: permissionIdArray
|
||||
}, null, function(code, data) {
|
||||
top.dialog.msg('修改成功');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
table.on('checkbox(dataTable)', function(obj) {
|
||||
if(obj.type === 'all') {
|
||||
updateCheckStatus(obj.checked, tableData);
|
||||
} else {
|
||||
var dataArray = [];
|
||||
dataArray.push(obj.data);
|
||||
updateCheckStatus(obj.checked, dataArray);
|
||||
}
|
||||
});
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
permissionType: $('#permissionType').val(),
|
||||
isPublic: $('#isPublic').val(),
|
||||
permissionClientId: $('#permissionClientId').val(),
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 60,
|
||||
});
|
||||
}
|
||||
// 初始化日期
|
||||
function initDate() {
|
||||
// 日期选择
|
||||
laydate.render({
|
||||
elem: '#startTime',
|
||||
format: 'yyyy-MM-dd'
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#endTime',
|
||||
format: 'yyyy-MM-dd'
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
initDate();
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,263 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/usercenter/">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
<!-- 表头按钮组 -->
|
||||
<script type="text/html" id="headerToolBar">
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||
<i class="fa fa-lg fa-plus"></i> 新增
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||||
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||
<i class="fa fa-lg fa-trash"></i> 删除
|
||||
</button>
|
||||
</div>
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var laydate = layui.laydate;
|
||||
var common = layui.common;
|
||||
var resizeTimeout = null;
|
||||
var permissionType = top.restAjax.params(window.location.href).permissionType;
|
||||
var tableUrl = 'api/permission/listpagepermission?permissionType='+ permissionType;
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 90,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: '#headerToolBar',
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field: 'permissionUrl', width: 300, title: '权限路径', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field:'permissionTitle', width:200, title: '权限名称', align:'center'},
|
||||
{field: 'permissionType', width: 100, title: '权限类型', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
if(rowData == 'permissionInsert') {
|
||||
return '新增权限';
|
||||
} else if(rowData == 'permissionDelete') {
|
||||
return '删除权限';
|
||||
} else if(rowData == 'permissionUpdate') {
|
||||
return '更新权限';
|
||||
} else if(rowData == 'permissionQuery') {
|
||||
return '查询权限';
|
||||
}
|
||||
return '错误';
|
||||
}
|
||||
},
|
||||
{field: 'permissionClientName', width: 180, title: '客户端名称', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'isPublic', width: 100, title: '公共接口', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null) {
|
||||
return '-';
|
||||
}
|
||||
if(rowData == '0') {
|
||||
return '否';
|
||||
} else if(rowData == '1') {
|
||||
return '是';
|
||||
}
|
||||
return '错误';
|
||||
}
|
||||
},
|
||||
]],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
startTime: $('#startTime').val(),
|
||||
endTime: $('#endTime').val()
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 90,
|
||||
});
|
||||
}
|
||||
// 初始化日期
|
||||
function initDate() {
|
||||
// 日期选择
|
||||
laydate.render({
|
||||
elem: '#startTime',
|
||||
format: 'yyyy-MM-dd'
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#endTime',
|
||||
format: 'yyyy-MM-dd'
|
||||
});
|
||||
}
|
||||
// 删除
|
||||
function removeData(ids) {
|
||||
top.dialog.msg(top.dataMessage.delete, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var layIndex;
|
||||
top.restAjax.delete(top.restAjax.path('api/permission/removepermission/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||
reloadTable();
|
||||
}, function (code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function () {
|
||||
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function () {
|
||||
top.dialog.close(layIndex);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
initDate();
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
// 事件 - 增删改
|
||||
table.on('toolbar(dataTable)', function(obj) {
|
||||
var layEvent = obj.event;
|
||||
var checkStatus = table.checkStatus('dataTable');
|
||||
var checkDatas = checkStatus.data;
|
||||
if(layEvent === 'saveEvent') {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/permission/save-permission.html?permissionType={permissionType}', [permissionType]),
|
||||
end: function() {
|
||||
reloadTable();
|
||||
}
|
||||
});
|
||||
} else if(layEvent === 'updateEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||
} else if(checkDatas.length > 1) {
|
||||
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||
} else {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/permission/update-permission.html?permissionId={permissionId}', [checkDatas[0].permissionId]),
|
||||
end: function() {
|
||||
reloadTable();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if(layEvent === 'removeEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||
} else {
|
||||
var ids = '';
|
||||
for(var i = 0, item; item = checkDatas[i++];) {
|
||||
if(i > 1) {
|
||||
ids += '_';
|
||||
}
|
||||
ids += item['permissionId'];
|
||||
}
|
||||
removeData(ids);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,158 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/usercenter/">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||
<a href="javascript:void(0);"><cite>新增内容</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 15px;">
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<input type="hidden" id="permissionType" name="permissionType" value="">
|
||||
<blockquote id="permissionTypeName" class="layui-elem-quote" style="display: none;"></blockquote>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权限名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="permissionTitle" name="permissionTitle" class="layui-input" value="" lay-verify="required" placeholder="请输入权限名称" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权限路径</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="permissionUrl" name="permissionUrl" class="layui-input" value="" lay-verify="required" placeholder="请输入权限路径,以'/'开头,符合Ant风格的通配符,例如:/api/**" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">客户端</label>
|
||||
<div class="layui-input-block layui-form" id="permissionClientIdSelectTemplateBox" lay-filter="permissionClientIdSelectTemplateBox"></div>
|
||||
<script id="permissionClientIdSelectTemplate" type="text/html">
|
||||
<select id="permissionClientId" name="permissionClientId">
|
||||
<option value="">请选择客户端</option>
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<option value="{{item.clientId}}">{{item.clientName}}</option>
|
||||
{{# } }}
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">公共接口</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="isPublic" value="0" title="否" checked>
|
||||
<input type="radio" name="isPublic" value="1" title="是">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="left: 0;">
|
||||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
var laydate = layui.laydate;
|
||||
var permissionType = top.restAjax.params(window.location.href).permissionType;
|
||||
$('#permissionType').val(permissionType);
|
||||
if(permissionType === 'permissionInsert') {
|
||||
$('#permissionTypeName').text('新增权限');
|
||||
} else if(permissionType === 'permissionDelete') {
|
||||
$('#permissionTypeName').text('删除权限');
|
||||
} else if(permissionType === 'permissionUpdate') {
|
||||
$('#permissionTypeName').text('修改权限');
|
||||
} else if(permissionType === 'permissionQuery') {
|
||||
$('#permissionTypeName').text('查询权限');
|
||||
} else {
|
||||
$('#permissionTypeName').text('权限错误!');
|
||||
}
|
||||
$('#permissionTypeName').show();
|
||||
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 初始化客户端下拉选择
|
||||
function initPermissionClientIdSelect() {
|
||||
top.restAjax.get(top.restAjax.path('api/oauthclient/listoauthclient', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('permissionClientIdSelectTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('permissionClientIdSelectTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('select', 'permissionClientIdSelectTemplateBox');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
initPermissionClientIdSelect();
|
||||
}
|
||||
initData();
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/permission/savepermission', []), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function(index) {
|
||||
top.dialog.close(index);
|
||||
window.location.reload();
|
||||
},
|
||||
btn2: function() {
|
||||
closeBox();
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 校验
|
||||
form.verify({
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,183 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/usercenter/">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 15px;">
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<input type="hidden" id="permissionType" name="permissionType" value="">
|
||||
<blockquote id="permissionTypeName" class="layui-elem-quote" style="display: none;"></blockquote>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权限名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="permissionTitle" name="permissionTitle" class="layui-input" value="" lay-verify="required" placeholder="请输入权限名称" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权限路径</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="permissionUrl" name="permissionUrl" class="layui-input" value="" lay-verify="required" placeholder="请输入权限路径,以'/'开头,符合Ant风格的通配符,例如:api/**" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">客户端</label>
|
||||
<div class="layui-input-block layui-form" id="permissionClientIdSelectTemplateBox" lay-filter="permissionClientIdSelectTemplateBox"></div>
|
||||
<script id="permissionClientIdSelectTemplate" type="text/html">
|
||||
<select id="permissionClientId" name="permissionClientId">
|
||||
<option value="">请选择客户端</option>
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<option value="{{item.clientId}}">{{item.clientName}}</option>
|
||||
{{# } }}
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">公共接口</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="isPublic" value="0" title="否">
|
||||
<input type="radio" name="isPublic" value="1" title="是">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="left: 0;">
|
||||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
var laydate = layui.laydate;
|
||||
var permissionId = top.restAjax.params(window.location.href).permissionId;
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 初始化客户端下拉选择
|
||||
function initPermissionClientIdSelect(selectValue) {
|
||||
top.restAjax.get(top.restAjax.path('api/oauthclient/listoauthclient', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('permissionClientIdSelectTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('permissionClientIdSelectTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('select', 'permissionClientIdSelectTemplateBox');
|
||||
|
||||
var selectObj = {};
|
||||
selectObj['permissionClientId'] = selectValue;
|
||||
form.val('dataForm', selectObj);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
function initPermissionType() {
|
||||
var permissionType = $('#permissionType').val();
|
||||
if(permissionType === 'permissionInsert') {
|
||||
$('#permissionTypeName').text('新增权限');
|
||||
} else if(permissionType === 'permissionDelete') {
|
||||
$('#permissionTypeName').text('删除权限');
|
||||
} else if(permissionType === 'permissionUpdate') {
|
||||
$('#permissionTypeName').text('修改权限');
|
||||
} else if(permissionType === 'permissionQuery') {
|
||||
$('#permissionTypeName').text('查询权限');
|
||||
} else {
|
||||
$('#permissionTypeName').text('权限错误!');
|
||||
}
|
||||
$('#permissionTypeName').show();
|
||||
}
|
||||
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/permission/getpermissionbyid/{permissionId}', [permissionId]), {}, null, function(code, data) {
|
||||
var dataFormData = {};
|
||||
for(var i in data) {
|
||||
dataFormData[i] = data[i] +'';
|
||||
}
|
||||
form.val('dataForm', dataFormData);
|
||||
form.render(null, 'dataForm');
|
||||
|
||||
initPermissionClientIdSelect(data['permissionClientId']);
|
||||
initPermissionType();
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
initData();
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/permission/updatepermission/{permissionId}', [permissionId]), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function(index) {
|
||||
top.dialog.close(index);
|
||||
window.location.reload();
|
||||
},
|
||||
btn2: function() {
|
||||
closeBox();
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 校验
|
||||
form.verify({
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
1
pom.xml
1
pom.xml
@ -20,6 +20,7 @@
|
||||
<module>service-role</module>
|
||||
<module>module-file</module>
|
||||
<module>module-dictionary</module>
|
||||
<module>module-permission</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
@ -174,7 +175,7 @@ public class DepartmentController extends DefaultBaseController {
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("uploadexcel")
|
||||
public UploadExcelResultDTO uploadExcel(MultipartFile excel) {
|
||||
public UploadExcelResultDTO uploadExcel(MultipartFile excel) throws IOException {
|
||||
if (Objects.isNull(excel)) {
|
||||
throw new ParamsException("Excel不能为空");
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import ink.wgink.service.department.service.IDepartmentService;
|
||||
import ink.wgink.service.department.service.IDepartmentUserService;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
import ink.wgink.util.map.HashMapUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -49,6 +50,7 @@ import java.util.*;
|
||||
* @Date: 2021/1/27 3:53 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DepartmentServiceImpl extends DefaultBaseService implements IDepartmentService {
|
||||
|
||||
@ -142,9 +144,9 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
|
||||
if (departmentDTO == null) {
|
||||
throw new SearchException("机构组织不存在");
|
||||
}
|
||||
LOG.debug("删除已经拆分的组织");
|
||||
log.debug("删除已经拆分的组织");
|
||||
removeByIdReturnDeletedUserIds(departmentId, departmentDTO.getDepartmentName());
|
||||
LOG.debug("新建拆分的组织");
|
||||
log.debug("新建拆分的组织");
|
||||
for (SplitDepartmentInfoVO splitDepartmentInfoVO : splitDepartmentVO.getSplitDepartments()) {
|
||||
String userIds = splitDepartmentInfoVO.getUserIds();
|
||||
String newDepartmentId = saveReturnId(splitDepartmentInfoVO);
|
||||
@ -431,13 +433,13 @@ public class DepartmentServiceImpl extends DefaultBaseService implements IDepart
|
||||
if (mergeDepartmentDTO == null) {
|
||||
throw new SearchException("合并部门不存在");
|
||||
}
|
||||
LOG.debug("新增合并日志");
|
||||
log.debug("新增合并日志");
|
||||
saveAdjustment(mergeDepartmentId, mergeDepartmentDTO.getDepartmentName(), departmentId, departmentDTO.getDepartmentName(), DepartmentAdjustmentTypeEnum.MERGE);
|
||||
LOG.debug("删除需要合并的组织人员");
|
||||
log.debug("删除需要合并的组织人员");
|
||||
List<String> oldDepartmentUserIds = removeByIdReturnDeletedUserIds(mergeDepartmentId, mergeDepartmentDTO.getDepartmentName());
|
||||
departmentUserIds.addAll(oldDepartmentUserIds);
|
||||
}
|
||||
LOG.debug("将合并组织的人员添加到新组织");
|
||||
log.debug("将合并组织的人员添加到新组织");
|
||||
departmentUserService.saveUserIdByDepartmentId(departmentId, departmentName, departmentUserIds);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,12 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>service-user</artifactId>
|
||||
<artifactId>module-permission</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ink.wgink</groupId>
|
||||
<artifactId>service-department</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -1,10 +1,27 @@
|
||||
package ink.wgink.service.role.controller.api;
|
||||
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.*;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityTypeDTO;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.role.pojo.vos.RoleDataAuthorityVO;
|
||||
import ink.wgink.service.role.pojo.vos.RoleUserAuthorizationVO;
|
||||
import ink.wgink.service.role.pojo.vos.RoleVO;
|
||||
import ink.wgink.service.role.service.IRoleService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleController
|
||||
@ -19,4 +36,193 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/role")
|
||||
public class RoleController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private IRoleService roleService;
|
||||
@Autowired
|
||||
private IMenuService menuService;
|
||||
|
||||
@ApiOperation(value = "角色新增", notes = "角色新增接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("saverole")
|
||||
public SuccessResult saveRole(@RequestBody RoleVO roleVO) {
|
||||
Map<String, Object> params = getParams();
|
||||
checkParams(roleVO, params);
|
||||
return roleService.saveRole(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色删除", notes = "通过id列表批量删除角色接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "角色ID列表,用下划线分隔", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@DeleteMapping("removerole/{ids}")
|
||||
public SuccessResult removeRole(@PathVariable("ids") String ids) throws RemoveException {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("roleIds", ids);
|
||||
return roleService.removeRole(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色修改", notes = "角色修改接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("updaterole/{roleId}")
|
||||
public SuccessResult updateRole(@PathVariable("roleId") String roleId, @RequestBody RoleVO roleVO) {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("roleId", roleId);
|
||||
checkParams(roleVO, params);
|
||||
return roleService.updateRole(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数校验
|
||||
*
|
||||
* @param roleVO
|
||||
* @param params
|
||||
* @throws ParamsException
|
||||
*/
|
||||
private void checkParams(RoleVO roleVO, Map<String, Object> params) {
|
||||
if (StringUtils.isBlank(roleVO.getRoleParentId())) {
|
||||
throw new ParamsException("上级ID不能为空");
|
||||
}
|
||||
params.put("roleParentId", roleVO.getRoleParentId());
|
||||
|
||||
if (StringUtils.isBlank(roleVO.getRoleName())) {
|
||||
throw new ParamsException("角色名称不能为空");
|
||||
}
|
||||
params.put("roleName", roleVO.getRoleName());
|
||||
|
||||
params.put("roleSummary", roleVO.getRoleSummary());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色列表", notes = "角色列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleParentId", value = "角色上级ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listrolesalljson/{roleParentId}")
|
||||
public List<RoleDTO> listRoles(@PathVariable("roleParentId") String roleParentId) {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("roleParentId", roleParentId);
|
||||
return roleService.listRolesAllJson(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色详情", notes = "角色详情接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("getrole/{roleId}")
|
||||
public RoleDTO getRole(@PathVariable("roleId") String roleId) {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("roleId", roleId);
|
||||
return roleService.getRole(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "上级ID", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listztreerole")
|
||||
public List<ZTreeDTO> listZTreeRole() throws SearchException {
|
||||
Map<String, Object> params = requestParams();
|
||||
String roleParentId = "0";
|
||||
if (!StringUtils.isBlank(params.get("id") == null ? null : params.get("id").toString())) {
|
||||
roleParentId = params.get("id").toString();
|
||||
}
|
||||
params.put("roleParentId", roleParentId);
|
||||
return roleService.listZTreeRole(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "easyui角色列表", notes = "easyui角色列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpagerole")
|
||||
public SuccessResultList<List<RoleDTO>> listPageRole(ListPage page) throws SearchException {
|
||||
Map<String, Object> params = requestParams();
|
||||
String roleParentId = "0";
|
||||
if (!StringUtils.isBlank(params.get("parentId") == null ? null : params.get("parentId").toString())) {
|
||||
roleParentId = params.get("parentId").toString();
|
||||
}
|
||||
params.put("roleParentId", roleParentId);
|
||||
page.setParams(params);
|
||||
return roleService.listPageRole(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "角色菜单列表", notes = "角色菜单列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "menuParentId", value = "上级菜单ID", paramType = "path", dataType = "String"),
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", dataType = "String"),
|
||||
@ApiImplicitParam(name = "type", value = "类型", paramType = "path", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listmenu/{menuParentId}/{roleId}/{type}")
|
||||
public List<MenuDTO> listMenu(@PathVariable("menuParentId") String menuParentId,
|
||||
@PathVariable("roleId") String roleId,
|
||||
@PathVariable("type") String type) throws SearchException, ParamsException {
|
||||
Map<String, Object> params = requestParams();
|
||||
params.put("menuParentId", menuParentId);
|
||||
params.put("roleId", roleId);
|
||||
if (!IRoleService.AUTH_TYPE_INSERT.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_DELETE.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_UPDATE.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_QUERY.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_MENU.equals(type)) {
|
||||
throw new ParamsException("授权类型错误");
|
||||
}
|
||||
params.put("type", type);
|
||||
if (IRoleService.AUTH_TYPE_MENU.equals(type)) {
|
||||
params.put("menuType", 1);
|
||||
}
|
||||
return menuService.listMenuAllJson(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "执行授权", notes = "执行授权接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", dataType = "String"),
|
||||
@ApiImplicitParam(name = "type", value = "类型", paramType = "path", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("authorization/{roleId}/{type}")
|
||||
public SuccessResult authorization(@PathVariable("roleId") String roleId,
|
||||
@PathVariable("type") String type,
|
||||
@RequestBody RoleUserAuthorizationVO roleUserAuthorizationVO) {
|
||||
Map<String, Object> params = getParams();
|
||||
params.put("roleId", roleId);
|
||||
if (!IRoleService.AUTH_TYPE_INSERT.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_DELETE.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_UPDATE.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_QUERY.equals(type) &&
|
||||
!IRoleService.AUTH_TYPE_MENU.equals(type)) {
|
||||
throw new ParamsException("授权类型错误");
|
||||
}
|
||||
params.put("type", type);
|
||||
params.put("menuIds", roleUserAuthorizationVO.getMenuIds());
|
||||
return roleService.authorization(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新角色数据权限", notes = "更新角色数据权限接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("updateroledataauthority/{roleId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateRoleDataAuthority(@PathVariable("roleId") String roleId, @RequestBody RoleDataAuthorityVO roleDataAuthorityVO) {
|
||||
return roleService.updateRoleDataAuthority(roleId, roleDataAuthorityVO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取角色数据权限类型", notes = "获取角色数据权限类型接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("getroledataauthoritytype/{roleId}")
|
||||
public RoleDataAuthorityTypeDTO getRoleDataAuthorityType(@PathVariable("roleId") String roleId) {
|
||||
return roleService.getRoleDataAuthorityType(roleId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,194 @@
|
||||
package ink.wgink.service.role.dao;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.pojo.bos.RoleBO;
|
||||
import ink.wgink.pojo.bos.RoleMenuBO;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IRoleDao
|
||||
* @Description: 角色
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/31 18:52
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IRoleDao {
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void saveRole(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void removeRole(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 修改角色
|
||||
*
|
||||
* @param params
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateRole(Map<String, Object> params) throws UpdateException;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleDTO> listRole(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
RoleDTO getRole(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
RolePO getRolePO(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 获取最后一个字角色
|
||||
*
|
||||
* @param parentId
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
RoleDTO getLastByParentId(String parentId) throws SearchException;
|
||||
|
||||
/**
|
||||
* 角色ZTree列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<ZTreeDTO> listZTreeRoles(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 子列表个数
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countByParentId(String id) throws SearchException;
|
||||
|
||||
/**
|
||||
* 通过用户获取角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleBO> listRoleBOByUser(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 通过用户组获取角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleBO> listRoleBOByGroup(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 删除角色菜单信息
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void removeRoleMenuInfo(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 保存角色菜单信息
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void saveRoleMenuInfo(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 角色菜单列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleMenuBO> listRoleMenuInfo(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 角色菜单列表详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleMenuBO> listRoleMenuDetail(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 新增自定义角色数据权限
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void saveRoleDataAuthority(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除自定义角色数据权限
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void deleteRoleDataAuthority(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 角色权限列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleDataAuthorityDTO> listRoleDataAuthority(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 统计角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countRole(Map<String, Object> params) throws SearchException;
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package ink.wgink.service.role.dao;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.pojo.dtos.role.RolePermissionDTO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IRolePermissionDao
|
||||
* @Description: 角色权限
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/31 21:24
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Repository
|
||||
public interface IRolePermissionDao {
|
||||
|
||||
/**
|
||||
* 新增权限角色
|
||||
*
|
||||
* @param params
|
||||
* @throws SaveException
|
||||
*/
|
||||
void save(Map<String, Object> params) throws SaveException;
|
||||
|
||||
/**
|
||||
* 删除权限角色
|
||||
*
|
||||
* @param params
|
||||
* @throws RemoveException
|
||||
*/
|
||||
void delete(Map<String, Object> params) throws RemoveException;
|
||||
|
||||
/**
|
||||
* 权限详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
RolePermissionDTO get(Map<String, Object> params) throws SearchException;
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package ink.wgink.service.role.pojo.vos;
|
||||
|
||||
import com.cm.common.annotation.CheckEmptyAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RoleDataAuthorityVO
|
||||
* @Description: 角色数据权限
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/23 8:10 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RoleDataAuthorityVO {
|
||||
|
||||
@ApiModelProperty(name = "dataAuthorityType", value = "数据权限类型")
|
||||
@CheckEmptyAnnotation(name = "数据权限类型", types = {"all", "department", "custom", "self"})
|
||||
private String dataAuthorityType;
|
||||
|
||||
@ApiModelProperty(name = "roleUserAuthorityList", value = "角色数据权限列表")
|
||||
private List<com.cm.serviceusercenter.pojo.vos.role.RoleUserAuthorityVO> roleUserAuthorityList;
|
||||
|
||||
public String getDataAuthorityType() {
|
||||
return dataAuthorityType == null ? "" : dataAuthorityType.trim();
|
||||
}
|
||||
|
||||
public void setDataAuthorityType(String dataAuthorityType) {
|
||||
this.dataAuthorityType = dataAuthorityType;
|
||||
}
|
||||
|
||||
public List<com.cm.serviceusercenter.pojo.vos.role.RoleUserAuthorityVO> getRoleUserAuthorityList() {
|
||||
return roleUserAuthorityList == null ? new ArrayList<>(0) : roleUserAuthorityList;
|
||||
}
|
||||
|
||||
public void setRoleUserAuthorityList(List<com.cm.serviceusercenter.pojo.vos.role.RoleUserAuthorityVO> roleUserAuthorityList) {
|
||||
this.roleUserAuthorityList = roleUserAuthorityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"dataAuthorityType\":")
|
||||
.append("\"").append(dataAuthorityType).append("\"");
|
||||
sb.append(",\"roleUserAuthorityList\":")
|
||||
.append(roleUserAuthorityList);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package ink.wgink.service.role.pojo.vos;
|
||||
|
||||
import ink.wgink.annotation.CheckBooleanAnnotation;
|
||||
import ink.wgink.annotation.CheckListAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: PermissionVO
|
||||
* @Description: 权限
|
||||
* @Author: WenG
|
||||
* @Date: 2020-05-27 15:58
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RolePermissionVO {
|
||||
|
||||
@ApiModelProperty(name = "isChecked", value = "是否选中")
|
||||
@CheckBooleanAnnotation(name = "是否选中")
|
||||
private Boolean isChecked;
|
||||
@ApiModelProperty(name = "permissionIdArray", value = "权限ID列表")
|
||||
@CheckListAnnotation(name = "权限ID列表")
|
||||
private List<String> permissionIdArray;
|
||||
|
||||
public Boolean getChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
public void setChecked(Boolean checked) {
|
||||
isChecked = checked;
|
||||
}
|
||||
|
||||
public List<String> getPermissionIdArray() {
|
||||
return permissionIdArray;
|
||||
}
|
||||
|
||||
public void setPermissionIdArray(List<String> permissionIdArray) {
|
||||
this.permissionIdArray = permissionIdArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"isChecked\":")
|
||||
.append(isChecked);
|
||||
sb.append(",\"permissionIdArray\":")
|
||||
.append(permissionIdArray);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package ink.wgink.service.role.pojo.vos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RoleUserAuthorityVO
|
||||
* @Description: 角色用户
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/11/23 8:14 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RoleUserAuthorityVO {
|
||||
|
||||
@ApiModelProperty(name = "departmentId", value = "部门ID")
|
||||
private String departmentId;
|
||||
@ApiModelProperty(name = "userId", value = "用户ID")
|
||||
private String userId;
|
||||
|
||||
public String getDepartmentId() {
|
||||
return departmentId == null ? "" : departmentId.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentId(String departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId == null ? "" : userId.trim();
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"departmentId\":")
|
||||
.append("\"").append(departmentId).append("\"");
|
||||
sb.append(",\"userId\":")
|
||||
.append("\"").append(userId).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package ink.wgink.service.role.pojo.vos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleUserAuthorizationVO
|
||||
* @Description: 角色用户授权
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/3/2 12:14 AM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RoleUserAuthorizationVO {
|
||||
|
||||
@ApiModelProperty(name = "menuIds", value = "菜单ID列表,下划线分隔", example = "1_2_3")
|
||||
private String menuIds;
|
||||
|
||||
public String getMenuIds() {
|
||||
return menuIds;
|
||||
}
|
||||
|
||||
public void setMenuIds(String menuIds) {
|
||||
this.menuIds = menuIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"menuIds\":")
|
||||
.append("\"").append(menuIds).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package ink.wgink.service.role.pojo.vos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: RoleVO
|
||||
* @Description: 角色视图
|
||||
* @Author: WangGeng
|
||||
* @Date: 2019/3/1 11:35 PM
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class RoleVO {
|
||||
|
||||
@ApiModelProperty(name = "roleParentId", value = "上级ID", required = true)
|
||||
private String roleParentId;
|
||||
@ApiModelProperty(name = "roleName", value = "角色名称", required = true, example = "角色名称")
|
||||
private String roleName;
|
||||
@ApiModelProperty(name = "roleSummary", value = "角色说明", example = "这是说明")
|
||||
private String roleSummary;
|
||||
|
||||
public String getRoleParentId() {
|
||||
return roleParentId == null ? null : roleParentId.trim();
|
||||
}
|
||||
|
||||
public void setRoleParentId(String roleParentId) {
|
||||
this.roleParentId = roleParentId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName == null ? null : roleName.trim();
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getRoleSummary() {
|
||||
return roleSummary == null ? null : roleSummary.trim();
|
||||
}
|
||||
|
||||
public void setRoleSummary(String roleSummary) {
|
||||
this.roleSummary = roleSummary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"roleParentId\":")
|
||||
.append("\"").append(roleParentId).append("\"");
|
||||
sb.append(",\"roleName\":")
|
||||
.append("\"").append(roleName).append("\"");
|
||||
sb.append(",\"roleSummary\":")
|
||||
.append("\"").append(roleSummary).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package ink.wgink.service.role.service;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.interfaces.role.IRoleBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.bos.DepartmentBO;
|
||||
import ink.wgink.pojo.bos.GroupBO;
|
||||
import ink.wgink.pojo.bos.RoleBO;
|
||||
import ink.wgink.pojo.bos.RoleMenuBO;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityTypeDTO;
|
||||
import ink.wgink.pojo.dtos.role.RolePermissionDTO;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.role.pojo.vos.RoleDataAuthorityVO;
|
||||
import ink.wgink.service.role.pojo.vos.RolePermissionVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IRoleService
|
||||
* @Description: 角色
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/31 18:50
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IRolePermissionService {
|
||||
|
||||
/**
|
||||
* 修改权限(通过角色)
|
||||
*
|
||||
* @param roleId
|
||||
* @param rolePermissionVO
|
||||
* @return
|
||||
* @throws UpdateException
|
||||
*/
|
||||
void updateByRoleId(String roleId, RolePermissionVO rolePermissionVO);
|
||||
|
||||
/**
|
||||
* 权限角色
|
||||
*
|
||||
* @param permissionId
|
||||
* @param roleId
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
RolePermissionDTO getByPermissionIdAndRole(String permissionId, String roleId);
|
||||
|
||||
}
|
@ -0,0 +1,299 @@
|
||||
package ink.wgink.service.role.service;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.interfaces.role.IRoleBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.bos.DepartmentBO;
|
||||
import ink.wgink.pojo.bos.GroupBO;
|
||||
import ink.wgink.pojo.bos.RoleBO;
|
||||
import ink.wgink.pojo.bos.RoleMenuBO;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityTypeDTO;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.role.pojo.vos.RoleDataAuthorityVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IRoleService
|
||||
* @Description: 角色
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/31 18:50
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface IRoleService extends IRoleBaseService {
|
||||
|
||||
/**
|
||||
* 授权新增
|
||||
*/
|
||||
String AUTH_TYPE_INSERT = "1";
|
||||
/**
|
||||
* 授权删除
|
||||
*/
|
||||
String AUTH_TYPE_DELETE = "2";
|
||||
/**
|
||||
* 授权更新
|
||||
*/
|
||||
String AUTH_TYPE_UPDATE = "3";
|
||||
/**
|
||||
* 授权查询
|
||||
*/
|
||||
String AUTH_TYPE_QUERY = "4";
|
||||
/**
|
||||
* 授权菜单
|
||||
*/
|
||||
String AUTH_TYPE_MENU = "5";
|
||||
/**
|
||||
* 角色菜单新增
|
||||
*/
|
||||
String ROLE_INSERT = "roleInsert";
|
||||
/**
|
||||
* 角色菜单删除
|
||||
*/
|
||||
String ROLE_DELETE = "roleDelete";
|
||||
/**
|
||||
* 角色菜单更新
|
||||
*/
|
||||
String ROLE_UPDATE = "roleUpdate";
|
||||
/**
|
||||
* 角色菜单查询
|
||||
*/
|
||||
String ROLE_QUERY = "roleQuery";
|
||||
/**
|
||||
* 角色菜单
|
||||
*/
|
||||
String ROLE_MENU = "roleMenu";
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
String ROLE_TYPE = "roleType";
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SaveException
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResult saveRole(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws RemoveException
|
||||
*/
|
||||
SuccessResult removeRole(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 修改角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws UpdateException
|
||||
*/
|
||||
SuccessResult updateRole(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 全部角色JSON列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleDTO> listRolesAllJson(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 角色详情
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
RoleDTO getRole(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 角色列表,递归获取全部内容
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleDTO> listRolesAll(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 角色zTree列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<ZTreeDTO> listZTreeRole(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 角色EasyUI列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<RoleDTO>> listPageRole(ListPage page);
|
||||
|
||||
/**
|
||||
* 执行授权
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws UpdateException
|
||||
*/
|
||||
SuccessResult authorization(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过用户获取角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleBO> listRoleBOByUser(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过用户组获取角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleBO> listRoleBOByGroup(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 角色菜单列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleMenuBO> listRoleMenuDetail(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 通过roleId获取角色
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
public RoleBO getRoleBOByRoleId(String roleId);
|
||||
|
||||
/**
|
||||
* 获取角色权限集合
|
||||
*
|
||||
* @param roleIds
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleBO> listRoleBO(String roleIds);
|
||||
|
||||
/**
|
||||
* 更新角色数据权限
|
||||
*
|
||||
* @param roleId
|
||||
* @param roleDataAuthorityVO
|
||||
* @return
|
||||
* @throws SaveException
|
||||
* @throws RemoveException
|
||||
*/
|
||||
SuccessResult updateRoleDataAuthority(String roleId, RoleDataAuthorityVO roleDataAuthorityVO);
|
||||
|
||||
/**
|
||||
* 获取角色数据权限类型
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
RoleDataAuthorityTypeDTO getRoleDataAuthorityType(String roleId);
|
||||
|
||||
/**
|
||||
* 获取角色数据权限列表(通过ID列表)
|
||||
*
|
||||
* @param roleIds
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<RoleDataAuthorityDTO> listRoleDataAuthorityByRoleIdList(List<String> roleIds);
|
||||
|
||||
/**
|
||||
* 通过角色列表获取数据权限
|
||||
*
|
||||
* @param roleBOs
|
||||
* @return
|
||||
*/
|
||||
List<String> listDataAuthorityUserIdByRole(List<RoleBO> roleBOs);
|
||||
|
||||
/**
|
||||
* 通过部门获取用户数据数据权限
|
||||
*
|
||||
* @param departmentBOs
|
||||
* @return
|
||||
*/
|
||||
List<String> listDataAuthorityUserIdByDepartment(List<DepartmentBO> departmentBOs);
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
*
|
||||
* @param roleBOs
|
||||
* @return
|
||||
*/
|
||||
String getRoleDataAuthority(List<RoleBO> roleBOs);
|
||||
|
||||
/**
|
||||
* 设置角色菜单
|
||||
*
|
||||
* @param roleBO
|
||||
* @throws SearchException
|
||||
*/
|
||||
void setRoleMenu(RoleBO roleBO);
|
||||
|
||||
/**
|
||||
* 批量设置角色菜单
|
||||
*
|
||||
* @param roleBOs
|
||||
* @throws SearchException
|
||||
*/
|
||||
void setRoleMenus(List<RoleBO> roleBOs);
|
||||
|
||||
/**
|
||||
* 设置组角色列表
|
||||
*
|
||||
* @param groupRoles
|
||||
* @param roleBOs
|
||||
*/
|
||||
void setGroupRoles(List<GroupBO> groupRoles, List<RoleBO> roleBOs);
|
||||
|
||||
/**
|
||||
* 去除重复值
|
||||
*
|
||||
* @param roleBOs
|
||||
*/
|
||||
void removalDuplicateRole(List<RoleBO> roleBOs);
|
||||
|
||||
/**
|
||||
* 统计角色
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
Integer countRole(Map<String, Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package ink.wgink.service.role.service.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.pojo.dtos.permission.PermissionDTO;
|
||||
import ink.wgink.pojo.dtos.role.RolePermissionDTO;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.service.permission.service.IPermissionService;
|
||||
import ink.wgink.service.role.dao.IRolePermissionDao;
|
||||
import ink.wgink.service.role.pojo.vos.RolePermissionVO;
|
||||
import ink.wgink.service.role.service.IRolePermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RolePermissionServiceImpl
|
||||
* @Description: 角色权限
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/31 21:23
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RolePermissionServiceImpl extends DefaultBaseService implements IRolePermissionService {
|
||||
|
||||
@Autowired
|
||||
private IRolePermissionDao rolePermissionDao;
|
||||
@Autowired
|
||||
private IPermissionService permissionService;
|
||||
|
||||
@Override
|
||||
public void updateByRoleId(String roleId, RolePermissionVO rolePermissionVO) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("roleId", roleId);
|
||||
if (rolePermissionVO.getChecked()) {
|
||||
log.debug("新增权限角色,roleId: {}", roleId);
|
||||
for (String permissionId : rolePermissionVO.getPermissionIdArray()) {
|
||||
if (getByPermissionIdAndRole(permissionId, roleId) != null) {
|
||||
continue;
|
||||
}
|
||||
params.put("permissionId", permissionId);
|
||||
rolePermissionDao.save(params);
|
||||
}
|
||||
} else {
|
||||
log.debug("删除权限角色,roleId: {}", roleId);
|
||||
params.put("permissionIds", rolePermissionVO.getPermissionIdArray());
|
||||
rolePermissionDao.delete(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RolePermissionDTO getByPermissionIdAndRole(String permissionId, String roleId) {
|
||||
PermissionDTO permissionDTO = permissionService.get(permissionId);
|
||||
if (permissionDTO == null) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("permissionId", permissionId);
|
||||
params.put("roleId", roleId);
|
||||
RolePermissionDTO rolePermissionDTO = rolePermissionDao.get(params);
|
||||
if (rolePermissionDTO == null) {
|
||||
return null;
|
||||
}
|
||||
rolePermissionDTO.setPermissionTitle(permissionDTO.getPermissionTitle());
|
||||
rolePermissionDTO.setPermissionType(permissionDTO.getPermissionType());
|
||||
rolePermissionDTO.setPermissionUrl(permissionDTO.getPermissionUrl());
|
||||
rolePermissionDTO.setPermissionClientId(permissionDTO.getPermissionClientId());
|
||||
rolePermissionDTO.setPermissionClientName(permissionDTO.getPermissionClientName());
|
||||
rolePermissionDTO.setIsPublic(permissionDTO.getIsPublic());
|
||||
return rolePermissionDTO;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,477 @@
|
||||
package ink.wgink.service.role.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.common.enums.RoleDataAuthorityEnum;
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.bos.*;
|
||||
import ink.wgink.pojo.dtos.ZTreeDTO;
|
||||
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityDTO;
|
||||
import ink.wgink.pojo.dtos.role.RoleDataAuthorityTypeDTO;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.service.role.dao.IRoleDao;
|
||||
import ink.wgink.service.role.pojo.vos.RoleDataAuthorityVO;
|
||||
import ink.wgink.service.role.pojo.vos.RoleUserAuthorityVO;
|
||||
import ink.wgink.service.role.service.IRoleService;
|
||||
import ink.wgink.service.user.service.IUserService;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RoleServiceImpl
|
||||
* @Description: 角色
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/1/31 18:51
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RoleServiceImpl extends DefaultBaseService implements IRoleService {
|
||||
|
||||
@Autowired
|
||||
private IRoleDao roleDao;
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
@Autowired
|
||||
private IPermissionService permissionService;
|
||||
|
||||
@Override
|
||||
public SuccessResult saveRole(Map<String, Object> params) throws SaveException, SearchException {
|
||||
String parentCode = null;
|
||||
String roleParentId = params.get("roleParentId").toString();
|
||||
if (!"0".equals(roleParentId)) {
|
||||
params.put("roleId", roleParentId);
|
||||
RoleDTO roleDTO = roleDao.getRole(params);
|
||||
parentCode = roleDTO.getRoleCode();
|
||||
}
|
||||
String roleCode = getCode(parentCode, roleParentId);
|
||||
params.put("roleCode", roleCode);
|
||||
params.put("roleId", UUIDUtil.getUUID());
|
||||
setSaveInfo(params);
|
||||
roleDao.saveRole(params);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResult removeRole(Map<String, Object> params) throws RemoveException {
|
||||
params.put("roleIds", Arrays.asList(params.get("roleIds").toString().split("_")));
|
||||
setUpdateInfo(params);
|
||||
roleDao.removeRole(params);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResult updateRole(Map<String, Object> params) throws UpdateException {
|
||||
setUpdateInfo(params);
|
||||
roleDao.updateRole(params);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDTO> listRolesAllJson(Map<String, Object> params) throws SearchException {
|
||||
return listRolesAll(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDTO getRole(Map<String, Object> params) throws SearchException {
|
||||
return roleDao.getRole(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDTO> listRolesAll(Map<String, Object> params) throws SearchException {
|
||||
List<RoleDTO> roleDTOs = roleDao.listRole(params);
|
||||
listSubRoles(roleDTOs, params);
|
||||
return roleDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ZTreeDTO> listZTreeRole(Map<String, Object> params) throws SearchException {
|
||||
List<ZTreeDTO> zTreeDTOs = roleDao.listZTreeRoles(params);
|
||||
for (ZTreeDTO zTreeDTO : zTreeDTOs) {
|
||||
Integer subCount = roleDao.countByParentId(zTreeDTO.getId());
|
||||
setZTreeInfo(zTreeDTO, subCount);
|
||||
}
|
||||
return zTreeDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<RoleDTO>> listPageRole(ListPage page) throws SearchException {
|
||||
PageHelper.startPage(page.getPage(), page.getRows());
|
||||
List<RoleDTO> roleDTOs = roleDao.listRole(page.getParams());
|
||||
PageInfo<RoleDTO> pageInfo = new PageInfo<>(roleDTOs);
|
||||
return new SuccessResultList<>(roleDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResult authorization(Map<String, Object> params) throws UpdateException, RemoveException, SaveException {
|
||||
List<String> menuIds = new ArrayList<>();
|
||||
if (!StringUtils.isBlank(params.get("menuIds") == null ? null : params.get("menuIds").toString())) {
|
||||
menuIds.addAll(Arrays.asList(params.get("menuIds").toString().trim().split("_")));
|
||||
}
|
||||
String type = params.get("type").toString();
|
||||
if (IRoleService.AUTH_TYPE_INSERT.equals(type)) {
|
||||
params.put(IRoleService.ROLE_TYPE, IRoleService.ROLE_INSERT);
|
||||
} else if (IRoleService.AUTH_TYPE_DELETE.equals(type)) {
|
||||
params.put(IRoleService.ROLE_TYPE, IRoleService.ROLE_DELETE);
|
||||
} else if (IRoleService.AUTH_TYPE_UPDATE.equals(type)) {
|
||||
params.put(IRoleService.ROLE_TYPE, IRoleService.ROLE_UPDATE);
|
||||
} else if (IRoleService.AUTH_TYPE_QUERY.equals(type)) {
|
||||
params.put(IRoleService.ROLE_TYPE, IRoleService.ROLE_QUERY);
|
||||
} else {
|
||||
params.put(IRoleService.ROLE_TYPE, IRoleService.ROLE_MENU);
|
||||
}
|
||||
log.debug("删除原有角色和菜单信息");
|
||||
roleDao.removeRoleMenuInfo(params);
|
||||
log.debug("新增角色菜单信息");
|
||||
for (String menuId : menuIds) {
|
||||
params.put("menuId", menuId);
|
||||
roleDao.saveRoleMenuInfo(params);
|
||||
}
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleBO> listRoleBOByUser(Map<String, Object> params) throws SearchException {
|
||||
return roleDao.listRoleBOByUser(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleBO> listRoleBOByGroup(Map<String, Object> params) throws SearchException {
|
||||
return roleDao.listRoleBOByGroup(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleMenuBO> listRoleMenuDetail(Map<String, Object> params) throws SearchException {
|
||||
return roleDao.listRoleMenuDetail(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleBO getRoleBOByRoleId(String roleId) throws SearchException {
|
||||
Map<String, Object> params = new HashMap<>(0);
|
||||
params.put("roleId", roleId);
|
||||
List<RoleMenuBO> roleMenuBOs = listRoleMenuDetail(params);
|
||||
|
||||
List<RoleMenuBO> apiSaveMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> apiDeleteMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> apiUpdateMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> apiQueryMenu = new ArrayList<>(0);
|
||||
|
||||
List<RoleMenuBO> resourceSaveMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> resourceDeleteMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> resourceUpdateMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> resourceQueryMenu = new ArrayList<>(0);
|
||||
|
||||
List<RoleMenuBO> routeSaveMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> routeUpdateMenu = new ArrayList<>(0);
|
||||
List<RoleMenuBO> routeQueryMenu = new ArrayList<>(0);
|
||||
|
||||
List<PermissionBO> permissionInsert = new ArrayList<>(0);
|
||||
List<PermissionBO> permissionDelete = new ArrayList<>(0);
|
||||
List<PermissionBO> permissionUpdate = new ArrayList<>(0);
|
||||
List<PermissionBO> permissionQuery = new ArrayList<>(0);
|
||||
|
||||
log.debug("角色菜单权限");
|
||||
for (RoleMenuBO roleMenuBO : roleMenuBOs) {
|
||||
roleMenuBO.setApiPrefix(roleMenuBO.getApiPrefix());
|
||||
roleMenuBO.setResourcePrefix(roleMenuBO.getResourcePrefix());
|
||||
roleMenuBO.setRoutePrefix(roleMenuBO.getRoutePrefix());
|
||||
if (IRoleService.ROLE_INSERT.equals(roleMenuBO.getRoleType())) {
|
||||
apiSaveMenu.add(roleMenuBO);
|
||||
resourceSaveMenu.add(roleMenuBO);
|
||||
routeSaveMenu.add(roleMenuBO);
|
||||
} else if (IRoleService.ROLE_DELETE.equals(roleMenuBO.getRoleType())) {
|
||||
apiDeleteMenu.add(roleMenuBO);
|
||||
resourceDeleteMenu.add(roleMenuBO);
|
||||
} else if (IRoleService.ROLE_UPDATE.equals(roleMenuBO.getRoleType())) {
|
||||
apiUpdateMenu.add(roleMenuBO);
|
||||
resourceUpdateMenu.add(roleMenuBO);
|
||||
routeUpdateMenu.add(roleMenuBO);
|
||||
} else if (IRoleService.ROLE_QUERY.equals(roleMenuBO.getRoleType())) {
|
||||
apiQueryMenu.add(roleMenuBO);
|
||||
resourceQueryMenu.add(roleMenuBO);
|
||||
routeQueryMenu.add(roleMenuBO);
|
||||
}
|
||||
}
|
||||
log.debug("角色接口权限");
|
||||
setApiPermission(roleId, permissionInsert, permissionDelete, permissionUpdate, permissionQuery);
|
||||
RoleBO roleBO = new RoleBO();
|
||||
roleBO.setRoleId(roleId);
|
||||
roleBO.setApiSaveMenu(apiSaveMenu);
|
||||
roleBO.setApiDeleteMenu(apiDeleteMenu);
|
||||
roleBO.setApiUpdateMenu(apiUpdateMenu);
|
||||
roleBO.setApiQueryMenu(apiQueryMenu);
|
||||
roleBO.setResourceSaveMenu(resourceSaveMenu);
|
||||
roleBO.setResourceDeleteMenu(resourceDeleteMenu);
|
||||
roleBO.setResourceUpdateMenu(resourceUpdateMenu);
|
||||
roleBO.setResourceQueryMenu(resourceQueryMenu);
|
||||
roleBO.setRouteSaveMenu(routeSaveMenu);
|
||||
roleBO.setRouteUpdateMenu(routeUpdateMenu);
|
||||
roleBO.setRouteQueryMenu(routeQueryMenu);
|
||||
roleBO.setPermissionInsert(permissionInsert);
|
||||
roleBO.setPermissionDelete(permissionDelete);
|
||||
roleBO.setPermissionUpdate(permissionUpdate);
|
||||
roleBO.setPermissionQuery(permissionQuery);
|
||||
return roleBO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置API权限
|
||||
*
|
||||
* @param roleId
|
||||
* @param permissionInsert
|
||||
* @param permissionDelete
|
||||
* @param permissionUpdate
|
||||
* @param permissionQuery
|
||||
*/
|
||||
private void setApiPermission(String roleId,
|
||||
List<PermissionBO> permissionInsert,
|
||||
List<PermissionBO> permissionDelete,
|
||||
List<PermissionBO> permissionUpdate,
|
||||
List<PermissionBO> permissionQuery) {
|
||||
List<PermissionRoleDTO> permissionRoleDTOs = permissionService.listPermissionByRoleId(roleId);
|
||||
for (PermissionRoleDTO permissionRoleDTO : permissionRoleDTOs) {
|
||||
if (StringUtils.equals(PermissionTypeEnum.PERMISSION_INSERT.getValue(), permissionRoleDTO.getPermissionType())) {
|
||||
PermissionBO permissionBO = new PermissionBO();
|
||||
permissionBO.setPermissionType(permissionRoleDTO.getPermissionType());
|
||||
permissionBO.setPermissionUrl(permissionRoleDTO.getPermissionUrl());
|
||||
permissionInsert.add(permissionBO);
|
||||
} else if (StringUtils.equals(PermissionTypeEnum.PERMISSION_DELETE.getValue(), permissionRoleDTO.getPermissionType())) {
|
||||
PermissionBO permissionBO = new PermissionBO();
|
||||
permissionBO.setPermissionType(permissionRoleDTO.getPermissionType());
|
||||
permissionBO.setPermissionUrl(permissionRoleDTO.getPermissionUrl());
|
||||
permissionDelete.add(permissionBO);
|
||||
} else if (StringUtils.equals(PermissionTypeEnum.PERMISSION_UPDATE.getValue(), permissionRoleDTO.getPermissionType())) {
|
||||
PermissionBO permissionBO = new PermissionBO();
|
||||
permissionBO.setPermissionType(permissionRoleDTO.getPermissionType());
|
||||
permissionBO.setPermissionUrl(permissionRoleDTO.getPermissionUrl());
|
||||
permissionUpdate.add(permissionBO);
|
||||
} else if (StringUtils.equals(PermissionTypeEnum.PERMISSION_QUERY.getValue(), permissionRoleDTO.getPermissionType())) {
|
||||
PermissionBO permissionBO = new PermissionBO();
|
||||
permissionBO.setPermissionType(permissionRoleDTO.getPermissionType());
|
||||
permissionBO.setPermissionUrl(permissionRoleDTO.getPermissionUrl());
|
||||
permissionQuery.add(permissionBO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleBO> listRoleBO(String roleIds) throws SearchException {
|
||||
String[] roleIdArray = roleIds.split("_");
|
||||
List<RoleBO> roleBOs = new ArrayList<>();
|
||||
for (String roleId : roleIdArray) {
|
||||
RoleBO roleBO = getRoleBOByRoleId(roleId);
|
||||
roleBOs.add(roleBO);
|
||||
}
|
||||
return roleBOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResult updateRoleDataAuthority(String roleId, RoleDataAuthorityVO roleDataAuthorityVO) throws SaveException, RemoveException {
|
||||
log.debug("更新角色数据权限");
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("roleId", roleId);
|
||||
params.put("roleDataAuthority", roleDataAuthorityVO.getDataAuthorityType());
|
||||
roleDao.updateRole(params);
|
||||
if (StringUtils.equals(roleDataAuthorityVO.getDataAuthorityType(), RoleDataAuthorityEnum.CUSTOM.getDataAuthorityType())) {
|
||||
params.remove("roleDataAuthority");
|
||||
log.debug("删除原有的自定义权限列表");
|
||||
roleDao.deleteRoleDataAuthority(params);
|
||||
log.debug("更新自定义权限列表");
|
||||
for (RoleUserAuthorityVO roleUserAuthorityVO : roleDataAuthorityVO.getRoleUserAuthorityList()) {
|
||||
params.put("departmentId", roleUserAuthorityVO.getDepartmentId());
|
||||
params.put("userId", roleUserAuthorityVO.getUserId());
|
||||
roleDao.saveRoleDataAuthority(params);
|
||||
}
|
||||
}
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoleMenu(RoleBO roleBO) throws SearchException {
|
||||
RoleBO role = getRoleBOByRoleId(roleBO.getRoleId());
|
||||
roleBO.setApiSaveMenu(role.getApiSaveMenu());
|
||||
roleBO.setApiDeleteMenu(role.getApiDeleteMenu());
|
||||
roleBO.setApiUpdateMenu(role.getApiUpdateMenu());
|
||||
roleBO.setApiQueryMenu(role.getApiQueryMenu());
|
||||
roleBO.setResourceSaveMenu(role.getResourceSaveMenu());
|
||||
roleBO.setResourceDeleteMenu(role.getResourceDeleteMenu());
|
||||
roleBO.setResourceUpdateMenu(role.getResourceUpdateMenu());
|
||||
roleBO.setResourceQueryMenu(role.getResourceQueryMenu());
|
||||
roleBO.setRouteSaveMenu(role.getRouteSaveMenu());
|
||||
roleBO.setRouteUpdateMenu(role.getRouteUpdateMenu());
|
||||
roleBO.setRouteQueryMenu(role.getRouteQueryMenu());
|
||||
roleBO.setPermissionInsert(role.getPermissionInsert());
|
||||
roleBO.setPermissionDelete(role.getPermissionDelete());
|
||||
roleBO.setPermissionUpdate(role.getPermissionUpdate());
|
||||
roleBO.setPermissionQuery(role.getPermissionQuery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoleMenus(List<RoleBO> roleBOs) throws SearchException {
|
||||
for (RoleBO roleBO : roleBOs) {
|
||||
setRoleMenu(roleBO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDataAuthorityTypeDTO getRoleDataAuthorityType(String roleId) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(1);
|
||||
params.put("roleId", roleId);
|
||||
RoleDTO roleDTO = roleDao.getRole(params);
|
||||
StringBuilder roleDataAuthority = new StringBuilder();
|
||||
if (StringUtils.equals(roleDTO.getRoleDataAuthority(), RoleDataAuthorityEnum.CUSTOM.getDataAuthorityType())) {
|
||||
List<RoleDataAuthorityDTO> roleDataAuthorityDTOs = roleDao.listRoleDataAuthority(params);
|
||||
for (RoleDataAuthorityDTO roleDataAuthorityDTO : roleDataAuthorityDTOs) {
|
||||
if (roleDataAuthority.length() > 0) {
|
||||
roleDataAuthority.append("_");
|
||||
}
|
||||
roleDataAuthority.append(roleDataAuthorityDTO.getUserId());
|
||||
}
|
||||
}
|
||||
RoleDataAuthorityTypeDTO roleDataAuthorityTypeDTO = new RoleDataAuthorityTypeDTO();
|
||||
roleDataAuthorityTypeDTO.setRoleDataAuthorityType(roleDTO.getRoleDataAuthority());
|
||||
roleDataAuthorityTypeDTO.setRoleDataAuthority(roleDataAuthority.toString());
|
||||
return roleDataAuthorityTypeDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDataAuthorityDTO> listRoleDataAuthorityByRoleIdList(List<String> roleIds) throws SearchException {
|
||||
Map<String, Object> params = getHashMap(1);
|
||||
params.put("roleIds", roleIds);
|
||||
return roleDao.listRoleDataAuthority(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listDataAuthorityUserIdByRole(List<RoleBO> roleBOs) {
|
||||
List<String> userIds = new ArrayList<>();
|
||||
List<String> roleIds = new ArrayList<>();
|
||||
for (RoleBO roleBO : roleBOs) {
|
||||
roleIds.add(roleBO.getRoleId());
|
||||
}
|
||||
List<RoleDataAuthorityDTO> roleDataAuthorityDTOs = listRoleDataAuthorityByRoleIdList(roleIds);
|
||||
for (RoleDataAuthorityDTO roleDataAuthorityDTO : roleDataAuthorityDTOs) {
|
||||
userIds.add(roleDataAuthorityDTO.getUserId());
|
||||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listDataAuthorityUserIdByDepartment(List<DepartmentBO> departmentBOs) {
|
||||
List<String> userIds = new ArrayList<>();
|
||||
if (departmentBOs.isEmpty()) {
|
||||
return userIds;
|
||||
}
|
||||
List<String> departmentIds = new ArrayList<>();
|
||||
for (DepartmentBO departmentBO : departmentBOs) {
|
||||
departmentIds.add(departmentBO.getDepartmentId());
|
||||
}
|
||||
Map<String, Object> params = new HashMap<>(1);
|
||||
params.put("departmentIds", departmentIds);
|
||||
List<DepartmentUserDTO> departmentUserDTOs = userService.listDepartmentUsers(params);
|
||||
for (DepartmentUserDTO departmentUserDTO : departmentUserDTOs) {
|
||||
userIds.add(departmentUserDTO.getUserId());
|
||||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoleDataAuthority(List<RoleBO> roleBOs) {
|
||||
String roleDataAuthority = RoleDataAuthorityEnum.SELF.getDataAuthorityType();
|
||||
for (RoleBO roleBO : roleBOs) {
|
||||
if (StringUtils.equals(RoleDataAuthorityEnum.ALL.getDataAuthorityType(), roleBO.getRoleDataAuthority())) {
|
||||
roleDataAuthority = RoleDataAuthorityEnum.ALL.getDataAuthorityType();
|
||||
break;
|
||||
}
|
||||
if (StringUtils.equals(RoleDataAuthorityEnum.DEPARTMENT.getDataAuthorityType(), roleBO.getRoleDataAuthority())) {
|
||||
roleDataAuthority = RoleDataAuthorityEnum.DEPARTMENT.getDataAuthorityType();
|
||||
break;
|
||||
}
|
||||
if (StringUtils.equals(RoleDataAuthorityEnum.CUSTOM.getDataAuthorityType(), roleBO.getRoleDataAuthority())) {
|
||||
roleDataAuthority = RoleDataAuthorityEnum.CUSTOM.getDataAuthorityType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return roleDataAuthority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupRoles(List<GroupBO> groupRoles, List<RoleBO> roleBOs) {
|
||||
Map<String, Object> params = getHashMap(1);
|
||||
groupRoles.forEach(groupBO -> {
|
||||
params.put("groupId", groupBO.getGroupId());
|
||||
roleBOs.addAll(listRoleBOByGroup(params));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removalDuplicateRole(List<RoleBO> roleBOs) {
|
||||
for (int i = 0; i < roleBOs.size(); i++) {
|
||||
RoleBO roleBO = roleBOs.get(i);
|
||||
boolean isExist = false;
|
||||
for (int j = i + 1; j < roleBOs.size(); j++) {
|
||||
if (StringUtils.equals(roleBO.getRoleId(), roleBOs.get(j).getRoleId())) {
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isExist) {
|
||||
roleBOs.remove(i);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countRole(Map<String, Object> params) throws SearchException {
|
||||
Integer roleCount = roleDao.countRole(params);
|
||||
return roleCount == null ? 0 : roleCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归查询子角色
|
||||
*
|
||||
* @param roleDTOs
|
||||
* @param params
|
||||
* @throws SearchException
|
||||
*/
|
||||
private void listSubRoles(List<RoleDTO> roleDTOs, Map<String, Object> params) throws SearchException {
|
||||
for (RoleDTO roleDTO : roleDTOs) {
|
||||
params.put("roleParentId", roleDTO.getRoleId());
|
||||
List<RoleDTO> subRoleDTOs = roleDao.listRole(params);
|
||||
roleDTO.setSubRoles(subRoleDTOs);
|
||||
listSubRoles(subRoleDTOs, params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取code
|
||||
*
|
||||
* @param parentCode
|
||||
* @param parentId
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
private String getCode(String parentCode, String parentId) throws SearchException {
|
||||
RoleDTO roleDTO = roleDao.getLastByParentId(parentId);
|
||||
String code = roleDTO != null ? roleDTO.getRoleCode() : "0000";
|
||||
return super.getNewCode(code, parentCode);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ink.wgink.service.role.dao.IRolePermissionDao">
|
||||
|
||||
<resultMap id="rolePermissionDTO" type="ink.wgink.pojo.dtos.role.RolePermissionDTO">
|
||||
<id column="permission_id" property="permissionId"/>
|
||||
<result column="role_id" property="roleId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 新增权限角色 -->
|
||||
<insert id="save" parameterType="map">
|
||||
INSERT INTO sys_permission_role(
|
||||
permission_id,
|
||||
role_id
|
||||
) VALUES(
|
||||
#{permissionId},
|
||||
#{roleId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 删除权限角色 -->
|
||||
<delete id="delete" parameterType="map">
|
||||
DELETE FROM
|
||||
sys_permission_role
|
||||
WHERE
|
||||
role_id = #{roleId}
|
||||
AND
|
||||
permission_id IN
|
||||
<foreach collection="permissionIds" index="index" open="(" separator="," close=")">
|
||||
#{permissionIds[${index}]}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 权限角色详情 -->
|
||||
<select id="get" parameterType="map" resultMap="rolePermissionDTO">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_permission_role
|
||||
WHERE
|
||||
permission_id = #{permissionId}
|
||||
AND
|
||||
role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user