修复redis 时间
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,76 @@
|
||||
package com.yunhai.bschclassmanage.service.impl.com;
|
||||
|
||||
import com.yunhai.bschclassmanage.Repository.OperationLogRecordRepository;
|
||||
import com.yunhai.bschclassmanage.Repository.specification.OperationLogSpecifications;
|
||||
import com.yunhai.bschclassmanage.entity.OperationLogRecord;
|
||||
import com.yunhai.bschclassmanage.model.vo.PageVO;
|
||||
import com.yunhai.bschclassmanage.service.ILogService;
|
||||
import com.yunhai.bschclassmanage.utils.UserContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.domain.Specification;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LogService implements ILogService {
|
||||
|
||||
@Autowired
|
||||
private OperationLogRecordRepository repository;
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW) // 独立事务,不受业务回滚影响
|
||||
public void save(OperationLogRecord log) {
|
||||
repository.save(log);
|
||||
}
|
||||
|
||||
@Async("logExecutor")
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW) // 独立事务,不受业务回滚影响
|
||||
public void saveAllLogAsync(List<OperationLogRecord> logs){
|
||||
repository.saveAll(logs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageVO<OperationLogRecord> search(Integer schId, String keyword,Boolean isSystem, Pageable pageable) {
|
||||
// 构建规格
|
||||
Specification<OperationLogRecord> spec = Specification
|
||||
.where(OperationLogSpecifications.schIdEquals(schId))
|
||||
.and(OperationLogSpecifications.keywordLike(keyword));
|
||||
// 默认排序:按操作时间降序
|
||||
if (!pageable.getSort().isSorted()) {
|
||||
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(),
|
||||
Sort.by(Sort.Direction.DESC, "operateTime"));
|
||||
}
|
||||
|
||||
spec = spec.and(OperationLogSpecifications.IsSystem(isSystem));
|
||||
|
||||
// 执行查询
|
||||
Page<OperationLogRecord> page = repository.findAll(spec, pageable);
|
||||
// 转换为 PageVO,注意 PageVO 构造方法可能需要 current, pageSize, total, list
|
||||
// 假设 PageVO 构造方法为 (int current, int pageSize, long total, List<T> list)
|
||||
return new PageVO<>(pageable.getPageNumber() + 1, pageable.getPageSize(), page.getTotalElements(), page.getContent());
|
||||
}
|
||||
|
||||
public OperationLogRecord buildLogRecord(UserContext.UserInfo ctx, String module, String content,LocalDateTime now) {
|
||||
OperationLogRecord logRecord = new OperationLogRecord();
|
||||
logRecord.setOperator(ctx.getUserName());
|
||||
logRecord.setOperatorId(ctx.getUserId());
|
||||
logRecord.setIp(ctx.getIp());
|
||||
logRecord.setSchId(ctx.getSchId());
|
||||
logRecord.setModule(module);
|
||||
logRecord.setOperateTime(now);
|
||||
logRecord.setContent(content);
|
||||
return logRecord;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
package com.yunhai.bschclassmanage.service.impl.sync;
|
||||
package com.yunhai.bschclassmanage.service.impl.com;
|
||||
|
||||
import com.yunhai.bschclassmanage.entity.SchStudent;
|
||||
import com.yunhai.bschclassmanage.entity.SchTeacher;
|
||||
@@ -27,8 +27,9 @@ import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
//SendUserBase
|
||||
@Service
|
||||
public class SyncUserBaseService implements ISyncUserBaseService {
|
||||
public class SendUserBaseService implements ISyncUserBaseService {
|
||||
|
||||
@SyncOpLog(SyncDataType.SEND_EDIT_GROUP)
|
||||
public BoaGroup addGroup(String name, Integer parentId, Integer sort, NodeType type){
|
||||
Reference in New Issue
Block a user