|
|
@@ -23,6 +23,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
@@ -30,6 +31,7 @@ import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static cc.iotkit.data.model.QTbSysLogininfor.tbSysLogininfor;
|
|
|
import static cc.iotkit.data.model.QTbSysOperLog.tbSysOperLog;
|
|
|
|
|
|
/**
|
|
|
@@ -86,6 +88,15 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData<SysOper
|
|
|
operLogRepository.deleteAll();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void cleanOperLog() {
|
|
|
+ SysOperLog sysOperLog = new SysOperLog();
|
|
|
+ sysOperLog.setTenantId(LoginHelper.getTenantId());
|
|
|
+ List<Long> childDepts = PredicateBuilder.queryCacheChildDeptIds(LoginHelper.getTenantId());
|
|
|
+ jpaQueryFactory.delete(tbSysOperLog).where(tbSysOperLog.createDept.in(CollectionUtil.isNotEmpty(childDepts)?childDepts:Collections.singletonList(-1L))).execute();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<SysOperLog> findAllByCondition(SysOperLog data) {
|
|
|
List<TbSysOperLog> ret = jpaQueryFactory.selectFrom(tbSysOperLog).where(buildQueryCondition(data))
|
|
|
@@ -95,6 +106,7 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData<SysOper
|
|
|
|
|
|
private Predicate buildQueryCondition(SysOperLog data) {
|
|
|
PredicateBuilder predicateBuilder = PredicateBuilder.instance()
|
|
|
+// .and(StringUtils.isNotBlank(data.getTenantId()), () -> tbSysOperLog.tenantId.eq(data.getTenantId()))
|
|
|
.and(StringUtils.isNotBlank(data.getTitle()), () -> tbSysOperLog.title.like(data.getTitle()))
|
|
|
.and(data.getBusinessType() != null && data.getBusinessType() > 0, () -> tbSysOperLog.businessType.eq(data.getBusinessType()))
|
|
|
.and(ArrayUtil.isNotEmpty(data.getBusinessTypes()), () -> tbSysOperLog.businessType.in(Arrays.asList(data.getBusinessTypes())))
|
|
|
@@ -105,19 +117,8 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData<SysOper
|
|
|
}
|
|
|
|
|
|
private static void checkDataPermission(PredicateBuilder predicateBuilder, String tenantId){
|
|
|
- Long deptId = LoginHelper.getDeptId();
|
|
|
- List<Long> deptList = new ArrayList<>();
|
|
|
- if(ObjectUtil.isNotNull(deptId)){
|
|
|
- String ChildDept = RedisUtils.getCacheObject(GlobalConstants.DEPT_CHILD_PREFIX+tenantId+":"+LoginHelper.getDeptId());
|
|
|
- if(StringUtils.isNotEmpty(ChildDept)){
|
|
|
- deptList= Arrays.stream(StringUtils.split(ChildDept,",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
- deptList.add(LoginHelper.getDeptId());
|
|
|
- }else{
|
|
|
- deptList = Collections.singletonList(LoginHelper.getDeptId());
|
|
|
- }
|
|
|
- }
|
|
|
- List<Long> finalDeptList = deptList;
|
|
|
- predicateBuilder.and(CollectionUtil.isNotEmpty(deptList),()->tbSysOperLog.createDept.in(finalDeptList));
|
|
|
+ List<Long> finalDeptList = PredicateBuilder.queryCacheChildDeptIds(tenantId);
|
|
|
+ predicateBuilder.and(CollectionUtil.isNotEmpty(finalDeptList),()->tbSysOperLog.createDept.in(finalDeptList));
|
|
|
|
|
|
}
|
|
|
|