소스 검색

用户权限信息调整

tags/24080901
liuxinxin 1 년 전
부모
커밋
cbc52f64c1
13개의 변경된 파일139개의 추가작업 그리고 119개의 파일을 삭제
  1. +5
    -5
      pmapi/pom.xml
  2. +3
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserAuthController.java
  3. +67
    -21
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java
  4. +0
    -16
      pmapi/src/main/java/com/ningdatech/pmapi/user/mapper/RoleInfoMapper.java
  5. +0
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/user/mapper/RoleInfoMapper.xml
  6. +4
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java
  7. +26
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java
  8. +27
    -9
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserInfoDetails.java
  9. +0
    -16
      pmapi/src/main/java/com/ningdatech/pmapi/user/service/IRoleInfoService.java
  10. +0
    -16
      pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserRoleService.java
  11. +0
    -20
      pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/RoleInfoServiceImpl.java
  12. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserAuthServiceImpl.java
  13. +6
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java

+ 5
- 5
pmapi/pom.xml 파일 보기

@@ -250,11 +250,11 @@
<groupId>com.ningdatech</groupId>
<artifactId>nd-flowable-starter</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.ningdatech</groupId>-->
<!-- <artifactId>nd-yxt-starter</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.ningdatech</groupId>-->
<!-- <artifactId>nd-yxt-starter</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
<!--浙政钉-->
<dependency>
<groupId>com.alibaba.xxpt</groupId>


+ 3
- 3
pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserAuthController.java 파일 보기

@@ -43,9 +43,9 @@ public class UserAuthController {
@ApiImplicitParam(name = "credential", value = "凭证", required = true, paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "loginType", value = "DING_QR_LOGIN 浙政钉扫码登陆,PHONE_VERIFICATION_CODE_LOGIN 手机号验证码登陆"
, required = true, paramType = "form", dataType = "String")})
public void loginByUsernameAndPassword(@RequestParam(value = "identifier",required = false) String identifier,
@RequestParam(value = "credential",required = false) String credential,
@RequestParam("loginType") String loginType) {
public void credentialLogin(@RequestParam(value = "identifier", required = false) String identifier,
@RequestParam(value = "credential", required = false) String credential,
@RequestParam("loginType") String loginType) {
// 不实现任何内容,只是为了出api文档
}



+ 67
- 21
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthLoginManage.java 파일 보기

@@ -1,6 +1,16 @@
package com.ningdatech.pmapi.user.manage;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.model.entity.UserRole;
import com.ningdatech.pmapi.sys.service.IRoleService;
import com.ningdatech.pmapi.sys.service.IUserRoleService;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.service.IUserAuthService;
@@ -8,7 +18,10 @@ import com.ningdatech.pmapi.user.service.IUserInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @author liuxinxin
@@ -21,6 +34,10 @@ public class UserAuthLoginManage {

private final IUserAuthService iUserAuthService;
private final IUserInfoService iUserInfoService;
private final IRoleService iRoleService;
private final IDingOrganizationService iDingOrganizationService;
private final IDingEmployeeInfoService iDingEmployeeInfoService;
private final IUserRoleService iUserRoleService;

/**
* 根据用户名获取
@@ -30,7 +47,7 @@ public class UserAuthLoginManage {
*/
public UserFullInfoDTO queryUserInfoInPasswordAuth(String username) {
UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO();
userFullInfoDTO.setCompanyId(1L);
// userFullInfoDTO.setCompanyId(1L);
userFullInfoDTO.setUserId(1L);
userFullInfoDTO.setIdentifier("123456");
userFullInfoDTO.setRealName("测试账号");
@@ -60,7 +77,7 @@ public class UserAuthLoginManage {
// return userFullInfoDTO;

UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO();
userFullInfoDTO.setCompanyId(1L);
// userFullInfoDTO.setCompanyId(1L);
userFullInfoDTO.setUserId(1L);
userFullInfoDTO.setIdentifier("123456");
userFullInfoDTO.setRealName("测试账号");
@@ -69,31 +86,60 @@ public class UserAuthLoginManage {
}

/**
* 根据accountId
* 根据accountId(浙政钉扫码登陆)
*
* @param accountId
* @return
*/
public UserFullInfoDTO queryUserInfoInAccountIdAuth(String accountId) {
// UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
// .eq(UserInfo::getAccountId, accountId));
// if (Objects.isNull(userInfo)) {
// return null;
// }
// UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO();
// userFullInfoDTO.setCompanyId(1L);
// userFullInfoDTO.setUserId(userInfo.getId());
// userFullInfoDTO.setIdentifier(userInfo.getRealName());
// userFullInfoDTO.setRealName(userInfo.getRealName());
// userFullInfoDTO.setUsername(userInfo.getRealName());
// return userFullInfoDTO;

// 返回用户全量信息
UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO();
userFullInfoDTO.setCompanyId(1L);
userFullInfoDTO.setUserId(1L);
userFullInfoDTO.setIdentifier("123456");
userFullInfoDTO.setRealName("测试账号");
userFullInfoDTO.setUsername("测试账号");

// 获取用户信息
UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getAccountId, accountId));
if (Objects.isNull(userInfo)) {
return null;
}

// 获取浙政钉雇员信息 组织信息
String employeeCode = userInfo.getEmployeeCode();
if (StringUtils.isNotBlank(employeeCode)) {
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService
.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)
.eq(DingEmployeeInfo::getMainJob, "true"));
DingEmployeeInfo dingEmployeeInfo = dingEmployeeInfoList.get(0);

String organizationCode = dingEmployeeInfo.getOrganizationCode();
List<DingOrganization> dingOrganizationList = iDingOrganizationService
.list(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getOrganizationCode, organizationCode));
DingOrganization dingOrganization = dingOrganizationList.get(0);

userFullInfoDTO.setOrganizationCode(dingOrganization.getOrganizationCode());
userFullInfoDTO.setOrganizationName(dingOrganization.getOrganizationName());
userFullInfoDTO.setRegionCode(dingOrganization.getDivisionCode());
}

List<Role> roleList = new ArrayList<>();
// 获取用户角色列表信息
List<UserRole> userRoleList = iUserRoleService
.list(Wrappers.lambdaQuery(UserRole.class)
.eq(UserRole::getUserId, userInfo.getId()));
if (CollectionUtil.isNotEmpty(userRoleList)) {
List<Long> roleIdList = userRoleList.stream()
.map(UserRole::getRoleId).distinct()
.collect(Collectors.toList());
roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList));
}
userFullInfoDTO.setUserRoleList(roleList);

// 装配返回
userFullInfoDTO.setUserId(userInfo.getId());
userFullInfoDTO.setIdentifier(userInfo.getRealName());
userFullInfoDTO.setRealName(userInfo.getRealName());
userFullInfoDTO.setUsername(userInfo.getRealName());
return userFullInfoDTO;
}
}

+ 0
- 16
pmapi/src/main/java/com/ningdatech/pmapi/user/mapper/RoleInfoMapper.java 파일 보기

@@ -1,16 +0,0 @@
package com.ningdatech.pmapi.user.mapper;

import com.ningdatech.pmapi.user.entity.RoleInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
* <p>
* 角色表 Mapper 接口
* </p>
*
* @author Liuxinxin
* @since 2023-01-05
*/
public interface RoleInfoMapper extends BaseMapper<RoleInfo> {

}

+ 0
- 5
pmapi/src/main/java/com/ningdatech/pmapi/user/mapper/RoleInfoMapper.xml 파일 보기

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.pmapi.user.mapper.RoleInfoMapper">

</mapper>

+ 4
- 2
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java 파일 보기

@@ -57,11 +57,13 @@ public class CredentialLoginUserDetailService implements UserDetailsService {
userInfoDetails.setUserId(userFullInfoDTO.getUserId());
userInfoDetails.setUsername(userFullInfoDTO.getUsername());
userInfoDetails.setRealName(userFullInfoDTO.getRealName());
userInfoDetails.setRole(userFullInfoDTO.getRole());
userInfoDetails.setUserRoleList(userFullInfoDTO.getUserRoleList());
userInfoDetails.setRegionCode(userFullInfoDTO.getRegionCode());
userInfoDetails.setCompanyId(userFullInfoDTO.getCompanyId());
userInfoDetails.setIdentifier(userFullInfoDTO.getIdentifier());
userInfoDetails.setPassword(userFullInfoDTO.getCredential());

userInfoDetails.setOrganizationCode(userFullInfoDTO.getOrganizationCode());
userInfoDetails.setOrganizationName(userFullInfoDTO.getOrganizationName());
return userInfoDetails;
}
}

+ 26
- 3
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java 파일 보기

@@ -1,7 +1,10 @@
package com.ningdatech.pmapi.user.security.auth.model;

import com.ningdatech.pmapi.sys.model.entity.Role;
import lombok.Data;

import java.util.List;

/**
* @author liuxinxin
* @date 2023/1/4 下午5:07
@@ -20,9 +23,29 @@ public class UserFullInfoDTO {

private String credential;

private String role;
/**
* 所属区域编码
*/
private String regionCode;

/**
* 浙政钉扫码 员工code
*/
private String employeeCode;

/**
* 浙政钉组织code
*/
private String organizationCode;

/**
* 浙政钉组织名称
*/
private String organizationName;

private Long regionCode;
/**
* 用户角色
*/
private List<Role> userRoleList;

private Long companyId;
}

+ 27
- 9
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserInfoDetails.java 파일 보기

@@ -2,9 +2,9 @@ package com.ningdatech.pmapi.user.security.auth.model;

import cn.hutool.core.collection.CollectionUtil;
import com.ningdatech.basic.auth.AbstractLoginUser;
import com.ningdatech.pmapi.sys.model.entity.Role;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
@@ -25,16 +25,31 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails {

private String password;

private String role;
/**
* 所属区域编码
*/
private String regionCode;

/**
* 浙政钉扫码 员工code
*/
private String employeeCode;

private List<Long> roleIdList;
/**
* 浙政钉组织code
*/
private String organizationCode;

/**
* 浙政钉组织名称
*/
private String organizationName;

/**
* 区域code
* 用户角色
*/
private Long regionCode;
private List<Role> userRoleList;

private Long companyId;

/**
* 获取用户权限
@@ -43,9 +58,12 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails {
*/
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
if (StringUtils.isNotBlank(role)) {
SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(this.role);
return CollectionUtil.toList(simpleGrantedAuthority);
if (CollectionUtil.isNotEmpty(this.userRoleList)) {
List<SimpleGrantedAuthority> authorities = new ArrayList<>();
for (Role role : this.userRoleList) {
authorities.add(new SimpleGrantedAuthority(role.getCode()));
}
return authorities;
}
return new ArrayList<>();
}


+ 0
- 16
pmapi/src/main/java/com/ningdatech/pmapi/user/service/IRoleInfoService.java 파일 보기

@@ -1,16 +0,0 @@
package com.ningdatech.pmapi.user.service;

import com.ningdatech.pmapi.user.entity.RoleInfo;
import com.baomidou.mybatisplus.extension.service.IService;

/**
* <p>
* 角色表 服务类
* </p>
*
* @author Liuxinxin
* @since 2023-01-05
*/
public interface IRoleInfoService extends IService<RoleInfo> {

}

+ 0
- 16
pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserRoleService.java 파일 보기

@@ -1,16 +0,0 @@
package com.ningdatech.pmapi.user.service;

import com.ningdatech.pmapi.user.entity.UserRole;
import com.baomidou.mybatisplus.extension.service.IService;

/**
* <p>
* 用户角色表 服务类
* </p>
*
* @author Liuxinxin
* @since 2023-01-05
*/
public interface IUserRoleService extends IService<UserRole> {

}

+ 0
- 20
pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/RoleInfoServiceImpl.java 파일 보기

@@ -1,20 +0,0 @@
package com.ningdatech.pmapi.user.service.impl;

import com.ningdatech.pmapi.user.entity.RoleInfo;
import com.ningdatech.pmapi.user.mapper.RoleInfoMapper;
import com.ningdatech.pmapi.user.service.IRoleInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
* <p>
* 角色表 服务实现类
* </p>
*
* @author Liuxinxin
* @since 2023-01-05
*/
@Service
public class RoleInfoServiceImpl extends ServiceImpl<RoleInfoMapper, RoleInfo> implements IRoleInfoService {

}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserAuthServiceImpl.java 파일 보기

@@ -3,8 +3,8 @@ package com.ningdatech.pmapi.user.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.user.entity.UserAuth;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.mapper.UserAuthMapper;
import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper;
import com.ningdatech.pmapi.user.mapper.UserAuthMapper;
import com.ningdatech.pmapi.user.service.IUserAuthService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


+ 6
- 2
pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java 파일 보기

@@ -1,6 +1,7 @@
package com.ningdatech.pmapi.user.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
@@ -9,11 +10,14 @@ import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.*;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**


불러오는 중...
취소
저장