mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-18 05:08:02 +00:00
update modules/kbase: add 2 mod 330 files
This commit is contained in:
@@ -50,5 +50,5 @@ public class ActionResponse extends BaseResponse {
|
||||
|
||||
private UserProtobuf user;
|
||||
|
||||
// public LocalDateTime createdAt;
|
||||
// public ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-01-29 16:21:24
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-06-17 18:05:00
|
||||
* @LastEditTime: 2025-07-03 12:02:16
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesa
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -29,9 +29,8 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import com.bytedesk.core.enums.LevelEnum;
|
||||
import com.bytedesk.core.enums.PlatformEnum;
|
||||
import com.bytedesk.core.utils.BdDateUtils;
|
||||
|
||||
// import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -41,9 +40,8 @@ import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
// import java.time.ZonedDateTime;
|
||||
// import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Date -> ZonedDateTime ?
|
||||
@@ -95,12 +93,14 @@ public abstract class BaseEntity implements Serializable {
|
||||
// @Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "created_at", updatable = false)
|
||||
@CreatedDate
|
||||
private LocalDateTime createdAt;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
// @Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "updated_at")
|
||||
@LastModifiedDate
|
||||
private LocalDateTime updatedAt;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
// soft delete
|
||||
@Builder.Default
|
||||
@@ -123,11 +123,11 @@ public abstract class BaseEntity implements Serializable {
|
||||
private String platform = PlatformEnum.BYTEDESK.name();
|
||||
|
||||
public String getCreatedAtString() {
|
||||
return BdDateUtils.formatDatetimeToString(createdAt);
|
||||
return createdAt != null ? createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null;
|
||||
}
|
||||
|
||||
public String getUpdatedAtString() {
|
||||
return BdDateUtils.formatDatetimeToString(updatedAt);
|
||||
return updatedAt != null ? updatedAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-01-29 16:21:24
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-05-29 16:58:21
|
||||
* @LastEditTime: 2025-07-03 12:02:57
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesa
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import com.bytedesk.core.enums.LevelEnum;
|
||||
import com.bytedesk.core.enums.PlatformEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -38,9 +39,9 @@ import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
// import java.time.ZonedDateTime;
|
||||
// import java.time.LocalDateTime;
|
||||
// import java.time.ZonedDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* Date -> ZonedDateTime ?
|
||||
@@ -83,12 +84,14 @@ public abstract class BaseEntityNoOrg implements Serializable {
|
||||
// @Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "created_at", updatable = false)
|
||||
@CreatedDate
|
||||
private LocalDateTime createdAt;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
// @Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "updated_at")
|
||||
@LastModifiedDate
|
||||
private LocalDateTime updatedAt;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
@Builder.Default
|
||||
@Column(name = "is_deleted")
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package com.bytedesk.core.base;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.bytedesk.core.utils.BdDateUtils;
|
||||
@@ -40,9 +40,9 @@ public abstract class BaseResponse implements Serializable {
|
||||
|
||||
private String platform;
|
||||
|
||||
protected LocalDateTime createdAt;
|
||||
protected ZonedDateTime createdAt;
|
||||
|
||||
protected LocalDateTime updatedAt;
|
||||
protected ZonedDateTime updatedAt;
|
||||
|
||||
public String getCreatedAt() {
|
||||
return BdDateUtils.formatDatetimeToString(createdAt);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package com.bytedesk.core.base;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.bytedesk.core.utils.BdDateUtils;
|
||||
@@ -32,9 +32,9 @@ public abstract class BaseResponseNoOrg implements Serializable {
|
||||
|
||||
private String platform;
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
public String getCreatedAt() {
|
||||
return BdDateUtils.formatDatetimeToString(createdAt);
|
||||
|
||||
@@ -50,7 +50,7 @@ package com.bytedesk.core.black;
|
||||
// // BlackEntity black = blackOpt.get();
|
||||
// // // 检查黑名单是否在有效期内
|
||||
// // if (black.getEndTime() == null ||
|
||||
// // black.getEndTime().isAfter(LocalDateTime.now())) {
|
||||
// // black.getEndTime().isAfter(ZonedDateTime.now())) {
|
||||
// // response.sendError(
|
||||
// // HttpServletResponse.SC_FORBIDDEN,
|
||||
// // "Access denied for visitor: " + uid + " in org: " + orgUid);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -79,12 +79,12 @@ public class BlackEntity extends BaseEntity {
|
||||
// 开始时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime = LocalDateTime.now();
|
||||
private ZonedDateTime startTime = ZonedDateTime.now();
|
||||
|
||||
// 结束时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime = LocalDateTime.now().plusHours(24);
|
||||
private ZonedDateTime endTime = ZonedDateTime.now().plusHours(24);
|
||||
|
||||
// 被拉黑是的 会话uid
|
||||
private String threadUid;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -31,7 +31,7 @@ public class BlackEventListener {
|
||||
@EventListener
|
||||
public void onQuartzDay0Event(QuartzDay0Event event) {
|
||||
// 每天0点,检查到期的黑名单,并清理
|
||||
blackRestService.findByEndTimeBefore(LocalDateTime.now()).forEach(black -> {
|
||||
blackRestService.findByEndTimeBefore(ZonedDateTime.now()).forEach(black -> {
|
||||
blackRestService.deleteByUid(black.getUid());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -61,15 +61,15 @@ public class BlackExcel extends BaseExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "开始时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime startTime;
|
||||
private ZonedDateTime startTime;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "结束时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime endTime;
|
||||
private ZonedDateTime endTime;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "拉黑时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -26,7 +26,7 @@ public interface BlackRepository extends JpaRepository<BlackEntity, String>, Jpa
|
||||
|
||||
Optional<BlackEntity> findFirstByBlackUidAndDeletedFalse(String blackUid);
|
||||
|
||||
List<BlackEntity> findByEndTimeBeforeAndDeletedFalse(LocalDateTime endTime);
|
||||
List<BlackEntity> findByEndTimeBeforeAndDeletedFalse(ZonedDateTime endTime);
|
||||
|
||||
Optional<BlackEntity> findByBlackUidAndOrgUidAndDeletedFalse(String blackUid, String orgUid);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseRequest;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -64,12 +64,12 @@ public class BlackRequest extends BaseRequest {
|
||||
// 开始时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime = LocalDateTime.now();
|
||||
private ZonedDateTime startTime = ZonedDateTime.now();
|
||||
|
||||
// 结束时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime = LocalDateTime.now().plusHours(24);
|
||||
private ZonedDateTime endTime = ZonedDateTime.now().plusHours(24);
|
||||
|
||||
// 被拉黑是的 会话uid
|
||||
private String threadUid;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseResponse;
|
||||
|
||||
@@ -56,10 +56,10 @@ public class BlackResponse extends BaseResponse {
|
||||
private String userAvatar;
|
||||
|
||||
// 开始时间
|
||||
private LocalDateTime startTime;
|
||||
private ZonedDateTime startTime;
|
||||
|
||||
// 结束时间
|
||||
private LocalDateTime endTime;
|
||||
private ZonedDateTime endTime;
|
||||
|
||||
// 被拉黑是的 会话uid
|
||||
private String threadUid;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class BlackRestService extends BaseRestServiceWithExcel<BlackEntity, Blac
|
||||
return repository.findByUid(uid);
|
||||
}
|
||||
|
||||
public List<BlackEntity> findByEndTimeBefore(LocalDateTime endTime) {
|
||||
public List<BlackEntity> findByEndTimeBefore(ZonedDateTime endTime) {
|
||||
return repository.findByEndTimeBeforeAndDeletedFalse(endTime);
|
||||
}
|
||||
// 根据黑名单用户uid查询
|
||||
|
||||
@@ -31,5 +31,5 @@ public class ClipboardResponse extends BaseResponse {
|
||||
|
||||
private MessageTypeEnum type;
|
||||
|
||||
// private LocalDateTime updatedAt;
|
||||
// private ZonedDateTime updatedAt;
|
||||
}
|
||||
|
||||
@@ -36,5 +36,5 @@ public class FavoriteResponse extends BaseResponse {
|
||||
|
||||
// private String color;
|
||||
|
||||
// private LocalDateTime createdAt;
|
||||
// private ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -124,8 +124,8 @@ public class GrayReleaseController {
|
||||
@PathVariable String feature,
|
||||
@RequestParam(required = false) Integer hours) {
|
||||
|
||||
LocalDateTime end = LocalDateTime.now();
|
||||
LocalDateTime start = end.minusHours(hours != null ? hours : 24);
|
||||
ZonedDateTime end = ZonedDateTime.now();
|
||||
ZonedDateTime start = end.minusHours(hours != null ? hours : 24);
|
||||
|
||||
GrayReleaseFeature grayFeature = GrayReleaseFeature.getByCode(feature);
|
||||
if (grayFeature == null) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
@@ -55,10 +55,10 @@ public class GrayReleaseEntity extends BaseEntity {
|
||||
|
||||
// 灰度时间
|
||||
@Column(name = "gray_release_start_time")
|
||||
private LocalDateTime startTime; // 灰度开始时间
|
||||
private ZonedDateTime startTime; // 灰度开始时间
|
||||
|
||||
@Column(name = "gray_release_end_time")
|
||||
private LocalDateTime endTime; // 灰度结束时间
|
||||
private ZonedDateTime endTime; // 灰度结束时间
|
||||
|
||||
// 灰度状态
|
||||
@Builder.Default
|
||||
@@ -89,7 +89,7 @@ public class GrayReleaseEntity extends BaseEntity {
|
||||
}
|
||||
|
||||
// 4. 检查灰度时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
if (startTime != null && now.isBefore(startTime)) {
|
||||
return false; // 灰度未开始
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GrayReleaseMetrics extends BaseEntity {
|
||||
private Boolean success; // 是否成功
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime timestamp; // 记录时间
|
||||
private ZonedDateTime timestamp; // 记录时间
|
||||
|
||||
@Column(length = 512)
|
||||
private String errorMessage; // 错误信息(如果有)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -40,7 +40,7 @@ public class GrayReleaseMetricsService {
|
||||
.userUid(userUid)
|
||||
.feature(feature.getCode())
|
||||
.success(success)
|
||||
.timestamp(LocalDateTime.now())
|
||||
.timestamp(ZonedDateTime.now())
|
||||
.build();
|
||||
|
||||
grayReleaseRepository.save(metrics);
|
||||
@@ -55,7 +55,7 @@ public class GrayReleaseMetricsService {
|
||||
* 获取功能的使用统计
|
||||
*/
|
||||
public GrayReleaseFeatureStatistics getFeatureStatistics(GrayReleaseFeature feature,
|
||||
LocalDateTime start, LocalDateTime end) {
|
||||
ZonedDateTime start, ZonedDateTime end) {
|
||||
|
||||
List<GrayReleaseMetrics> metrics = grayReleaseRepository
|
||||
.findByFeatureAndTimestampBetween(feature.getCode(), start, end);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@@ -12,7 +12,7 @@ public interface GrayReleaseRepository extends JpaRepository<GrayReleaseMetrics,
|
||||
|
||||
// 根据功能和时间范围查询指标
|
||||
List<GrayReleaseMetrics> findByFeatureAndTimestampBetween(
|
||||
String feature, LocalDateTime start, LocalDateTime end);
|
||||
String feature, ZonedDateTime start, ZonedDateTime end);
|
||||
|
||||
// 根据用户和功能查询最近的使用记录
|
||||
GrayReleaseMetrics findFirstByUserUidAndFeatureOrderByTimestampDesc(
|
||||
@@ -21,15 +21,15 @@ public interface GrayReleaseRepository extends JpaRepository<GrayReleaseMetrics,
|
||||
// 统计功能的使用次数
|
||||
@Query("SELECT COUNT(m) FROM GrayReleaseMetrics m WHERE m.feature = ?1 AND m.timestamp BETWEEN ?2 AND ?3")
|
||||
long countByFeatureAndTimestampBetween(
|
||||
String feature, LocalDateTime start, LocalDateTime end);
|
||||
String feature, ZonedDateTime start, ZonedDateTime end);
|
||||
|
||||
// 统计功能的成功次数
|
||||
@Query("SELECT COUNT(m) FROM GrayReleaseMetrics m WHERE m.feature = ?1 AND m.success = true AND m.timestamp BETWEEN ?2 AND ?3")
|
||||
long countSuccessByFeatureAndTimestampBetween(
|
||||
String feature, LocalDateTime start, LocalDateTime end);
|
||||
String feature, ZonedDateTime start, ZonedDateTime end);
|
||||
|
||||
// 统计功能的独立用户数
|
||||
@Query("SELECT COUNT(DISTINCT m.userUid) FROM GrayReleaseMetrics m WHERE m.feature = ?1 AND m.timestamp BETWEEN ?2 AND ?3")
|
||||
long countUniqueUsersByFeatureAndTimestampBetween(
|
||||
String feature, LocalDateTime start, LocalDateTime end);
|
||||
String feature, ZonedDateTime start, ZonedDateTime end);
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -68,8 +68,8 @@ public class GrayReleaseService {
|
||||
public void monitorFeature(GrayReleaseFeature feature) {
|
||||
GrayReleaseFeatureStatistics stats = metricsService.getFeatureStatistics(
|
||||
feature,
|
||||
LocalDateTime.now().minusHours(24),
|
||||
LocalDateTime.now()
|
||||
ZonedDateTime.now().minusHours(24),
|
||||
ZonedDateTime.now()
|
||||
);
|
||||
|
||||
if (stats.getFailureRate() > 0.1) {
|
||||
@@ -102,7 +102,7 @@ public class GrayReleaseService {
|
||||
.enabled(true)
|
||||
.percentage(0)
|
||||
.status(GrayReleaseStatus.STATUS_PENDING)
|
||||
.startTime(LocalDateTime.now())
|
||||
.startTime(ZonedDateTime.now())
|
||||
.build();
|
||||
|
||||
// 更新缓存
|
||||
@@ -139,7 +139,7 @@ public class GrayReleaseService {
|
||||
status.setPercentage(targetPercentage);
|
||||
if (targetPercentage >= 100) {
|
||||
status.setStatus(GrayReleaseStatus.STATUS_COMPLETED);
|
||||
status.setEndTime(LocalDateTime.now());
|
||||
status.setEndTime(ZonedDateTime.now());
|
||||
}
|
||||
|
||||
// 更新缓存
|
||||
@@ -202,7 +202,7 @@ public class GrayReleaseService {
|
||||
|
||||
status.setStatus(GrayReleaseStatus.STATUS_COMPLETED);
|
||||
status.setPercentage(100);
|
||||
status.setEndTime(LocalDateTime.now());
|
||||
status.setEndTime(ZonedDateTime.now());
|
||||
featureStatusCache.put(feature, status);
|
||||
|
||||
log.info("Completed rollout for feature: {}", feature);
|
||||
@@ -233,8 +233,8 @@ public class GrayReleaseService {
|
||||
}
|
||||
|
||||
// 缓存未命中,从数据库加载
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime dayStart = now.minusDays(1);
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
ZonedDateTime dayStart = now.minusDays(1);
|
||||
|
||||
// 获取最近24小时的统计数据
|
||||
GrayReleaseFeatureStatistics stats = metricsService.getFeatureStatistics(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
@@ -45,10 +45,10 @@ public class GrayReleaseStatus {
|
||||
private double failureRate; // 失败率
|
||||
|
||||
@Column(name = "gray_start_time")
|
||||
private LocalDateTime startTime; // 开始时间
|
||||
private ZonedDateTime startTime; // 开始时间
|
||||
|
||||
@Column(name = "gray_end_time")
|
||||
private LocalDateTime endTime; // 结束时间
|
||||
private ZonedDateTime endTime; // 结束时间
|
||||
|
||||
// 状态常量
|
||||
public static final String STATUS_PENDING = "pending"; // 待发布
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.gray_release;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -43,8 +43,8 @@ public class GrayReleaseStrategy {
|
||||
// @Scheduled(cron = "0 0 * * * *")
|
||||
// public void autoAdjustRollout() {
|
||||
// List<GrayReleaseFeature> features = Arrays.asList(GrayReleaseFeature.values());
|
||||
// // LocalDateTime end = LocalDateTime.now();
|
||||
// // LocalDateTime start = end.minusHours(1);
|
||||
// // ZonedDateTime end = ZonedDateTime.now();
|
||||
// // ZonedDateTime start = end.minusHours(1);
|
||||
|
||||
// for (GrayReleaseFeature feature : features) {
|
||||
// try {
|
||||
@@ -59,7 +59,7 @@ public class GrayReleaseStrategy {
|
||||
* 调整单个功能的灰度比例
|
||||
*/
|
||||
public void adjustFeatureRollout(GrayReleaseFeature feature,
|
||||
LocalDateTime start, LocalDateTime end) {
|
||||
ZonedDateTime start, ZonedDateTime end) {
|
||||
|
||||
GrayReleaseFeatureStatistics stats = metricsService.getFeatureStatistics(feature, start, end);
|
||||
|
||||
@@ -89,8 +89,8 @@ public class GrayReleaseStrategy {
|
||||
* 检查是否可以启动灰度发布
|
||||
*/
|
||||
public Boolean canStartRollout(GrayReleaseFeature feature) {
|
||||
LocalDateTime end = LocalDateTime.now();
|
||||
LocalDateTime start = end.minusDays(1);
|
||||
ZonedDateTime end = ZonedDateTime.now();
|
||||
ZonedDateTime start = end.minusDays(1);
|
||||
|
||||
GrayReleaseFeatureStatistics stats = metricsService.getFeatureStatistics(feature, start, end);
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class GroupEntity extends BaseEntity {
|
||||
// MemberEntity member = MemberEntity.builder()
|
||||
// .user(user)
|
||||
// .group(this)
|
||||
// .joinTime(LocalDateTime.now())
|
||||
// .joinTime(ZonedDateTime.now())
|
||||
// .build();
|
||||
// members.add(member);
|
||||
// }
|
||||
|
||||
@@ -40,5 +40,5 @@ public class GroupInviteResponse extends BaseResponse {
|
||||
|
||||
private Integer order;
|
||||
|
||||
// private LocalDateTime createdAt;
|
||||
// private ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -40,5 +40,5 @@ public class GroupNoticeResponse extends BaseResponse {
|
||||
|
||||
private Integer order;
|
||||
|
||||
// private LocalDateTime createdAt;
|
||||
// private ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
import com.bytedesk.core.constant.TypeConsts;
|
||||
@@ -43,7 +43,7 @@ public class IpAccessEntity extends BaseEntity {
|
||||
@Column(columnDefinition = TypeConsts.COLUMN_TYPE_TEXT)
|
||||
private String params; // 访问的参数
|
||||
|
||||
private LocalDateTime accessTime;
|
||||
private ZonedDateTime accessTime;
|
||||
private Integer accessCount; // 访问次数
|
||||
private LocalDateTime lastAccessTime;
|
||||
private ZonedDateTime lastAccessTime;
|
||||
}
|
||||
@@ -14,10 +14,10 @@
|
||||
package com.bytedesk.core.ip.access;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface IpAccessRepository extends JpaRepository<IpAccessEntity, Long> {
|
||||
|
||||
Optional<IpAccessEntity> findFirstByIpAndEndpointAndAccessTimeAfter(String ip, String endpoint, LocalDateTime time);
|
||||
Optional<IpAccessEntity> findFirstByIpAndEndpointAndAccessTimeAfter(String ip, String endpoint, ZonedDateTime time);
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.ip.access;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseResponse;
|
||||
|
||||
@@ -35,8 +35,8 @@ public class IpAccessResponse extends BaseResponse {
|
||||
private String endpoint; // 访问的接口
|
||||
private String params; // 访问的参数
|
||||
|
||||
private LocalDateTime accessTime;
|
||||
private ZonedDateTime accessTime;
|
||||
private Integer accessCount; // 访问次数
|
||||
private LocalDateTime lastAccessTime;
|
||||
private ZonedDateTime lastAccessTime;
|
||||
//
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.bytedesk.core.base.BaseRestService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@@ -59,7 +59,7 @@ public class IpAccessRestService extends BaseRestService<IpAccessEntity, IpAcces
|
||||
|
||||
// 检查是否在黑名单中且未过期
|
||||
Optional<IpBlacklistEntity> blacklist = ipBlacklistService.findByIp(ip);
|
||||
if (blacklist.isPresent() && blacklist.get().getEndTime().isAfter(LocalDateTime.now())) {
|
||||
if (blacklist.isPresent() && blacklist.get().getEndTime().isAfter(ZonedDateTime.now())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ public class IpAccessRestService extends BaseRestService<IpAccessEntity, IpAcces
|
||||
int retryCount = 0;
|
||||
while (retryCount < MAX_RETRY_COUNT) {
|
||||
try {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime oneMinuteAgo = now.minusMinutes(1);
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
ZonedDateTime oneMinuteAgo = now.minusMinutes(1);
|
||||
|
||||
// 获取最近一分钟的访问记录
|
||||
Optional<IpAccessEntity> accessOptional = ipAccessRepository
|
||||
@@ -141,7 +141,7 @@ public class IpAccessRestService extends BaseRestService<IpAccessEntity, IpAcces
|
||||
IpAccessEntity fresh = refreshedEntity.get();
|
||||
// 更新访问计数和最后访问时间
|
||||
fresh.setAccessCount(fresh.getAccessCount() + 1);
|
||||
fresh.setLastAccessTime(LocalDateTime.now());
|
||||
fresh.setLastAccessTime(ZonedDateTime.now());
|
||||
ipAccessRepository.save(fresh);
|
||||
|
||||
// 如果访问次数超过限制,加入黑名单
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.ip.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -41,12 +41,12 @@ public class IpBlacklistEntity extends BaseEntity {
|
||||
// 开始时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime = LocalDateTime.now();
|
||||
private ZonedDateTime startTime = ZonedDateTime.now();
|
||||
|
||||
// 结束时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime = LocalDateTime.now().plusHours(24);
|
||||
private ZonedDateTime endTime = ZonedDateTime.now().plusHours(24);
|
||||
|
||||
//
|
||||
private String reason;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.ip.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -26,5 +26,5 @@ public interface IpBlacklistRepository extends JpaRepository<IpBlacklistEntity,
|
||||
|
||||
Optional<IpBlacklistEntity> findByUidAndDeletedFalse(String uid);
|
||||
|
||||
List<IpBlacklistEntity> findByEndTimeBeforeAndDeletedFalse(LocalDateTime endTime);
|
||||
List<IpBlacklistEntity> findByEndTimeBeforeAndDeletedFalse(ZonedDateTime endTime);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.ip.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseRequest;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -38,12 +38,12 @@ public class IpBlacklistRequest extends BaseRequest {
|
||||
// 开始时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime = LocalDateTime.now();
|
||||
private ZonedDateTime startTime = ZonedDateTime.now();
|
||||
|
||||
// 结束时间
|
||||
@Builder.Default
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime = LocalDateTime.now().plusHours(24);
|
||||
private ZonedDateTime endTime = ZonedDateTime.now().plusHours(24);
|
||||
//
|
||||
private String reason;
|
||||
//
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.ip.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseResponse;
|
||||
|
||||
@@ -32,8 +32,8 @@ public class IpBlacklistResponse extends BaseResponse {
|
||||
//
|
||||
private String ip;
|
||||
private String ipLocation;
|
||||
private LocalDateTime startTime;
|
||||
private LocalDateTime endTime;
|
||||
private ZonedDateTime startTime;
|
||||
private ZonedDateTime endTime;
|
||||
private String reason;
|
||||
//
|
||||
private String blackUid;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.ip.black;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class IpBlacklistRestService extends BaseRestServiceWithExcel<IpBlacklist
|
||||
return ipBlacklistRepository.findByIpAndDeletedFalse(ip);
|
||||
}
|
||||
|
||||
public List<IpBlacklistEntity> findByEndTimeBefore(LocalDateTime dateTime) {
|
||||
public List<IpBlacklistEntity> findByEndTimeBefore(ZonedDateTime dateTime) {
|
||||
return ipBlacklistRepository.findByEndTimeBeforeAndDeletedFalse(dateTime);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class IpBlacklistRestService extends BaseRestServiceWithExcel<IpBlacklist
|
||||
public void addToBlacklistSystem(String ip) {
|
||||
//
|
||||
String ipLocation = ipService.getIpLocation(ip);
|
||||
LocalDateTime endTime = LocalDateTime.now().plusHours(BLOCK_HOURS);
|
||||
ZonedDateTime endTime = ZonedDateTime.now().plusHours(BLOCK_HOURS);
|
||||
//
|
||||
IpBlacklistRequest request = IpBlacklistRequest.builder()
|
||||
.ip(ip)
|
||||
|
||||
@@ -81,7 +81,7 @@ public class JmsArtemisConfig {
|
||||
// NOTE: 我们不在这里定义类型映射,而是在消费者端使用自定义解析逻辑
|
||||
// 这样可以避免模块间的直接依赖
|
||||
|
||||
// ObjectMapper objectMapper, for transforming localDateTime to json
|
||||
// ObjectMapper objectMapper, for transforming ZonedDateTime to json
|
||||
// converter.setObjectMapper(objectMapper);
|
||||
return converter;
|
||||
}
|
||||
|
||||
@@ -36,5 +36,5 @@ public class MenuResponse extends BaseResponse {
|
||||
|
||||
private String color;
|
||||
|
||||
// private LocalDateTime createdAt;
|
||||
// private ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.message;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -41,7 +41,7 @@ public class MessageExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(20)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-02-21 10:00:55
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-05-17 15:01:00
|
||||
* @LastEditTime: 2025-07-03 12:04:29
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -14,8 +14,9 @@
|
||||
package com.bytedesk.core.message;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
// import java.time.ZonedDateTime;
|
||||
// import java.util.Date;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.bytedesk.core.enums.ClientEnum;
|
||||
@@ -52,7 +53,7 @@ public class MessageProtobuf implements Serializable {
|
||||
|
||||
private MessageStatusEnum status;
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
private ClientEnum client;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-03-13 10:04:42
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-05-19 10:54:10
|
||||
* @LastEditTime: 2025-07-03 12:04:54
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -13,7 +13,8 @@
|
||||
*/
|
||||
package com.bytedesk.core.message;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -35,7 +36,7 @@ public class MessageService {
|
||||
}
|
||||
|
||||
// 防止客户端时间错误,使用服务器时间戳
|
||||
messageProtobuf.setCreatedAt(LocalDateTime.now());
|
||||
messageProtobuf.setCreatedAt(ZonedDateTime.now());
|
||||
|
||||
// 保存消息
|
||||
// Cache message for persistence
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-08-31 16:23:54
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-05-12 15:22:19
|
||||
* @LastEditTime: 2025-07-03 12:04:11
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -13,7 +13,8 @@
|
||||
*/
|
||||
package com.bytedesk.core.message;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.config.BytedeskEventPublisher;
|
||||
import com.bytedesk.core.enums.ClientEnum;
|
||||
@@ -40,7 +41,7 @@ public class MessageUtils {
|
||||
.type(MessageTypeEnum.NOTICE)
|
||||
.content(content)
|
||||
.status(MessageStatusEnum.SUCCESS)
|
||||
.createdAt(LocalDateTime.now())
|
||||
.createdAt(ZonedDateTime.now())
|
||||
.client(ClientEnum.SYSTEM)
|
||||
.thread(threadProtobuf)
|
||||
.user(system)
|
||||
@@ -60,7 +61,7 @@ public class MessageUtils {
|
||||
.type(type)
|
||||
.content(content)
|
||||
.status(MessageStatusEnum.SUCCESS)
|
||||
.createdAt(LocalDateTime.now())
|
||||
.createdAt(ZonedDateTime.now())
|
||||
.client(ClientEnum.SYSTEM)
|
||||
.thread(threadProtobuf)
|
||||
.user(sender)
|
||||
@@ -129,8 +130,8 @@ public class MessageUtils {
|
||||
.client(ClientEnum.SYSTEM.name())
|
||||
.user(user)
|
||||
.orgUid(thread.getOrgUid())
|
||||
.createdAt(LocalDateTime.now())
|
||||
.updatedAt(LocalDateTime.now())
|
||||
.createdAt(ZonedDateTime.now())
|
||||
.updatedAt(ZonedDateTime.now())
|
||||
.thread(thread)
|
||||
.extra(extra)
|
||||
.build();
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PushResponse extends BaseResponse {
|
||||
|
||||
// private PlatformEnum platform;
|
||||
|
||||
// private LocalDateTime createdAt;
|
||||
// private ZonedDateTime createdAt;
|
||||
|
||||
// private LocalDateTime updatedAt;
|
||||
// private ZonedDateTime updatedAt;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-04-25 15:41:33
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-04-11 11:17:17
|
||||
* @LastEditTime: 2025-07-03 12:05:12
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -312,10 +312,10 @@ public class PushRestService extends BaseRestService<PushEntity, PushRequest, Pu
|
||||
pendingPushes.forEach(push -> {
|
||||
// 计算两个日期之间的毫秒差
|
||||
// long diffInMilliseconds = Math.abs(new Date().getTime() - push.getUpdatedAt().getTime());
|
||||
// 将LocalDateTime转换为时间戳
|
||||
// 将ZonedDateTime转换为时间戳
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
ZoneId systemZone = ZoneId.systemDefault(); // 获取系统默认时区
|
||||
long updatedAtMillis = push.getUpdatedAt().atZone(systemZone).toInstant().toEpochMilli();
|
||||
// ZoneId systemZone = ZoneId.systemDefault(); // 获取系统默认时区
|
||||
long updatedAtMillis = push.getUpdatedAt().toInstant().toEpochMilli();
|
||||
long diffInMilliseconds = Math.abs(currentTimeMillis - updatedAtMillis);
|
||||
|
||||
// 转换为分钟
|
||||
|
||||
@@ -67,6 +67,6 @@ public class QuartzResponse extends BaseResponse {
|
||||
// private String orgUid;
|
||||
|
||||
//
|
||||
// private LocalDateTime updatedAt;
|
||||
// private ZonedDateTime updatedAt;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.rbac.auth;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.lang.NonNull;
|
||||
@@ -142,9 +142,9 @@ public class AuthService {
|
||||
.build();
|
||||
// 只有当client中含有web字样时,expiresAt有效期24小时,否则为365天
|
||||
if (client.toLowerCase().contains("web")) {
|
||||
tokenRequest.setExpiresAt(LocalDateTime.now().plusDays(30)); // 默认30天过期
|
||||
tokenRequest.setExpiresAt(ZonedDateTime.now().plusDays(30)); // 默认30天过期
|
||||
} else {
|
||||
tokenRequest.setExpiresAt(LocalDateTime.now().plusDays(365)); // 其他客户端默认365天过期
|
||||
tokenRequest.setExpiresAt(ZonedDateTime.now().plusDays(365)); // 其他客户端默认365天过期
|
||||
}
|
||||
|
||||
tokenRestService.create(tokenRequest);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.rbac.organization_apply;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -42,11 +42,11 @@ public class OrganizationApplyExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(20)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "修改时间")
|
||||
@ColumnWidth(20)
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,5 @@ public class OrganizationApplyResponse extends BaseResponse {
|
||||
|
||||
private Integer order;
|
||||
|
||||
// private LocalDateTime createdAt;
|
||||
// private ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.rbac.token;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntityNoOrg;
|
||||
import com.bytedesk.core.enums.ClientEnum;
|
||||
@@ -61,7 +61,7 @@ public class TokenEntity extends BaseEntityNoOrg {
|
||||
@Column(name = "token_type")
|
||||
private String type = TokenTypeEnum.LOGIN.name();
|
||||
|
||||
private LocalDateTime expiresAt;
|
||||
private ZonedDateTime expiresAt;
|
||||
|
||||
@Builder.Default
|
||||
@Column(name = "is_revoked")
|
||||
@@ -75,7 +75,7 @@ public class TokenEntity extends BaseEntityNoOrg {
|
||||
|
||||
// 验证token是否有效
|
||||
public Boolean isValid() {
|
||||
return !revoked && expiresAt.isAfter(LocalDateTime.now());
|
||||
return !revoked && expiresAt.isAfter(ZonedDateTime.now());
|
||||
}
|
||||
|
||||
// 撤销token
|
||||
@@ -84,7 +84,7 @@ public class TokenEntity extends BaseEntityNoOrg {
|
||||
}
|
||||
|
||||
// 刷新token过期时间
|
||||
public void refresh(LocalDateTime newExpiresAt) {
|
||||
public void refresh(ZonedDateTime newExpiresAt) {
|
||||
this.expiresAt = newExpiresAt;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.rbac.token;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -38,5 +38,5 @@ public interface TokenRepository extends JpaRepository<TokenEntity, Long>, JpaSp
|
||||
* @param now 当前时间
|
||||
* @return 有效令牌列表
|
||||
*/
|
||||
List<TokenEntity> findByUserUidAndTypeAndRevokedFalseAndExpiresAtAfter(String userUid, String type, LocalDateTime now);
|
||||
List<TokenEntity> findByUserUidAndTypeAndRevokedFalseAndExpiresAtAfter(String userUid, String type, ZonedDateTime now);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.rbac.token;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseRequest;
|
||||
import com.bytedesk.core.enums.ClientEnum;
|
||||
@@ -43,7 +43,7 @@ public class TokenRequest extends BaseRequest {
|
||||
@Builder.Default
|
||||
private String type = TokenTypeEnum.LOGIN.name();
|
||||
|
||||
private LocalDateTime expiresAt;
|
||||
private ZonedDateTime expiresAt;
|
||||
|
||||
@Builder.Default
|
||||
private Boolean revoked = false;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.rbac.token;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseResponse;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class TokenResponse extends BaseResponse {
|
||||
|
||||
private String type;
|
||||
|
||||
private LocalDateTime expiresAt;
|
||||
private ZonedDateTime expiresAt;
|
||||
|
||||
private Boolean revoked;
|
||||
|
||||
|
||||
@@ -145,6 +145,6 @@ public class TokenRestService extends BaseRestService<TokenEntity, TokenRequest,
|
||||
// public List<TokenEntity> findValidTokensByUserUidAndType(String userUid,
|
||||
// String type) {
|
||||
// return tokenRepository.findByUserUidAndTypeAndRevokedFalseAndExpiresAtAfter(
|
||||
// userUid, type, LocalDateTime.now());
|
||||
// userUid, type, ZonedDateTime.now());
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-01-23 07:53:01
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-05-22 16:23:17
|
||||
* @LastEditTime: 2025-07-03 12:05:34
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -23,7 +23,8 @@ import com.bytedesk.core.rbac.role.RoleEntity;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
// import java.time.ZonedDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -54,8 +55,8 @@ public class UserDetailsImpl implements UserDetails {
|
||||
private String device;
|
||||
//
|
||||
private String orgUid;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime createdAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
//
|
||||
private OrganizationEntity currentOrganization;
|
||||
private Set<UserOrganizationRoleEntity> userOrganizationRoles;
|
||||
@@ -83,8 +84,8 @@ public class UserDetailsImpl implements UserDetails {
|
||||
String client,
|
||||
String device,
|
||||
String orgUid,
|
||||
LocalDateTime createdAt,
|
||||
LocalDateTime updatedAt,
|
||||
ZonedDateTime createdAt,
|
||||
ZonedDateTime updatedAt,
|
||||
//
|
||||
Collection<? extends GrantedAuthority> authorities,
|
||||
OrganizationEntity currentOrganization,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.core.rbac.user;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -152,8 +152,8 @@ public class UserEntity extends BaseEntityNoOrg {
|
||||
});
|
||||
|
||||
// 2. 设置角色有效期
|
||||
uor.setStartDate(LocalDateTime.now());
|
||||
uor.setEndDate(LocalDateTime.now().plusYears(100));
|
||||
uor.setStartDate(ZonedDateTime.now());
|
||||
uor.setEndDate(ZonedDateTime.now().plusYears(100));
|
||||
|
||||
// 3. 检查是否已存在该角色ID
|
||||
Long roleId = role.getId();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package com.bytedesk.core.rbac.user;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -72,8 +72,8 @@ public class UserOrganizationRoleEntity implements Serializable {
|
||||
private Set<RoleEntity> roles = new HashSet<>();
|
||||
|
||||
// 用户角色有效期
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private ZonedDateTime startDate;
|
||||
private ZonedDateTime endDate;
|
||||
|
||||
// 可能还有其他字段,如权限等
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.tag;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -42,11 +42,11 @@ public class TagExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "修改时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.thread;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -60,6 +60,6 @@ public class ThreadExcel extends BaseExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(28)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.thread;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -46,12 +46,12 @@ public class ThreadSpecification extends BaseSpecification {
|
||||
// 仅当mergeByTopic为true时才应用topic合并逻辑
|
||||
if (Boolean.TRUE.equals(request.getMergeByTopic())) {
|
||||
// 创建子查询获取每个topic的最新记录的updatedAt时间
|
||||
Subquery<LocalDateTime> maxDateSubquery = query.subquery(LocalDateTime.class);
|
||||
Subquery<ZonedDateTime> maxDateSubquery = query.subquery(ZonedDateTime.class);
|
||||
var subRoot = maxDateSubquery.from(ThreadEntity.class);
|
||||
|
||||
// 明确指定类型为 LocalDateTime
|
||||
Path<LocalDateTime> updatedAtPath = subRoot.get("updatedAt");
|
||||
Expression<LocalDateTime> maxExpression = criteriaBuilder.greatest(updatedAtPath);
|
||||
// 明确指定类型为 ZonedDateTime
|
||||
Path<ZonedDateTime> updatedAtPath = subRoot.get("updatedAt");
|
||||
Expression<ZonedDateTime> maxExpression = criteriaBuilder.greatest(updatedAtPath);
|
||||
|
||||
maxDateSubquery.select(maxExpression)
|
||||
.where(criteriaBuilder.equal(subRoot.get("topic"), root.get("topic")));
|
||||
@@ -59,11 +59,11 @@ public class ThreadSpecification extends BaseSpecification {
|
||||
// 如果ownerUid不为空,优先选择owner不为空的记录
|
||||
if (StringUtils.hasText(request.getOwnerUid())) {
|
||||
// 创建子查询来获取同一topic中匹配ownerUid的最新记录
|
||||
Subquery<LocalDateTime> ownerMaxDateSubquery = query.subquery(LocalDateTime.class);
|
||||
Subquery<ZonedDateTime> ownerMaxDateSubquery = query.subquery(ZonedDateTime.class);
|
||||
var ownerSubRoot = ownerMaxDateSubquery.from(ThreadEntity.class);
|
||||
|
||||
Path<LocalDateTime> ownerUpdatedAtPath = ownerSubRoot.get("updatedAt");
|
||||
Expression<LocalDateTime> ownerMaxExpression = criteriaBuilder.greatest(ownerUpdatedAtPath);
|
||||
Path<ZonedDateTime> ownerUpdatedAtPath = ownerSubRoot.get("updatedAt");
|
||||
Expression<ZonedDateTime> ownerMaxExpression = criteriaBuilder.greatest(ownerUpdatedAtPath);
|
||||
|
||||
ownerMaxDateSubquery.select(ownerMaxExpression)
|
||||
.where(criteriaBuilder.and(
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// import java.text.ParseException;
|
||||
// import java.util.Calendar;
|
||||
// import java.time.LocalDateTime;
|
||||
// import java.time.ZonedDateTime;
|
||||
|
||||
// import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
|
||||
@@ -33,5 +33,5 @@ public class UrlResponse extends BaseResponse {
|
||||
|
||||
private String userUid;
|
||||
|
||||
// private LocalDateTime createdAt;
|
||||
// private ZonedDateTime createdAt;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@ package com.bytedesk.core.utils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -43,26 +42,24 @@ public class BdDateUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 LocalDateTime 转换为格式化的日期时间字符串
|
||||
* @param localDateTime LocalDateTime对象
|
||||
* 将 ZonedDateTime 转换为格式化的日期时间字符串
|
||||
* @param ZonedDateTime ZonedDateTime对象
|
||||
* @return 格式化的日期时间字符串 (yyyy-MM-dd HH:mm:ss)
|
||||
*/
|
||||
public static String formatDatetimeToString(LocalDateTime localDateTime) {
|
||||
if (localDateTime == null) {
|
||||
public static String formatDatetimeToString(ZonedDateTime ZonedDateTime) {
|
||||
if (ZonedDateTime == null) {
|
||||
return null;
|
||||
}
|
||||
// 使用 DateTimeFormatter 直接格式化 LocalDateTime
|
||||
// return localDateTime.format(DateTimeFormatter.ofPattern(datetimeFormat));
|
||||
// 使用 DateTimeFormatter 直接格式化 ZonedDateTime
|
||||
// return ZonedDateTime.format(DateTimeFormatter.ofPattern(datetimeFormat));
|
||||
|
||||
// 使用应用配置的时区
|
||||
// ZonedDateTime zonedDateTime = localDateTime.atZone(LocaleContextHolder.getTimeZone().toZoneId());
|
||||
// 使用应用配置的时区
|
||||
ZonedDateTime zonedDateTime = java.time.ZonedDateTime.ofInstant(ZonedDateTime.toInstant(), LocaleContextHolder.getTimeZone().toZoneId());
|
||||
// 或者固定使用中国时区
|
||||
ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Shanghai"));
|
||||
// ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(ZonedDateTime.toInstant(), ZoneId.of("Asia/Shanghai"));
|
||||
return DateTimeFormatter.ofPattern(datetimeFormat).format(zonedDateTime);
|
||||
|
||||
// 或者如果一定要使用 SimpleDateFormat,可以这样转换:
|
||||
// try {
|
||||
// Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
// Date date = Date.from(ZonedDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat(datetimeFormat);
|
||||
// return formatter.format(date);
|
||||
// } catch (Exception e) {
|
||||
@@ -200,20 +197,16 @@ public class BdDateUtils {
|
||||
return DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public static LocalDateTime parseLocalDateTime(String dateTime) {
|
||||
return LocalDateTime.parse(dateTime, BdDateUtils.getDateTimeFormatter());
|
||||
public static ZonedDateTime parseZonedDateTime(String dateTime) {
|
||||
return ZonedDateTime.parse(dateTime, BdDateUtils.getDateTimeFormatter());
|
||||
}
|
||||
|
||||
public static LocalDateTime parseLocalDateTime(String dateTime, DateTimeFormatter formatter) {
|
||||
return LocalDateTime.parse(dateTime, formatter);
|
||||
public static ZonedDateTime parseZonedDateTime(String dateTime, DateTimeFormatter formatter) {
|
||||
return ZonedDateTime.parse(dateTime, formatter);
|
||||
}
|
||||
|
||||
public static String getCurrentLocalDateTime() {
|
||||
return LocalDateTime.now().atZone(LocaleContextHolder.getTimeZone().toZoneId()).toString();
|
||||
}
|
||||
|
||||
public static ZonedDateTime getCurrentZonedDateTime() {
|
||||
return LocalDateTime.now().atZone(LocaleContextHolder.getTimeZone().toZoneId());
|
||||
|
||||
public static String getCurrentZonedDateTime() {
|
||||
return ZonedDateTime.now(LocaleContextHolder.getTimeZone().toZoneId()).toString();
|
||||
}
|
||||
|
||||
public static ZoneId getCurrentZoneId() {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.core.workflow_result;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -34,11 +34,11 @@ public class WorkflowResultExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "修改时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user