bug的修改
This commit is contained in:
parent
db1b8d8f90
commit
5c4faae97b
|
|
@ -9,6 +9,9 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||||
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
|
import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
|
||||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
import redis.clients.jedis.JedisPoolConfig;
|
import redis.clients.jedis.JedisPoolConfig;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
@ -125,6 +128,51 @@ public class RedisConfig {
|
||||||
return jedisPoolConfig;
|
return jedisPoolConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置 RedisTemplate
|
||||||
|
* 使用 String 序列化器作为 key 的序列化器
|
||||||
|
* 使用 JSON 序列化器作为 value 的序列化器
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(@Qualifier("redisConnectionFactory") RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||||
|
template.setConnectionFactory(redisConnectionFactory);
|
||||||
|
|
||||||
|
// 使用 StringRedisSerializer 来序列化和反序列化 redis 的 key 值
|
||||||
|
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||||
|
template.setKeySerializer(stringRedisSerializer);
|
||||||
|
template.setHashKeySerializer(stringRedisSerializer);
|
||||||
|
|
||||||
|
// 使用 GenericJackson2JsonRedisSerializer 来序列化和反序列化 redis 的 value 值
|
||||||
|
GenericJackson2JsonRedisSerializer jsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||||
|
template.setValueSerializer(jsonRedisSerializer);
|
||||||
|
template.setHashValueSerializer(jsonRedisSerializer);
|
||||||
|
|
||||||
|
template.afterPropertiesSet();
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置第二个 RedisTemplate(使用第二个数据库)
|
||||||
|
*/
|
||||||
|
@Bean(name = "secondRedisTemplate")
|
||||||
|
public RedisTemplate<String, Object> secondRedisTemplate(@Qualifier("secondRedisConnectionFactory") RedisConnectionFactory secondRedisConnectionFactory) {
|
||||||
|
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||||
|
template.setConnectionFactory(secondRedisConnectionFactory);
|
||||||
|
|
||||||
|
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||||
|
template.setKeySerializer(stringRedisSerializer);
|
||||||
|
template.setHashKeySerializer(stringRedisSerializer);
|
||||||
|
|
||||||
|
GenericJackson2JsonRedisSerializer jsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||||
|
template.setValueSerializer(jsonRedisSerializer);
|
||||||
|
template.setHashValueSerializer(jsonRedisSerializer);
|
||||||
|
|
||||||
|
template.afterPropertiesSet();
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,5 +33,9 @@ public class CategoryConstants {
|
||||||
public static final Integer CATEGORY_TYPE_CONFIG = 6;
|
public static final Integer CATEGORY_TYPE_CONFIG = 6;
|
||||||
/** 分类类型-秒杀配置 */
|
/** 分类类型-秒杀配置 */
|
||||||
public static final Integer CATEGORY_TYPE_SECKILL = 7;
|
public static final Integer CATEGORY_TYPE_SECKILL = 7;
|
||||||
|
/** 分类类型-直播间分类 */
|
||||||
|
public static final Integer CATEGORY_TYPE_LIVE_ROOM = 8;
|
||||||
|
/** 分类类型-作品分类 */
|
||||||
|
public static final Integer CATEGORY_TYPE_WORK = 9;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
@ -36,6 +37,10 @@ public class LiveRoom implements Serializable {
|
||||||
@TableField("streamer_name")
|
@TableField("streamer_name")
|
||||||
private String streamerName;
|
private String streamerName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分类ID")
|
||||||
|
@TableField("category_id")
|
||||||
|
private Integer categoryId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "流密钥(推流 streamKey)")
|
@ApiModelProperty(value = "流密钥(推流 streamKey)")
|
||||||
@TableField("stream_key")
|
@TableField("stream_key")
|
||||||
private String streamKey;
|
private String streamKey;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.zbkj.common.model.ratelimit;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流配置实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("eb_rate_limit_config")
|
||||||
|
@ApiModel(value = "RateLimitConfig对象", description = "限流配置")
|
||||||
|
public class RateLimitConfig implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "配置ID")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "限流类型")
|
||||||
|
private String limitType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "限流名称")
|
||||||
|
private String limitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "限流速率(每时间窗口允许的请求数)")
|
||||||
|
private Integer rate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "令牌桶容量")
|
||||||
|
private Integer capacity;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "时间窗口(秒)")
|
||||||
|
private Integer timeWindow;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态: 0-禁用, 1-启用")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否删除: 0-未删除, 1-已删除")
|
||||||
|
private Integer isDeleted;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.zbkj.common.model.ratelimit;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流记录实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("eb_rate_limit_record")
|
||||||
|
@ApiModel(value = "RateLimitRecord对象", description = "限流记录")
|
||||||
|
public class RateLimitRecord implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "记录ID")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户ID")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "限流类型")
|
||||||
|
private String limitType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "请求路径")
|
||||||
|
private String requestPath;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "请求方法")
|
||||||
|
private String requestMethod;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "IP地址")
|
||||||
|
private String ipAddress;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户代理")
|
||||||
|
private String userAgent;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "请求次数")
|
||||||
|
private Integer requestCount;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "限流阈值")
|
||||||
|
private Integer limitThreshold;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "处理动作: block-拒绝, allow-允许")
|
||||||
|
private String action;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
}
|
||||||
|
|
@ -38,6 +38,11 @@
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.8.9</version>
|
<version>2.8.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- WebSocket 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.zbkj.service.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zbkj.common.model.ratelimit.RateLimitConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流配置 Mapper 接口
|
||||||
|
*/
|
||||||
|
public interface RateLimitConfigDao extends BaseMapper<RateLimitConfig> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.zbkj.service.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zbkj.common.model.ratelimit.RateLimitRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流记录 Mapper 接口
|
||||||
|
*/
|
||||||
|
public interface RateLimitRecordDao extends BaseMapper<RateLimitRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user