Compare commits
2 Commits
6ec672ebfa
...
3d1970ec09
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d1970ec09 | |||
| 3e43d437e6 |
4
.idea/compiler.xml
generated
4
.idea/compiler.xml
generated
@@ -7,8 +7,8 @@
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="gringotts-web" />
|
||||
<module name="gringotts-chain" />
|
||||
<module name="gringotts-web" />
|
||||
<module name="gringotts-core" />
|
||||
<module name="gringotts-gateway" />
|
||||
<module name="gringotts-forest" />
|
||||
@@ -24,7 +24,7 @@
|
||||
<module name="gringotts-core" options="-parameters" />
|
||||
<module name="gringotts-forest" options="-parameters" />
|
||||
<module name="gringotts-gateway" options="-parameters" />
|
||||
<module name="gringotts-web" options="-parameters" />
|
||||
<module name="gringotts-web" options="-parameters -processor lombok.launch.AnnotationProcessorHider$AnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -264,8 +264,9 @@ export const checkTypeMapping = [
|
||||
]
|
||||
|
||||
export const checkOverMapping = [
|
||||
mappingItem('完结', 'true', 'bg-success'),
|
||||
mappingItem('进行中', 'false', 'bg-primary'),
|
||||
mappingItem('进行中', 'CHECKING', 'bg-warning'),
|
||||
mappingItem('已撤销', 'RETRACT', 'bg-primary'),
|
||||
mappingItem('已办结', 'OVER', 'bg-success'),
|
||||
]
|
||||
|
||||
function api(method, url) {
|
||||
|
||||
@@ -16,6 +16,16 @@ import {resourceDetailDialog} from "../resource/dialog-resource.js";
|
||||
const CONFIRMATION_TYPE = 'confirmation'
|
||||
const AUTHENTICATION_TYPE = 'authentication'
|
||||
|
||||
const CONFIRMATION = {
|
||||
type: 'confirmation',
|
||||
pickerApi: apiGet('${base}/data_resource/list_no_confirmation')
|
||||
}
|
||||
|
||||
const AUTHENTICATION = {
|
||||
type: 'authentication',
|
||||
pickerApi: apiGet('${base}/data_resource/list_no_authentication')
|
||||
}
|
||||
|
||||
function detailForm(pickerApi = apiGet('${base}/data_resource/list'), showCreatedUserAndModifiedUser = false) {
|
||||
return {
|
||||
debug: information.debug,
|
||||
@@ -98,16 +108,16 @@ function detailForm(pickerApi = apiGet('${base}/data_resource/list'), showCreate
|
||||
}
|
||||
|
||||
export function confirmationAddDialog() {
|
||||
return permissionAddDialog(CONFIRMATION_TYPE)
|
||||
return permissionAddDialog(CONFIRMATION)
|
||||
}
|
||||
|
||||
export function authenticationAddDialog() {
|
||||
return permissionAddDialog(AUTHENTICATION_TYPE)
|
||||
return permissionAddDialog(AUTHENTICATION)
|
||||
}
|
||||
|
||||
function permissionAddDialog(type) {
|
||||
function permissionAddDialog(config) {
|
||||
let data = {add: true}
|
||||
data[type] = true
|
||||
data[config.type] = true
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
@@ -125,8 +135,8 @@ function permissionAddDialog(type) {
|
||||
}
|
||||
],
|
||||
body: {
|
||||
...detailForm(generateApi(type)),
|
||||
api: apiPost(`\${base}/${type}/save`),
|
||||
...detailForm(config.pickerApi),
|
||||
api: apiPost(`\${base}/${config.type}/save`),
|
||||
data: data,
|
||||
}
|
||||
}
|
||||
@@ -134,16 +144,16 @@ function permissionAddDialog(type) {
|
||||
}
|
||||
|
||||
export function confirmationDetailDialog(field = 'id', actions = []) {
|
||||
return permissionDetailDialog(CONFIRMATION_TYPE, field, actions)
|
||||
return permissionDetailDialog(CONFIRMATION, field, actions)
|
||||
}
|
||||
|
||||
export function authenticationDetailDialog(field = 'id', actions = []) {
|
||||
return permissionDetailDialog(AUTHENTICATION_TYPE, field, actions)
|
||||
return permissionDetailDialog(AUTHENTICATION, field, actions)
|
||||
}
|
||||
|
||||
function permissionDetailDialog(type, field = 'id', actions = []) {
|
||||
function permissionDetailDialog(config, field = 'id', actions = []) {
|
||||
let data = {detail: true}
|
||||
data[type] = true
|
||||
data[config.type] = true
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
@@ -151,8 +161,8 @@ function permissionDetailDialog(type, field = 'id', actions = []) {
|
||||
size: 'md',
|
||||
actions: actions,
|
||||
body: {
|
||||
...detailForm(generateApi(type), true),
|
||||
initApi: apiGet(`\${base}/${type}/detail/\${${field}}`),
|
||||
...detailForm(config.pickerApi, true),
|
||||
initApi: apiGet(`\${base}/${config.type}/detail/\${${field}}`),
|
||||
static: true,
|
||||
data: data,
|
||||
}
|
||||
@@ -161,16 +171,16 @@ function permissionDetailDialog(type, field = 'id', actions = []) {
|
||||
}
|
||||
|
||||
export function confirmationEditeDialog(field = 'id') {
|
||||
return permissionEditeDialog(CONFIRMATION_TYPE, field)
|
||||
return permissionEditeDialog(CONFIRMATION, field)
|
||||
}
|
||||
|
||||
export function authenticationEditeDialog(field = 'id') {
|
||||
return permissionEditeDialog(CONFIRMATION_TYPE, field)
|
||||
return permissionEditeDialog(AUTHENTICATION, field)
|
||||
}
|
||||
|
||||
function permissionEditeDialog(type, field = 'id') {
|
||||
function permissionEditeDialog(config, field = 'id') {
|
||||
let data = {edit: true}
|
||||
data[type] = true
|
||||
data[config.type] = true
|
||||
return {
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
@@ -188,20 +198,11 @@ function permissionEditeDialog(type, field = 'id') {
|
||||
}
|
||||
],
|
||||
body: {
|
||||
...detailForm(generateApi(type)),
|
||||
api: apiPost(`\${base}/${type}/save`),
|
||||
initApi: apiGet(`\${base}/${type}/detail/\${${field}}`),
|
||||
...detailForm(config.pickerApi),
|
||||
api: apiPost(`\${base}/${config.type}/save`),
|
||||
initApi: apiGet(`\${base}/${config.type}/detail/\${${field}}`),
|
||||
data: data,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateApi(type) {
|
||||
switch (type) {
|
||||
case AUTHENTICATION_TYPE:
|
||||
return apiGet('${base}/data_resource/list_no_authentication')
|
||||
case CONFIRMATION_TYPE:
|
||||
return apiGet('${base}/data_resource/list_no_confirmation')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ export function tabCheck() {
|
||||
columns: [
|
||||
stringField('description', '描述'),
|
||||
mappingField('type', '类型', checkTypeMapping),
|
||||
mappingField('over', '状态', checkOverMapping),
|
||||
mappingField('state', '状态', checkOverMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
stringField('createdUsername', '创建人', 100),
|
||||
timeField('modifiedTime', '最后修改时间'),
|
||||
stringField('modifiedUsername', '最后操作人', 100),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
visibleOn: `\${type == 'CONFIRMATION' && !over}`,
|
||||
visibleOn: `\${type === 'CONFIRMATION' && state === 'CHECKING'}`,
|
||||
type: 'action',
|
||||
label: '处理',
|
||||
level: 'link',
|
||||
@@ -63,14 +63,14 @@ export function tabCheck() {
|
||||
),
|
||||
},
|
||||
{
|
||||
visibleOn: `\${type == 'CONFIRMATION' && over}`,
|
||||
visibleOn: `\${type === 'CONFIRMATION' && state !== NORMAL}`,
|
||||
type: 'action',
|
||||
label: '查看',
|
||||
level: 'link',
|
||||
...confirmationDetailDialog('parameters.confirmationId'),
|
||||
},
|
||||
{
|
||||
visibleOn: `\${type == 'AUTHENTICATION' && !over}`,
|
||||
visibleOn: `\${type === 'AUTHENTICATION' && state === 'CHECKING'}`,
|
||||
type: 'action',
|
||||
label: '处理',
|
||||
level: 'link',
|
||||
@@ -97,7 +97,7 @@ export function tabCheck() {
|
||||
),
|
||||
},
|
||||
{
|
||||
visibleOn: `\${type == 'AUTHENTICATION' && over}`,
|
||||
visibleOn: `\${type === 'AUTHENTICATION' && state !== NORMAL}`,
|
||||
type: 'action',
|
||||
label: '查看',
|
||||
level: 'link',
|
||||
|
||||
@@ -63,7 +63,7 @@ export function tabPermissions() {
|
||||
...authenticationDetailDialog(),
|
||||
},
|
||||
{
|
||||
visibleOn: arrayInCheck([checkState.ownerChecking, checkState.checking], checkState),
|
||||
visibleOn: arrayInCheck([checkState.ownerChecking, checkState.checking], 'state'),
|
||||
type: 'action',
|
||||
label: '撤销',
|
||||
level: 'link',
|
||||
|
||||
@@ -28,6 +28,12 @@
|
||||
<groupId>com.blinkfox</groupId>
|
||||
<artifactId>fenix-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
@@ -37,6 +43,18 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
<compilerArguments>
|
||||
<processor>
|
||||
lombok.launch.AnnotationProcessorHider$AnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
|
||||
</processor>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
@@ -2,15 +2,11 @@ package com.eshore.gringotts.web.domain.authentication.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.transaction.Transactional;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
@@ -31,13 +27,4 @@ public interface AuthenticationRepository extends SimpleRepository<Authenticatio
|
||||
@Override
|
||||
@EntityGraph(value = "authentication.detail", type = EntityGraph.EntityGraphType.FETCH)
|
||||
Optional<Authentication> findOne(Specification<Authentication> specification);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("update Authentication authentication \n" +
|
||||
"set authentication.state = ?2, \n" +
|
||||
" authentication.modifiedUser = ?3, \n" +
|
||||
" authentication.modifiedTime = current_timestamp \n" +
|
||||
"where authentication.id = ?1")
|
||||
void updateStateById(Long id, Authentication.State state, User modifiedUser);
|
||||
}
|
||||
|
||||
@@ -3,17 +3,23 @@ package com.eshore.gringotts.web.domain.authentication.service;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication_;
|
||||
import com.eshore.gringotts.web.domain.authentication.repository.AuthenticationRepository;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.service.CheckingService;
|
||||
import com.eshore.gringotts.web.domain.base.service.LogicDeleteService;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder_;
|
||||
import com.eshore.gringotts.web.domain.check.service.CheckOrderService;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
@@ -41,6 +47,25 @@ public class AuthenticationService extends LogicDeleteService<Authentication> im
|
||||
this.mapper = builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Predicate listPredicate(Root<Authentication> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
if (ignoreWhenAdministrator()) {
|
||||
return null;
|
||||
}
|
||||
User loginUser = userService.currentLoginUser();
|
||||
return builder.or(
|
||||
builder.equal(root.get(Authentication_.createdUser), loginUser),
|
||||
builder.and(
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.target), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.targetRole), loginUser.getRole())
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.target), CheckOrder.Target.USER),
|
||||
builder.equal(root.get(Authentication_.order).get(CheckOrder_.targetUser), loginUser)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(Authentication entity) {
|
||||
if (ObjectUtil.isNull(entity.getId()) && authenticationRepository.findOne(
|
||||
@@ -62,7 +87,7 @@ public class AuthenticationService extends LogicDeleteService<Authentication> im
|
||||
public void submit(Long id) throws JsonProcessingException {
|
||||
Authentication authentication = detailOrThrow(id);
|
||||
authentication.setState(CheckingNeededEntity.State.OWNER_CHECKING);
|
||||
checkOrderService.save(new CheckOrder(
|
||||
Long orderId = checkOrderService.save(new CheckOrder(
|
||||
"authentication_owner_check",
|
||||
StrUtil.format("数据资源「{}」的授权申请", authentication.getTarget().getName()),
|
||||
CheckOrder.Type.AUTHENTICATION,
|
||||
@@ -70,43 +95,54 @@ public class AuthenticationService extends LogicDeleteService<Authentication> im
|
||||
"com.eshore.gringotts.web.domain.authentication.service.AuthenticationService",
|
||||
authentication.getCreatedUser()
|
||||
));
|
||||
CheckOrder order = checkOrderService.detailOrThrow(orderId);
|
||||
authentication.setOrder(order);
|
||||
save(authentication);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void retract(Long id) {
|
||||
authenticationRepository.updateStateById(id, Authentication.State.DRAFT, userService.currentLoginUser());
|
||||
Authentication authentication = detailOrThrow(id);
|
||||
authentication.setState(Authentication.State.DRAFT);
|
||||
save(authentication);
|
||||
|
||||
CheckOrder order = authentication.getOrder();
|
||||
order.setState(CheckOrder.State.RETRACT);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap<String, Object> parameters) {
|
||||
Long id = (Long) parameters.get("authenticationId");
|
||||
User user = userService.currentLoginUser();
|
||||
Authentication authentication = detailOrThrow(id);
|
||||
if (StrUtil.equals(order.getKeyword(), "authentication_owner_check")) {
|
||||
switch (operation) {
|
||||
case APPLY:
|
||||
authenticationRepository.updateStateById(id, Authentication.State.CHECKING, user);
|
||||
authentication.setState(Authentication.State.CHECKING);
|
||||
order.setKeyword("authentication_checker_check");
|
||||
order.setTarget(CheckOrder.Target.ROLE);
|
||||
order.setTargetRole(User.Role.CHECKER);
|
||||
checkOrderService.save(order);
|
||||
break;
|
||||
case REJECT:
|
||||
authenticationRepository.updateStateById(id, Authentication.State.DRAFT, user);
|
||||
authentication.setState(Authentication.State.DRAFT);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
}
|
||||
} else if (StrUtil.equals(order.getKeyword(), "authentication_checker_check")) {
|
||||
switch (operation) {
|
||||
case APPLY:
|
||||
authenticationRepository.updateStateById(id, Authentication.State.NORMAL, user);
|
||||
checkOrderService.over(order.getId());
|
||||
authentication.setState(Authentication.State.NORMAL);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
case REJECT:
|
||||
authenticationRepository.updateStateById(id, Authentication.State.DRAFT, user);
|
||||
checkOrderService.over(order.getId());
|
||||
authentication.setState(Authentication.State.DRAFT);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
save(authentication);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
|
||||
public static final class AuthenticationDuplicatedException extends RuntimeException {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.eshore.gringotts.web.domain.base.entity;
|
||||
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToOne;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
@@ -22,6 +26,10 @@ public class CheckingNeededEntity extends LogicDeleteEntity {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private State state = State.DRAFT;
|
||||
|
||||
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
|
||||
@ToString.Exclude
|
||||
private CheckOrder order;
|
||||
|
||||
public enum State {
|
||||
/**
|
||||
* 无确权
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.eshore.gringotts.web.domain.base.repository;
|
||||
import com.blinkfox.fenix.jpa.FenixJpaRepository;
|
||||
import com.blinkfox.fenix.specification.FenixJpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||
|
||||
/**
|
||||
* 整合一下
|
||||
@@ -11,5 +12,5 @@ import org.springframework.data.repository.NoRepositoryBean;
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
@NoRepositoryBean
|
||||
public interface SimpleRepository<E, ID> extends FenixJpaRepository<E, ID>, FenixJpaSpecificationExecutor<E> {
|
||||
public interface SimpleRepository<E, ID> extends FenixJpaRepository<E, ID>, FenixJpaSpecificationExecutor<E>, QueryByExampleExecutor<E> {
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
|
||||
/**
|
||||
* @author lanyuanxiaoyao
|
||||
@@ -30,8 +28,8 @@ public abstract class LogicDeleteService<ENTITY extends LogicDeleteEntity> exten
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicates(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
return Lists.immutable.of(builder.equal(root.get("deleted"), false));
|
||||
protected Predicate listPredicate(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
return builder.equal(root.get("deleted"), false);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
|
||||
@@ -58,17 +58,16 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
|
||||
@Override
|
||||
public ImmutableList<ENTITY> list() throws Exception {
|
||||
return Lists.immutable.ofAll(repository.findAll((root, query, builder) -> builder.and(listPredicates(root, query, builder).toArray(new Predicate[]{}))));
|
||||
return Lists.immutable.ofAll(repository.findAll(this::listPredicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ENTITY> list(ImmutableSet<Long> ids) throws Exception {
|
||||
return Lists.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) -> {
|
||||
MutableList<Predicate> predicates = Lists.mutable.ofAll(listPredicates(root, query, builder));
|
||||
predicates.add(builder.in(root.get("id")).value(ids));
|
||||
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
}
|
||||
(root, query, builder) -> builder.and(
|
||||
listPredicate(root, query, builder),
|
||||
builder.in(root.get("id")).value(ids)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -153,20 +152,23 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
return predicates.toImmutable();
|
||||
}
|
||||
|
||||
protected ImmutableList<Predicate> listPredicates(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
MutableList<Predicate> predicates = Lists.mutable.empty();
|
||||
protected Boolean ignoreWhenAdministrator() {
|
||||
return User.isAdministrator(userService.currentLoginUser());
|
||||
}
|
||||
|
||||
protected Predicate listPredicate(Root<ENTITY> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User user = userService.currentLoginUser();
|
||||
if (User.isNotAdministrator(user)) {
|
||||
predicates.add(builder.equal(root.get("createdUser"), user));
|
||||
return builder.equal(root.get("createdUser"), user);
|
||||
}
|
||||
return predicates.toImmutable();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ENTITY> list(Query listQuery) throws Exception {
|
||||
return Lists.immutable.ofAll(repository.findAll(
|
||||
(root, query, builder) -> {
|
||||
MutableList<Predicate> predicates = Lists.mutable.ofAll(listPredicates(root, query, builder));
|
||||
MutableList<Predicate> predicates = Lists.mutable.of(listPredicate(root, query, builder));
|
||||
predicates.addAllIterable(queryPredicates(listQuery.getQuery(), root, query, builder));
|
||||
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
},
|
||||
@@ -180,11 +182,10 @@ public abstract class SimpleServiceSupport<ENTITY extends SimpleEntity> implemen
|
||||
return Optional.empty();
|
||||
}
|
||||
return repository.findOne(
|
||||
(root, query, builder) -> {
|
||||
MutableList<Predicate> predicates = Lists.mutable.ofAll(listPredicates(root, query, builder));
|
||||
predicates.add(builder.equal(root.get("id"), id));
|
||||
return builder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
}
|
||||
(root, query, builder) -> builder.and(
|
||||
listPredicate(root, query, builder),
|
||||
builder.equal(root.get("id"), id)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CheckOrderController implements ListController<CheckOrderController
|
||||
item.setDescription(order.getDescription());
|
||||
item.setType(order.getType());
|
||||
item.setParameters(mapper.readValue(order.getParameters(), new TypeReference<>() {}));
|
||||
item.setOver(order.getOver());
|
||||
item.setState(order.getState());
|
||||
item.setCreatedUsername(order.getCreatedUser().getUsername());
|
||||
item.setCreatedTime(order.getCreatedTime());
|
||||
item.setModifiedUsername(order.getModifiedUser().getUsername());
|
||||
@@ -80,7 +80,7 @@ public class CheckOrderController implements ListController<CheckOrderController
|
||||
private String description;
|
||||
private CheckOrder.Type type;
|
||||
private ImmutableMap<String, Object> parameters;
|
||||
private Boolean over;
|
||||
private CheckOrder.State state;
|
||||
private LocalDateTime createdTime;
|
||||
private String createdUsername;
|
||||
private LocalDateTime modifiedTime;
|
||||
|
||||
@@ -70,7 +70,8 @@ public class CheckOrder extends SimpleEntity {
|
||||
private User.Role targetRole;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean over = false;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private State state = State.CHECKING;
|
||||
|
||||
public CheckOrder(
|
||||
String keyword,
|
||||
@@ -120,4 +121,10 @@ public class CheckOrder extends SimpleEntity {
|
||||
USER,
|
||||
ROLE,
|
||||
}
|
||||
|
||||
public enum State {
|
||||
CHECKING,
|
||||
RETRACT,
|
||||
OVER,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,6 @@ public interface CheckOrderRepository extends SimpleRepository<CheckOrder, Long>
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("update CheckOrder check set check.over = true, check.modifiedUser = ?2, check.modifiedTime = current_timestamp where check.id = ?1")
|
||||
void overById(Long id, User modifiedUser);
|
||||
@Query("update CheckOrder check set check.state = ?2, check.modifiedUser = ?3, check.modifiedTime = current_timestamp where check.id = ?1")
|
||||
void overById(Long id, CheckOrder.State state, User modifiedUser);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.list.ImmutableList;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
@@ -44,19 +42,20 @@ public class CheckOrderService extends SimpleServiceSupport<CheckOrder> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<Predicate> listPredicates(Root<CheckOrder> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
protected Predicate listPredicate(Root<CheckOrder> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
User user = userService.currentLoginUser();
|
||||
return Lists.immutable.of(
|
||||
builder.or(
|
||||
builder.equal(root.get("createdUser"), user),
|
||||
builder.and(
|
||||
builder.equal(root.get("target"), CheckOrder.Target.USER),
|
||||
builder.equal(root.get("targetUser"), user)
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get("target"), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get("targetRole"), user.getRole())
|
||||
)
|
||||
if (ObjectUtil.equals(user.getRole(), User.Role.ADMINISTRATOR)) {
|
||||
return null;
|
||||
}
|
||||
return builder.or(
|
||||
builder.equal(root.get("createdUser"), user),
|
||||
builder.and(
|
||||
builder.equal(root.get("target"), CheckOrder.Target.USER),
|
||||
builder.equal(root.get("targetUser"), user)
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get("target"), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get("targetRole"), user.getRole())
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -71,7 +70,11 @@ public class CheckOrderService extends SimpleServiceSupport<CheckOrder> {
|
||||
service.onChecked(order, operation, parameters);
|
||||
}
|
||||
|
||||
public void retract(Long id) {
|
||||
checkOrderRepository.overById(id, CheckOrder.State.RETRACT, userService.currentLoginUser());
|
||||
}
|
||||
|
||||
public void over(Long id) {
|
||||
checkOrderRepository.overById(id, userService.currentLoginUser());
|
||||
checkOrderRepository.overById(id, CheckOrder.State.OVER, userService.currentLoginUser());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,11 @@ package com.eshore.gringotts.web.domain.confirmation.repository;
|
||||
|
||||
import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.transaction.Transactional;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
@@ -33,13 +29,4 @@ public interface ConfirmationRepository extends SimpleRepository<Confirmation, L
|
||||
Optional<Confirmation> findOne(Specification<Confirmation> specification);
|
||||
|
||||
Boolean existsByTarget_Id(Long id);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("update Confirmation confirmation \n" +
|
||||
"set confirmation.state = ?2, \n" +
|
||||
" confirmation.modifiedUser = ?3, \n" +
|
||||
" confirmation.modifiedTime = current_timestamp \n" +
|
||||
"where confirmation.id = ?1")
|
||||
void updateStateById(Long id, Confirmation.State state, User modifiedUser);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,23 @@ package com.eshore.gringotts.web.domain.confirmation.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.service.CheckingService;
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder_;
|
||||
import com.eshore.gringotts.web.domain.check.service.CheckOrderService;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation_;
|
||||
import com.eshore.gringotts.web.domain.confirmation.repository.ConfirmationRepository;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.transaction.Transactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
@@ -27,18 +34,35 @@ import org.springframework.stereotype.Service;
|
||||
@Service("com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService")
|
||||
public class ConfirmationService extends SimpleServiceSupport<Confirmation> implements CheckingService {
|
||||
private final ConfirmationRepository confirmationRepository;
|
||||
private final UserService userService;
|
||||
private final CheckOrderService checkOrderService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService, CheckOrderService checkOrderService, Jackson2ObjectMapperBuilder builder) {
|
||||
super(confirmationRepository, userService);
|
||||
this.confirmationRepository = confirmationRepository;
|
||||
this.userService = userService;
|
||||
this.checkOrderService = checkOrderService;
|
||||
this.mapper = builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Predicate listPredicate(Root<Confirmation> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
if (ignoreWhenAdministrator()) {
|
||||
return null;
|
||||
}
|
||||
User loginUser = userService.currentLoginUser();
|
||||
return builder.or(
|
||||
builder.equal(root.get(Confirmation_.createdUser), loginUser),
|
||||
builder.and(
|
||||
builder.equal(root.get(Confirmation_.order).get(CheckOrder_.target), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get(Confirmation_.order).get(CheckOrder_.targetRole), loginUser.getRole())
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get(Confirmation_.order).get(CheckOrder_.target), CheckOrder.Target.USER),
|
||||
builder.equal(root.get(Confirmation_.order).get(CheckOrder_.targetUser), loginUser)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(Confirmation entity) {
|
||||
if (ObjectUtil.isNull(entity.getId()) && confirmationRepository.existsByTarget_Id(entity.getTarget().getId())) {
|
||||
@@ -51,35 +75,48 @@ public class ConfirmationService extends SimpleServiceSupport<Confirmation> impl
|
||||
public void submit(Long id) throws JsonProcessingException {
|
||||
Confirmation confirmation = detailOrThrow(id);
|
||||
confirmation.setState(Confirmation.State.CHECKING);
|
||||
checkOrderService.save(new CheckOrder(
|
||||
Long orderId = checkOrderService.save(new CheckOrder(
|
||||
"confirmation_check",
|
||||
StrUtil.format("数据资源「{}」的确权申请", confirmation.getTarget().getName()),
|
||||
CheckOrder.Type.CONFIRMATION,
|
||||
mapper.writeValueAsString(Maps.immutable.of("confirmationId", confirmation.getId())),
|
||||
"com.eshore.gringotts.web.domain.confirmation.service.ConfirmationService",
|
||||
User.Role.ADMINISTRATOR
|
||||
User.Role.CHECKER
|
||||
));
|
||||
CheckOrder order = checkOrderService.detailOrThrow(orderId);
|
||||
confirmation.setOrder(order);
|
||||
save(confirmation);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void retract(Long id) {
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.DRAFT, userService.currentLoginUser());
|
||||
Confirmation confirmation = detailOrThrow(id);
|
||||
confirmation.setState(CheckingNeededEntity.State.DRAFT);
|
||||
save(confirmation);
|
||||
|
||||
CheckOrder order = confirmation.getOrder();
|
||||
order.setState(CheckOrder.State.RETRACT);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = Throwable.class)
|
||||
public void onChecked(CheckOrder order, CheckOrder.Operation operation, ImmutableMap<String, Object> parameters) {
|
||||
if (StrUtil.equals(order.getKeyword(), "confirmation_check")) {
|
||||
Long id = (Long) parameters.get("confirmationId");
|
||||
Confirmation confirmation = detailOrThrow(id);
|
||||
switch (operation) {
|
||||
case APPLY:
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.NORMAL, userService.currentLoginUser());
|
||||
checkOrderService.over(order.getId());
|
||||
confirmation.setState(Confirmation.State.NORMAL);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
case REJECT:
|
||||
confirmationRepository.updateStateById(id, Confirmation.State.DRAFT, userService.currentLoginUser());
|
||||
checkOrderService.over(order.getId());
|
||||
confirmation.setState(Confirmation.State.DRAFT);
|
||||
order.setState(CheckOrder.State.OVER);
|
||||
break;
|
||||
}
|
||||
save(confirmation);
|
||||
checkOrderService.save(order);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
package com.eshore.gringotts.web.domain.resource.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication_;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation_;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.DataResource_;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.format.ResourceFormat;
|
||||
import com.eshore.gringotts.web.domain.resource.entity.type.ResourceType;
|
||||
import com.eshore.gringotts.web.domain.resource.repository.DataResourceRepository;
|
||||
import com.eshore.gringotts.web.domain.resource.repository.ResourceFormatRepository;
|
||||
import com.eshore.gringotts.web.domain.resource.repository.ResourceTypeRepository;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import com.eshore.gringotts.web.helper.EntityHelper;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Join;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Subquery;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -40,6 +48,36 @@ public class DataResourceService extends SimpleServiceSupport<DataResource> {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Predicate listPredicate(Root<DataResource> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
if (ignoreWhenAdministrator()) {
|
||||
return null;
|
||||
}
|
||||
User loginUser = userService.currentLoginUser();
|
||||
|
||||
Subquery<Confirmation> confirmationSubquery = query.subquery(Confirmation.class);
|
||||
Root<Confirmation> confirmationRoot = confirmationSubquery.from(Confirmation.class);
|
||||
confirmationSubquery.select(confirmationRoot)
|
||||
.where(
|
||||
builder.equal(confirmationRoot.get(Confirmation_.target), root),
|
||||
EntityHelper.checkNeededEntityPrediction(confirmationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
Subquery<Authentication> authenticationSubquery = query.subquery(Authentication.class);
|
||||
Root<Authentication> authenticationRoot = authenticationSubquery.from(Authentication.class);
|
||||
authenticationSubquery.select(authenticationRoot)
|
||||
.where(
|
||||
builder.equal(authenticationRoot.get(Authentication_.target), root),
|
||||
EntityHelper.checkNeededEntityPrediction(authenticationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
return builder.or(
|
||||
builder.equal(root.get(DataResource_.createdUser), loginUser),
|
||||
builder.exists(confirmationSubquery),
|
||||
builder.exists(authenticationSubquery)
|
||||
);
|
||||
}
|
||||
|
||||
public ImmutableList<DataResource> listNoConfirmation() {
|
||||
return Lists.immutable.ofAll(dataResourceRepository.findAllByConfirmationIsNull());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
package com.eshore.gringotts.web.domain.upload.service;
|
||||
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication;
|
||||
import com.eshore.gringotts.web.domain.authentication.entity.Authentication_;
|
||||
import com.eshore.gringotts.web.domain.base.service.SimpleServiceSupport;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation;
|
||||
import com.eshore.gringotts.web.domain.confirmation.entity.Confirmation_;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile;
|
||||
import com.eshore.gringotts.web.domain.upload.entity.DataFile_;
|
||||
import com.eshore.gringotts.web.domain.upload.repository.DataFileRepository;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import com.eshore.gringotts.web.domain.user.service.UserService;
|
||||
import com.eshore.gringotts.web.helper.EntityHelper;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Subquery;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -26,11 +37,34 @@ public class DataFileService extends SimpleServiceSupport<DataFile> {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public DataFile detail(String id) {
|
||||
if (id == null) {
|
||||
@Override
|
||||
protected Predicate listPredicate(Root<DataFile> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
||||
if (ignoreWhenAdministrator()) {
|
||||
return null;
|
||||
}
|
||||
return detail(Long.valueOf(id));
|
||||
User loginUser = userService.currentLoginUser();
|
||||
|
||||
Subquery<Confirmation> confirmationSubquery = query.subquery(Confirmation.class);
|
||||
Root<Confirmation> confirmationRoot = confirmationSubquery.from(Confirmation.class);
|
||||
confirmationSubquery.select(confirmationRoot)
|
||||
.where(
|
||||
builder.isMember(root, confirmationRoot.get(Confirmation_.evidences)),
|
||||
EntityHelper.checkNeededEntityPrediction(confirmationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
Subquery<Authentication> authenticationSubquery = query.subquery(Authentication.class);
|
||||
Root<Authentication> authenticationRoot = authenticationSubquery.from(Authentication.class);
|
||||
authenticationSubquery.select(authenticationRoot)
|
||||
.where(
|
||||
builder.isMember(root, authenticationRoot.get(Authentication_.evidences)),
|
||||
EntityHelper.checkNeededEntityPrediction(authenticationRoot, builder, loginUser)
|
||||
);
|
||||
|
||||
return builder.or(
|
||||
builder.equal(root.get(DataFile_.createdUser), loginUser),
|
||||
builder.exists(confirmationSubquery),
|
||||
builder.exists(authenticationSubquery)
|
||||
);
|
||||
}
|
||||
|
||||
public Long initialDataFile(String filename) {
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
package com.eshore.gringotts.web.helper;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity;
|
||||
import com.eshore.gringotts.web.domain.base.entity.CheckingNeededEntity_;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder;
|
||||
import com.eshore.gringotts.web.domain.check.entity.CheckOrder_;
|
||||
import com.eshore.gringotts.web.domain.user.entity.User;
|
||||
import java.util.function.Supplier;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
@@ -17,4 +25,17 @@ public class EntityHelper {
|
||||
repository.delete(old);
|
||||
}
|
||||
}
|
||||
|
||||
public static Predicate checkNeededEntityPrediction(Root<? extends CheckingNeededEntity> root, CriteriaBuilder builder, User loginUser) {
|
||||
return builder.or(
|
||||
builder.and(
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.target), CheckOrder.Target.ROLE),
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.targetRole), loginUser.getRole())
|
||||
),
|
||||
builder.and(
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.target), CheckOrder.Target.USER),
|
||||
builder.equal(root.get(CheckingNeededEntity_.order).get(CheckOrder_.targetUser), loginUser)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
27
pom.xml
27
pom.xml
@@ -29,6 +29,8 @@
|
||||
<hutool.version>5.8.32</hutool.version>
|
||||
<fisco.sdk.version>2.10.0</fisco.sdk.version>
|
||||
<eclipse-collections.version>11.1.0</eclipse-collections.version>
|
||||
<querydsl.version>5.1.0</querydsl.version>
|
||||
<hibernate.version>5.6.15.Final</hibernate.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -103,6 +105,17 @@
|
||||
<artifactId>fenix-spring-boot-starter</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-jpa</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-apt</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Others -->
|
||||
<dependency>
|
||||
@@ -144,7 +157,6 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
@@ -152,11 +164,24 @@
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>apt-maven-plugin</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
Reference in New Issue
Block a user