combine role group

This commit is contained in:
MaxKey
2022-06-06 20:12:02 +08:00
parent d51b68ce73
commit a605bf60be
135 changed files with 1118 additions and 5391 deletions

View File

@@ -24,7 +24,7 @@ import java.util.List;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.AccountsStrategy;
import org.maxkey.entity.Groups;
import org.maxkey.entity.Roles;
/**
* @author Crystal.sea
@@ -33,5 +33,5 @@ import org.maxkey.entity.Groups;
public interface AccountsStrategyMapper extends IJpaBaseMapper<AccountsStrategy> {
public List<Groups> queryDynamicGroups(Groups groups);
public List<Roles> queryDynamicGroups(Roles groups);
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package org.maxkey.persistence.mapper;
import java.util.List;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.GroupMember;
import org.maxkey.entity.Groups;
import org.maxkey.entity.UserInfo;
/**
* @author Crystal.sea
*
*/
public interface GroupMemberMapper extends IJpaBaseMapper<GroupMember> {
public List<GroupMember> memberInGroup(GroupMember entity);
public List<GroupMember> memberNotInGroup(GroupMember entity);
public List<GroupMember> groupMemberInGroup(GroupMember entity);
public List<Groups> groupsNoMember(GroupMember entity);
public int addDynamicGroupMember(Groups dynamicGroup);
public int deleteDynamicGroupMember(Groups dynamicGroup);
public int deleteByGroupId(String groupId);
public List<UserInfo> queryMemberByGroupId(String groupId);
}

View File

@@ -1,33 +0,0 @@
/*
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
*/
package org.maxkey.persistence.mapper;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.Notices;
/**
* @author Crystal.sea
*
*/
public interface NoticesMapper extends IJpaBaseMapper<Notices> {
public Notices queryLastedNotices();
}

View File

