!26 1.更新2.6.12版本

Merge pull request !26 from Dawn/dev
This commit is contained in:
Dawn
2025-05-25 17:44:12 +00:00
committed by Gitee
7 changed files with 34 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
FROM openjdk:21
EXPOSE 9190
ADD hula-im-service-v2.6.11.jar app.jar
ADD hula-im-service-v2.6.12.jar app.jar
RUN sh -c 'touch /app.jar'
ENTRYPOINT ["java","-jar","-Djava.security.egd=file:/dev/./urandom","/app.jar"]

View File

@@ -38,6 +38,12 @@ public class Black implements Serializable {
@TableField("target")
private String target;
/**
* 截止时间
*/
@TableField("deadline")
private LocalDateTime deadline;
/**
* 创建时间
*/
@@ -49,6 +55,4 @@ public class Black implements Serializable {
*/
@TableField("update_time")
private LocalDateTime updateTime;
}

View File

@@ -3,7 +3,6 @@ package com.hula.core.user.domain.vo.req.user;
import com.hula.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotNull;
/**
@@ -12,7 +11,11 @@ import jakarta.validation.constraints.NotNull;
@Data
public class BlackReq extends BaseEntity {
@NotNull
@NotNull(message = "请选择拉黑用户")
@Schema(description = "拉黑用户的uid")
private Long uid;
@NotNull(message = "请输入截止时间")
@Schema(description = "截止时间, 分钟")
private Long deadline;
}

View File

@@ -2,6 +2,7 @@ package com.hula.core.user.service.cache;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hula.common.constant.RedisKey;
import com.hula.common.domain.vo.req.CursorPageBaseReq;
import com.hula.common.domain.vo.res.CursorPageBaseResp;
@@ -18,8 +19,10 @@ import com.hula.core.user.domain.entity.UserRole;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -42,6 +45,14 @@ public class UserCache {
@Resource
private UserSummaryCache userSummaryCache;
/**
* 每小时一执行
*/
@Scheduled(cron = "0 0 * * * ?")
public void cleanExpiredBlacks() {
evictBlackMap();
}
public Long getOnlineNum() {
String onlineKey = RedisKey.getKey(RedisKey.ONLINE_UID_ZET);
return RedisUtils.zCard(onlineKey);
@@ -159,7 +170,8 @@ public class UserCache {
@Cacheable(cacheNames = "user", key = "'blackList'")
public Map<Integer, Set<String>> getBlackMap() {
Map<Integer, List<Black>> collect = blackDao.list().stream().collect(Collectors.groupingBy(Black::getType));
LocalDateTime now = LocalDateTime.now();
Map<Integer, List<Black>> collect = blackDao.getBaseMapper().selectList(new QueryWrapper<Black>().gt("deadline", now)).stream().collect(Collectors.groupingBy(Black::getType));
Map<Integer, Set<String>> result = new HashMap<>(collect.size());
for (Map.Entry<Integer, List<Black>> entry : collect.entrySet()) {
result.put(entry.getKey(), entry.getValue().stream().map(Black::getTarget).collect(Collectors.toSet()));

View File

@@ -37,6 +37,7 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -48,6 +49,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class UserServiceImpl implements UserService {
public static final LocalDateTime MAX_DATE = LocalDateTime.of(2099, 12, 31, 00, 00, 00);
private UserCache userCache;
private UserBackpackDao userBackpackDao;
private UserDao userDao;
@@ -143,6 +145,11 @@ public class UserServiceImpl implements UserService {
Black user = new Black();
user.setTarget(uid.toString());
user.setType(BlackTypeEnum.UID.getType());
if(ObjectUtil.isNull(req.getDeadline()) || req.getDeadline().equals(0L)){
user.setDeadline(MAX_DATE);
} else {
user.setDeadline(LocalDateTime.now().plusMinutes(req.getDeadline()));
}
blackDao.save(user);
User byId = userDao.getById(uid);
blackIp(byId.getIpInfo().getCreateIp());

View File

@@ -1,4 +1,4 @@
version: 2.6.11
version: 2.6.12
HuLa-IM:
HOST: 127.0.0.1 #域名
MYSQL_PORT: 3306 #端口

View File

@@ -15,7 +15,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>v2.6.11</revision>
<revision>v2.6.12</revision>
<java.version>21</java.version>
<spring-boot.version>3.4.4</spring-boot.version>
<hutool.version>5.8.27</hutool.version>