添加角色代码 未测试

master
bynt 12 months ago
parent d15641dc94
commit 17642414d4

@ -36,4 +36,7 @@ public class RoleNumberConstants {
* *
*/ */
public static final Long MINUS_TEN_NUMBER = 10L; public static final Long MINUS_TEN_NUMBER = 10L;
} }

@ -544,10 +544,10 @@ public class OrganizeServiceImpl implements OrganizeService {
List<Long> roles = Lists.newArrayList(); List<Long> roles = Lists.newArrayList();
Long roleId = Collections.min(roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getId).collect(Collectors.toList())); Long roleId = Collections.min(roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getId).collect(Collectors.toList()));
// 判断角色,管理员只查组长角色的用户 // 判断角色,管理员只查组长角色的用户
if (roleId.equals(RoleNumberConstants.MINUS_EIGHT_NUMBER) || roleId.equals(RoleNumberConstants.MINUS_TEN_NUMBER)) { if (roleId.equals(RoleNumberConstants.MINUS_NINE_NUMBER)) {
roles.add(RoleNumberConstants.MINUS_NINE_NUMBER);
} else {
roles.add(RoleNumberConstants.MINUS_FIVE_NUMBER); roles.add(RoleNumberConstants.MINUS_FIVE_NUMBER);
} else {
roles.add(RoleNumberConstants.MINUS_NINE_NUMBER);
} }
//查询本公司-角色下所有用户 //查询本公司-角色下所有用户
List<UserDto> userDtoList = userService.findByManager(roles); List<UserDto> userDtoList = userService.findByManager(roles);

@ -62,6 +62,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
@ -252,6 +253,7 @@ public class UserServiceImpl implements UserService {
Set<Role> roles = userDTO.getRoles(); Set<Role> roles = userDTO.getRoles();
if (CollUtil.isNotEmpty(roles)) { if (CollUtil.isNotEmpty(roles)) {
for (Role role : roles) { for (Role role : roles) {
// 为管理员
if (businessConfig.getIds().contains(role.getId())) { if (businessConfig.getIds().contains(role.getId())) {
flag = Boolean.TRUE; flag = Boolean.TRUE;
break; break;
@ -535,6 +537,7 @@ public class UserServiceImpl implements UserService {
if (Boolean.FALSE.equals(resources.getEnabled())) { if (Boolean.FALSE.equals(resources.getEnabled())) {
this.remoteAuthService.delete(Collections.singleton(resources.getId())); this.remoteAuthService.delete(Collections.singleton(resources.getId()));
for (Role role : resources.getRoles()) { for (Role role : resources.getRoles()) {
// 禁用管理员账号 同时禁用下面所有账号
if (businessConfig.getIds().contains(role.getId())) { if (businessConfig.getIds().contains(role.getId())) {
List<User> byWhichUserId = userRepository.findByWhichUserId(user.getId()); List<User> byWhichUserId = userRepository.findByWhichUserId(user.getId());
if (CollUtil.isNotEmpty(byWhichUserId)) { if (CollUtil.isNotEmpty(byWhichUserId)) {
@ -660,8 +663,9 @@ public class UserServiceImpl implements UserService {
if (replaceUserId != null) if (replaceUserId != null)
replaceRoleIds = findById(replaceUserId).getRoles().stream().map(RoleSmallDto::getId).collect(Collectors.toSet()); replaceRoleIds = findById(replaceUserId).getRoles().stream().map(RoleSmallDto::getId).collect(Collectors.toSet());
// 一: 删除业务管理员账号(删除公司) // 一: 删除业务管理员账号(删除公司)
if (roleIds.contains(RoleNumberConstants.MINUS_EIGHT_NUMBER) // 求交集
|| roleIds.contains(RoleNumberConstants.MINUS_TEN_NUMBER)) { Collection<Long> intersection = CollectionUtils.intersection(businessConfig.getIds(), roleIds);
if (!intersection.isEmpty()) {
UserQueryCriteria userQueryCriteria = new UserQueryCriteria(); UserQueryCriteria userQueryCriteria = new UserQueryCriteria();
userQueryCriteria.setCompanyId(user.getCompanyId()); userQueryCriteria.setCompanyId(user.getCompanyId());
List<UserDto> userDtos = queryAll(userQueryCriteria); List<UserDto> userDtos = queryAll(userQueryCriteria);
@ -801,7 +805,10 @@ public class UserServiceImpl implements UserService {
if (role.getId() == DefaultNumberConstants.FIVE_NUMBER) { if (role.getId() == DefaultNumberConstants.FIVE_NUMBER) {
convert.setIsOperator(Boolean.TRUE); convert.setIsOperator(Boolean.TRUE);
} }
if (role.getId() == DefaultNumberConstants.TEN_NUMBER) { // TODO
if (role.getId() == DefaultNumberConstants.TEN_NUMBER
|| role.getId() == DefaultNumberConstants.FIFTEEN_NUMBER
|| role.getId() == DefaultNumberConstants.SIXTEEN_NUMBER) {
convert.setIsTokerAdmin(Boolean.TRUE); convert.setIsTokerAdmin(Boolean.TRUE);
} }
} }

@ -7,12 +7,12 @@ spring:
server-addr: localhost:8848 server-addr: localhost:8848
redis: redis:
database: 2 database: 2
host: 8.130.96.163 host: 39.100.77.21
timeout: 5000 timeout: 5000
password: password: sC33HXphkHBRj4Jb
elasticsearch: elasticsearch:
rest: rest:
uris: 8.130.96.163:9200 uris: 39.100.77.21:9200
read-timeout: 30s read-timeout: 30s
connection-timeout: 5s connection-timeout: 5s
username: elastic username: elastic
@ -21,7 +21,7 @@ spring:
druid: druid:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://8.130.96.163:3306/ad_platform?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull url: jdbc:mysql://39.100.77.21:3306/ad_platform?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull
username: root username: root
password: y7z7noq2 password: y7z7noq2
# 初始连接数 # 初始连接数
@ -93,7 +93,8 @@ business:
ids: ids:
- 8 - 8
- 10 - 10
- 15
- 16
#是否允许生成代码生产环境设置为false #是否允许生成代码生产环境设置为false
generator: generator:

@ -89,6 +89,8 @@ business:
ids: ids:
- 8 - 8
- 10 - 10
- 15
- 16
#是否允许生成代码生产环境设置为false #是否允许生成代码生产环境设置为false
generator: generator:

Loading…
Cancel
Save