提交 44a02d96 authored 作者: gongwenjie's avatar gongwenjie

合并分支 'gwj' 到 'master'

代码修改 查看合并请求 !55
流水线 #76 已取消 于阶段
...@@ -121,4 +121,11 @@ public class UserController { ...@@ -121,4 +121,11 @@ public class UserController {
return ok(iUserService.encryPas()); return ok(iUserService.encryPas());
} }
@ApiOperation(value = "添加关联", response = User.class)
@GetMapping("/addGuanLian")
public ResponseEntity deleteRoot() {
return ok(iUserService.deleteRoot());
}
} }
...@@ -24,4 +24,8 @@ public interface AuthorityDao extends MongoRepository<Authority, String> { ...@@ -24,4 +24,8 @@ public interface AuthorityDao extends MongoRepository<Authority, String> {
* @return * @return
*/ */
Authority findByIdInAndName(List<String> ids,String name); Authority findByIdInAndName(List<String> ids,String name);
void deleteAllByNameIn(List<String> name);
List<Authority> findAllByNameIn(List<String> name);
} }
...@@ -16,4 +16,8 @@ public interface RoleDao extends MongoRepository<Role, String> { ...@@ -16,4 +16,8 @@ public interface RoleDao extends MongoRepository<Role, String> {
List<Role> findAllByDepartmentIdAndIsLeader(String departmentIds,String isLeader); List<Role> findAllByDepartmentIdAndIsLeader(String departmentIds,String isLeader);
List<Role> findAllByDepartmentId(String departmentId); List<Role> findAllByDepartmentId(String departmentId);
Role findAllByName(String name);
void deleteByName(String name);
} }
...@@ -112,4 +112,11 @@ public interface IUserService { ...@@ -112,4 +112,11 @@ public interface IUserService {
List<String> findUsers(String userId); List<String> findUsers(String userId);
Object encryPas(); Object encryPas();
/**
* 删除root用户
* @return
*/
Object deleteRoot();
} }
...@@ -6,6 +6,7 @@ import com.zjty.tynotes.pas.entity.vo.PageRequest; ...@@ -6,6 +6,7 @@ import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse; import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.pas.service.IDepartmentService; import com.zjty.tynotes.pas.service.IDepartmentService;
import com.zjty.tynotes.pas.service.IUserService; import com.zjty.tynotes.pas.service.IUserService;
import com.zjty.tynotes.pas.task.Init;
import com.zjty.tynotes.search.subject.service.EsUtil; import com.zjty.tynotes.search.subject.service.EsUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -58,6 +59,8 @@ public class UserServiceImpl implements IUserService { ...@@ -58,6 +59,8 @@ public class UserServiceImpl implements IUserService {
@Autowired @Autowired
EsUtil esUtil; EsUtil esUtil;
@Autowired
private Init init;
@Override @Override
...@@ -390,6 +393,34 @@ public class UserServiceImpl implements IUserService { ...@@ -390,6 +393,34 @@ public class UserServiceImpl implements IUserService {
return pasUserDao.saveAll(users); return pasUserDao.saveAll(users);
} }
@Override
public Object deleteRoot() {
User root = pasUserDao.findByUsername("root");
List<UserRole> userRoles = userRoleDao.findAllByUserId(root.getId());
Role role = roleDao.findAllByName("管理员");
if(userRoles==null||userRoles.size()==0){
UserRole userRole = new UserRole(null,root.getId(),role.getId());
userRoleDao.save(userRole);
}
List<String> auname = new ArrayList<>();
auname.add("用户管理");
auname.add("权限管理");
auname.add("角色管理");
auname.add("考勤管理");
auname.add("部门管理");
List<RoleAuthority> roleAuthoritieList = new ArrayList<>();
List<Authority> authorities = authorityDao.findAllByNameIn(auname);
List<RoleAuthority> roleAuthorities = roleAuthorityDao.findAllByRoleId(role.getId());
if(roleAuthorities==null&&roleAuthorities.size()==0){
for (Authority authority : authorities) {
roleAuthoritieList.add(new RoleAuthority(null,role.getId(),authority.getId()));
}
roleAuthorityDao.saveAll(roleAuthoritieList);
}
return null;
}
/** /**
* 查询可查看的部门id集合 * 查询可查看的部门id集合
* @param id * @param id
......
...@@ -25,11 +25,7 @@ public class Init implements CommandLineRunner { ...@@ -25,11 +25,7 @@ public class Init implements CommandLineRunner {
@Autowired @Autowired
PasUserDao pasUserDao; PasUserDao pasUserDao;
@Autowired
private IAuthorityService iAuthorityService;
@Autowired
private IRoleService iRoleService;
@Autowired @Autowired
private AuthorityDao authorityDao; private AuthorityDao authorityDao;
@Autowired @Autowired
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论