|
2 | 2 |
|
3 | 3 | import static run.ikaros.api.infra.utils.ReactiveBeanUtils.copyProperties;
|
4 | 4 |
|
| 5 | +import java.time.Instant; |
5 | 6 | import java.time.LocalDateTime;
|
6 |
| -import java.time.Year; |
| 7 | +import java.time.ZoneId; |
7 | 8 | import java.util.Objects;
|
8 | 9 | import lombok.extern.slf4j.Slf4j;
|
9 | 10 | import org.springframework.data.domain.PageRequest;
|
@@ -78,45 +79,16 @@ public Mono<PagingWrap> listCollectionsByCondition(FindCollectionCondition condi
|
78 | 79 | if (CollectionCategory.EPISODE == condition.getCategory()
|
79 | 80 | && StringUtils.isNotBlank(time)
|
80 | 81 | ) {
|
81 |
| - if (time.indexOf('-') > 0) { |
82 |
| - // 日期范围,例如;2000.9-2010.8 |
83 |
| - String[] split = time.split("-"); |
84 |
| - String first = split[0]; |
85 |
| - String second = split[1]; |
86 |
| - LocalDateTime startTime; |
87 |
| - if (first.indexOf(".") > 0) { |
88 |
| - String[] split1 = first.split("\\."); |
89 |
| - startTime = |
90 |
| - Year.parse(split1[0]).atMonth(Integer.parseInt(split1[1])).atDay(1) |
91 |
| - .atStartOfDay(); |
92 |
| - } else { |
93 |
| - startTime = Year.parse(first).atMonth(1).atDay(1).atStartOfDay(); |
94 |
| - } |
95 |
| - LocalDateTime endTime; |
96 |
| - if (second.indexOf(".") > 0) { |
97 |
| - String[] split2 = second.split("\\."); |
98 |
| - endTime = |
99 |
| - Year.parse(split2[0]).atMonth(Integer.parseInt(split2[1])).atDay(1) |
100 |
| - .atStartOfDay().plusMonths(1); |
101 |
| - } else { |
102 |
| - endTime = Year.parse(second).atDay(1).atStartOfDay().plusMonths(1); |
103 |
| - } |
104 |
| - criteria = criteria.and(Criteria.where("update_time").between(startTime, endTime)); |
105 |
| - } else { |
106 |
| - // 单个类型,例如:2020.8 |
107 |
| - if (time.indexOf('.') > 0) { |
108 |
| - String[] split = time.split("\\."); |
109 |
| - LocalDateTime startTime = |
110 |
| - Year.parse(split[0]).atMonth(Integer.parseInt(split[1])).atDay(1) |
111 |
| - .atStartOfDay(); |
112 |
| - criteria = criteria.and( |
113 |
| - Criteria.where("update_time").between(startTime, startTime.plusMonths(1))); |
114 |
| - } else { |
115 |
| - LocalDateTime startTime = Year.parse(time).atMonth(1).atDay(1).atStartOfDay(); |
116 |
| - criteria = criteria.and( |
117 |
| - Criteria.where("update_time").between(startTime, startTime.plusYears(1))); |
118 |
| - } |
119 |
| - } |
| 82 | + String[] split = time.split("-"); |
| 83 | + String first = split[0]; |
| 84 | + String second = split[1]; |
| 85 | + LocalDateTime startTime = Instant.ofEpochMilli(Long.parseLong(first)) |
| 86 | + .atZone(ZoneId.systemDefault()) |
| 87 | + .toLocalDateTime(); |
| 88 | + LocalDateTime endTime = Instant.ofEpochMilli(Long.parseLong(second)) |
| 89 | + .atZone(ZoneId.systemDefault()) |
| 90 | + .toLocalDateTime(); |
| 91 | + criteria = criteria.and(Criteria.where("update_time").between(startTime, endTime)); |
120 | 92 | }
|
121 | 93 |
|
122 | 94 | Query query = Query.query(criteria);
|
|
0 commit comments