Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-execute-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2720cf0c
authored
Jan 04, 2024
by
chizw
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]增加批量生成短链接口
1 parent
3c2a6874
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
400 additions
and
20 deletions
platform-execute/pom.xml
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/DBConstants.java
platform-execute/src/main/java/cn/com/glsx/execute/config/RedissonBloomFilterConfig.java
platform-execute/src/main/java/cn/com/glsx/execute/config/RedissonConfig.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/shorturl/ShortUrlService.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/CacheUtil.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/HashUtil.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/RedisUtil.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/BaseTest.java
platform-execute/target/generated-sources/annotations/cn/com/glsx/execute/modules/converter/UserConverterImpl.java
platform-execute/pom.xml
View file @
2720cf0
...
...
@@ -20,6 +20,10 @@
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
transmittable-thread-local
</artifactId>
<version>
${ttl.version}
</version>
...
...
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/DBConstants.java
View file @
2720cf0
...
...
@@ -25,5 +25,7 @@ public final class DBConstants {
public
static
final
String
COMPRESS_CODE
=
"compressCode"
;
public
static
final
String
CODE_STATUS
=
"codeStatus"
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/config/RedissonBloomFilterConfig.java
View file @
2720cf0
...
...
@@ -8,6 +8,7 @@ import org.redisson.api.RedissonClient;
import
org.redisson.config.Config
;
import
org.redisson.config.SingleServerConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -42,4 +43,12 @@ public class RedissonBloomFilterConfig {
bloomFilter
.
tryInit
(
100000000L
,
0.01
);
return
bloomFilter
;
}
// @PostConstruct
public
void
initializeBloomFilter
(
@Autowired
@Qualifier
(
"executeBloomFilter"
)
RBloomFilter
<
String
>
rBloomFilter
)
{
rBloomFilter
.
add
(
"qqq"
);
log
.
info
(
"qqq========{}"
,
rBloomFilter
.
contains
(
"qqq"
));
log
.
info
(
"xxx========{}"
,
rBloomFilter
.
contains
(
"xxx"
));
log
.
info
(
"BloomFilter init success"
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/config/RedissonConfig.java
0 → 100644
View file @
2720cf0
package
cn
.
com
.
glsx
.
execute
.
config
;
import
lombok.Data
;
import
org.redisson.Redisson
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* @Description
* @author chizw
* @create 2024/1/2 17:58
* @version ver.1.0.0
*/
@Data
@Configuration
public
class
RedissonConfig
{
@Value
(
"${spring.redis.host}"
)
private
String
host
;
@Value
(
"${spring.redis.port}"
)
private
String
port
;
@Value
(
"${spring.redis.password}"
)
private
String
password
;
@Bean
public
RedissonClient
getRedisSon
()
{
Config
config
=
new
Config
();
String
address
=
new
StringBuilder
(
"redis://"
).
append
(
host
).
append
(
":"
).
append
(
port
).
toString
();
config
.
useSingleServer
().
setAddress
(
address
);
if
(
null
!=
password
&&
!
""
.
equals
(
password
.
trim
()))
{
config
.
useSingleServer
().
setPassword
(
password
);
}
return
Redisson
.
create
(
config
);
}
}
\ No newline at end of file
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/shorturl/ShortUrlService.java
View file @
2720cf0
...
...
@@ -25,6 +25,7 @@ import cn.com.glsx.execute.modules.request.shorturl.GenerateShortUrlRequest;
import
cn.com.glsx.execute.modules.service.proxy.WechatUserInfoService
;
import
cn.com.glsx.execute.utils.HashUtil
;
import
cn.com.glsx.execute.utils.JacksonUtils
;
import
cn.com.glsx.execute.utils.RedisUtil
;
import
cn.com.glsx.execute.utils.UrlUtil
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -94,6 +95,7 @@ public class ShortUrlService {
@GlsxDistributeLockable
(
name
=
"'asyncGenerate' + #request.url"
,
timeoutException
=
RpcServiceException
.
class
,
time
=
10
*
1000
)
public
String
asyncGenerate
(
GenerateShortUrlRequest
request
)
{
log
.
info
(
"async短链服务生成短链请求 request:{}"
,
request
);
String
b4RedirectPage
=
request
.
getB4RedirectPage
();
// 分布式锁
// 校验长链
...
...
@@ -123,9 +125,10 @@ public class ShortUrlService {
private
String
getCompressCode
()
{
// 查询缓存
String
code
=
RedisUtil
.
lGet
(
"111"
);
// 缓存为空时,更新压缩码池
// 返回压缩码
return
null
;
return
code
;
}
/**
...
...
@@ -148,7 +151,7 @@ public class ShortUrlService {
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
{
Exception
.
class
})
public
String
generate
(
GenerateUrlRequest
request
)
{
log
.
info
(
"短链服务生成短链请求 request:{}"
,
request
);
log
.
info
(
"
sync
短链服务生成短链请求 request:{}"
,
request
);
String
b4RedirectPage
=
request
.
getB4RedirectPage
();
Boolean
isThroughAuth
=
request
.
getIsThroughAuth
();
// 校验长链
...
...
@@ -253,7 +256,8 @@ public class ShortUrlService {
public
void
sendDelaySopEvent
(
String
message
)
throws
Exception
{
Assert
.
hasLength
(
message
,
"delay sop event send message is empty"
);
List
<
Map
<
String
,
Object
>>
list
=
JacksonUtils
.
X
.
parse
(
message
,
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{});
List
<
Map
<
String
,
Object
>>
list
=
JacksonUtils
.
X
.
parse
(
message
,
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{
});
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
for
(
Map
<
String
,
Object
>
map
:
list
)
{
String
unionId
=
(
String
)
map
.
get
(
"unionId"
);
...
...
@@ -329,6 +333,19 @@ public class ShortUrlService {
int
i
=
shortUrlCompressCodeMapper
.
insertSelective
(
dto
);
return
i
>
0
;
}
public
boolean
insertCompressCodeList
(
List
<
ShortUrlCompressCodeDTO
>
dtoList
)
{
int
i
=
shortUrlCompressCodeMapper
.
insertList
(
dtoList
);
return
i
>
0
;
}
public
List
<
ShortUrlCompressCodeDTO
>
selectAllCompressCode
(
Integer
status
)
{
Example
example
=
new
Example
(
ShortUrlCompressCodeDTO
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
().
andEqualTo
(
DBConstants
.
DEL_FLAG
,
Constants
.
NORMAL_FLAG
);
if
(
status
!=
null
)
criteria
.
andEqualTo
(
DBConstants
.
ShortUrl
.
CODE_STATUS
,
status
);
List
<
ShortUrlCompressCodeDTO
>
codeDTOList
=
shortUrlCompressCodeMapper
.
selectByExample
(
example
);
log
.
info
(
"select short_url_compress_code table result:{}"
,
codeDTOList
);
return
codeDTOList
;
}
public
ShortUrlCompressCodeDTO
selectCompressCodeByCode
(
String
code
)
{
Example
example
=
new
Example
(
ShortUrlCompressCodeDTO
.
class
);
...
...
platform-execute/src/main/java/cn/com/glsx/execute/utils/CacheUtil.java
View file @
2720cf0
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
cn.com.glsx.execute.common.constant.shorturl.CompressCodeStatus
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlCompressCodeDTO
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
com.esotericsoftware.minlog.Log
;
import
lombok.RequiredArgsConstructor
;
import
org.oreframework.distribute.lock.annotation.GlsxDistributeLockable
;
import
org.redisson.Redisson
;
import
org.redisson.api.RBloomFilter
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
* @Description 缓存工具
* @author chizw
* @create 2023/9/18 16:08
* @version ver.1.0.0
* @Description 缓存工具
* @create 2023/9/18 16:08
*/
@RequiredArgsConstructor
@Component
public
class
CacheUtil
{
@Resource
private
ShortUrlService
shortUrlService
;
private
final
StringRedisTemplate
stringRedisTemplate
;
public
void
test
(){
private
static
final
String
FILL_CODE_LIST_LOCK
=
"fillCodeListLock"
;
@Value
(
"${sop_execute_code_pool_threshold:100}"
)
public
int
codePoolThreshold
;
public
void
test
()
{
Config
config
=
new
Config
();
config
.
useSingleServer
().
setAddress
(
"redis://192.168.x.x:6379"
);
config
.
useSingleServer
().
setPassword
(
"xxx"
);
...
...
@@ -28,11 +54,62 @@ public class CacheUtil {
RBloomFilter
<
Object
>
bloomFilter
=
client
.
getBloomFilter
(
"nameBloom"
);
//初始化布隆过滤器:预计元素为100000000L,误差半为3%
//第二个 0.01 期代表误判率最大允许为 1%,在我们以前的项目中通常也是设置为 1%,如果把这个数值设置太小,虽然会降低误判率,但会产生更多次的
bloomFilter
.
tryInit
(
100000000L
,
0.01
);
bloomFilter
.
tryInit
(
100000000L
,
0.01
);
//将数据插入布隆过滤器
bloomFilter
.
add
(
"qqq"
);
bloomFilter
.
contains
(
"qqq"
);
bloomFilter
.
contains
(
"xxx"
);
}
@Async
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
{
Exception
.
class
})
@GlsxDistributeLockable
(
name
=
FILL_CODE_LIST_LOCK
,
timeoutException
=
RpcServiceException
.
class
,
time
=
10
*
1000
)
public
void
fillCodePool
(
String
key
)
{
try
{
// 查看队列长度
Long
size
=
RedisUtil
.
lGetListSize
(
key
);
// 为空时selectAll
if
(
size
==
null
||
size
==
0
)
{
size
=
0L
;
List
<
ShortUrlCompressCodeDTO
>
codeDTOList
=
shortUrlService
.
selectAllCompressCode
(
CompressCodeStatus
.
AVAILABLE
);
if
(!
CollectionUtils
.
isEmpty
(
codeDTOList
))
{
List
<
String
>
list
=
codeDTOList
.
stream
().
map
(
ShortUrlCompressCodeDTO:
:
getCompressCode
).
collect
(
Collectors
.
toList
());
RedisUtil
.
del
(
key
);
RedisUtil
.
lSet
(
key
,
list
);
size
=
(
long
)
list
.
size
();
}
}
if
(
codePoolThreshold
>
size
)
{
// 少于阈值时补充压缩码
// 批量生成压缩码
Set
<
String
>
set
=
new
HashSet
<>();
String
uuid
=
UUIDUtils
.
getUUID
();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
set
.
add
(
HashUtil
.
X
.
encode2Base62
(
uuid
+
i
));
}
// 查询所有压缩码
List
<
String
>
existList
=
new
ArrayList
<>();
List
<
ShortUrlCompressCodeDTO
>
codeDTOList
=
shortUrlService
.
selectAllCompressCode
(
null
);
if
(!
CollectionUtils
.
isEmpty
(
codeDTOList
))
{
existList
=
codeDTOList
.
stream
().
map
(
ShortUrlCompressCodeDTO:
:
getCompressCode
).
collect
(
Collectors
.
toList
());
}
// 过滤出已有压缩码(此处可使用布隆过滤器)
List
<
String
>
finalExistList
=
existList
;
List
<
String
>
insertList
=
set
.
stream
().
filter
(
s
->
!
finalExistList
.
contains
(
s
)).
collect
(
Collectors
.
toList
());
List
<
ShortUrlCompressCodeDTO
>
dtoList
=
insertList
.
stream
().
map
(
s
->
{
ShortUrlCompressCodeDTO
dto
=
new
ShortUrlCompressCodeDTO
();
dto
.
setCompressCode
(
s
);
dto
.
setCodeStatus
(
CompressCodeStatus
.
AVAILABLE
);
return
dto
;
}
).
collect
(
Collectors
.
toList
());
// 批量插入压缩码表
boolean
b
=
shortUrlService
.
insertCompressCodeList
(
dtoList
);
// 填充压缩码池
if
(
b
)
RedisUtil
.
lSet
(
key
,
insertList
);
}
}
catch
(
Exception
e
)
{
Log
.
error
(
"fillCodePool error"
,
e
);
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/HashUtil.java
View file @
2720cf0
...
...
@@ -6,15 +6,14 @@ import org.springframework.util.Assert;
import
java.util.Stack
;
/**
* @Description 哈希工具
* @author chizw
* @create 2023/9/18 16:08
* @version ver.1.0.0
* @Description 哈希工具
* @create 2023/9/18 16:08
*/
public
enum
HashUtil
{
X
;
X
;
/**
* 62个字符
...
...
@@ -24,31 +23,33 @@ public enum HashUtil {
private
static
final
char
[]
CHAR_SET
=
CHARS
.
toCharArray
();
public
String
encode2Base62
(
String
param
)
{
Assert
.
hasLength
(
param
,
"encode2Base62 method param must not be empty"
);
Assert
.
hasLength
(
param
,
"encode2Base62 method param must not be empty"
);
return
this
.
_10_to_62
(
this
.
murmurHash32
(
param
));
}
/**
* murmurhash算法
*
* @param param
*/
private
long
murmurHash32
(
String
param
){
private
long
murmurHash32
(
String
param
)
{
return
Hashing
.
murmur3_32
().
hashUnencodedChars
(
param
).
padToLong
();
}
/**
* 10进制转62进制
*
* @param num
* @return
*/
private
String
encodeToBase62
(
long
num
){
private
String
encodeToBase62
(
long
num
)
{
// StringBuffer线程安全,StringBuilder线程不安全
StringBuffer
sb
=
new
StringBuffer
();
do
{
int
i
=
(
int
)(
num
%
62
);
do
{
int
i
=
(
int
)
(
num
%
62
);
sb
.
append
(
CHARS
.
charAt
(
i
));
num
=
num
/
62
;
}
while
(
num
>
0
);
num
=
num
/
62
;
}
while
(
num
>
0
);
String
value
=
sb
.
reverse
().
toString
();
return
value
;
...
...
platform-execute/src/main/java/cn/com/glsx/execute/utils/RedisUtil.java
0 → 100644
View file @
2720cf0
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
com.glsx.plat.context.utils.SpringUtils
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.Redisson
;
import
org.redisson.api.RBloomFilter
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.data.redis.connection.RedisConnection
;
import
org.springframework.data.redis.connection.RedisStringCommands
;
import
org.springframework.data.redis.core.*
;
import
org.springframework.data.redis.core.types.Expiration
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
/**
* @author chizw
* @version ver.1.0.0
* @Description redis工具
* @create 2023/9/18 16:08
*/
@Slf4j
@RequiredArgsConstructor
@Component
public
class
RedisUtil
{
@Resource
private
RedissonClient
redissonClient
;
private
static
final
StringRedisTemplate
stringRedisTemplate
;
static
{
stringRedisTemplate
=
SpringUtils
.
getBean
(
"stringRedisTemplate"
);
}
public
static
boolean
set
(
String
key
,
String
value
)
{
try
{
stringRedisTemplate
.
opsForValue
().
set
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"redis set {} error: "
,
key
,
e
);
return
false
;
}
}
public
static
boolean
set
(
String
key
,
String
value
,
long
time
)
{
try
{
stringRedisTemplate
.
opsForValue
().
set
(
key
,
value
,
time
,
TimeUnit
.
SECONDS
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"redis set {} error: "
,
key
,
e
);
return
false
;
}
}
public
static
String
get
(
String
key
)
{
try
{
return
key
==
null
?
null
:
stringRedisTemplate
.
opsForValue
().
get
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
"redis get {} error: "
,
key
,
e
);
return
null
;
}
}
public
static
boolean
del
(
String
...
key
)
{
try
{
if
(
key
!=
null
&&
key
.
length
>
0
)
{
if
(
key
.
length
==
1
)
{
stringRedisTemplate
.
delete
(
key
[
0
]);
}
else
{
stringRedisTemplate
.
delete
(
Arrays
.
asList
(
key
));
}
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"redis del {} error: "
,
key
,
e
);
return
false
;
}
}
public
static
Long
incr
(
String
key
,
long
delta
)
{
try
{
return
stringRedisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
}
catch
(
Exception
e
)
{
log
.
error
(
"redis incr {} error: "
,
key
,
e
);
return
null
;
}
}
public
static
boolean
lSet
(
String
key
,
String
value
)
{
try
{
stringRedisTemplate
.
opsForList
().
rightPush
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"redis lSet {} error: "
,
key
,
e
);
return
false
;
}
}
public
static
boolean
lSet
(
String
key
,
String
value
,
long
time
)
{
try
{
stringRedisTemplate
.
opsForList
().
rightPush
(
key
,
value
);
if
(
time
>
0
)
stringRedisTemplate
.
expire
(
key
,
time
,
TimeUnit
.
SECONDS
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"redis lSet {} error: "
,
key
,
e
);
return
false
;
}
}
public
static
boolean
lSet
(
String
key
,
List
<
String
>
value
)
{
try
{
stringRedisTemplate
.
opsForList
().
rightPushAll
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"redis lSet {} error: "
,
key
,
e
);
return
false
;
}
}
public
static
String
lGet
(
String
key
)
{
try
{
return
stringRedisTemplate
.
opsForList
().
leftPop
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
"redis lGet {} error: "
,
key
,
e
);
return
null
;
}
}
public
static
Long
lGetListSize
(
String
key
)
{
try
{
return
stringRedisTemplate
.
opsForList
().
size
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
"redis listSize {} error: "
,
key
,
e
);
return
null
;
}
}
//批量添加
public
static
boolean
multiSet
(
Map
<
String
,
String
>
map
)
{
try
{
stringRedisTemplate
.
opsForValue
().
multiSet
(
map
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"redis multiSet {} error: "
,
map
,
e
);
return
false
;
}
}
//批量添加 并且设置失效时间
public
static
void
multiSet
(
Map
<
String
,
String
>
map
,
Long
seconds
)
{
try
{
RedisSerializer
<
String
>
serializer
=
stringRedisTemplate
.
getStringSerializer
();
stringRedisTemplate
.
executePipelined
((
RedisCallback
<
Object
>)
connection
->
{
map
.
forEach
((
key
,
value
)
->
{
if
(
StringUtils
.
hasLength
(
key
)
&&
StringUtils
.
hasLength
(
value
))
{
connection
.
set
(
serializer
.
serialize
(
key
),
serializer
.
serialize
(
value
),
Expiration
.
seconds
(
seconds
),
RedisStringCommands
.
SetOption
.
UPSERT
);
}
});
return
null
;
},
serializer
);
}
catch
(
Exception
e
)
{
log
.
error
(
"redis multiSet {} error: "
,
map
,
e
);
}
}
//批量获取
public
static
List
<
String
>
multiGet
(
List
<
String
>
list
)
{
try
{
return
stringRedisTemplate
.
opsForValue
().
multiGet
(
list
);
}
catch
(
Exception
e
)
{
log
.
error
(
"redis multiGet {} error: "
,
list
,
e
);
return
null
;
}
}
}
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/BaseTest.java
View file @
2720cf0
...
...
@@ -2,8 +2,13 @@ package cn.com.glsx.cn.com.glsx;
import
cn.com.glsx.Application
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.utils.RedisUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.redisson.api.RBloomFilter
;
import
org.redisson.api.RList
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
...
...
@@ -18,6 +23,7 @@ import java.util.Date;
* @Description: 基础测试类
* @Date 2023/9/8 14:00
*/
@Slf4j
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
public
class
BaseTest
{
...
...
@@ -28,6 +34,12 @@ public class BaseTest {
@Resource
private
MsgProducer
msgProducer
;
@Resource
private
RBloomFilter
<
String
>
executeBloomFilter
;
@Resource
private
RedissonClient
redissonClient
;
@Test
public
void
rabbitTest
()
throws
InterruptedException
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
...
...
@@ -36,4 +48,33 @@ public class BaseTest {
msgProducer
.
sendDelayedMessage
(
i
+
"hello world"
+
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
()),
3000
);
}
}
@Test
public
void
executeBloomFilterTest
(){
executeBloomFilter
.
add
(
"qqq"
);
log
.
info
(
"qqq========{}"
,
executeBloomFilter
.
contains
(
"qqq"
));
log
.
info
(
"xxx========{}"
,
executeBloomFilter
.
contains
(
"xxx"
));
log
.
info
(
"BloomFilter init success"
);
}
@Test
public
void
redisTest
(){
RedisUtil
.
set
(
"111"
,
"2222"
);
log
.
info
(
"get=======:{}"
,
RedisUtil
.
get
(
"111"
));
log
.
info
(
"get=======:{}"
,
RedisUtil
.
get
(
"111"
));
log
.
info
(
"del=======:{}"
,
RedisUtil
.
del
(
"111"
));
RedisUtil
.
lSet
(
"111"
,
"aaa"
);
RedisUtil
.
lSet
(
"111"
,
"bbb"
);
log
.
info
(
"lGet1=======:{}"
,
RedisUtil
.
lGet
(
"111"
));
log
.
info
(
"lGet2=======:{}"
,
RedisUtil
.
lGet
(
"111"
));
log
.
info
(
"lGet3=======:{}"
,
RedisUtil
.
lGet
(
"111"
));
log
.
info
(
"lGet4=======:{}"
,
RedisUtil
.
lGet
(
"222"
));
boolean
b
=
RedisUtil
.
set
(
"qqq"
,
"1"
);
log
.
info
(
"incr=======:{}"
,
RedisUtil
.
incr
(
"qqq"
,
1
));
log
.
info
(
"incr=======:{}"
,
RedisUtil
.
incr
(
"qqq"
,
1
));
log
.
info
(
"incr=======:{}"
,
RedisUtil
.
get
(
"qqq"
));
log
.
info
(
"incr=======:{}"
,
RedisUtil
.
incr
(
"qqq"
,
2
));
log
.
info
(
"del=======:{}"
,
RedisUtil
.
del
(
"111"
,
"qqq"
,
"2222"
));
}
}
platform-execute/target/generated-sources/annotations/cn/com/glsx/execute/modules/converter/UserConverterImpl.java
View file @
2720cf0
...
...
@@ -7,8 +7,8 @@ import javax.annotation.Generated;
@Generated
(
value
=
"org.mapstruct.ap.MappingProcessor"
,
date
=
"2024-01-0
2T15:33:58
+0800"
,
comments
=
"version: 1.5.2.Final, compiler: javac, environment: Java 1.8.0_
33
1 (Oracle Corporation)"
date
=
"2024-01-0
3T11:29:10
+0800"
,
comments
=
"version: 1.5.2.Final, compiler: javac, environment: Java 1.8.0_
18
1 (Oracle Corporation)"
)
public
class
UserConverterImpl
implements
UserConverter
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment