use of com.baomidou.mybatisplus.core.toolkit.Wrappers in project SurveyKing by javahuang.
the class RepoServiceImpl method batchAddRepoTemplate.
@Override
public void batchAddRepoTemplate(RepoTemplateRequest request) {
List<Tag> tagList = new ArrayList<>();
List<TemplateRequest> templatesAdd = new ArrayList<>();
List<TemplateRequest> templatesUpdate = new ArrayList<>();
List<RepoTemplate> repoTemplatesAdd = new ArrayList<>();
request.getTemplates().forEach(template -> {
RepoTemplate repoTemplate = new RepoTemplate();
if (template.getId() == null) {
template.setId(IdWorker.getIdStr());
templatesAdd.add(template);
if (request.getRepoId() != null) {
repoTemplate.setRepoId(request.getRepoId());
repoTemplate.setTemplateId(template.getId());
repoTemplatesAdd.add(repoTemplate);
}
} else {
templatesUpdate.add(template);
}
// template 里面的 tags 冗余了
if (template.getTemplate().getTags() != null) {
template.setTag(template.getTemplate().getTags().toArray(new String[0]));
}
List<String> tags = template.getTemplate().getTags();
if (tags != null && tags.size() > 0) {
tags.forEach(tagStr -> {
Tag tag = new Tag();
tag.setName(tagStr);
tag.setEntityId(template.getId());
tag.setCategory(TagCategoryEnum.template.name());
tagList.add(tag);
});
}
template.setQuestionType(template.getTemplate().getType());
});
if (templatesAdd.size() > 0) {
// 添加模板的时候,需要添加题库与模板的关联关系
templateService.batchAddTemplate(templatesAdd);
repoTemplateService.saveBatch(repoTemplatesAdd);
}
if (templatesUpdate.size() > 0) {
templateService.batchUpdateTemplate(templatesUpdate);
// 更新模板时需要删除之前的标签
tagService.remove(Wrappers.<Tag>lambdaUpdate().eq(Tag::getEntityId, templatesUpdate.stream().map(x -> x.getId()).collect(Collectors.toList())));
}
// 添加模板问题标签
if (tagList.size() > 0) {
tagService.saveBatch(tagList);
}
}
use of com.baomidou.mybatisplus.core.toolkit.Wrappers in project SurveyKing by javahuang.
the class AbstractTaskHandler method getHistoricTree.
/**
* 将任务流转记录转换成一棵节点树
* @param processInstanceId 任务实例 ID
* @return 最后一个操作节点
*/
protected TaskTreeNode getHistoricTree(String processInstanceId) {
List<String> approvalTypes = new ArrayList<>();
approvalTypes.add(FlowApprovalType.SAVE);
approvalTypes.add(FlowApprovalType.AGREE);
approvalTypes.add(FlowApprovalType.ROLLBACK);
approvalTypes.add(FlowApprovalType.REVERT);
List<FlowOperation> operations = flowOperationService.list(Wrappers.<FlowOperation>lambdaQuery().eq(FlowOperation::getInstanceId, processInstanceId).in(FlowOperation::getApprovalType, approvalTypes).orderByAsc(FlowOperation::getCreateAt));
TaskTreeNode rootNode = null, lastNode = null;
for (int i = 0; i < operations.size(); i++) {
FlowOperation operation = operations.get(i);
TaskTreeNode currNode = new TaskTreeNode();
currNode.setId(operation.getId());
currNode.setActivityId(operation.getActivityId());
if (i == 0) {
rootNode = currNode;
lastNode = currNode;
continue;
}
if (lastNode != null && lastNode.getActivityId() != null && lastNode.getActivityId().equals(currNode.getActivityId())) {
continue;
}
if (FlowApprovalType.SAVE.equals(operation.getApprovalType())) {
lastNode = rootNode;
continue;
} else if (FlowApprovalType.AGREE.equals(operation.getApprovalType())) {
currNode.setParent(lastNode);
if (lastNode.getChildren().stream().noneMatch(node -> node.getActivityId().equals(currNode.getActivityId()))) {
lastNode.getChildren().add(currNode);
}
} else if (FlowApprovalType.ROLLBACK.equals(operation.getApprovalType())) {
lastNode = lastNode.findParentByKey(operation.getNewActivityId());
continue;
} else if (FlowApprovalType.REVERT.equals(operation.getApprovalType())) {
// 撤回节点的 taskDefKey 和已完成节点是一致的
}
lastNode = currNode;
}
return lastNode;
}
use of com.baomidou.mybatisplus.core.toolkit.Wrappers in project albedo by somowhere.
the class DeptRelationServiceImpl method saveDeptRelation.
/**
* 维护部门关系
*
* @param deptDto 部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDeptRelation(DeptDto deptDto) {
// 增加部门关系表
DeptRelationDo condition = new DeptRelationDo();
condition.setDescendant(deptDto.getParentId());
List<DeptRelationDo> relationList = deptRelationRepository.selectList(Wrappers.<DeptRelationDo>query().lambda().eq(DeptRelationDo::getDescendant, deptDto.getParentId())).stream().map(relation -> {
relation.setDescendant(deptDto.getId());
return relation;
}).collect(Collectors.toList());
if (CollUtil.isNotEmpty(relationList)) {
this.saveBatch(relationList);
}
// 自己也要维护到关系表中
DeptRelationDo own = new DeptRelationDo();
own.setDescendant(deptDto.getId());
own.setAncestor(deptDto.getId());
deptRelationRepository.insert(own);
}
use of com.baomidou.mybatisplus.core.toolkit.Wrappers in project tansci by typ1805.
the class SysOrgServiceImpl method list.
@Override
public List<SysOrg> list(SysOrg sysOrg) {
LambdaQueryWrapper queryWrapper = null;
if (Objects.equals(0, SecurityUserUtils.getUser().getType())) {
queryWrapper = Wrappers.<SysOrg>lambdaQuery().eq(SysOrg::getDelFlag, 0).like(Objects.nonNull(sysOrg.getName()), SysOrg::getName, sysOrg.getName()).orderByDesc(SysOrg::getCreateTime);
} else {
queryWrapper = Wrappers.<SysOrg>lambdaQuery().eq(SysOrg::getDelFlag, 0).in(SysOrg::getId, SecurityUserUtils.getUser().getOrgIds()).like(Objects.nonNull(sysOrg.getName()), SysOrg::getName, sysOrg.getName()).orderByDesc(SysOrg::getCreateTime);
}
List<SysOrg> orgList = this.baseMapper.selectList(queryWrapper);
List<SysOrg> newOrgList = orgList.stream().filter(item -> item.getParentId() == 0).map(item -> {
item.setChildren(this.getChildrens(item, orgList));
return item;
}).sorted((item1, item2) -> {
return (item1.getSort() == null ? 0 : item1.getSort()) - (item2.getSort() == null ? 0 : item2.getSort());
}).collect(Collectors.toList());
return newOrgList.size() > 0 ? newOrgList : orgList;
}
use of com.baomidou.mybatisplus.core.toolkit.Wrappers in project tansci by typ1805.
the class SysRoleServiceImpl method page.
@Override
public IPage<SysRole> page(Page page, SysRole role) {
LambdaQueryWrapper queryWrapper = null;
if (Objects.equals(0, SecurityUserUtils.getUser().getType())) {
queryWrapper = Wrappers.<SysRole>lambdaQuery().like(Objects.nonNull(role.getName()), SysRole::getName, role.getName()).orderByDesc(SysRole::getCreateTime, SysRole::getUpdateTime);
} else {
List<SysUserOrg> orgs = sysUserOrgService.list(Wrappers.<SysUserOrg>lambdaQuery().in(SysUserOrg::getOrgId, SecurityUserUtils.getUser().getOrgIds()));
List<String> userIds = new ArrayList<>();
if (Objects.nonNull(orgs) && orgs.size() > 0) {
userIds = orgs.stream().map(SysUserOrg::getUserId).distinct().collect(Collectors.toList());
} else {
userIds.add(SecurityUserUtils.getUser().getId());
}
queryWrapper = Wrappers.<SysRole>lambdaQuery().in(SysRole::getCreator, userIds).like(Objects.nonNull(role.getName()), SysRole::getName, role.getName()).orderByDesc(SysRole::getCreateTime, SysRole::getUpdateTime);
}
IPage<SysRole> roleIPage = this.baseMapper.selectPage(page, queryWrapper);
List<SysDic> statusList = roleIPage.getSize() > 0 ? sysDicService.list(Wrappers.<SysDic>lambdaQuery().eq(SysDic::getGroupName, "role_status")) : new ArrayList<>();
roleIPage.getRecords().forEach(item -> {
Optional<SysDic> sOptional = statusList.stream().filter(s -> s.getDicValue() == item.getStatus()).findFirst();
if (sOptional.isPresent()) {
item.setStatusName(sOptional.get().getDicLabel());
}
item.setTypeName(Enums.getVlaueByGroup(item.getType(), "role_type"));
});
return roleIPage;
}
Aggregations