Commit fd3266f7 authored by suntao's avatar suntao

用户 角色mapping 修改

parent 60ddfd96
...@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* Created by WeiWei on 2019/7/22. * Created by WeiWei on 2019/7/22.
...@@ -290,6 +291,10 @@ public class UserServiceImpl implements UserService { ...@@ -290,6 +291,10 @@ public class UserServiceImpl implements UserService {
return Result.buildFail("不存在对应的角色"); return Result.buildFail("不存在对应的角色");
} }
Role role = roleRepository.getOne(roleId); 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) { if (roleId == 1L) {
// 将普通用户设置成超级管理,需要级联设置用户级别 // 将普通用户设置成超级管理,需要级联设置用户级别
exist.setRank(UserRank.SUPER_ADMINISTRATOR); exist.setRank(UserRank.SUPER_ADMINISTRATOR);
...@@ -299,7 +304,7 @@ public class UserServiceImpl implements UserService { ...@@ -299,7 +304,7 @@ public class UserServiceImpl implements UserService {
exist.setRank(UserRank.OPERATOR); exist.setRank(UserRank.OPERATOR);
} }
} }
exist.setRoles(Collections.singletonList(role));
} }
Long channelId = exist.getChannelId(); Long channelId = exist.getChannelId();
......
...@@ -15,6 +15,7 @@ public class Primary implements Serializable { ...@@ -15,6 +15,7 @@ public class Primary implements Serializable {
@Id @Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; 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