@@ -232,11 +232,11 @@ | |||||
<groupId>com.ningdatech</groupId> | <groupId>com.ningdatech</groupId> | ||||
<artifactId>nd-flowable-starter</artifactId> | <artifactId>nd-flowable-starter</artifactId> | ||||
</dependency> | </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> | <dependency> | ||||
<groupId>com.alibaba.xxpt</groupId> | <groupId>com.alibaba.xxpt</groupId> | ||||
@@ -12,11 +12,11 @@ import org.springframework.stereotype.Component; | |||||
public interface UserInfoHelper { | public interface UserInfoHelper { | ||||
/** | /** | ||||
* 根据用户id 获取 用户所属公司id | |||||
* 根据用户id 获取 用户所属公司 organizationCode | |||||
* | * | ||||
* @param userId | * @param userId | ||||
* @return | * @return | ||||
*/ | */ | ||||
Long getCompanyId(Long userId); | |||||
String getOrganizationCode(Long userId); | |||||
} | } |
@@ -1,6 +1,9 @@ | |||||
package com.ningdatech.pmapi.common.helper.impl; | package com.ningdatech.pmapi.common.helper.impl; | ||||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | import com.ningdatech.pmapi.common.helper.UserInfoHelper; | ||||
import com.ningdatech.pmapi.user.manage.UserAuthLoginManage; | |||||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||||
import lombok.RequiredArgsConstructor; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
/** | /** | ||||
@@ -8,11 +11,17 @@ import org.springframework.stereotype.Component; | |||||
* @date 2023/2/10 下午4:40 | * @date 2023/2/10 下午4:40 | ||||
*/ | */ | ||||
@Component | @Component | ||||
@RequiredArgsConstructor | |||||
public class UserInfoHelperImpl implements UserInfoHelper { | public class UserInfoHelperImpl implements UserInfoHelper { | ||||
private final UserAuthLoginManage userAuthLoginManage; | |||||
@Override | @Override | ||||
public Long getCompanyId(Long userId) { | |||||
return null; | |||||
public String getOrganizationCode(Long userId) { | |||||
UserFullInfoDTO userFullInfo = userAuthLoginManage.getUserFullInfo(userId); | |||||
return userFullInfo.getOrganizationCode(); | |||||
} | } | ||||
} | } |
@@ -26,7 +26,7 @@ public class CompanyFiscalCode implements Serializable { | |||||
private String fiscalCode; | private String fiscalCode; | ||||
private Long companyId; | |||||
private String organizationCode; | |||||
private LocalDateTime createOn; | private LocalDateTime createOn; | ||||
@@ -28,14 +28,14 @@ public class CompanyFiscalCodeManage { | |||||
public void fiscalCodeConfigure(ReqCompanyFiscalCodeAndSealSnPO reqCompanyFiscalCodeAndSealSnPO) { | public void fiscalCodeConfigure(ReqCompanyFiscalCodeAndSealSnPO reqCompanyFiscalCodeAndSealSnPO) { | ||||
Long userId = LoginUserUtil.getUserId(); | Long userId = LoginUserUtil.getUserId(); | ||||
Long companyId = userInfoHelper.getCompanyId(userId); | |||||
String organizationCode = userInfoHelper.getOrganizationCode(userId); | |||||
// TODO 校验用户权限 | // TODO 校验用户权限 | ||||
// 保存财政编码配置 | // 保存财政编码配置 | ||||
String fiscalCode = reqCompanyFiscalCodeAndSealSnPO.getFiscalCode(); | String fiscalCode = reqCompanyFiscalCodeAndSealSnPO.getFiscalCode(); | ||||
CompanyFiscalCode companyFiscalCodeSaveRecord = new CompanyFiscalCode(); | CompanyFiscalCode companyFiscalCodeSaveRecord = new CompanyFiscalCode(); | ||||
companyFiscalCodeSaveRecord.setFiscalCode(fiscalCode); | companyFiscalCodeSaveRecord.setFiscalCode(fiscalCode); | ||||
companyFiscalCodeSaveRecord.setCompanyId(companyId); | |||||
companyFiscalCodeSaveRecord.setOrganizationCode(organizationCode); | |||||
companyFiscalCodeSaveRecord.setCreateOn(LocalDateTime.now()); | companyFiscalCodeSaveRecord.setCreateOn(LocalDateTime.now()); | ||||
companyFiscalCodeSaveRecord.setUpdateOn(LocalDateTime.now()); | companyFiscalCodeSaveRecord.setUpdateOn(LocalDateTime.now()); | ||||
companyFiscalCodeSaveRecord.setCreateBy(userId); | companyFiscalCodeSaveRecord.setCreateBy(userId); | ||||
@@ -46,7 +46,7 @@ public class CompanyFiscalCodeManage { | |||||
String sealSn = reqCompanyFiscalCodeAndSealSnPO.getSealSn(); | String sealSn = reqCompanyFiscalCodeAndSealSnPO.getSealSn(); | ||||
CompanySignature companySignatureSaveRecord = new CompanySignature(); | CompanySignature companySignatureSaveRecord = new CompanySignature(); | ||||
companySignatureSaveRecord.setSealSn(sealSn); | companySignatureSaveRecord.setSealSn(sealSn); | ||||
companySignatureSaveRecord.setCompanyId(companyId); | |||||
companySignatureSaveRecord.setOrganizationCode(organizationCode); | |||||
companySignatureSaveRecord.setCreateOn(LocalDateTime.now()); | companySignatureSaveRecord.setCreateOn(LocalDateTime.now()); | ||||
companySignatureSaveRecord.setUpdateOn(LocalDateTime.now()); | companySignatureSaveRecord.setUpdateOn(LocalDateTime.now()); | ||||
companySignatureSaveRecord.setCreateBy(userId); | companySignatureSaveRecord.setCreateBy(userId); | ||||
@@ -26,7 +26,7 @@ public class CompanySignature implements Serializable { | |||||
private String sealSn; | private String sealSn; | ||||
private Long companyId; | |||||
private String organizationCode; | |||||
private LocalDateTime createOn; | private LocalDateTime createOn; | ||||
@@ -43,9 +43,9 @@ public class UserAuthController { | |||||
@ApiImplicitParam(name = "credential", value = "凭证", required = true, paramType = "form", dataType = "String"), | @ApiImplicitParam(name = "credential", value = "凭证", required = true, paramType = "form", dataType = "String"), | ||||
@ApiImplicitParam(name = "loginType", value = "DING_QR_LOGIN 浙政钉扫码登陆,PHONE_VERIFICATION_CODE_LOGIN 手机号验证码登陆" | @ApiImplicitParam(name = "loginType", value = "DING_QR_LOGIN 浙政钉扫码登陆,PHONE_VERIFICATION_CODE_LOGIN 手机号验证码登陆" | ||||
, required = true, paramType = "form", dataType = "String")}) | , 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文档 | // 不实现任何内容,只是为了出api文档 | ||||
} | } | ||||
@@ -1,6 +1,16 @@ | |||||
package com.ningdatech.pmapi.user.manage; | 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.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.entity.UserInfo; | ||||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | ||||
import com.ningdatech.pmapi.user.service.IUserAuthService; | import com.ningdatech.pmapi.user.service.IUserAuthService; | ||||
@@ -8,7 +18,10 @@ import com.ningdatech.pmapi.user.service.IUserInfoService; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Objects; | import java.util.Objects; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* @author liuxinxin | * @author liuxinxin | ||||
@@ -21,6 +34,28 @@ public class UserAuthLoginManage { | |||||
private final IUserAuthService iUserAuthService; | private final IUserAuthService iUserAuthService; | ||||
private final IUserInfoService iUserInfoService; | private final IUserInfoService iUserInfoService; | ||||
private final IRoleService iRoleService; | |||||
private final IDingOrganizationService iDingOrganizationService; | |||||
private final IDingEmployeeInfoService iDingEmployeeInfoService; | |||||
private final IUserRoleService iUserRoleService; | |||||
/** | |||||
* 根据用户id 获取用户全量信息 | |||||
* | |||||
* @param userId | |||||
* @return | |||||
*/ | |||||
public UserFullInfoDTO getUserFullInfo(Long userId) { | |||||
UserInfo userInfo = iUserInfoService.getById(userId); | |||||
if (Objects.isNull(userInfo)) { | |||||
return null; | |||||
} | |||||
// 返回用户全量信息 | |||||
UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); | |||||
userFullInfoDTOAssembler(userInfo, userFullInfoDTO); | |||||
return userFullInfoDTO; | |||||
} | |||||
/** | /** | ||||
* 根据用户名获取 | * 根据用户名获取 | ||||
@@ -29,12 +64,14 @@ public class UserAuthLoginManage { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public UserFullInfoDTO queryUserInfoInPasswordAuth(String username) { | public UserFullInfoDTO queryUserInfoInPasswordAuth(String username) { | ||||
// TODO 目前账号密码登陆测试使用 强制用户登录 userId 1L | |||||
UserInfo userInfo = iUserInfoService.getById(1L); | |||||
if (Objects.isNull(userInfo)) { | |||||
return null; | |||||
} | |||||
// 返回用户全量信息 | |||||
UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); | UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); | ||||
userFullInfoDTO.setCompanyId(1L); | |||||
userFullInfoDTO.setUserId(1L); | |||||
userFullInfoDTO.setIdentifier("123456"); | |||||
userFullInfoDTO.setRealName("测试账号"); | |||||
userFullInfoDTO.setUsername("测试账号"); | |||||
userFullInfoDTOAssembler(userInfo, userFullInfoDTO); | |||||
return userFullInfoDTO; | return userFullInfoDTO; | ||||
} | } | ||||
@@ -45,55 +82,76 @@ public class UserAuthLoginManage { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public UserFullInfoDTO queryUserInfoInPhoneNoAuth(String phoneNo) { | public UserFullInfoDTO queryUserInfoInPhoneNoAuth(String phoneNo) { | ||||
// UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||||
// .eq(UserInfo::getMobile, phoneNo)); | |||||
// 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; | |||||
UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||||
.eq(UserInfo::getMobile, phoneNo)); | |||||
if (Objects.isNull(userInfo)) { | |||||
return null; | |||||
} | |||||
// 返回用户全量信息 | |||||
UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); | UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); | ||||
userFullInfoDTO.setCompanyId(1L); | |||||
userFullInfoDTO.setUserId(1L); | |||||
userFullInfoDTO.setIdentifier("123456"); | |||||
userFullInfoDTO.setRealName("测试账号"); | |||||
userFullInfoDTO.setUsername("测试账号"); | |||||
userFullInfoDTOAssembler(userInfo, userFullInfoDTO); | |||||
return userFullInfoDTO; | return userFullInfoDTO; | ||||
} | } | ||||
/** | /** | ||||
* 根据accountId | |||||
* 根据accountId(浙政钉扫码登陆) | |||||
* | * | ||||
* @param accountId | * @param accountId | ||||
* @return | * @return | ||||
*/ | */ | ||||
public UserFullInfoDTO queryUserInfoInAccountIdAuth(String accountId) { | 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; | |||||
// 获取用户信息 | |||||
UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||||
.eq(UserInfo::getAccountId, accountId)); | |||||
if (Objects.isNull(userInfo)) { | |||||
return null; | |||||
} | |||||
// 返回用户全量信息 | |||||
UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); | UserFullInfoDTO userFullInfoDTO = new UserFullInfoDTO(); | ||||
userFullInfoDTO.setCompanyId(1L); | |||||
userFullInfoDTO.setUserId(1L); | |||||
userFullInfoDTO.setIdentifier("123456"); | |||||
userFullInfoDTO.setRealName("测试账号"); | |||||
userFullInfoDTO.setUsername("测试账号"); | |||||
userFullInfoDTOAssembler(userInfo, userFullInfoDTO); | |||||
return userFullInfoDTO; | return userFullInfoDTO; | ||||
} | } | ||||
private void userFullInfoDTOAssembler(UserInfo userInfo, UserFullInfoDTO userFullInfoDTO) { | |||||
// 获取浙政钉雇员信息 组织信息 | |||||
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()); | |||||
} | |||||
} | } |
@@ -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> { | |||||
} |
@@ -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> |
@@ -57,11 +57,13 @@ public class CredentialLoginUserDetailService implements UserDetailsService { | |||||
userInfoDetails.setUserId(userFullInfoDTO.getUserId()); | userInfoDetails.setUserId(userFullInfoDTO.getUserId()); | ||||
userInfoDetails.setUsername(userFullInfoDTO.getUsername()); | userInfoDetails.setUsername(userFullInfoDTO.getUsername()); | ||||
userInfoDetails.setRealName(userFullInfoDTO.getRealName()); | userInfoDetails.setRealName(userFullInfoDTO.getRealName()); | ||||
userInfoDetails.setRole(userFullInfoDTO.getRole()); | |||||
userInfoDetails.setUserRoleList(userFullInfoDTO.getUserRoleList()); | |||||
userInfoDetails.setRegionCode(userFullInfoDTO.getRegionCode()); | userInfoDetails.setRegionCode(userFullInfoDTO.getRegionCode()); | ||||
userInfoDetails.setCompanyId(userFullInfoDTO.getCompanyId()); | |||||
userInfoDetails.setIdentifier(userFullInfoDTO.getIdentifier()); | userInfoDetails.setIdentifier(userFullInfoDTO.getIdentifier()); | ||||
userInfoDetails.setPassword(userFullInfoDTO.getCredential()); | userInfoDetails.setPassword(userFullInfoDTO.getCredential()); | ||||
userInfoDetails.setOrganizationCode(userFullInfoDTO.getOrganizationCode()); | |||||
userInfoDetails.setOrganizationName(userFullInfoDTO.getOrganizationName()); | |||||
return userInfoDetails; | return userInfoDetails; | ||||
} | } | ||||
} | } |
@@ -1,7 +1,10 @@ | |||||
package com.ningdatech.pmapi.user.security.auth.model; | package com.ningdatech.pmapi.user.security.auth.model; | ||||
import com.ningdatech.pmapi.sys.model.entity.Role; | |||||
import lombok.Data; | import lombok.Data; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @author liuxinxin | * @author liuxinxin | ||||
* @date 2023/1/4 下午5:07 | * @date 2023/1/4 下午5:07 | ||||
@@ -20,9 +23,29 @@ public class UserFullInfoDTO { | |||||
private String credential; | 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; | |||||
} | } |
@@ -2,9 +2,9 @@ package com.ningdatech.pmapi.user.security.auth.model; | |||||
import cn.hutool.core.collection.CollectionUtil; | import cn.hutool.core.collection.CollectionUtil; | ||||
import com.ningdatech.basic.auth.AbstractLoginUser; | import com.ningdatech.basic.auth.AbstractLoginUser; | ||||
import com.ningdatech.pmapi.sys.model.entity.Role; | |||||
import lombok.Data; | import lombok.Data; | ||||
import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.security.core.GrantedAuthority; | import org.springframework.security.core.GrantedAuthority; | ||||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||||
import org.springframework.security.core.userdetails.UserDetails; | import org.springframework.security.core.userdetails.UserDetails; | ||||
@@ -25,16 +25,31 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { | |||||
private String password; | 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 | @Override | ||||
public Collection<? extends GrantedAuthority> getAuthorities() { | 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<>(); | return new ArrayList<>(); | ||||
} | } | ||||
@@ -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> { | |||||
} |
@@ -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> { | |||||
} |
@@ -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 { | |||||
} |
@@ -3,8 +3,8 @@ package com.ningdatech.pmapi.user.service.impl; | |||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
import com.ningdatech.pmapi.user.entity.UserAuth; | import com.ningdatech.pmapi.user.entity.UserAuth; | ||||
import com.ningdatech.pmapi.user.entity.UserInfo; | 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.NdUserInfoMapper; | ||||
import com.ningdatech.pmapi.user.mapper.UserAuthMapper; | |||||
import com.ningdatech.pmapi.user.service.IUserAuthService; | import com.ningdatech.pmapi.user.service.IUserAuthService; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
@@ -1,6 +1,7 @@ | |||||
package com.ningdatech.pmapi.user.service.impl; | package com.ningdatech.pmapi.user.service.impl; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.ningdatech.basic.exception.BizException; | import com.ningdatech.basic.exception.BizException; | ||||
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | ||||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | 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.entity.UserInfo; | ||||
import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper; | import com.ningdatech.pmapi.user.mapper.NdUserInfoMapper; | ||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | import com.ningdatech.pmapi.user.service.IUserInfoService; | ||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.stereotype.Service; | 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; | import java.util.stream.Collectors; | ||||
/** | /** | ||||
@@ -1,10 +1,11 @@ | |||||
package com.ningdatech.pmapi.user.util; | package com.ningdatech.pmapi.user.util; | ||||
import com.ningdatech.basic.auth.AbstractLoginUserUtil; | import com.ningdatech.basic.auth.AbstractLoginUserUtil; | ||||
import com.ningdatech.pmapi.sys.model.entity.Role; | |||||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
@@ -19,9 +20,9 @@ public class LoginUserUtil extends AbstractLoginUserUtil { | |||||
} | } | ||||
public static List<Long> getRoleIdList() { | public static List<Long> getRoleIdList() { | ||||
List<Long> roleIdList = new ArrayList<>(); | |||||
roleIdList.add(1L); | |||||
return roleIdList; | |||||
UserInfoDetails userInfoDetails = loginUserDetail(); | |||||
List<Role> userRoleList = userInfoDetails.getUserRoleList(); | |||||
return userRoleList.stream().map(Role::getId).collect(Collectors.toList()); | |||||
} | } | ||||
} | } |