Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
zhangshaowu
/
pipi-helper
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 841bb3ef
authored
Oct 15, 2022
by
liushuangwu
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
6ace790c
fdb24f2c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
1 deletions
src/main/java/com/pipihelper/project/feishu/dto/RedisPoolConfig.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/utils/RedisUtil.java
src/main/java/com/pipihelper/project/feishu/dto/RedisPoolConfig.java
0 → 100644
View file @
841bb3e
package
com
.
pipihelper
.
project
.
feishu
.
dto
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
@Configuration
public
class
RedisPoolConfig
{
@Bean
@ConditionalOnMissingBean
(
name
=
"redisTemplate"
)
public
RedisTemplate
redisTemplate
(
RedisConnectionFactory
redisConnectionFactory
)
{
RedisTemplate
redisTemplate
=
new
RedisTemplate
();
redisTemplate
.
setKeySerializer
(
new
StringRedisSerializer
());
//value序列器
redisTemplate
.
setValueSerializer
(
new
GenericJackson2JsonRedisSerializer
());
//Hash类型 key序列器
redisTemplate
.
setHashKeySerializer
(
new
StringRedisSerializer
());
//Hash类型 value序列器
redisTemplate
.
setHashValueSerializer
(
new
GenericJackson2JsonRedisSerializer
());
redisTemplate
.
setConnectionFactory
(
redisConnectionFactory
);
return
redisTemplate
;
}
@Bean
@ConditionalOnMissingBean
(
StringRedisTemplate
.
class
)
public
StringRedisTemplate
stringRedisTemplate
(
RedisConnectionFactory
redisConnectionFactory
)
{
StringRedisTemplate
template
=
new
StringRedisTemplate
();
template
.
setConnectionFactory
(
redisConnectionFactory
);
return
template
;
}
}
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
841bb3e
...
@@ -17,6 +17,7 @@ import com.pipihelper.project.feishu.dto.doc.FieldsDTO;
...
@@ -17,6 +17,7 @@ import com.pipihelper.project.feishu.dto.doc.FieldsDTO;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuBatchMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuBatchMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.utils.RedisUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.MediaType
;
import
okhttp3.MediaType
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
...
@@ -24,6 +25,7 @@ import okhttp3.Request;
...
@@ -24,6 +25,7 @@ import okhttp3.Request;
import
okhttp3.RequestBody
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
okhttp3.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
...
@@ -52,7 +54,8 @@ import java.util.List;
...
@@ -52,7 +54,8 @@ import java.util.List;
public
class
FeiShuApiService
{
public
class
FeiShuApiService
{
@Resource
@Resource
private
FeiShuConfig
feiShuConfig
;
private
FeiShuConfig
feiShuConfig
;
@Autowired
private
RedisUtil
redisUtil
;
private
static
ObjectMapper
objectMapper
=
new
ObjectMapper
();
private
static
ObjectMapper
objectMapper
=
new
ObjectMapper
();
...
...
src/main/java/com/pipihelper/project/utils/RedisUtil.java
0 → 100644
View file @
841bb3e
package
com
.
pipihelper
.
project
.
utils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
@Component
public
class
RedisUtil
{
@Autowired
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
public
Object
get
(
String
key
)
{
return
key
==
null
?
null
:
redisTemplate
.
opsForValue
().
get
(
key
);
}
public
boolean
set
(
String
key
,
Object
value
)
{
try
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
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