Commit fd3266f7 authored by suntao's avatar suntao

用户 角色mapping 修改

parent 60ddfd96
......@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.Predicate;
import java.util.*;
import java.util.stream.Collectors;
/**
* Created by WeiWei on 2019/7/22.
......@@ -290,6 +291,10 @@ public class UserServiceImpl implements UserService {
return Result.buildFail("不存在对应的角色");
}
Role role = roleRepository.getOne(roleId);
List<Long> idList = exist.getRoles().stream().map(Role::getId).collect(Collectors.toList());
if (!idList.contains(roleId)) {
exist.getRoles().add(role);
}
if (roleId == 1L) {
// 将普通用户设置成超级管理,需要级联设置用户级别
exist.setRank(UserRank.SUPER_ADMINISTRATOR);
......@@ -299,7 +304,7 @@ public class UserServiceImpl implements UserService {
exist.setRank(UserRank.OPERATOR);
}
}
exist.setRoles(Collections.singletonList(role));
}
Long channelId = exist.getChannelId();
......
......@@ -15,6 +15,7 @@ public class Primary implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment