feat:资产授权
parent
7a8a75dc53
commit
70cad5369c
|
@ -0,0 +1,27 @@
|
||||||
|
package com.etl.data.source.remote;
|
||||||
|
|
||||||
|
import com.etl.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.etl.common.core.domain.Result;
|
||||||
|
import com.etl.common.core.web.page.TableDataInfo;
|
||||||
|
import com.etl.data.domain.DataSource;
|
||||||
|
import com.etl.data.domain.req.DataSourceQueryReq;
|
||||||
|
import com.etl.data.source.remote.factory.DataSourceFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 远程数据源服务
|
||||||
|
* @author YunFei.Du
|
||||||
|
* @date 14:09 2024/5/10
|
||||||
|
*/
|
||||||
|
@FeignClient(
|
||||||
|
contextId = "RemoteDataAccess",
|
||||||
|
value = ServiceNameConstants.DATA_SOURCE_SERVICE,
|
||||||
|
fallbackFactory = DataSourceFactory.class,
|
||||||
|
path = "/source"
|
||||||
|
)
|
||||||
|
public interface RemoteDataSourceService {
|
||||||
|
@PostMapping("/list")
|
||||||
|
public Result< TableDataInfo< DataSource > > getDataSourceList (@RequestBody DataSourceQueryReq req);
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.etl.data.remote;
|
||||||
|
|
||||||
|
import com.etl.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.etl.common.core.domain.Result;
|
||||||
|
import com.etl.common.core.web.page.TableDataInfo;
|
||||||
|
import com.etl.common.system.domain.SysDept;
|
||||||
|
import com.etl.common.system.domain.SysUser;
|
||||||
|
import com.etl.data.remote.factory.RemoteUser;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RemoteSys
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei.Du
|
||||||
|
* @Date 2024/5/10 21:04
|
||||||
|
*/
|
||||||
|
|
||||||
|
@FeignClient(
|
||||||
|
contextId = "RemoteSys",
|
||||||
|
value = ServiceNameConstants.SYSTEM_SERVICE,
|
||||||
|
fallbackFactory = RemoteUser.class
|
||||||
|
)
|
||||||
|
public interface RemoteSys {
|
||||||
|
/**
|
||||||
|
* 根据用户id查询用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/dept/list")
|
||||||
|
public Result<List<SysDept>> list();
|
||||||
|
|
||||||
|
@GetMapping("/user/list")
|
||||||
|
public Result<TableDataInfo<SysUser>> userList();
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.etl.data.remote.factory;
|
||||||
|
|
||||||
|
import com.etl.common.core.domain.Result;
|
||||||
|
import com.etl.common.core.web.page.TableDataInfo;
|
||||||
|
import com.etl.common.system.domain.SysDept;
|
||||||
|
import com.etl.common.system.domain.SysUser;
|
||||||
|
import com.etl.data.remote.RemoteSys;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RemoteUser
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YunFei.Du
|
||||||
|
* @Date 2024/5/10 21:03
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteUser implements FallbackFactory< RemoteSys > {
|
||||||
|
@Override
|
||||||
|
public RemoteSys create(Throwable cause) {
|
||||||
|
RemoteSys remoteSys = new RemoteSys ( ) {
|
||||||
|
@Override
|
||||||
|
public Result< List< SysDept > > list() {
|
||||||
|
return Result.error ( cause.getMessage () );
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Result< TableDataInfo< SysUser > > userList() {
|
||||||
|
return Result.error ( cause.getMessage () );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return remoteSys;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,9 +7,11 @@ import com.etl.common.security.utils.SecurityUtils;
|
||||||
import com.etl.common.system.domain.SysUser;
|
import com.etl.common.system.domain.SysUser;
|
||||||
import com.etl.common.system.remote.RemoteUserService;
|
import com.etl.common.system.remote.RemoteUserService;
|
||||||
import com.etl.data.domain.AssetAccredit;
|
import com.etl.data.domain.AssetAccredit;
|
||||||
|
import com.etl.data.domain.SourceAccredit;
|
||||||
import com.etl.data.domain.model.AccreditModel;
|
import com.etl.data.domain.model.AccreditModel;
|
||||||
import com.etl.data.domain.req.AssetAccreditReq;
|
import com.etl.data.domain.req.AssetAccreditReq;
|
||||||
import com.etl.data.mapper.AssetAccreditMapper;
|
import com.etl.data.mapper.AssetAccreditMapper;
|
||||||
|
import com.etl.data.remote.RemoteSys;
|
||||||
import com.etl.data.service.AssetAccreditService;
|
import com.etl.data.service.AssetAccreditService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -29,16 +31,16 @@ public class AssetAccreditServiceImpl extends ServiceImpl< AssetAccreditMapper,
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteUserService remoteUserService;
|
private RemoteSys remoteSys;
|
||||||
@Autowired
|
|
||||||
private AssetAccreditService assetAccreditService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result getAssetAccreditByDataAssetId(Long id) {
|
public Result getAssetAccreditByDataAssetId(Long id) {
|
||||||
List< AssetAccredit > assetAccreditList = this.list ( new LambdaQueryWrapper< AssetAccredit > ( ).eq ( AssetAccredit::getDataAssetId, id ) );
|
List< AssetAccredit > assetAccreditList = this.list ( new LambdaQueryWrapper< AssetAccredit > ( ).eq ( AssetAccredit::getDataAssetId, id ) );
|
||||||
|
|
||||||
List< Long > userAccreditIds = assetAccreditList.stream ( ).map ( AssetAccredit::getUserId ).filter ( Objects::isNull ).toList ( );
|
List< Long > userAccreditIds = assetAccreditList.stream ().filter ( sourceAccredit -> sourceAccredit.getDeptId ( ) != null ).map ( AssetAccredit::getDeptId ).toList ();
|
||||||
List< Long > deptAccreditIds = assetAccreditList.stream ( ).map ( AssetAccredit::getDeptId ).filter ( Objects::isNull ).toList ( );
|
List< Long > deptAccreditIds = assetAccreditList.stream ().filter ( sourceAccredit -> sourceAccredit.getUserId ( ) != null ).map ( AssetAccredit::getUserId ).toList ();
|
||||||
|
|
||||||
|
|
||||||
AccreditModel accreditModel = new AccreditModel ( );
|
AccreditModel accreditModel = new AccreditModel ( );
|
||||||
accreditModel.setDeptAccreditModelIds ( deptAccreditIds );
|
accreditModel.setDeptAccreditModelIds ( deptAccreditIds );
|
||||||
|
@ -66,9 +68,8 @@ public class AssetAccreditServiceImpl extends ServiceImpl< AssetAccreditMapper,
|
||||||
assetAccredit.setCreateTime(new Date());
|
assetAccredit.setCreateTime(new Date());
|
||||||
return assetAccredit;
|
return assetAccredit;
|
||||||
}).toList();
|
}).toList();
|
||||||
List< Long > deptIds = assetAccreditReq.getDeptIds ( );
|
List< Long > deptIds = assetAccreditReq.getDeptIds ( );
|
||||||
Result<List<SysUser>> list = remoteUserService.userList(new SysUser());
|
List< SysUser > sysUsers = remoteSys.userList ( ).getData ( ).getRows ( );
|
||||||
List<SysUser> sysUsers = list.getData();
|
|
||||||
assetAccredits.addAll(sysUsers.stream().filter(sysUser -> deptIds.contains(sysUser.getDeptId())).toList().stream().map(sysUser -> {
|
assetAccredits.addAll(sysUsers.stream().filter(sysUser -> deptIds.contains(sysUser.getDeptId())).toList().stream().map(sysUser -> {
|
||||||
AssetAccredit assetAccredit = new AssetAccredit();
|
AssetAccredit assetAccredit = new AssetAccredit();
|
||||||
assetAccredit.setDataAssetId(assetAccreditReq.getDataAssetId());
|
assetAccredit.setDataAssetId(assetAccreditReq.getDataAssetId());
|
||||||
|
@ -78,30 +79,35 @@ public class AssetAccreditServiceImpl extends ServiceImpl< AssetAccreditMapper,
|
||||||
return assetAccredit;
|
return assetAccredit;
|
||||||
}).toList());
|
}).toList());
|
||||||
}
|
}
|
||||||
assetAccreditService.saveBatch ( assetAccredits );
|
this.saveBatch ( assetAccredits );
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq) {
|
public Result deleteAssetAccreditByAssetIds(AssetAccreditReq assetAccreditReq) {
|
||||||
if (assetAccreditReq.getUserId() != null){
|
// 如果用户ID不为空,则删除该用户对应的源数据授权信息
|
||||||
this.remove(new LambdaQueryWrapper<AssetAccredit>()
|
if (assetAccreditReq.getUserId ()!=null){
|
||||||
.eq(AssetAccredit::getDataAssetId, assetAccreditReq.getDataAssetId())
|
this.remove ( new LambdaQueryWrapper< AssetAccredit> ( )
|
||||||
.eq(AssetAccredit::getUserId, assetAccreditReq.getUserId()));
|
.eq ( AssetAccredit::getDataAssetId, assetAccreditReq.getDataAssetId () )
|
||||||
}else {
|
.eq ( AssetAccredit::getUserId, assetAccreditReq.getUserId () ) );
|
||||||
List< Long > deptIds = assetAccreditReq.getDeptIds ( );
|
|
||||||
Result< List< SysUser > > list = remoteUserService.userList ( new SysUser ( ) );
|
|
||||||
List< SysUser > sysUsers = list.getData ( );
|
|
||||||
List<Long> userIds = sysUsers.stream()
|
|
||||||
.filter(sysUser -> deptIds.contains(sysUser.getDeptId())).toList().stream()
|
|
||||||
.filter(sysUser -> deptIds.contains(sysUser.getDeptId())).toList().stream()
|
|
||||||
.map(SysUser::getUserId).toList();
|
|
||||||
assetAccreditService.remove ( new LambdaQueryWrapper< AssetAccredit > ( ).in( AssetAccredit::getUserId, userIds).eq ( AssetAccredit::getDataAssetId, assetAccreditReq.getDataAssetId() ));
|
|
||||||
assetAccreditService.remove ( new LambdaQueryWrapper< AssetAccredit > ( ).in ( AssetAccredit::getDeptId, deptIds).eq ( AssetAccredit::getDataAssetId, assetAccreditReq.getDataAssetId() ) );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return Result.success();
|
// 获取所有系统部门ID和所有用户信息
|
||||||
}
|
List< Long > deptIds = remoteSys.list ( ).getData ( ).stream ( ).map ( sysDept -> sysDept.getDeptId ( ) ).toList ( );
|
||||||
|
List< SysUser > userList = remoteSys.userList ( ).getData ( ).getRows ( );
|
||||||
|
// 筛选出属于指定部门ID的用户ID
|
||||||
|
List< Long > userIds = userList.stream ( )
|
||||||
|
.filter ( sysUser -> deptIds.contains ( sysUser.getDeptId ( ) ) ).toList ( ).stream ( )
|
||||||
|
.map ( SysUser::getUserId ).toList ( );
|
||||||
|
|
||||||
|
// 删除指定部门ID的源数据授权信息
|
||||||
|
this.remove ( new LambdaQueryWrapper<AssetAccredit> ( )
|
||||||
|
.eq ( AssetAccredit::getDataAssetId, assetAccreditReq.getDataAssetId () )
|
||||||
|
.in ( AssetAccredit::getDeptId, assetAccreditReq.getDeptIds () ));
|
||||||
|
// 删除属于指定部门ID的用户的源数据授权信息
|
||||||
|
this.remove ( new LambdaQueryWrapper<AssetAccredit> ( )
|
||||||
|
.eq ( AssetAccredit::getDataAssetId, assetAccreditReq.getDataAssetId () )
|
||||||
|
.in ( AssetAccredit::getUserId, userIds ));
|
||||||
|
return Result.success ( );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,73 +4,126 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.etl.common.core.domain.Result;
|
import com.etl.common.core.domain.Result;
|
||||||
import com.etl.common.security.utils.SecurityUtils;
|
import com.etl.common.security.utils.SecurityUtils;
|
||||||
|
import com.etl.common.system.domain.SysDept;
|
||||||
|
import com.etl.common.system.domain.SysUser;
|
||||||
import com.etl.data.domain.AssetAccredit;
|
import com.etl.data.domain.AssetAccredit;
|
||||||
import com.etl.data.domain.SourceAccredit;
|
import com.etl.data.domain.SourceAccredit;
|
||||||
import com.etl.data.domain.model.AccreditModel;
|
import com.etl.data.domain.model.AccreditModel;
|
||||||
import com.etl.data.domain.req.AssetAccreditReq;
|
import com.etl.data.domain.req.AssetAccreditReq;
|
||||||
import com.etl.data.domain.req.SourceAccreditReq;
|
import com.etl.data.domain.req.SourceAccreditReq;
|
||||||
import com.etl.data.mapper.SourceAccreditMapper;
|
import com.etl.data.mapper.SourceAccreditMapper;
|
||||||
|
import com.etl.data.remote.RemoteSys;
|
||||||
|
import com.etl.data.remote.factory.RemoteUser;
|
||||||
import com.etl.data.service.SourceAccreditService;
|
import com.etl.data.service.SourceAccreditService;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据源授权
|
* 数据源授权
|
||||||
|
*
|
||||||
* @author YunFei.Du
|
* @author YunFei.Du
|
||||||
* @date 15:26 2024/5/1
|
* @date 15:26 2024/5/1
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
@Transactional
|
||||||
public class SourceAccreditServiceImpl extends ServiceImpl< SourceAccreditMapper, SourceAccredit > implements SourceAccreditService {
|
public class SourceAccreditServiceImpl extends ServiceImpl< SourceAccreditMapper, SourceAccredit > implements SourceAccreditService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteSys remoteSys;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result getSourceAccreditByDataSourceId(Long id) {
|
public Result getSourceAccreditByDataSourceId(Long id) {
|
||||||
List< SourceAccredit > sourceAccreditList = this.list ( new LambdaQueryWrapper< SourceAccredit > ( ).eq ( SourceAccredit::getDataSourceId, id ) );
|
List< SourceAccredit > sourceAccreditList = this.list ( new LambdaQueryWrapper< SourceAccredit > ( ).eq ( SourceAccredit::getDataSourceId, id ) );
|
||||||
|
|
||||||
List< Long > userAccreditIds = sourceAccreditList.stream ( ).map ( SourceAccredit::getUserId ).filter ( Objects::isNull ).toList ( );
|
List< Long > userAccreditIds = sourceAccreditList.stream ().filter ( sourceAccredit -> sourceAccredit.getDeptId ( ) != null ).map ( SourceAccredit::getDeptId ).toList ();
|
||||||
List< Long > deptAccreditIds = sourceAccreditList.stream ( ).map ( SourceAccredit::getDeptId ).filter ( Objects::isNull ).toList ( );
|
List< Long > deptAccreditIds = sourceAccreditList.stream ().filter ( sourceAccredit -> sourceAccredit.getUserId ( ) != null ).map ( SourceAccredit::getUserId ).toList ();
|
||||||
|
|
||||||
AccreditModel accreditModel = new AccreditModel ( );
|
AccreditModel accreditModel = new AccreditModel ( );
|
||||||
accreditModel.setDeptAccreditModelIds ( deptAccreditIds );
|
accreditModel.setDeptAccreditModelIds ( deptAccreditIds );
|
||||||
accreditModel.setUserAccreditModelIds ( userAccreditIds );
|
accreditModel.setUserAccreditModelIds ( userAccreditIds );
|
||||||
return Result.success ( accreditModel );
|
return Result.success ( accreditModel );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result insertSourceAccredit(SourceAccreditReq sourceAccreditReq) {
|
public Result insertSourceAccredit(SourceAccreditReq sourceAccreditReq) {
|
||||||
deleteSourceAccreditBySourceIds(sourceAccreditReq);
|
// TODO 删除id
|
||||||
List<SourceAccredit> sourceAccredits = new ArrayList<> ();
|
List< SourceAccredit > sourceAccredits;
|
||||||
if (sourceAccreditReq.getUserId() != null){
|
if (sourceAccreditReq.getUserId ( ) != null) {
|
||||||
SourceAccredit sourceAccredit = new SourceAccredit();
|
sourceAccredits = new ArrayList<> ( );
|
||||||
sourceAccredit.setDataSourceId(sourceAccreditReq.getDataSourceId());
|
SourceAccredit sourceAccredit = new SourceAccredit ( );
|
||||||
sourceAccredit.setUserId(sourceAccreditReq.getUserId());
|
sourceAccredit.setDataSourceId ( sourceAccreditReq.getDataSourceId ( ) );
|
||||||
sourceAccredit.setCreateBy( SecurityUtils.getUsername());
|
sourceAccredit.setUserId ( sourceAccreditReq.getUserId ( ) );
|
||||||
sourceAccredit.setCreateTime(new Date ());
|
sourceAccredit.setCreateBy ( SecurityUtils.getUsername ( ) );
|
||||||
sourceAccredits.add(sourceAccredit);
|
sourceAccredit.setCreateTime ( new Date ( ) );
|
||||||
}else{
|
sourceAccredits.add ( sourceAccredit );
|
||||||
sourceAccredits=sourceAccreditReq.getDeptIds().stream().map(deptId -> {
|
} else {
|
||||||
SourceAccredit sourceAccredit = new SourceAccredit();
|
|
||||||
sourceAccredit.setDataSourceId(sourceAccreditReq.getDataSourceId());
|
sourceAccredits = new ArrayList<> ( sourceAccreditReq.getDeptIds ( ).stream ( ).map ( deptId -> {
|
||||||
sourceAccredit.setDeptId(deptId);
|
SourceAccredit sourceAccredit = new SourceAccredit ( );
|
||||||
sourceAccredit.setCreateBy(SecurityUtils.getUsername());
|
sourceAccredit.setDataSourceId ( sourceAccreditReq.getDataSourceId ( ) );
|
||||||
sourceAccredit.setCreateTime(new Date());
|
sourceAccredit.setDeptId ( deptId );
|
||||||
|
sourceAccredit.setCreateBy ( SecurityUtils.getUsername ( ) );
|
||||||
|
sourceAccredit.setCreateTime ( new Date ( ) );
|
||||||
return sourceAccredit;
|
return sourceAccredit;
|
||||||
}).toList();
|
} ).toList ( ) );
|
||||||
|
List< Long > deptIds = sourceAccreditReq.getDeptIds ( );
|
||||||
|
List< SysUser > sysUsers = remoteSys.userList ( ).getData ( ).getRows ( );
|
||||||
|
sourceAccredits.addAll ( sysUsers.stream ( ).filter ( sysUser -> deptIds.contains
|
||||||
|
( sysUser.getDeptId ( ) ) ).toList ( ).stream ( ).map ( sysUser -> {
|
||||||
|
SourceAccredit sourceAccredit = new SourceAccredit ( );
|
||||||
|
sourceAccredit.setDataSourceId ( sourceAccreditReq.getDataSourceId ( ) );
|
||||||
|
sourceAccredit.setUserId ( sysUser.getUserId ( ) );
|
||||||
|
sourceAccredit.setCreateBy ( SecurityUtils.getUsername ( ) );
|
||||||
|
sourceAccredit.setCreateTime ( new Date ( ) );
|
||||||
|
return sourceAccredit;
|
||||||
|
} ).toList ( ) );
|
||||||
}
|
}
|
||||||
this.saveBatch ( sourceAccredits );
|
this.saveBatch ( sourceAccredits );
|
||||||
return Result.success();
|
return Result.success ( );
|
||||||
}
|
}
|
||||||
|
//mapped
|
||||||
|
/**
|
||||||
|
* 根据源数据ID和用户ID或部门ID删除源数据授权信息。
|
||||||
|
*
|
||||||
|
* @param sourceAccreditReq 包含要删除的源数据ID、用户ID(可选)和部门ID集合。
|
||||||
|
* @return 返回操作结果,成功则为Result.success()。
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq) {
|
public Result deleteSourceAccreditBySourceIds(SourceAccreditReq sourceAccreditReq) {
|
||||||
this.remove(new LambdaQueryWrapper<SourceAccredit>()
|
// 如果用户ID不为空,则删除该用户对应的源数据授权信息
|
||||||
.eq(SourceAccredit::getDataSourceId, sourceAccreditReq.getDataSourceId ())
|
if (sourceAccreditReq.getUserId ()!=null){
|
||||||
.eq(sourceAccreditReq.getUserId() != null, SourceAccredit::getUserId, sourceAccreditReq.getUserId())
|
this.remove ( new LambdaQueryWrapper<SourceAccredit> ( )
|
||||||
.eq(sourceAccreditReq.getDataSourceId () != null, SourceAccredit::getDeptId, sourceAccreditReq.getDataSourceId ()));
|
.eq ( SourceAccredit::getDataSourceId, sourceAccreditReq.getDataSourceId () )
|
||||||
|
.eq ( SourceAccredit::getUserId, sourceAccreditReq.getUserId () ) );
|
||||||
|
}else {
|
||||||
|
// 获取所有系统部门ID和所有用户信息
|
||||||
|
List< Long > deptIds = remoteSys.list ( ).getData ( ).stream ( ).map ( sysDept -> sysDept.getDeptId ( ) ).toList ( );
|
||||||
|
List< SysUser > userList = remoteSys.userList ( ).getData ( ).getRows ( );
|
||||||
|
// 筛选出属于指定部门ID的用户ID
|
||||||
|
List< Long > userIds = userList.stream ( )
|
||||||
|
.filter ( sysUser -> deptIds.contains ( sysUser.getDeptId ( ) ) ).toList ( ).stream ( )
|
||||||
|
.map ( SysUser::getUserId ).toList ( );
|
||||||
|
|
||||||
|
// 删除指定部门ID的源数据授权信息
|
||||||
return Result.success ( );
|
this.remove ( new LambdaQueryWrapper<SourceAccredit> ( )
|
||||||
|
.eq ( SourceAccredit::getDataSourceId, sourceAccreditReq.getDataSourceId () )
|
||||||
|
.in ( SourceAccredit::getDeptId, sourceAccreditReq.getDeptIds () ));
|
||||||
|
// 删除属于指定部门ID的用户的源数据授权信息
|
||||||
|
this.remove ( new LambdaQueryWrapper<SourceAccredit> ( )
|
||||||
|
.eq ( SourceAccredit::getDataSourceId, sourceAccreditReq.getDataSourceId () )
|
||||||
|
.in ( SourceAccredit::getUserId, userIds ));
|
||||||
|
}
|
||||||
|
return Result.success ( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue