use of cn.surveyking.server.domain.dto.ProjectPartnerRequest in project SurveyKing by javahuang.
the class ProjectPartnerServiceImpl method addProjectPartner.
@Override
public void addProjectPartner(ProjectPartnerRequest request) {
// 过滤掉已存在的用户
List<String> existUserIds = list(Wrappers.<ProjectPartner>lambdaQuery().in(ProjectPartner::getUserId, request.getUserIds()).eq(ProjectPartner::getProjectId, request.getProjectId())).stream().map(x -> x.getUserId()).collect(Collectors.toList());
saveBatch(request.getUserIds().stream().filter(userId -> {
if (existUserIds.contains(userId)) {
return false;
}
cacheManager.getCache(CacheConsts.projectPermissionCacheName).evict(userId);
return true;
}).map(userId -> {
ProjectPartner partner = new ProjectPartner();
partner.setProjectId(request.getProjectId());
partner.setUserId(userId);
partner.setType(request.getType());
return partner;
}).collect(Collectors.toList()));
}
Aggregations