parent
96051bb89c
commit
58ce8e320b
|
@ -10,6 +10,7 @@ import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.jpa.convert.QueryByExamplePredicateBuilder;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -41,6 +42,8 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
import javax.persistence.criteria.Expression;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ -604,9 +607,24 @@ public class ProcessController {
|
||||||
.withMatcher("applyPersonName", ExampleMatcher.GenericPropertyMatcher::contains);
|
.withMatcher("applyPersonName", ExampleMatcher.GenericPropertyMatcher::contains);
|
||||||
|
|
||||||
// 只展示自己创建的草稿
|
// 只展示自己创建的草稿
|
||||||
// Admin admin = InterfaceUtil.getAdmin();
|
Admin admin = InterfaceUtil.getAdmin();
|
||||||
// projectProcess.setApplyPersonId(admin.getId());
|
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);
|
return repository.findAll(Example.of(projectProcess, exampleMatcher), pageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.palmte.work.model.process;
|
||||||
import org.springframework.data.domain.Example;
|
import org.springframework.data.domain.Example;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,4 +13,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
|
||||||
public interface ProjectProcessRepository extends PagingAndSortingRepository<ProjectProcess, Integer> {
|
public interface ProjectProcessRepository extends PagingAndSortingRepository<ProjectProcess, Integer> {
|
||||||
|
|
||||||
Page<ProjectProcess> findAll(Example<ProjectProcess> example, Pageable pageable);
|
Page<ProjectProcess> findAll(Example<ProjectProcess> example, Pageable pageable);
|
||||||
|
|
||||||
|
Page<ProjectProcess> findAll(Specification<ProjectProcess> spec, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const { size, current } = this.page
|
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'
|
method: 'POST', // or 'PUT'
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
Loading…
Reference in New Issue