|
|
@@ -13,7 +13,6 @@ import com.pharmacopoeia.repository.QuestionRepository;
|
|
|
import com.pharmacopoeia.repository.QuickAskAuditLogRepository;
|
|
|
import com.pharmacopoeia.repository.QuickAskRepository;
|
|
|
import com.pharmacopoeia.util.IpUtils;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
@@ -23,6 +22,9 @@ import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneOffset;
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
@Service
|
|
|
@@ -389,7 +391,7 @@ public class AdminKnowledgeService {
|
|
|
int updated = 0;
|
|
|
for (Map<String, Object> item : items) {
|
|
|
int id = ((Number) item.get("id")).intValue();
|
|
|
- int sortOrder = ((Number) item.get("sort_order")).intValue();
|
|
|
+ int sortOrder = ((Number) item.get("sortOrder")).intValue();
|
|
|
updated += quickAskRepository.updateSortOrder(id, sortOrder, operator);
|
|
|
}
|
|
|
return Map.of("ok", updated > 0, "message", "已更新 " + updated + " 条排序");
|
|
|
@@ -416,14 +418,21 @@ public class AdminKnowledgeService {
|
|
|
return "unknown";
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> listQuickAskAuditLog(int page, int pageSize, String action) {
|
|
|
- var pageable = org.springframework.data.domain.PageRequest.of(page - 1, pageSize);
|
|
|
- Page<QuickAskAuditLog> result;
|
|
|
- if (action != null && !action.isBlank()) {
|
|
|
- result = auditLogRepository.findByActionOrderByCreatedAtDesc(action, pageable);
|
|
|
- } else {
|
|
|
- result = auditLogRepository.findAllByOrderByCreatedAtDesc(pageable);
|
|
|
- }
|
|
|
+ public Map<String, Object> listQuickAskAuditLog(int page, int pageSize, String action,
|
|
|
+ String startDate, String endDate) {
|
|
|
+ var pageable = PageRequest.of(page - 1, pageSize);
|
|
|
+
|
|
|
+ Instant startTime = startDate != null && !startDate.isBlank()
|
|
|
+ ? LocalDate.parse(startDate).atStartOfDay(ZoneOffset.UTC).toInstant()
|
|
|
+ : null;
|
|
|
+ Instant endTime = endDate != null && !endDate.isBlank()
|
|
|
+ ? LocalDate.parse(endDate).plusDays(1).atStartOfDay(ZoneOffset.UTC).toInstant()
|
|
|
+ : null;
|
|
|
+
|
|
|
+ var result = auditLogRepository.findByFilters(
|
|
|
+ action != null && !action.isBlank() ? action : null,
|
|
|
+ startTime, endTime, pageable);
|
|
|
+
|
|
|
return Map.of(
|
|
|
"items", result.getContent(),
|
|
|
"page", page,
|