Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
0e7a7d0d
提交
0e7a7d0d
authored
9月 28, 2022
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
根据人群包获取用户 & redis配置添加
上级
2f9ad24f
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
277 行增加
和
5 行删除
+277
-5
pom.xml
pom.xml
+6
-0
MyCatchConfig.java
...ain/java/com/yaoyaozw/customer/configs/MyCatchConfig.java
+45
-0
RedisConfig.java
src/main/java/com/yaoyaozw/customer/configs/RedisConfig.java
+52
-0
RedissonConfig.java
...in/java/com/yaoyaozw/customer/configs/RedissonConfig.java
+40
-0
RedissonConfigProperties.java
...m/yaoyaozw/customer/configs/RedissonConfigProperties.java
+20
-0
CustomerCommonConstant.java
...m/yaoyaozw/customer/constants/CustomerCommonConstant.java
+11
-0
RegisterUserEntityMapper.java
...om/yaoyaozw/customer/mapper/RegisterUserEntityMapper.java
+14
-0
CrowdPackageConditionMatchService.java
...w/customer/service/CrowdPackageConditionMatchService.java
+2
-1
RegisterUserEntityService.java
.../yaoyaozw/customer/service/RegisterUserEntityService.java
+12
-0
CrowdPackageConditionMatchServiceImpl.java
...r/service/impl/CrowdPackageConditionMatchServiceImpl.java
+6
-2
CustomerGraphicsServiceImpl.java
...zw/customer/service/impl/CustomerGraphicsServiceImpl.java
+13
-1
RegisterUserEntityServiceImpl.java
.../customer/service/impl/RegisterUserEntityServiceImpl.java
+7
-0
CrowdPackageUserVO.java
...com/yaoyaozw/customer/vo/customer/CrowdPackageUserVO.java
+24
-0
bootstrap.yml
src/main/resources/bootstrap.yml
+1
-1
RegisterUserEntityMapper.xml
src/main/resources/mapper/RegisterUserEntityMapper.xml
+24
-0
没有找到文件。
pom.xml
浏览文件 @
0e7a7d0d
...
...
@@ -196,6 +196,12 @@
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
<dependency>
<groupId>
org.redisson
</groupId>
<artifactId>
redisson
</artifactId>
<version>
3.12.0
</version>
</dependency>
<!-- JWT -->
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
...
...
src/main/java/com/yaoyaozw/customer/configs/MyCatchConfig.java
0 → 100644
浏览文件 @
0e7a7d0d
package
com
.
yaoyaozw
.
customer
.
configs
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.boot.autoconfigure.cache.CacheProperties
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cache.annotation.CachingConfigurationSelector
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheConfiguration
;
import
org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.RedisSerializationContext
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
* @author 10626
*/
@Configuration
@ConditionalOnClass
(
CachingConfigurationSelector
.
class
)
@EnableConfigurationProperties
(
CacheProperties
.
class
)
@ConditionalOnProperty
(
prefix
=
"spring.cache"
,
name
=
"type"
,
havingValue
=
"redis"
)
public
class
MyCatchConfig
{
@Bean
public
RedisCacheConfiguration
redisCacheConfiguration
(
CacheProperties
cacheProperties
)
{
RedisCacheConfiguration
config
=
RedisCacheConfiguration
.
defaultCacheConfig
();
config
=
config
.
serializeKeysWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
new
StringRedisSerializer
()));
config
=
config
.
serializeValuesWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
new
GenericJackson2JsonRedisSerializer
()));
CacheProperties
.
Redis
redis
=
cacheProperties
.
getRedis
();
if
(
redis
.
getTimeToLive
()
!=
null
)
{
config
=
config
.
entryTtl
(
redis
.
getTimeToLive
());
}
if
(
StringUtils
.
isNotEmpty
(
redis
.
getKeyPrefix
()))
{
config
=
config
.
prefixKeysWith
(
redis
.
getKeyPrefix
());
}
if
(!
redis
.
isCacheNullValues
())
{
config
=
config
.
disableCachingNullValues
();
}
if
(!
redis
.
isUseKeyPrefix
())
{
config
=
config
.
disableKeyPrefix
();
}
return
config
;
}
}
src/main/java/com/yaoyaozw/customer/configs/RedisConfig.java
0 → 100644
浏览文件 @
0e7a7d0d
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
yaoyaozw
.
customer
.
configs
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
* Redis配置
*
* @author Mark sunlightcs@gmail.com
*/
@Configuration
public
class
RedisConfig
{
@Autowired
private
RedisConnectionFactory
factory
;
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
()
{
RedisTemplate
<
String
,
Object
>
redisTemplate
=
new
RedisTemplate
<
String
,
Object
>();
redisTemplate
.
setConnectionFactory
(
factory
);
// key的序列化类型
redisTemplate
.
setKeySerializer
(
new
StringRedisSerializer
());
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
objectMapper
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
objectMapper
);
// value的序列化类型
redisTemplate
.
setValueSerializer
(
jackson2JsonRedisSerializer
);
redisTemplate
.
setHashKeySerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setHashValueSerializer
(
jackson2JsonRedisSerializer
);
redisTemplate
.
afterPropertiesSet
();
return
redisTemplate
;
}
}
src/main/java/com/yaoyaozw/customer/configs/RedissonConfig.java
0 → 100644
浏览文件 @
0e7a7d0d
package
com
.
yaoyaozw
.
customer
.
configs
;
import
org.redisson.Redisson
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.data.redis.RedisProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.io.IOException
;
/**
* @author 10626
*/
@Configuration
@EnableConfigurationProperties
({
RedisProperties
.
class
,
RedissonConfigProperties
.
class
})
@ConditionalOnClass
(
RedissonClient
.
class
)
public
class
RedissonConfig
{
/**
* 所有对Redisson的使用都是通过RedissonClient对象
*/
@Bean
(
destroyMethod
=
"shutdown"
)
public
RedissonClient
redissonClient
(
RedisProperties
redisProperties
,
RedissonConfigProperties
redissonConfigProperties
)
throws
IOException
{
//1、创建配置
Config
config
=
new
Config
();
config
.
useSingleServer
().
setAddress
(
"redis://"
+
redisProperties
.
getHost
()+
":"
+
redisProperties
.
getPort
())
.
setPassword
(
redisProperties
.
getPassword
())
.
setTimeout
(
redissonConfigProperties
.
getTimeout
())
.
setRetryAttempts
(
redissonConfigProperties
.
getRetryAttempts
())
.
setRetryInterval
(
redissonConfigProperties
.
getRetryInterval
())
.
setConnectionPoolSize
(
redissonConfigProperties
.
getConnectionPoolSize
())
.
setConnectionMinimumIdleSize
(
redissonConfigProperties
.
getConnectionMinimumIdleSize
())
.
setPingConnectionInterval
(
redissonConfigProperties
.
getPingConnectionInterval
());
//**此项务必设置为redisson解决之前bug的timeout问题关键***** setPingConnectionInterval
//2、根据Config创建出RedissonClient示例
return
Redisson
.
create
(
config
);
}
}
src/main/java/com/yaoyaozw/customer/configs/RedissonConfigProperties.java
0 → 100644
浏览文件 @
0e7a7d0d
package
com
.
yaoyaozw
.
customer
.
configs
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
/**
* @author 10626
*/
@ConfigurationProperties
(
prefix
=
"spring.redisson"
)
@Component
@Data
public
class
RedissonConfigProperties
{
private
Integer
timeout
;
private
Integer
retryAttempts
;
private
Integer
retryInterval
;
private
Integer
pingConnectionInterval
;
private
Integer
connectionPoolSize
;
private
Integer
connectionMinimumIdleSize
;
}
src/main/java/com/yaoyaozw/customer/constants/CustomerCommonConstant.java
0 → 100644
浏览文件 @
0e7a7d0d
package
com
.
yaoyaozw
.
customer
.
constants
;
/**
* @author darker
* @date 2022/9/28 20:09
*/
public
class
CustomerCommonConstant
{
public
final
static
String
CROWD_HUMAN_NUN_REDIS_KEY
=
"crowdHumanNum"
;
}
src/main/java/com/yaoyaozw/customer/mapper/RegisterUserEntityMapper.java
浏览文件 @
0e7a7d0d
...
...
@@ -2,8 +2,21 @@ package com.yaoyaozw.customer.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
RegisterUserEntityMapper
extends
BaseMapper
<
RegisterUserEntity
>
{
/**
* 获取符合动态条件的用户
*
* @param dynamicExpressList 动态表达列表
* @return {@link List}<{@link RegisterUserEntity}>
*/
List
<
CrowdPackageUserVO
>
getUserMatchDynamicExpress
(
@Param
(
"dynamicExpressList"
)
List
<
String
>
dynamicExpressList
);
}
\ No newline at end of file
src/main/java/com/yaoyaozw/customer/service/CrowdPackageConditionMatchService.java
浏览文件 @
0e7a7d0d
...
...
@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.entity.CrowdPackageConditionMatch
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
java.util.List
;
...
...
@@ -18,6 +19,6 @@ public interface CrowdPackageConditionMatchService extends IService<CrowdPackage
* @param packageId 包id
* @return {@link List}<{@link RegisterUserEntity}>
*/
List
<
RegisterUserEntity
>
getUserListFromPackage
(
Long
packageId
);
List
<
CrowdPackageUserVO
>
getUserListFromPackage
(
Long
packageId
);
}
src/main/java/com/yaoyaozw/customer/service/RegisterUserEntityService.java
浏览文件 @
0e7a7d0d
...
...
@@ -3,6 +3,10 @@ package com.yaoyaozw.customer.service;
import
com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO
;
import
com.yaoyaozw.customer.entity.RegisterUserEntity
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
java.util.List
;
public
interface
RegisterUserEntityService
extends
IService
<
RegisterUserEntity
>{
...
...
@@ -10,5 +14,13 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
void
sendCustomerMessage
(
IntegrationRequestDTO
integrationRequestDTO
);
/**
* 获取符合动态条件的用户
*
* @param dynamicExpressList 动态表达列表
* @return {@link List}<{@link RegisterUserEntity}>
*/
List
<
CrowdPackageUserVO
>
getUserMatchDynamicExpress
(
List
<
String
>
dynamicExpressList
);
}
src/main/java/com/yaoyaozw/customer/service/impl/CrowdPackageConditionMatchServiceImpl.java
浏览文件 @
0e7a7d0d
...
...
@@ -10,6 +10,8 @@ import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import
com.yaoyaozw.customer.mapper.MaterialCrowdConditionMatchMapper
;
import
com.yaoyaozw.customer.service.CrowdPackageConditionMatchService
;
import
com.yaoyaozw.customer.service.CustomerServiceCommonService
;
import
com.yaoyaozw.customer.service.RegisterUserEntityService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -32,9 +34,11 @@ public class CrowdPackageConditionMatchServiceImpl extends ServiceImpl<MaterialC
@Autowired
private
CustomerServiceCommonService
commonService
;
@Autowired
private
RegisterUserEntityService
userEntityService
;
@Override
public
List
<
RegisterUserEntity
>
getUserListFromPackage
(
Long
packageId
)
{
public
List
<
CrowdPackageUserVO
>
getUserListFromPackage
(
Long
packageId
)
{
long
startTime
=
System
.
currentTimeMillis
();
// 获取人群包下的条件
...
...
@@ -51,7 +55,7 @@ public class CrowdPackageConditionMatchServiceImpl extends ServiceImpl<MaterialC
LOCAL_LOG
.
info
(
"获取SetupId列表耗时 {}ms, setupId列表长度: {}"
,
getSetupIdTime
-
getConditionTime
,
setupIdList
.
size
());
// 根据动态条件获取用户列表
List
<
RegisterUserEntity
>
userList
=
new
ArrayList
<>(
);
List
<
CrowdPackageUserVO
>
userList
=
userEntityService
.
getUserMatchDynamicExpress
(
nonStaticConditionList
);
long
dynamicUserTime
=
System
.
currentTimeMillis
();
LOCAL_LOG
.
info
(
"获取SetupId列表符合动态条件的用户耗时 {}ms, 符合动态条件的用户: {}个"
,
dynamicUserTime
-
getSetupIdTime
,
userList
.
size
());
...
...
src/main/java/com/yaoyaozw/customer/service/impl/CustomerGraphicsServiceImpl.java
浏览文件 @
0e7a7d0d
...
...
@@ -2,11 +2,16 @@ package com.yaoyaozw.customer.service.impl;
import
com.yaoyaozw.customer.common.BaseResult
;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.constants.CustomerCommonConstant
;
import
com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO
;
import
com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO
;
import
com.yaoyaozw.customer.service.CrowdPackageConditionMatchService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
com.yaoyaozw.customer.vo.customer.CustomerMessageListVO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
...
@@ -25,15 +30,22 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
private
final
static
Logger
LOCAL_LOG
=
LoggerFactory
.
getLogger
(
CustomerGraphicsServiceImpl
.
class
);
@Autowired
private
CrowdPackageConditionMatchService
matchService
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Override
public
BaseResult
insertCustomerMessage
(
CustomerMessageSaveDTO
saveDto
)
{
LOCAL_LOG
.
info
(
"根据人群包找到符合条件的用户数据"
);
List
<
CrowdPackageUserVO
>
userList
=
matchService
.
getUserListFromPackage
(
saveDto
.
getPackageId
());
redisTemplate
.
opsForHash
().
put
(
CustomerCommonConstant
.
CROWD_HUMAN_NUN_REDIS_KEY
,
saveDto
.
getPackageId
().
toString
(),
userList
.
size
());
// TODO: 2022/9/28 根据人群包找到下面的人所在的公众号,进行链接获取
return
n
ull
;
return
n
ew
BaseResult
().
success
()
;
}
@Override
...
...
src/main/java/com/yaoyaozw/customer/service/impl/RegisterUserEntityServiceImpl.java
浏览文件 @
0e7a7d0d
...
...
@@ -8,6 +8,7 @@ import com.yaoyaozw.customer.service.AuthorizerTokenService;
import
com.yaoyaozw.customer.service.CustomerGraphicsDelayService
;
import
com.yaoyaozw.customer.service.CustomerGraphicsService
;
import
com.yaoyaozw.customer.service.wechat.service.WeChatService
;
import
com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO
;
import
com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -50,4 +51,10 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
}
@Override
public
List
<
CrowdPackageUserVO
>
getUserMatchDynamicExpress
(
List
<
String
>
dynamicExpressList
)
{
return
baseMapper
.
getUserMatchDynamicExpress
(
dynamicExpressList
);
}
}
src/main/java/com/yaoyaozw/customer/vo/customer/CrowdPackageUserVO.java
0 → 100644
浏览文件 @
0e7a7d0d
package
com
.
yaoyaozw
.
customer
.
vo
.
customer
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/28 19:20
*/
@Data
public
class
CrowdPackageUserVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6564547615107105008L
;
private
Long
id
;
private
String
accountId
;
private
String
openId
;
private
Long
setupId
;
}
src/main/resources/bootstrap.yml
浏览文件 @
0e7a7d0d
...
...
@@ -4,7 +4,7 @@ spring:
application
:
name
:
customer-service
profiles
:
active
:
pro
active
:
dev
---
spring
:
profiles
:
dev
...
...
src/main/resources/mapper/RegisterUserEntityMapper.xml
浏览文件 @
0e7a7d0d
...
...
@@ -20,4 +20,27 @@
id, app_id, open_id, setup_id, pay_type, pay_num, pay_amount, avg_month, last_active,
gmt_create, customer_sort, customer_publish
</sql>
<select
id=
"getUserMatchDynamicExpress"
resultType=
"com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO"
>
select
rue.id,
ai.account_id as accountId,
rue.setup_id as setupId,
rue.open_id as openId
from register_user_entity rue
left join authorizer_info ai
on rue.app_id = ai.appid
<if
test=
"dynamicExpressList != null and dynamicExpressList.size() != 0"
>
<where>
<foreach
collection=
"dynamicExpressList"
separator=
" and "
item=
"express"
>
${express}
</foreach>
</where>
</if>
</select>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论