提交 2a5060fe authored 作者: gongwenjie's avatar gongwenjie

代码修改

上级 2ca10300
......@@ -52,21 +52,21 @@
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.dingtalk</groupId>
<artifactId>2</artifactId>
<version>2.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/jar/taobao-sdk-java-auto_1479188381469-20200309-source.jar</systemPath>
</dependency>
<!--<dependency>-->
<!--<groupId>com.dingtalk</groupId>-->
<!--<artifactId>2</artifactId>-->
<!--<version>2.3</version>-->
<!--<scope>system</scope>-->
<!--<systemPath>${project.basedir}/src/main/resources/jar/taobao-sdk-java-auto_1479188381469-20200309-source.jar</systemPath>-->
<!--</dependency>-->
<dependency>
<groupId>com.dingtalk</groupId>
<artifactId>3</artifactId>
<version>2.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/jar/taobao-sdk-java-auto_1479188381469-20200309.jar</systemPath>
</dependency>
<!--<dependency>-->
<!--<groupId>com.dingtalk</groupId>-->
<!--<artifactId>3</artifactId>-->
<!--<version>2.3</version>-->
<!--<scope>system</scope>-->
<!--<systemPath>${project.basedir}/src/main/resources/jar/taobao-sdk-java-auto_1479188381469-20200309.jar</systemPath>-->
<!--</dependency>-->
</dependencies>
......
package com.zjty.tynotes.pas.controller;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
......@@ -102,12 +100,10 @@ public class UserController {
@ApiOperation(value = "根据用户id查询该用户可发布id的人员", response = User.class)
@GetMapping("/findUserList/{id}")
public ResponseEntity findUserList(@PathVariable("id") String id) {
return ok(iUserService.findUserList(id));
String authoryName = "发布任务";
return ok(iUserService.findUserList(id,authoryName));
}
public static void main(String[] args) {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/get");
}
}
......@@ -43,4 +43,7 @@ public interface IDepartmentService {
boolean deleteDepartment(String id);
boolean updateDepartment(Department department);
}
......@@ -102,6 +102,13 @@ public interface IUserService {
* @param userId
* @return
*/
List<User> findUserList(String userId);
List<User> findUserList(String userId,String authoryName);
/**
* 供任务模块调用,根据人员id查询该人员能看到任务的所有人员.
* @param userId
* @return
*/
List<String> findUsers(String userId);
}
......@@ -3,9 +3,7 @@ package com.zjty.tynotes.pas.service.impl;
import com.zjty.tynotes.pas.dao.DepartmentDao;
import com.zjty.tynotes.pas.dao.PasUserDao;
import com.zjty.tynotes.pas.dao.RoleDao;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.Role;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.*;
import com.zjty.tynotes.pas.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -114,4 +112,8 @@ public class DepartmentServiceImpl implements IDepartmentService {
department.setDepartments(departmentList);
}
}
}
......@@ -301,8 +301,8 @@ public class UserServiceImpl implements IUserService {
}
@Override
public List<User> findUserList(String userId){
List<String> departmentList = findDepartmentList(userId);
public List<User> findUserList(String userId,String authoryName){
List<String> departmentList = findDepartmentList(userId,authoryName);
List<User> all = pasUserDao.findAll();
List<User> users = new ArrayList<>();
if(all!=null){
......@@ -323,12 +323,28 @@ public class UserServiceImpl implements IUserService {
}
/**
* 根据人员id查询可查看的所有人员
* @param userId
* @return
*/
@Override
public List<String> findUsers(String userId){
String authorityName = "查看任务";
List<User> userList = findUserList(userId, authorityName);
List<String> userIds = new ArrayList<>();
for (User user : userList) {
userIds.add(user.getId());
}
return userIds;
}
/**
* 查询可查看的部门id集合
* @param id
* @return
*/
private List<String> findDepartmentList(String id) {
private List<String> findDepartmentList(String id,String authoryName) {
List<UserRole> userRoles = userRoleDao.findAllByUserId(id);
List<String> roleIds = new ArrayList<>();
List<String> departmentIds = new ArrayList<>();
......@@ -342,7 +358,7 @@ public class UserServiceImpl implements IUserService {
for (RoleAuthority roleAuthority : roleAuthorities) {
authorityIds.add(roleAuthority.getAuthorityId());
}
Authority authority = authorityDao.findByIdInAndName(authorityIds, "发布任务");
Authority authority = authorityDao.findByIdInAndName(authorityIds, authoryName);
if(authority!=null){
String departmentId = role.getDepartmentId();
departmentIds.add(departmentId);
......
......@@ -2,9 +2,9 @@ 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;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.dao.RoleDao;
import com.zjty.tynotes.pas.dao.UserRoleDao;
import com.zjty.tynotes.pas.entity.*;
import com.zjty.tynotes.pas.service.IAuthorityService;
import com.zjty.tynotes.pas.service.IDepartmentService;
import com.zjty.tynotes.pas.service.IRoleService;
......@@ -35,6 +35,10 @@ public class Init implements CommandLineRunner {
private IRoleService iRoleService;
@Autowired
private AuthorityDao authorityDao;
@Autowired
private RoleDao roleDao;
@Autowired
private UserRoleDao userRoleDao;
public User root;
......@@ -75,30 +79,49 @@ public class Init implements CommandLineRunner {
// iRoleService.deleteAll();
root = new User();
Role role = new Role(null,"管理员","管理系统的人员",null,null,null);
List<Authority> authorities = new ArrayList<>();
Authority authority2 = new Authority(null,"用户管理","无");
Authority authority1 = new Authority(null,"权限管理","无");
Authority authority3 = new Authority(null,"角色管理","无");
Authority authority4 = new Authority(null,"考勤管理","无");
Authority authority5 = new Authority(null,"部门管理","无");
authorities.add(authority2);
authorities.add(authority1);
authorities.add(authority3);
authorities.add(authority4);
authorities.add(authority5);
role.setAuthorities(authorities);
root.createUser();
root.setUsername("root");
root.setPassword(bCryptPasswordEncoder.encode("root"));
List<Role> roles = new ArrayList<>();
roles.add(role);
root.setRoles(roles);
User user = pasUserDao.findByUsername("管理员");
if(user!=null){
root = user;
}else{
this.root = new User();
Role role = new Role(null,"管理员","管理系统的人员",null,null,null);
List<Authority> authorities = new ArrayList<>();
Authority authority2 = new Authority(null,"用户管理","无");
Authority authority1 = new Authority(null,"权限管理","无");
Authority authority3 = new Authority(null,"角色管理","无");
Authority authority4 = new Authority(null,"考勤管理","无");
Authority authority5 = new Authority(null,"部门管理","无");
authorities.add(authority2);
authorities.add(authority1);
authorities.add(authority3);
authorities.add(authority4);
authorities.add(authority5);
role.setAuthorities(authorities);
this.root.createUser();
this.root.setUsername("root");
root.setPassword("root");
List<Role> roles = new ArrayList<>();
roles.add(role);
this.root.setRoles(roles);
List<Authority> authorities2 = authorityDao.saveAll(authorities);
List<Role> roles1 = roleDao.saveAll(roles);
Role role1 = roles1.get(0);
String id = role1.getId();
List<RoleAuthority> roleAuthorities = new ArrayList<>();
for (Authority authority : authorities2) {
roleAuthorities.add(new RoleAuthority(null,id,authority.getId()));
}
User save = pasUserDao.save(this.root);
UserRole userRole = new UserRole(null,save.getId(),id);
userRoleDao.save(userRole);
this.root.setPassword(bCryptPasswordEncoder.encode(root.getPassword()));
}
;
// User user1 = new User();
// user1.createUser();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论