@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.RoleMember;
import org.maxkey.entity.Roles;
import org.maxkey.entity.UserInfo;
/**
* @author Crystal.sea
@@ -35,13 +36,17 @@ public interface RoleMemberMapper extends IJpaBaseMapper<RoleMember> {
public List<RoleMember> memberInRole(RoleMember entity);
public List<RoleMember> memberNotInRole(RoleMember entity);
public List<RoleMember> roleMemberInRole(RoleMember entity);
public List<Roles> rolesNoMember(RoleMember entity);
public int addDynamicRoleMember(Roles dynamicRole);
public int deleteDynamicRoleMember(Roles dynamicRole);
public int deleteByRoleId(String roleId);
public int addDynamicRoleMember(Roles dynamicRole);
public int deleteDynamicRoleMember(Roles dynamicRole);
public int deleteByRoleId(String roleId);
public List<UserInfo> queryMemberByRoleId(String roleId);
}

View File

@@ -23,19 +23,19 @@ package org.maxkey.persistence.mapper;
import java.util.List;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.GroupPrivileges;
import org.maxkey.entity.RolePermissions;
/**
* @author Crystal.sea
*
*/
public interface GroupPrivilegesMapper extends IJpaBaseMapper<GroupPrivileges> {
public interface RolePermissionsMapper extends IJpaBaseMapper<RolePermissions> {
public List<GroupPrivileges>appsInGroup(GroupPrivileges entity);
public List<RolePermissions>appsInRole(RolePermissions entity);
public List<GroupPrivileges> appsNotInGroup(GroupPrivileges entity);
public List<RolePermissions> appsNotInRole(RolePermissions entity);
}

View File

@@ -23,16 +23,19 @@ package org.maxkey.persistence.mapper;
import java.util.List;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.Groups;
import org.maxkey.entity.RolePrivileges;
/**
* @author Crystal.sea
*
*/
public interface GroupsMapper extends IJpaBaseMapper<Groups> {
public List<Groups> queryDynamicGroups(Groups groups);
public interface RolePrivilegesMapper extends IJpaBaseMapper<RolePrivileges> {
public List<Groups> queryGroupByUserId(String userId);
public int insertRolePrivileges(List<RolePrivileges> rolePermissionsList);
public int deleteRolePrivileges(List<RolePrivileges> rolePermissionsList);
public List<RolePrivileges> queryRolePrivileges(RolePrivileges rolePermissions);
}

View File

@@ -23,7 +23,6 @@ package org.maxkey.persistence.mapper;
import java.util.List;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.entity.RolePrivileges;
import org.maxkey.entity.Roles;
/**
@@ -32,12 +31,8 @@ import org.maxkey.entity.Roles;
*/
public interface RolesMapper extends IJpaBaseMapper<Roles> {
public int insertRolePrivileges(List<RolePrivileges> rolePermissionsList);
public int deleteRolePrivileges(List<RolePrivileges> rolePermissionsList);
public List<RolePrivileges> queryRolePrivileges(RolePrivileges rolePermissions);
public List<Roles> queryDynamicRoles(Roles role);
public List<Roles> queryDynamicRoles(Roles groups);
public List<Roles> queryRolesByUserId(String userId);
}

View File

@@ -25,19 +25,15 @@ public class MqProvisionTopic {
public final static String ORG_TOPIC = "MXK_IDENTITY_ORG_TOPIC";
public final static String GROUP_TOPIC = "MXK_IDENTITY_GROUP_TOPIC";
public final static String GROUP_MEMBER_TOPIC = "MXK_IDENTITY_GROUP_MEMBER_TOPIC";
public final static String ACCOUNT_TOPIC = "MXK_IDENTITY_ACCOUNT_TOPIC";
public final static String AUTHORITY_ROLE_TOPIC = "MXK_AUTHORITY_ROLE_TOPIC";
public final static String ROLE_TOPIC = "MXK_ROLE_TOPIC";
public final static String AUTHORITY_ROLE_MEMBER_TOPIC = "MXK_AUTHORITY_ROLE_MEMBER_TOPIC";
public final static String ROLE_MEMBER_TOPIC = "MXK_ROLE_MEMBER_TOPIC";
public final static String AUTHORITY_RESOURCE_TOPIC = "MXK_AUTHORITY_RESOURCE_TOPIC";
public final static String ROLE_PRIVILEGES_TOPIC = "MXK_ROLE_PRIVILEGES_TOPIC";
public final static String AUTHORITY_ROLE_PERMISSION_TOPIC = "MXK_AUTHORITY_ROLE_PERMISSION_TOPIC";
public final static String RESOURCE_TOPIC = "MXK_RESOURCE_TOPIC";
public final static String CONNECTOR_HISTORY_TOPIC = "MXK_CONNECTOR_HISTORY_TOPIC";

View File

@@ -22,7 +22,7 @@ import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.entity.AccountsStrategy;
import org.maxkey.entity.Groups;
import org.maxkey.entity.Roles;
import org.maxkey.persistence.mapper.AccountsStrategyMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,7 +55,7 @@ public class AccountsStrategyService extends JpaBaseService<AccountsStrategy> i
}
public List<Groups> queryDynamicGroups(Groups groups){
public List<Roles> queryDynamicGroups(Roles groups){
return this.getMapper().queryDynamicGroups(groups);
}

View File

@@ -1,89 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.persistence.service;
import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.entity.GroupMember;
import org.maxkey.entity.Groups;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.mapper.GroupMemberMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
@Repository
public class GroupMemberService extends JpaBaseService<GroupMember>{
final static Logger _logger = LoggerFactory.getLogger(GroupMemberService.class);
public GroupMemberService() {
super(GroupMemberMapper.class);
}
/* (non-Javadoc)
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public GroupMemberMapper getMapper() {
return (GroupMemberMapper)super.getMapper();
}
public int addDynamicGroupMember(Groups dynamicGroup) {
return getMapper().addDynamicGroupMember(dynamicGroup);
}
public int deleteDynamicGroupMember(Groups dynamicGroup) {
return getMapper().deleteDynamicGroupMember(dynamicGroup);
}
public int deleteByGroupId(String groupId) {
return getMapper().deleteByGroupId(groupId);
}
public List<UserInfo> queryMemberByGroupId(String groupId){
return getMapper().queryMemberByGroupId(groupId);
}
public JpaPageResults<Groups> groupsNoMember(GroupMember entity) {
entity.setPageResultSelectUUID(entity.generateId());
entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
entity.setPageable(true);
List<Groups> resultslist = null;
try {
resultslist = getMapper().groupsNoMember(entity);
} catch (Exception e) {
_logger.error("queryPageResults Exception " , e);
}
entity.setPageable(false);
Integer totalPage = resultslist.size();
Integer totalCount = 0;
if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
totalCount = totalPage;
}else {
totalCount = parseCount(getMapper().queryPageResultsCount(entity));
}
return new JpaPageResults<Groups>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
}
}

View File

@@ -1,147 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.persistence.service;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.constants.ConstsStatus;
import org.maxkey.entity.Groups;
import org.maxkey.persistence.mapper.GroupsMapper;
import org.maxkey.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Repository
public class GroupsService extends JpaBaseService<Groups> implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4156671926199393550L;
final static Logger _logger = LoggerFactory.getLogger(GroupsService.class);
@JsonIgnore
@Autowired
@Qualifier("groupMemberService")
GroupMemberService groupMemberService;
public GroupsService() {
super(GroupsMapper.class);
}
/* (non-Javadoc)
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public GroupsMapper getMapper() {
return (GroupsMapper)super.getMapper();
}
public List<Groups> queryDynamicGroups(Groups groups){
return this.getMapper().queryDynamicGroups(groups);
}
public boolean deleteById(String groupId) {
this.remove(groupId);
groupMemberService.deleteByGroupId(groupId);
return true;
}
public List<Groups> queryGroupByUserId(String userId){
return this.getMapper().queryGroupByUserId(userId);
}
public void refreshDynamicGroups(Groups dynamicGroup){
if(dynamicGroup.getDynamic().equals(ConstsStatus.ACTIVE+"")) {
boolean isDynamicTimeSupport = false;
boolean isBetweenEffectiveTime = false;
if(StringUtils.isNotBlank(dynamicGroup.getResumeTime())
&&StringUtils.isNotBlank(dynamicGroup.getSuspendTime())
&&!dynamicGroup.getSuspendTime().equals("00:00")) {
LocalTime currentTime = LocalDateTime.now().toLocalTime();
LocalTime resumeTime = LocalTime.parse(dynamicGroup.getResumeTime());
LocalTime suspendTime = LocalTime.parse(dynamicGroup.getSuspendTime());
_logger.info("currentTime: " + currentTime
+ " , resumeTime : " + resumeTime
+ " , suspendTime: " + suspendTime);
isDynamicTimeSupport = true;
if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
isBetweenEffectiveTime = true;
}
}
if(StringUtils.isNotBlank(dynamicGroup.getOrgIdsList())) {
dynamicGroup.setOrgIdsList("'"+dynamicGroup.getOrgIdsList().replace(",", "','")+"'");
}
String filters = dynamicGroup.getFilters();
if(StringUtils.isNotBlank(filters)) {
if(StringUtils.filtersSQLInjection(filters.toLowerCase())) {
_logger.info("filters include SQL Injection Attack Risk.");
return;
}
filters = filters.replace("&", " AND ");
filters = filters.replace("|", " OR ");
dynamicGroup.setFilters(filters);
}
if(isDynamicTimeSupport) {
if(isBetweenEffectiveTime) {
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
groupMemberService.addDynamicGroupMember(dynamicGroup);
}else {
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
}
}else{
groupMemberService.deleteDynamicGroupMember(dynamicGroup);
groupMemberService.addDynamicGroupMember(dynamicGroup);
}
}
}
public void refreshAllDynamicGroups(){
List<Groups> groupsList = queryDynamicGroups(null);
for(Groups group : groupsList) {
_logger.debug("group " + group);
refreshDynamicGroups(group);
}
}
public GroupMemberService getGroupMemberService() {
return groupMemberService;
}
public void setGroupMemberService(GroupMemberService groupMemberService) {
this.groupMemberService = groupMemberService;
}
}

View File

@@ -20,15 +20,13 @@ package org.maxkey.persistence.service;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.entity.Accounts;
import org.maxkey.entity.ChangePassword;
import org.maxkey.entity.GroupMember;
import org.maxkey.entity.GroupPrivileges;
import org.maxkey.entity.Groups;
import org.maxkey.entity.RoleMember;
import org.maxkey.entity.RolePermissions;
import org.maxkey.entity.Roles;
import org.maxkey.entity.HistorySystemLogs;
import org.maxkey.entity.Organizations;
import org.maxkey.entity.Resources;
import org.maxkey.entity.RoleMember;
import org.maxkey.entity.RolePrivileges;
import org.maxkey.entity.Roles;
import org.maxkey.entity.SocialsProvider;
import org.maxkey.entity.Synchronizers;
import org.maxkey.entity.UserInfo;
@@ -66,16 +64,12 @@ public class HistorySystemLogsService extends JpaBaseService<HistorySystemLogs>
message = buildMsg((ChangePassword)entity);
}else if(entity instanceof Accounts) {
message = buildMsg((Accounts)entity);
}else if(entity instanceof Groups) {
message = buildMsg((Groups)entity);
}else if(entity instanceof Roles) {
message = buildMsg((Roles)entity);
}else if(entity instanceof GroupMember) {
message = buildMsg((GroupMember)entity);
}else if(entity instanceof RoleMember) {
message = buildMsg((RoleMember)entity);
}else if(entity instanceof GroupPrivileges) {
message = buildMsg((GroupPrivileges)entity);
}else if(entity instanceof RolePermissions) {
message = buildMsg((RolePermissions)entity);
}else if(entity instanceof Resources) {
message = buildMsg((Resources)entity);
}else if(entity instanceof Synchronizers) {
@@ -147,18 +141,12 @@ public class HistorySystemLogsService extends JpaBaseService<HistorySystemLogs>
.toString();
}
public String buildMsg(Groups g) {
public String buildMsg(Roles g) {
return new StringBuilder()
.append(g.getName())
.toString();
}
public String buildMsg(Roles r) {
return new StringBuilder()
.append(r.getName())
.toString();
}
public String buildMsg(RoleMember rm) {
return new StringBuilder()
.append(rm.getRoleName())
@@ -169,21 +157,11 @@ public class HistorySystemLogsService extends JpaBaseService<HistorySystemLogs>
.toString();
}
public String buildMsg(GroupMember gm) {
public String buildMsg(RolePermissions permission) {
return new StringBuilder()
.append(gm.getGroupName())
.append(permission.getRoleName())
.append("[")
.append(gm.getUsername()).append(",")
.append(gm.getDisplayName())
.append("]")
.toString();
}
public String buildMsg(GroupPrivileges privilege) {
return new StringBuilder()
.append(privilege.getGroupName())
.append("[")
.append(privilege.getAppName())
.append(permission.getAppName())
.append("]")
.toString();
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.persistence.service;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.entity.Notices;
import org.maxkey.persistence.mapper.NoticesMapper;
import org.springframework.stereotype.Repository;
@Repository
public class NoticesService extends JpaBaseService<Notices>{
public NoticesService() {
super(NoticesMapper.class);
}
/* (non-Javadoc)
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public NoticesMapper getMapper() {
return (NoticesMapper)super.getMapper();
}
public Notices queryLastedNotices() {
return getMapper().queryLastedNotices();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.entity.RoleMember;
import org.maxkey.entity.Roles;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.mapper.RoleMemberMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +31,6 @@ import org.springframework.stereotype.Repository;
@Repository
public class RoleMemberService extends JpaBaseService<RoleMember>{
final static Logger _logger = LoggerFactory.getLogger(RoleMemberService.class);
public RoleMemberService() {
@@ -45,19 +45,23 @@ public class RoleMemberService extends JpaBaseService<RoleMember>{
return (RoleMemberMapper)super.getMapper();
}
public int addDynamicRoleMember(Roles dynamicGroup) {
return getMapper().addDynamicRoleMember(dynamicGroup);
}
public int addDynamicRoleMember(Roles dynamicRole) {
return getMapper().addDynamicRoleMember(dynamicRole);
public int deleteDynamicRoleMember(Roles dynamicGroup) {
return getMapper().deleteDynamicRoleMember(dynamicGroup);
}
public int deleteByRoleId(String groupId) {
return getMapper().deleteByRoleId(groupId);
}
public int deleteDynamicRoleMember(Roles dynamicRole) {
return getMapper().deleteDynamicRoleMember(dynamicRole);
}
public int deleteByRoleId(String roleId) {
return getMapper().deleteByRoleId(roleId);
}
public List<UserInfo> queryMemberByRoleId(String groupId){
return getMapper().queryMemberByRoleId(groupId);
}
public JpaPageResults<Roles> rolesNoMember(RoleMember entity) {
entity.setPageResultSelectUUID(entity.generateId());
entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
@@ -81,4 +85,5 @@ public class RoleMemberService extends JpaBaseService<RoleMember>{
return new JpaPageResults<Roles>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
}
}

View File

@@ -18,15 +18,15 @@
package org.maxkey.persistence.service;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.entity.GroupPrivileges;
import org.maxkey.persistence.mapper.GroupPrivilegesMapper;
import org.maxkey.entity.RolePermissions;
import org.maxkey.persistence.mapper.RolePermissionsMapper;
import org.springframework.stereotype.Repository;
@Repository
public class GroupPrivilegesService extends JpaBaseService<GroupPrivileges>{
public class RolePermissionssService extends JpaBaseService<RolePermissions>{
public GroupPrivilegesService() {
super(GroupPrivilegesMapper.class);
public RolePermissionssService() {
super(RolePermissionsMapper.class);
}
@@ -35,8 +35,8 @@ public class GroupPrivilegesService extends JpaBaseService<GroupPrivileges>{
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public GroupPrivilegesMapper getMapper() {
return (GroupPrivilegesMapper)super.getMapper();
public RolePermissionsMapper getMapper() {
return (RolePermissionsMapper)super.getMapper();
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.persistence.service;
import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.entity.RolePrivileges;
import org.maxkey.persistence.mapper.RolePrivilegesMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
@Repository
public class RolePrivilegesService extends JpaBaseService<RolePrivileges>{
final static Logger _logger = LoggerFactory.getLogger(RolePrivilegesService.class);
public RolePrivilegesService() {
super(RolePrivilegesMapper.class);
}
/* (non-Javadoc)
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public RolePrivilegesMapper getMapper() {
return (RolePrivilegesMapper)super.getMapper();
}
public boolean insertRolePrivileges(List<RolePrivileges> rolePermissionsList) {
return getMapper().insertRolePrivileges(rolePermissionsList)>0;
};
public boolean deleteRolePrivileges(List<RolePrivileges> rolePermissionsList) {
return getMapper().deleteRolePrivileges(rolePermissionsList)>=0;
}
public List<RolePrivileges> queryRolePrivileges(RolePrivileges rolePermissions){
return getMapper().queryRolePrivileges(rolePermissions);
}
}

View File

@@ -17,25 +17,33 @@
package org.maxkey.persistence.service;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.entity.RolePrivileges;
import org.maxkey.constants.ConstsStatus;
import org.maxkey.entity.Roles;
import org.maxkey.persistence.mapper.RolesMapper;
import org.maxkey.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Repository
public class RolesService extends JpaBaseService<Roles>{
final static Logger _logger = LoggerFactory.getLogger(RolesService.class);
public class RolesService extends JpaBaseService<Roles> implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4156671926199393550L;
final static Logger _logger = LoggerFactory.getLogger(RolesService.class);
@JsonIgnore
@Autowired
@Qualifier("roleMemberService")
RoleMemberService roleMemberService;
public RolesService() {
@@ -50,47 +58,78 @@ public class RolesService extends JpaBaseService<Roles>{
return (RolesMapper)super.getMapper();
}
public boolean insertRolePrivileges(List<RolePrivileges> rolePermissionsList) {
return getMapper().insertRolePrivileges(rolePermissionsList)>0;
};
public boolean deleteRolePrivileges(List<RolePrivileges> rolePermissionsList) {
return getMapper().deleteRolePrivileges(rolePermissionsList)>=0;
}
public List<RolePrivileges> queryRolePrivileges(RolePrivileges rolePermissions){
return getMapper().queryRolePrivileges(rolePermissions);
}
public List<Roles> queryDynamicRoles(Roles dynamicRole){
return this.getMapper().queryDynamicRoles(dynamicRole);
}
public boolean deleteById(String roleId) {
this.remove(roleId);
roleMemberService.deleteByRoleId(roleId);
return true;
}
public void refreshDynamicRoles(Roles dynamicRole){
if(dynamicRole.getDynamic().equals("1")) {
if(dynamicRole.getOrgIdsList()!=null && !dynamicRole.getOrgIdsList().equals("")) {
dynamicRole.setOrgIdsList("'"+dynamicRole.getOrgIdsList().replace(",", "','")+"'");
public List<Roles> queryDynamicRoles(Roles groups){
return this.getMapper().queryDynamicRoles(groups);
}
public boolean deleteById(String groupId) {
this.remove(groupId);
roleMemberService.deleteByRoleId(groupId);
return true;
}
public List<Roles> queryRolesByUserId(String userId){
return this.getMapper().queryRolesByUserId(userId);
}
public void refreshDynamicRoles(Roles dynamicRole){
if(dynamicRole.getDynamic().equals(ConstsStatus.ACTIVE+"")) {
boolean isDynamicTimeSupport = false;
boolean isBetweenEffectiveTime = false;
if(StringUtils.isNotBlank(dynamicRole.getResumeTime())
&&StringUtils.isNotBlank(dynamicRole.getSuspendTime())
&&!dynamicRole.getSuspendTime().equals("00:00")) {
LocalTime currentTime = LocalDateTime.now().toLocalTime();
LocalTime resumeTime = LocalTime.parse(dynamicRole.getResumeTime());
LocalTime suspendTime = LocalTime.parse(dynamicRole.getSuspendTime());
_logger.info("currentTime: " + currentTime
+ " , resumeTime : " + resumeTime
+ " , suspendTime: " + suspendTime);
isDynamicTimeSupport = true;
if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
isBetweenEffectiveTime = true;
}
}
if(StringUtils.isNotBlank(dynamicRole.getOrgIdsList())) {
dynamicRole.setOrgIdsList("'"+dynamicRole.getOrgIdsList().replace(",", "','")+"'");
}
String filters = dynamicRole.getFilters();
if(StringUtils.isNotBlank(filters)) {
if(StringUtils.filtersSQLInjection(filters.toLowerCase())) {
_logger.info("filters include SQL Injection Attack Risk.");
return;
}
filters = filters.replace("&", " AND ");
filters = filters.replace("|", " OR ");
dynamicRole.setFilters(filters);
}
if(isDynamicTimeSupport) {
if(isBetweenEffectiveTime) {
roleMemberService.deleteDynamicRoleMember(dynamicRole);
roleMemberService.addDynamicRoleMember(dynamicRole);
}else {
roleMemberService.deleteDynamicRoleMember(dynamicRole);
}
}else{
roleMemberService.deleteDynamicRoleMember(dynamicRole);
roleMemberService.addDynamicRoleMember(dynamicRole);
}
String filters = dynamicRole.getFilters();
if(StringUtils.filtersSQLInjection(filters.toLowerCase())) {
_logger.info("filters include SQL Injection Attack Risk.");
return;
}
filters = filters.replace("&", " AND ");
filters = filters.replace("|", " OR ");
dynamicRole.setFilters(filters);
roleMemberService.deleteDynamicRoleMember(dynamicRole);
roleMemberService.addDynamicRoleMember(dynamicRole);
}
}
public void refreshAllDynamicRoles(){
List<Roles> groupsList = queryDynamicRoles(null);
for(Roles group : groupsList) {
_logger.debug("group " + group);
refreshDynamicRoles(group);
}
}
}
}

View File

@@ -1,287 +0,0 @@
<?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="org.maxkey.persistence.mapper.GroupMemberMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
</sql>
<select id="memberInGroup" parameterType="GroupMember" resultType="GroupMember">
select distinct
gm.id as id,
g.id as groupid,
g.name as groupname,
g.dynamic dynamic,
u.username,
u.usertype,
u.windowsaccount,
u.displayname ,
u.nickname ,
u.namezhspell,
u.namezhshortspell,
u.givenname ,
u.middlename ,
u.familyname ,
u.gender,
u.authntype,
u.mobile,
u.email,
u.workemail,
u.workphonenumber,
u.employeenumber,
u.division,
u.costcenter,
u.organization,
u.departmentid,
u.department,
u.jobtitle,
u.joblevel,
gm.createddate,
u.status
from
mxk_userinfo u,
mxk_groups g,
mxk_group_member gm
where u.instid = #{instId}
and g.instid = #{instId}
and gm.instid = #{instId}
<if test="groupId != null and groupId != ''">
and gm.groupid = #{groupId}
and g.id = #{groupId}
</if>
<if test="groupName != null and groupName != ''">
and g.name = #{groupName}
</if>
<if test="username != null and username != ''">
and u.username = #{username}
</if>
<if test="displayName != null and displayName != ''">
and u.displayname like '%${displayName}%'
</if>
and gm.type in( 'USER','USER-DYNAMIC')
and gm.groupid = g.id
and gm.memberid = u.id
</select>
<select id="memberNotInGroup" parameterType="GroupMember" resultType="GroupMember">
select distinct
u.id,
u.username,
u.usertype,
u.windowsaccount,
u.displayname ,
u.nickname ,
u.namezhspell,
u.namezhshortspell,
u.givenname ,
u.middlename ,
u.familyname ,
u.gender,
u.authntype,
u.mobile,
u.email,
u.workemail,
u.workphonenumber,
u.employeenumber,
u.division,
u.costcenter,
u.organization,
u.departmentid,
u.department,
u.jobtitle,
u.joblevel,
u.createdby,
u.createddate,
u.modifiedby,
u.modifieddate,
u.status
from
mxk_userinfo u
where
u.id not in(
select gm.memberid
from `mxk_groups` g,mxk_group_member gm
where 1 = 1
<if test="groupId != null and groupId != ''">
and gm.groupid = #{groupId}
and g.id = #{groupId}
</if>
<if test="groupName != null and groupName != ''">
and g.name = #{groupName}
</if>
and gm.type in( 'USER','USER-DYNAMIC')
and gm.groupid = g.id
)
<if test="username != null and username != ''">
and u.username = #{username}
</if>
<if test="displayName != null and displayName != ''">
and u.displayname like '%${displayName}%'
</if>
</select>
<select id="groupsNoMember" parameterType="GroupMember" resultType="Groups">
select distinct
g.*
from
mxk_groups g
where
g.id not in(
select
gm.groupid
from mxk_group_member gm,mxk_userinfo u
where gm.memberid = u.id
<if test="username != null and username != ''">
and u.username = #{username}
</if>
<if test="memberId != null and memberId != ''">
and gm.memberid = #{memberid}
</if>
)
<if test="groupName != null and groupName != ''">
and g.name = #{groupName}
</if>
</select>
<!-- GROUP_MEMBER Group Member-->
<select id="groupMemberInGroup" parameterType="GroupMember" resultType="Groups">
select distinct
ig.*
from
`mxk_groups` ig,
`mxk_groups` g,
mxk_group_member gm
where
1 = 1
and gm.groupid = g.id
and gm.memberid = ig.id
and gm.type = 'GROUP'
<if test="groupId != null and groupId != ''">
and gm.groupid = #{groupId}
and g.id = #{groupId}
</if>
<if test="groupName != null and groupName != ''">
and g.name = #{groupName}
</if>
</select>
<update id="addDynamicGroupMember" parameterType="Groups" >
insert into mxk_group_member(
id,
groupid,
memberid,
type,
instid
)
select
concat('${id}_',u.id) id,
'${id}' groupid,
u.id memberid,
'USER-DYNAMIC' type,
'${instId}' instid
from mxk_userinfo u
where not exists(
select 1 from mxk_group_member gm
where gm.groupid=#{id}
and gm.memberid=u.id
and gm.type='USER-DYNAMIC'
)
<if test="filters != null and filters != ''">
and (${filters})
</if>
<if test="orgIdsList != null and orgIdsList != ''">
and u.departmentid in( ${orgIdsList})
</if>
</update>
<delete id="deleteDynamicGroupMember" parameterType="Groups" >
delete from mxk_group_member gm
where type = 'user-dynamic'
and gm.groupid=#{id}
and not exists(
select 1
from mxk_userinfo u
where 1 = 1
and u.id=gm.memberid
<if test="filters != null and filters != ''">
and (${filters})
</if>
<if test="orgIdsList != null and orgIdsList != ''">
and u.departmentid in ( ${orgIdsList})
</if>
)
</delete>
<select id="queryMemberByGroupId" parameterType="string" resultType="UserInfo">
select distinct
g.groupId,
g.groupName,
u.id,
u.username,
u.usertype,
u.windowsaccount,
u.displayname ,
u.nickname ,
u.namezhspell,
u.namezhshortspell,
u.givenname ,
u.middlename ,
u.familyname ,
u.gender,
u.authntype,
u.mobile,
u.email,
u.workemail,
u.workphonenumber,
u.employeenumber,
u.division,
u.costcenter,
u.organization,
u.departmentid,
u.department,
u.jobtitle,
u.joblevel,
gm.createddate,
u.status
from
mxk_userinfo u,
mxk_groups g,
mxk_group_member gm
where 1 = 1
and gm.groupid = #{value}
and g.id = #{value}
and gm.type in( 'USER','USER-DYNAMIC')
and gm.groupid = g.id
and gm.memberid = u.id
</select>
<delete id="deleteByGroupId" parameterType="string" >
delete from mxk_group_member gm
where gm.groupid = #{value} and groupId != 'ROLE_ALL_USER'
</delete>
</mapper>

View File

@@ -1,78 +0,0 @@
<?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="org.maxkey.persistence.mapper.GroupsMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name like '%${name}%'
</if>
</sql>
<select id="queryPageResults" parameterType="Groups" resultType="Groups">
select
*
from
`mxk_groups`
where instid = #{instId}
<include refid="where_statement"/>
</select>
<select id="queryDynamicGroups" parameterType="Groups" resultType="Groups">
select
*
from
`mxk_groups`
where instid = #{instId}
and dynamic = '1'
<include refid="where_statement"/>
</select>
<update id="logisticDelete" parameterType="Groups" >
update `mxk_groups` set
status = '2'
where instid = #{instId}
<if test="id != null">
and id = #{id}
</if>
<if test="name != name">
and name = #{name}
</if>
</update>
<update id="logisticBatchDelete" parameterType="java.util.List">
update `mxk_groups`
set status='2'
where instid = #{instId}
and id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="queryGroupByUserId" parameterType="string" resultType="Groups">
select distinct
g.*
from
mxk_userinfo u,
mxk_groups g,
mxk_group_member gm
where u.instid = #{instId}
and g.instid = #{instId}
and gm.instid = #{instId}
and gm.memberid = #{value}
and u.id = #{value}
and gm.type in( 'USER','USER-DYNAMIC')
and gm.groupid = g.id
and gm.memberid = u.id
</select>
</mapper>

View File

@@ -1,37 +0,0 @@
<?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="org.maxkey.persistence.mapper.NoticesMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="title != null and title != ''">
and title like '%${title}%'
</if>
</sql>
<select id="queryPageResults" parameterType="Notices" resultType="Notices">
select
*
from
mxk_notices
where
instid = #{instId}
<include refid="where_statement"/>
order by modifieddate desc
</select>
<select id="queryLastedNotices" parameterType="Notices" resultType="Notices">
select
*
from
mxk_notices
where instid = #{instId}
order by modifieddate desc
limit 1
</select>
</mapper>

View File

@@ -10,13 +10,13 @@
and name = #{name}
</if>
</sql>
<select id="memberInRole" parameterType="RoleMember" resultType="RoleMember">
select distinct
r.id as roleid,
r.name as rolename,
r.dynamic dynamic,
rm.id as id,
r.id as roleid,
r.name as rolename,
r.dynamic dynamic,
u.username,
u.usertype,
u.windowsaccount,
@@ -46,23 +46,22 @@
u.jobtitle,
u.joblevel,
rm.createddate,
u.status
from
mxk_userinfo u,
mxk_roles r,
mxk_roles r,
mxk_role_member rm
where u.instid = #{instId}
and r.instid = #{instId}
and rm.instid = #{instId}
where u.instid = #{instId}
and r.instid = #{instId}
and rm.instid = #{instId}
<if test="roleId != null and roleId != ''">
and rm.roleid = #{roleId}
and r.id = #{roleId}
</if>
<if test="roleName != null and roleName != ''">
and r.name = #{roleName}
and g.name = #{roleName}
</if>
<if test="username != null and username != ''">
and u.username = #{username}
@@ -127,9 +126,8 @@
and r.id = #{roleId}
</if>
<if test="roleName != null and roleName != ''">
and r.name = #{roleName}
and g.name = #{roleName}
</if>
and rm.type in( 'USER','USER-DYNAMIC')
and rm.roleid = r.id
)
@@ -141,7 +139,6 @@
</if>
</select>
<select id="rolesNoMember" parameterType="RoleMember" resultType="Roles">
select distinct
r.*
@@ -154,9 +151,9 @@
from mxk_role_member rm,mxk_userinfo u
where rm.memberid = u.id
<if test="username != null and username != ''">
and u.username = #{username}
</if>
<if test="memberId != null and memberId != ''">
and u.username = #{username}
</if>
<if test="memberId != null and memberId != ''">
and rm.memberid = #{memberid}
</if>
)
@@ -164,20 +161,20 @@
and r.name = #{roleName}
</if>
</select>
<!-- ROLE_MEMBER Roles Member-->
<!-- ROLE_MEMBER ROLE Member-->
<select id="roleMemberInRole" parameterType="RoleMember" resultType="Roles">
select distinct
ir.*
ig.*
from
mxk_roles ir,
mxk_roles r,
mxk_role_member rm
where
1 = 1
and rm.groupid = r.id
and rm.memberid = ir.id
and rm.type in( 'USER','USER-DYNAMIC')
and rm.roleid = g.id
and rm.memberid = ig.id
and rm.type = 'ROLE'
<if test="roleId != null and roleId != ''">
and rm.roleid = #{roleId}
and r.id = #{roleId}
@@ -192,13 +189,15 @@
id,
roleid,
memberid,
type
type,
instid
)
select
concat('${id}_',u.id) id,
'${id}' ROLEID,
'${id}' roleid,
u.id memberid,
'USER-DYNAMIC' type
'USER-DYNAMIC' type,
'${instId}' instid
from mxk_userinfo u
where not exists(
select 1 from mxk_role_member rm
@@ -207,7 +206,7 @@
and rm.type='USER-DYNAMIC'
)
<if test="filters != null and filters != ''">
${filters}
and (${filters})
</if>
<if test="orgIdsList != null and orgIdsList != ''">
and u.departmentid in( ${orgIdsList})
@@ -216,25 +215,73 @@
<delete id="deleteDynamicRoleMember" parameterType="Roles" >
delete from mxk_role_member rm
where type = 'USER-DYNAMIC'
and rm.roleid = #{id}
where type = 'user-dynamic'
and rm.roleid=#{id}
and not exists(
select 1
from mxk_userinfo u
where 1 = 1
and u.id=rm.memberid
<if test="filters != null and filters != ''">
${filters}
and (${filters})
</if>
<if test="orgIdsList != null and orgIdsList != ''">
and u.departmentid in( ${orgIdsList})
and u.departmentid in ( ${orgIdsList})
</if>
)
</delete>
<select id="queryMemberByRoleId" parameterType="string" resultType="UserInfo">
select distinct
r.roleId,
r.roleName,
u.id,
u.username,
u.usertype,
u.windowsaccount,
u.displayname ,
u.nickname ,
u.namezhspell,
u.namezhshortspell,
u.givenname ,
u.middlename ,
u.familyname ,
u.gender,
u.authntype,
u.mobile,
u.email,
u.workemail,
u.workphonenumber,
u.employeenumber,
u.division,
u.costcenter,
u.organization,
u.departmentid,
u.department,
u.jobtitle,
u.joblevel,
rm.createddate,
u.status
from
mxk_userinfo u,
mxk_roles r,
mxk_role_member rm
where 1 = 1
and rm.roleid = #{value}
and g.id = #{value}
and rm.type in( 'USER','USER-DYNAMIC')
and rm.roleid = r.id
and rm.memberid = u.id
</select>
<delete id="deleteByRoleId" parameterType="string" >
delete from mxk_role_member rm
where rm.roleid=#{value}
where rm.roleid = #{value} and roleId != 'ROLE_ALL_USER'
</delete>
</mapper>

View File

@@ -1,6 +1,6 @@
<?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="org.maxkey.persistence.mapper.GroupPrivilegesMapper" >
<mapper namespace="org.maxkey.persistence.mapper.RolePermissionsMapper" >
<sql id="where_statement">
<if test="id != null and id != ''">
@@ -18,12 +18,12 @@
</sql>
<!-- AppGroup -->
<select id="appsInGroup" parameterType="GroupPrivileges" resultType="GroupPrivileges">
<select id="appsInRole" parameterType="RolePermissions" resultType="RolePermissions">
select
gp.id,
gp.groupid,
g.name groupname,
gp.appid,
p.id,
p.roleid,
r.name rolename,
apps.id appid,
apps.name,
apps.name appname,
apps.icon,
@@ -35,22 +35,22 @@
apps.vendorurl
from
mxk_apps apps,
mxk_group_privileges gp,
mxk_groups g
mxk_role_permissions p,
mxk_roles r
where
apps.instid = #{instId}
and gp.instid = #{instId}
and g.instid = #{instId}
and gp.appid = apps.id
and gp.groupid = g.id
<if test="groupId != null and groupId != ''">
and gp.groupid = #{groupId}
and g.id = #{groupId}
apps.instid = #{instId}
and p.instid = #{instId}
and r.instid = #{instId}
and p.appid = apps.id
and p.roleid = r.id
<if test="roleId != null and roleId != ''">
and p.roleid = #{roleId}
and r.id = #{roleId}
</if>
<include refid="where_statement"/>
</select>
<select id="appsNotInGroup" parameterType="GroupPrivileges" resultType="GroupPrivileges">
<select id="appsNotInRole" parameterType="RolePermissions" resultType="RolePermissions">
select
*
from
@@ -61,9 +61,9 @@
select
appid
from
mxk_group_privileges
mxk_role_permissions
where
groupid = #{groupId}
roleid = #{roleId}
)
<include refid="where_statement"/>
</select>

View File

@@ -0,0 +1,52 @@
<?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="org.maxkey.persistence.mapper.RolePrivilegesMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name like '%${name}%'
</if>
</sql>
<select id="queryRolePrivileges" parameterType="RolePrivileges" resultType="RolePrivileges">
select
*
from
mxk_role_privileges
where instid = #{instId}
and status = 1
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="roleId != null and roleId != ''">
and roleid = #{roleId}
</if>
<if test="appId != null and appId != ''">
and appid = #{appId}
</if>
</select>
<update id="deleteRolePrivileges" parameterType="java.util.List">
update mxk_role_privileges
set status = 9
where 1 = 1 and
<foreach item="item" collection="list" open="(" separator="or" close=")">
( id = #{item.id} and instid = #{item.instId} )
</foreach>
</update>
<insert id="insertRolePrivileges" parameterType="java.util.List">
insert into mxk_role_privileges ( id,appid,roleid,resourceid,status,instid)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.appId},#{item.roleId},#{item.resourceId},#{item.status},#{item.instId})
</foreach>
</insert>
</mapper>

View File

@@ -11,23 +11,24 @@
</if>
</sql>
<select id="queryDynamicRoles" parameterType="Roles" resultType="Roles">
select
*
from
mxk_roles
where instid = #{instId}
and dynamic = '1'
<include refid="where_statement"/>
</select>
<select id="queryPageResults" parameterType="Roles" resultType="Roles">
select
*
from
mxk_roles
where
instid = #{instId}
where instid = #{instId}
<include refid="where_statement"/>
</select>
<select id="queryDynamicRoles" parameterType="Roles" resultType="Roles">
select
*
from
mxk_roles
where instid = #{instId}
and dynamic = '1'
<include refid="where_statement"/>
</select>
@@ -46,9 +47,9 @@
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_roles
update mxk_roles
set status='2'
where instid = #{instId}
where instid = #{instId}
and id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
@@ -56,42 +57,22 @@
</update>
<select id="queryRolePrivileges" parameterType="RolePrivileges" resultType="RolePrivileges">
select
*
from
mxk_role_privileges
where instid = #{instId}
and status = 1
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="roleId != null and roleId != ''">
and roleid = #{roleId}
</if>
<if test="appId != null and appId != ''">
and appid = #{appId}
</if>
<select id="queryRolesByUserId" parameterType="string" resultType="Roles">
select distinct
r.*
from
mxk_userinfo u,
mxk_roles r,
mxk_role_member rm
where u.instid = #{instId}
and r.instid = #{instId}
and rm.instid = #{instId}
and rm.memberid = #{value}
and u.id = #{value}
and rm.type in( 'USER','USER-DYNAMIC')
and rm.groupid = r.id
and rm.memberid = u.id
</select>
<update id="deleteRolePrivileges" parameterType="java.util.List">
update mxk_role_privileges
set status = 9
where 1 = 1 and
<foreach item="item" collection="list" open="(" separator="or" close=")">
( id = #{item.id} and instid = #{item.instId} )
</foreach>
</update>
<insert id="insertRolePrivileges" parameterType="java.util.List">
insert into mxk_role_privileges ( id,appid,roleid,resourceid,status,instid)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.appId},#{item.roleId},#{item.resourceId},#{item.status},#{item.instId})
</foreach>
</insert>
</mapper>