流程在审批过程中,只有当前审核节点的人、发起人和admin可见,其他人不可见

目前所有人可见,需要添加限制
master
Harry Yang 2023-01-03 21:04:15 +08:00
parent 96051bb89c
commit 58ce8e320b
3 changed files with 24 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.convert.QueryByExamplePredicateBuilder;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
@ -41,6 +42,8 @@ import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Predicate;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
@ -604,9 +607,24 @@ public class ProcessController {
.withMatcher("applyPersonName", ExampleMatcher.GenericPropertyMatcher::contains);
// 只展示自己创建的草稿
// Admin admin = InterfaceUtil.getAdmin();
// projectProcess.setApplyPersonId(admin.getId());
Admin admin = InterfaceUtil.getAdmin();
if (!isAdministrator(admin)) {
Integer loginUserId = admin.getId();
if (forAudit) {
return repository.findAll((root, query, cb) -> {
Predicate predicate = QueryByExamplePredicateBuilder.getPredicate(root, cb, Example.of(projectProcess, exampleMatcher));
// 添加新的条件
Predicate equal = cb.equal(root.get("applyPersonId"), loginUserId);
Expression<Integer> findInSet = cb.function("find_in_set", Integer.class, cb.literal(loginUserId), root.get("currentAuditId"));
return cb.and(predicate, cb.or(equal, cb.greaterThan(findInSet, 0)));
}, pageRequest);
}
else {
projectProcess.setApplyPersonId(loginUserId);
}
}
// 超级好管理员不需要
return repository.findAll(Example.of(projectProcess, exampleMatcher), pageRequest);
}

View File

@ -3,6 +3,7 @@ package cn.palmte.work.model.process;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
@ -12,4 +13,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface ProjectProcessRepository extends PagingAndSortingRepository<ProjectProcess, Integer> {
Page<ProjectProcess> findAll(Example<ProjectProcess> example, Pageable pageable);
Page<ProjectProcess> findAll(Specification<ProjectProcess> spec, Pageable pageable);
}

View File

@ -267,7 +267,7 @@
})
const { size, current } = this.page
fetch("${base}/process/query?size=" + size + "&page=" + current, {
fetch("${base}/process/query?size=" + size + "&page=" + current + "&forAudit=true", {
method: 'POST', // or 'PUT'
headers: {
'Content-Type': 'application/json',