提交 ff3b8bf9 authored 作者: gongwenjie's avatar gongwenjie

代码修改

上级 6ffd9ce5
......@@ -57,7 +57,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.cors().and()
.authorizeRequests()
.antMatchers(HttpMethod.GET,"/pas/department").permitAll()
// .requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.antMatchers("/pas/user/findUserList/**").permitAll()
// .requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.antMatchers("/pas/user").hasAnyAuthority("用户管理")
.antMatchers("/pas/authority").hasAnyAuthority("权限管理")
.antMatchers("/pas/config").hasAnyAuthority("考勤管理")
......
......@@ -97,8 +97,11 @@ public class UserController {
return ok(iUserService.findUserById(id));
}
@ApiOperation(value = "根据用户id查询该用户可发布id的人员", response = User.class)
@GetMapping("/findUserList/{id}")
public ResponseEntity findUserList(@PathVariable("id") String id) {
return ok(iUserService.findUserList(id));
}
}
......@@ -97,4 +97,11 @@ public interface IUserService {
*/
List<User> findParentManager(String userId);
/**
* 根据人员id查询可发布任务的人员
* @param userId
* @return
*/
List<User> findUserList(String userId);
}
......@@ -300,6 +300,77 @@ public class UserServiceImpl implements IUserService {
return null;
}
@Override
public List<User> findUserList(String userId){
List<String> departmentList = findDepartmentList(userId);
List<User> all = pasUserDao.findAll();
List<User> users = new ArrayList<>();
if(all!=null){
for (User user : all) {
List<String> departmentIds = user.getDepartmentIds();
if(departmentIds!=null){
for (String departId : departmentIds) {
if(departmentList.contains(departId)){
users.add(user);
break;
}
}
}
}
}
return users;
}
/**
* 查询可查看的部门id集合
* @param id
* @return
*/
private List<String> findDepartmentList(String id) {
List<UserRole> userRoles = userRoleDao.findAllByUserId(id);
List<String> roleIds = new ArrayList<>();
List<String> departmentIds = new ArrayList<>();
for (UserRole userRole : userRoles) {
roleIds.add(userRole.getRoleId());
}
List<Role> roles = roleDao.findAllByIdIn(roleIds);
for (Role role : roles) {
List<RoleAuthority> roleAuthorities = roleAuthorityDao.findAllByRoleId(role.getId());
List<String> authorityIds = new ArrayList<>();
for (RoleAuthority roleAuthority : roleAuthorities) {
authorityIds.add(roleAuthority.getAuthorityId());
}
Authority authority = authorityDao.findByIdInAndName(authorityIds, "发布任务");
if(authority!=null){
String departmentId = role.getDepartmentId();
departmentIds.add(departmentId);
}
}
List<String> departmentIdList = new ArrayList<>();
getDepartments(departmentIdList,departmentIds);
return departmentIdList;
}
public void getDepartments(List<String> departmentIdList,List<String> departmentIds) {
for (String string : departmentIds) {
if(departmentIdList.contains(string)){
continue;
}
List<Department> departmentList = departmentDao.findAllByParentId(string);
List<String> departments = new ArrayList<>();
for (Department department : departmentList) {
departments.add(department.getId());
}
departmentIdList.add(string);
getDepartments(departmentIdList,departments);
}
}
}
package com.zjty.tynotes.pas.task;
import com.zjty.tynotes.pas.dao.AuthorityDao;
import com.zjty.tynotes.pas.dao.PasUserDao;
import com.zjty.tynotes.pas.entity.Authority;
import com.zjty.tynotes.pas.entity.Role;
......@@ -32,6 +33,8 @@ public class Init implements CommandLineRunner {
@Autowired
private IRoleService iRoleService;
@Autowired
private AuthorityDao authorityDao;
public User root;
......@@ -40,6 +43,37 @@ public class Init implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
List<Authority> authorities1 = new ArrayList<>();
List<Authority> authorityList = authorityDao.findAll();
List<String> authorityName = new ArrayList<>();
if(authorityList!=null){
for (Authority authority : authorityList) {
authorityName.add(authority.getName());
}
}
if(!authorityName.contains("查看任务")){
authorities1.add(new Authority(null,"查看任务","能够查看员工的任务"));
}
if(!authorityName.contains("发布任务")){
authorities1.add(new Authority(null,"发布任务","能够发布任务给其他用户"));
}
if(!authorityName.contains("分解任务")){
authorities1.add(new Authority(null,"分解任务","对任务具有分解的功能"));
}
if(!authorityName.contains("删除任务")){
authorities1.add(new Authority(null,"删除任务","能够对任务进行删除"));
}
if(!authorityName.contains("修改任务")){
authorities1.add(new Authority(null,"修改任务","能够对任务进行修改"));
}
if(!authorityName.contains("查看人员")){
authorities1.add(new Authority(null,"查看人员","能够查看人员"));
}
if(authorities1!=null){
authorityDao.saveAll(authorities1);
}
// iRoleService.deleteAll();
root = new User();
Role role = new Role(null,"管理员","管理系统的人员",null,null,null);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论