mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善查询
This commit is contained in:
@@ -15,6 +15,7 @@ import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.hibernate.Filter;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -22,6 +23,7 @@ import java.lang.reflect.Method;
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
@Order
|
||||
public class OrgScopeAop {
|
||||
|
||||
@PersistenceContext
|
||||
@@ -42,33 +44,11 @@ public class OrgScopeAop {
|
||||
}
|
||||
|
||||
if (annotation != null) {
|
||||
Boolean old = orgScope.get();
|
||||
orgScope.set(annotation.value());
|
||||
try {
|
||||
return pjp.proceed();
|
||||
} finally {
|
||||
orgScope.set(old);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
return pjp.proceed();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Before(value = "@annotation(org.springframework.transaction.annotation.Transactional))")
|
||||
public void beforeTransactionMethod() {
|
||||
|
||||
|
||||
if (orgScope.get() != null) {
|
||||
boolean enabled = annotation.value();
|
||||
|
||||
Session session = entityManager.unwrap(Session.class);
|
||||
if (orgScope.get()) {
|
||||
|
||||
if (enabled) {
|
||||
|
||||
if (StringUtils.isEmpty(Ctx.currentUser().getOrganizationId())) {
|
||||
throw new BizException("当前用户未绑定机构, 无法进行机构数据过滤");
|
||||
@@ -97,6 +77,22 @@ public class OrgScopeAop {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return pjp.proceed();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Before(value = "@annotation(org.springframework.transaction.annotation.Transactional))")
|
||||
public void beforeTransactionMethod() {
|
||||
|
||||
|
||||
if (orgScope.get() != null) {
|
||||
|
||||
Session session = entityManager.unwrap(Session.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.hibernate.annotations.ParamDef;
|
||||
@Getter
|
||||
@Setter
|
||||
@FilterDef(name = "orgFilter", parameters = @ParamDef(name = "organizationId", type = String.class))
|
||||
@Filter(name = "orgFilter", condition = "organizationId = :organizationId")
|
||||
@Filter(name = "orgFilter", condition = "organization_id = :organizationId")
|
||||
public class OrgCommonEntity extends CommonEntity {
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
@Order(Integer.MIN_VALUE + 100)
|
||||
@Order(0)
|
||||
public class AuthFilter extends OncePerRequestFilter {
|
||||
|
||||
@Autowired
|
||||
@@ -127,7 +127,7 @@ public class AuthFilter extends OncePerRequestFilter {
|
||||
.filter(x -> StringUtils.equals(x.getId(), resource.get().getId())).findAny();
|
||||
|
||||
|
||||
if (userResource.isEmpty()) {
|
||||
if (userResource.isEmpty() && !user.getSysAdmin()) {
|
||||
writeResponse(new BizException("invalidAccess", "当前资源未授权,请联系机构管理员处理。"), response);
|
||||
} else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user