44 行
1.3 KiB
Java
44 行
1.3 KiB
Java
|
|
package com.xuqm.im.service;
|
||
|
|
|
||
|
|
import com.xuqm.im.entity.ImOperationLogEntity;
|
||
|
|
import com.xuqm.im.repository.ImOperationLogRepository;
|
||
|
|
import org.springframework.data.domain.Page;
|
||
|
|
import org.springframework.data.domain.Pageable;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
import java.time.LocalDateTime;
|
||
|
|
import java.util.UUID;
|
||
|
|
|
||
|
|
@Service
|
||
|
|
public class OperationLogService {
|
||
|
|
|
||
|
|
private final ImOperationLogRepository repository;
|
||
|
|
|
||
|
|
public OperationLogService(ImOperationLogRepository repository) {
|
||
|
|
this.repository = repository;
|
||
|
|
}
|
||
|
|
|
||
|
|
public ImOperationLogEntity record(
|
||
|
|
String appId,
|
||
|
|
String operatorId,
|
||
|
|
String action,
|
||
|
|
String resourceType,
|
||
|
|
String resourceId,
|
||
|
|
String detail) {
|
||
|
|
ImOperationLogEntity entity = new ImOperationLogEntity();
|
||
|
|
entity.setId(UUID.randomUUID().toString());
|
||
|
|
entity.setAppId(appId);
|
||
|
|
entity.setOperatorId(operatorId);
|
||
|
|
entity.setAction(action);
|
||
|
|
entity.setResourceType(resourceType);
|
||
|
|
entity.setResourceId(resourceId);
|
||
|
|
entity.setDetail(detail);
|
||
|
|
entity.setCreatedAt(LocalDateTime.now());
|
||
|
|
return repository.save(entity);
|
||
|
|
}
|
||
|
|
|
||
|
|
public Page<ImOperationLogEntity> list(String appId, Pageable pageable) {
|
||
|
|
return repository.findByAppIdOrderByCreatedAtDesc(appId, pageable);
|
||
|
|
}
|
||
|
|
}
|