Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
push-message
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liucheng
push-message
Commits
f047f356
Commit
f047f356
authored
Jan 24, 2022
by
renandong
🇨🇳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,定时任务更新标签
parent
03d0ab85
Changes
55
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
4234 additions
and
926 deletions
+4234
-926
pom.xml
pom.xml
+4
-0
RRException.java
src/main/java/com/weface/common/exception/RRException.java
+0
-8
RRExceptionHandler.java
.../java/com/weface/common/exception/RRExceptionHandler.java
+0
-8
Base64Util.java
src/main/java/com/weface/common/utils/Base64Util.java
+1
-1
CacheUtil.java
src/main/java/com/weface/common/utils/CacheUtil.java
+0
-55
ConfigConstant.java
src/main/java/com/weface/common/utils/ConfigConstant.java
+0
-8
Constant.java
src/main/java/com/weface/common/utils/Constant.java
+0
-10
DateUtils.java
src/main/java/com/weface/common/utils/DateUtils.java
+0
-8
HttpContextUtils.java
src/main/java/com/weface/common/utils/HttpContextUtils.java
+3
-8
HttpUtil.java
src/main/java/com/weface/common/utils/HttpUtil.java
+4
-92
IPUtils.java
src/main/java/com/weface/common/utils/IPUtils.java
+19
-27
MapUtils.java
src/main/java/com/weface/common/utils/MapUtils.java
+0
-8
Model.java
src/main/java/com/weface/common/utils/Model.java
+0
-1
PageUtils.java
src/main/java/com/weface/common/utils/PageUtils.java
+0
-8
PicUtils.java
src/main/java/com/weface/common/utils/PicUtils.java
+6
-1
Query.java
src/main/java/com/weface/common/utils/Query.java
+0
-8
RedisUtil.java
src/main/java/com/weface/common/utils/RedisUtil.java
+2953
-0
SpringContextUtils.java
...main/java/com/weface/common/utils/SpringContextUtils.java
+0
-8
SQLFilter.java
src/main/java/com/weface/common/xss/SQLFilter.java
+0
-8
XssFilter.java
src/main/java/com/weface/common/xss/XssFilter.java
+1
-8
XssHttpServletRequestWrapper.java
...a/com/weface/common/xss/XssHttpServletRequestWrapper.java
+0
-8
GeTuiUtils.java
src/main/java/com/weface/component/GeTuiUtils.java
+368
-111
MenuService.java
src/main/java/com/weface/component/MenuService.java
+138
-170
MessageTemplate.java
src/main/java/com/weface/component/MessageTemplate.java
+138
-21
CorsConfig.java
src/main/java/com/weface/config/CorsConfig.java
+3
-8
ExecutorConfig.java
src/main/java/com/weface/config/ExecutorConfig.java
+3
-0
FilterConfig.java
src/main/java/com/weface/config/FilterConfig.java
+0
-8
MetaObjectHandlerConfig.java
src/main/java/com/weface/config/MetaObjectHandlerConfig.java
+1
-1
MybatisPlusConfig.java
src/main/java/com/weface/config/MybatisPlusConfig.java
+0
-8
RedisConfig.java
src/main/java/com/weface/config/RedisConfig.java
+42
-0
MenuTagsController.java
src/main/java/com/weface/controller/MenuTagsController.java
+2
-4
PushController.java
src/main/java/com/weface/controller/PushController.java
+4
-1
UserTagsController.java
src/main/java/com/weface/controller/UserTagsController.java
+8
-6
MenuTagsDao.java
src/main/java/com/weface/dao/MenuTagsDao.java
+0
-1
TUserTagDao.java
src/main/java/com/weface/dao/TUserTagDao.java
+0
-38
UserMenusDao.java
src/main/java/com/weface/dao/UserMenusDao.java
+12
-3
UserTagDao.java
src/main/java/com/weface/dao/UserTagDao.java
+76
-0
UserTagFrom.java
src/main/java/com/weface/dto/UserTagFrom.java
+6
-2
MenuTagsEntity.java
src/main/java/com/weface/entity/MenuTagsEntity.java
+0
-1
UserMenusEntity.java
src/main/java/com/weface/entity/UserMenusEntity.java
+0
-4
UserTagEntity.java
src/main/java/com/weface/entity/UserTagEntity.java
+1
-8
MenuTagsService.java
src/main/java/com/weface/service/MenuTagsService.java
+13
-3
TUserTagService.java
src/main/java/com/weface/service/TUserTagService.java
+0
-37
UserMenusService.java
src/main/java/com/weface/service/UserMenusService.java
+5
-2
UserTagService.java
src/main/java/com/weface/service/UserTagService.java
+76
-0
MenuTagsServiceImpl.java
...main/java/com/weface/serviceimpl/MenuTagsServiceImpl.java
+10
-2
UserMenusServiceImpl.java
...ain/java/com/weface/serviceimpl/UserMenusServiceImpl.java
+6
-4
UserTagServiceImpl.java
src/main/java/com/weface/serviceimpl/UserTagServiceImpl.java
+27
-50
UserTagsTask.java
src/main/java/com/weface/task/UserTagsTask.java
+128
-37
application-dev.yml
src/main/resources/application-dev.yml
+33
-33
application-prod.yml
src/main/resources/application-prod.yml
+33
-33
application.yml
src/main/resources/application.yml
+12
-1
UserMenusDao.xml
src/main/resources/mapper/UserMenusDao.xml
+1
-0
UserTagDao.xml
src/main/resources/mapper/UserTagDao.xml
+42
-37
PushMessageApplicationTests.java
src/test/java/com/weface/PushMessageApplicationTests.java
+55
-9
No files found.
pom.xml
View file @
f047f356
...
...
@@ -48,6 +48,10 @@
<artifactId>
lombok
</artifactId>
<version>
${lombok.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
src/main/java/com/weface/common/exception/RRException.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
exception
;
/**
...
...
src/main/java/com/weface/common/exception/RRExceptionHandler.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
exception
;
import
com.weface.common.utils.Model
;
...
...
src/main/java/com/weface/common/utils/Base64Util.java
View file @
f047f356
...
...
@@ -68,7 +68,7 @@ public class Base64Util {
}
private
static
String
byte2Hex
(
byte
[]
bytes
)
{
StringBu
ffer
stringBuffer
=
new
StringBuff
er
();
StringBu
ilder
stringBuffer
=
new
StringBuild
er
();
String
temp
=
null
;
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
temp
=
Integer
.
toHexString
(
bytes
[
i
]
&
0xFF
);
...
...
src/main/java/com/weface/common/utils/CacheUtil.java
deleted
100644 → 0
View file @
03d0ab85
package
com
.
weface
.
common
.
utils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @CreateUser: Administrator
* @CreateTime: 2021/12/1
* 实现简单缓存
*/
public
class
CacheUtil
{
private
static
CacheUtil
cacheUtil
;
private
static
Map
<
String
,
Object
>
cacheMap
;
private
CacheUtil
()
{
cacheMap
=
new
HashMap
<
String
,
Object
>();
}
public
static
CacheUtil
getInstance
()
{
if
(
cacheUtil
==
null
)
{
cacheUtil
=
new
CacheUtil
();
}
return
cacheUtil
;
}
/**
* 添加缓存
*
* @param key
* @param obj
*/
public
void
addCacheData
(
String
key
,
Object
obj
)
{
cacheMap
.
put
(
key
,
obj
);
}
/**
* 取出缓存
*
* @param key
* @return
*/
public
Object
getCacheData
(
String
key
)
{
return
cacheMap
.
get
(
key
);
}
/**
* 清除缓存
*
* @param key
*/
public
void
removeCacheData
(
String
key
)
{
cacheMap
.
remove
(
key
);
}
}
src/main/java/com/weface/common/utils/ConfigConstant.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
/**
...
...
src/main/java/com/weface/common/utils/Constant.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
/**
...
...
@@ -40,7 +32,6 @@ public class Constant {
* 菜单类型
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2016年11月15日 下午1:24:29
*/
public
enum
MenuType
{
...
...
@@ -72,7 +63,6 @@ public class Constant {
* 定时任务状态
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2016年12月3日 上午12:07:22
*/
public
enum
ScheduleStatus
{
...
...
src/main/java/com/weface/common/utils/DateUtils.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
import
org.apache.commons.lang.StringUtils
;
...
...
src/main/java/com/weface/common/utils/HttpContextUtils.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
import
org.springframework.web.context.request.RequestContextHolder
;
...
...
@@ -13,6 +5,9 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
javax.servlet.http.HttpServletRequest
;
/**
* @author Administrator
*/
public
class
HttpContextUtils
{
public
static
HttpServletRequest
getHttpServletRequest
()
{
...
...
src/main/java/com/weface/common/utils/HttpUtil.java
View file @
f047f356
...
...
@@ -4,14 +4,13 @@ package com.weface.common.utils;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
java.io.BufferedReader
;
import
java.io.DataOutputStream
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
import
java.util.Map
;
/**
* http 工具类
...
...
@@ -63,70 +62,14 @@ public class HttpUtil {
// 建立实际的连接
connection
.
connect
();
// 获取所有响应头字段
Map
<
String
,
List
<
String
>>
headers
=
connection
.
getHeaderFields
();
// 遍历所有的响应头字段
// for (String key : headers.keySet()) {
// log.info(key + "--->" + headers.get(key));
// }
// 定义 BufferedReader输入流来读取URL的响应
// BufferedReader in = null;
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
(),
encoding
));
String
result
=
""
;
String
getLine
;
while
((
getLine
=
in
.
readLine
())
!=
null
)
{
result
+=
getLine
;
}
in
.
close
();
return
result
;
}
public
static
String
getGeneralUrl
(
String
generalUrl
,
String
contentType
,
String
params
,
String
encoding
)
throws
Exception
{
return
HttpUtil
.
getGeneralUrl
(
generalUrl
,
contentType
,
params
,
encoding
,
null
);
}
public
static
String
getGeneralUrl
(
String
generalUrl
,
String
contentType
,
String
params
,
String
encoding
,
String
token
)
throws
Exception
{
URL
url
=
new
URL
(
generalUrl
);
// 打开和URL之间的连接
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
// 设置通用的请求属性
connection
.
setRequestProperty
(
"Content-Type"
,
contentType
);
connection
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
if
(
StringUtils
.
isNotEmpty
(
token
))
{
connection
.
setRequestProperty
(
"token"
,
token
);
}
connection
.
setUseCaches
(
false
);
connection
.
setDoOutput
(
true
);
connection
.
setDoInput
(
true
);
// 得到请求的输出流对象
DataOutputStream
out
=
new
DataOutputStream
(
connection
.
getOutputStream
());
out
.
write
(
params
.
getBytes
(
encoding
));
out
.
flush
();
out
.
close
();
// 建立实际的连接
connection
.
connect
();
// 获取所有响应头字段
Map
<
String
,
List
<
String
>>
headers
=
connection
.
getHeaderFields
();
// 遍历所有的响应头字段
for
(
String
key
:
headers
.
keySet
())
{
log
.
info
(
key
+
"--->"
+
headers
.
get
(
key
));
}
// 定义 BufferedReader输入流来读取URL的响应
BufferedReader
in
=
null
;
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
(),
encoding
));
String
result
=
""
;
StringBuilder
result
=
new
StringBuilder
();
String
getLine
;
while
((
getLine
=
in
.
readLine
())
!=
null
)
{
result
+=
getLine
;
result
.
append
(
getLine
)
;
}
in
.
close
();
log
.
info
(
"result:"
+
result
);
return
result
;
return
result
.
toString
();
}
public
static
boolean
isJson2
(
String
str
)
{
...
...
@@ -136,38 +79,7 @@ public class HttpUtil {
flag
=
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
flag
=
false
;
}
return
flag
;
}
// public static String postGeTui(String url, Object obj, String token) {
// CloseableHttpClient httpClient = HttpClients.createDefault();
// HttpPost httpPost = new HttpPost(url);
// httpPost.setHeader("token", token);
// httpPost.setHeader("Content-Type", "application/json");
// httpPost.setHeader("Accept", "application/json");
// StringEntity stringEntity = new StringEntity(JSONObject.toJSONString(obj), "UTF-8");
// System.out.println(stringEntity);
// httpPost.setEntity(stringEntity);
// CloseableHttpResponse response = null;
// try {
// response = httpClient.execute(httpPost);
// StatusLine status = response.getStatusLine();
// int state = status.getStatusCode();
// if (state == HttpStatus.SC_OK) {
// HttpEntity responseEntity = response.getEntity();
// return EntityUtils.toString(responseEntity);
// } else {
// log.error("请求返回:" + state + "(" + url + ")");
// }
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// IoUtil.close(response);
// IoUtil.close(httpClient);
// }
//
// return null;
// }
}
src/main/java/com/weface/common/utils/IPUtils.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
import
com.alibaba.druid.util.StringUtils
;
...
...
@@ -20,16 +12,16 @@ import javax.servlet.http.HttpServletRequest;
* @author Mark sunlightcs@gmail.com
*/
public
class
IPUtils
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
IPUtils
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
IPUtils
.
class
);
/**
* 获取IP地址
*
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
*/
public
static
String
getIpAddr
(
HttpServletRequest
request
)
{
String
ip
=
null
;
/**
* 获取IP地址
* <p>
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
*/
public
static
String
getIpAddr
(
HttpServletRequest
request
)
{
String
ip
=
null
;
try
{
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
StringUtils
.
isEmpty
(
ip
)
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
...
...
@@ -48,17 +40,17 @@ public class IPUtils {
ip
=
request
.
getRemoteAddr
();
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"IPUtils ERROR "
,
e
);
logger
.
error
(
"IPUtils ERROR "
,
e
);
}
//
//使用代理,则获取第一个IP地址
// if
(StringUtils.isEmpty(ip) && ip.length() > 15) {
// if
(ip.indexOf(",") > 0) {
//
ip = ip.substring(0, ip.indexOf(","));
//
}
// }
//使用代理,则获取第一个IP地址
/*if
(StringUtils.isEmpty(ip) && ip.length() > 15) {
if
(ip.indexOf(",") > 0) {
ip = ip.substring(0, ip.indexOf(","));
}
}*/
return
ip
;
}
}
src/main/java/com/weface/common/utils/MapUtils.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
import
java.util.HashMap
;
...
...
src/main/java/com/weface/common/utils/Model.java
View file @
f047f356
...
...
@@ -8,7 +8,6 @@ import java.util.Map;
/**
* @author Aleyn
* @description Model
* @since 2021/11/10 16:34
*/
@Getter
...
...
src/main/java/com/weface/common/utils/PageUtils.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
...
src/main/java/com/weface/common/utils/PicUtils.java
View file @
f047f356
...
...
@@ -15,8 +15,13 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
* @author Administrator
*/
public
class
PicUtils
{
//以下是常量,按照阿里代码开发规范,不允许代码中出现魔法值
/**
* 以下是常量,按照阿里代码开发规范,不允许代码中出现魔法值
*/
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PicUtils
.
class
);
private
static
final
Integer
ZERO
=
0
;
private
static
final
Integer
ONE_ZERO_TWO_FOUR
=
1024
;
...
...
src/main/java/com/weface/common/utils/Query.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
import
cn.hutool.core.convert.Convert
;
...
...
src/main/java/com/weface/common/utils/RedisUtil.java
0 → 100644
View file @
f047f356
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/main/java/com/weface/common/utils/SpringContextUtils.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
utils
;
import
org.springframework.beans.BeansException
;
...
...
src/main/java/com/weface/common/xss/SQLFilter.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
xss
;
import
org.apache.commons.lang.StringUtils
;
...
...
src/main/java/com/weface/common/xss/XssFilter.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
xss
;
import
javax.servlet.*
;
...
...
@@ -23,6 +15,7 @@ public class XssFilter implements Filter {
public
void
init
(
FilterConfig
config
)
throws
ServletException
{
}
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
XssHttpServletRequestWrapper
xssRequest
=
new
XssHttpServletRequestWrapper
(
...
...
src/main/java/com/weface/common/xss/XssHttpServletRequestWrapper.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
common
.
xss
;
import
org.apache.commons.io.IOUtils
;
...
...
src/main/java/com/weface/component/GeTuiUtils.java
View file @
f047f356
This diff is collapsed.
Click to expand it.
src/main/java/com/weface/component/MenuService.java
View file @
f047f356
This diff is collapsed.
Click to expand it.
src/main/java/com/weface/component/MessageTemplate.java
View file @
f047f356
...
...
@@ -4,48 +4,165 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @
CreateUser:
Administrator
* @
author
Administrator
* @CreateTime: 2021/11/23
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
MessageTemplate
{
public
class
MessageTemplate
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
*/
private
String
request_id
;
/**
* 任务组
*/
private
String
group_name
;
/**
*
消息离线时间设置,单位毫秒,-1表示不设离线,-1 ~ 3 * 24 * 3600 * 1000(3天)之间
*
推送目标用户该接口audience 对应值为all,表示推送所有用户
*/
private
Long
ttl
;
private
Audience
audience
;
/**
*
通知消息标题,长度 ≤ 50
*
推送条件设置
*/
private
S
tring
title
;
private
S
ettings
settings
;
/**
*
通知消息内容,长度 ≤ 256
*
个推推送消息参数
*/
private
String
body
;
private
PushMessage
push_message
;
/**
* 点击通知后续动作,
* 目前支持以下后续动作,
* intent:打开应用内特定页面,
* url:打开网页地址,
* payload:自定义消息内容启动应用,
* payload_custom:自定义消息内容不启动应用,
* startapp:打开应用首页,
* none:纯通知,无后续动作
* 厂商推送消息参数,包含ios消息参数,android厂商消息参数
*/
private
String
click_type
;
private
PushChannel
push_channel
;
/**
*
click_type为url时必填 无 点击通知打开链接
*
推送目标用户该接口audience 对应值为all,表示推送所有用户
*/
private
String
url
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
static
class
Audience
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
//别名数组,只能填一个别名
private
String
[]
alias
;
}
/**
*
click_type为intent时必填 无 点击通知打开应用特定页面,长度 ≤ 4096;
*
推送条件设置
*/
private
String
intent
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
static
class
Settings
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
//消息离线时间设置,单位毫秒,-1表示不设离线,-1 ~ 3 * 24 * 3600 * 1000(3天)之间
private
Integer
ttl
;
//定速推送,例如100,个推控制下发速度在100条/秒左右,0表示不限速
private
Integer
speed
;
}
/**
* 个推推送消息参数
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public
static
class
PushMessage
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
//手机端通知展示时间段,格式为毫秒时间戳段,两个时间的时间差必须大于10分钟,例如:"1590547347000-1590633747000"
private
String
duration
;
//纯透传消息内容,安卓和iOS均支持,与notification、revoke 三选一,都填写时报错,长度 ≤ 3072
private
String
transmission
;
//消息模板
private
Notification
notification
;
//撤回消息时使用(仅撤回个推通道消息),与notification、transmission三选一,都填写时报错(消息撤回请勿填写策略参数)
private
Revoke
revoke
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
static
class
Notification
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
title
;
private
String
body
;
private
String
big_text
;
private
String
big_image
;
private
String
logo
;
private
String
logo_url
;
private
String
channel_id
;
private
String
channel_name
;
private
Integer
channel_level
;
private
String
click_type
;
private
String
intent
;
private
String
url
;
private
String
payload
;
private
Integer
notify_id
;
private
String
ring_name
;
private
Integer
badge_add_num
;
private
String
thread_id
;
}
@Data
public
static
class
Revoke
{
private
String
old_task_id
;
private
Integer
force
;
}
}
/**
* 厂商推送消息参数,包含ios消息参数,android厂商消息参数
*/
@Data
public
static
class
PushChannel
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Android
android
;
/**
* ios通道推送消息内容
*/
@Data
public
static
class
Ios
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
}
/**
* android通道推送消息内容
*/
@Data
public
static
class
Android
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Ups
ups
;
@Data
public
static
class
Ups
{
private
Notification
notification
;
private
String
transmission
;
private
Revoke
revoke
;
@Data
public
static
class
Notification
{
private
String
title
;
private
String
body
;
private
String
click_type
;
private
String
intent
;
private
String
url
;
private
Integer
notify_id
;
}
@Data
public
static
class
Revoke
{
private
String
old_task_id
;
}
}
}
}
}
src/main/java/com/weface/config/CorsConfig.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
* @author Administrator
*/
@Configuration
public
class
CorsConfig
implements
WebMvcConfigurer
{
...
...
src/main/java/com/weface/config/ExecutorConfig.java
View file @
f047f356
...
...
@@ -9,6 +9,9 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* @author Administrator
*/
@EnableAsync
@Configuration
public
class
ExecutorConfig
{
...
...
src/main/java/com/weface/config/FilterConfig.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
config
;
import
com.weface.common.xss.XssFilter
;
...
...
src/main/java/com/weface/config/MetaObjectHandlerConfig.java
View file @
f047f356
...
...
@@ -6,7 +6,7 @@ import org.apache.ibatis.reflection.MetaObject;
import
java.util.Date
;
/**
* @
CreateUser:
Administrator
* @
author
Administrator
* @CreateTime: 2021/11/16
* 自动填充属性
*/
...
...
src/main/java/com/weface/config/MybatisPlusConfig.java
View file @
f047f356
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package
com
.
weface
.
config
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
...
...
src/main/java/com/weface/config/RedisConfig.java
0 → 100644
View file @
f047f356
package
com
.
weface
.
config
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
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
;
/**
* @author : Administrator
*/
@Configuration
public
class
RedisConfig
{
@Bean
@SuppressWarnings
(
"all"
)
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
factory
)
{
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<
String
,
Object
>();
template
.
setConnectionFactory
(
factory
);
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
om
);
StringRedisSerializer
stringRedisSerializer
=
new
StringRedisSerializer
();
// key采用String的序列化方式
template
.
setKeySerializer
(
stringRedisSerializer
);
// hash的key也采用String的序列化方式
template
.
setHashKeySerializer
(
stringRedisSerializer
);
// value序列化方式采用jackson
template
.
setValueSerializer
(
jackson2JsonRedisSerializer
);
// hash的value序列化方式采用jackson
template
.
setHashValueSerializer
(
jackson2JsonRedisSerializer
);
template
.
afterPropertiesSet
();
return
template
;
}
}
src/main/java/com/weface/controller/MenuTagsController.java
View file @
f047f356
...
...
@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Arrays
;
import
java.util.Map
;
...
...
@@ -19,7 +20,6 @@ import java.util.Map;
* 所有标签等级划分
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
@RestController
...
...
@@ -41,12 +41,10 @@ public class MenuTagsController {
/**
* 根据用户giUid先调个推拿到code后走数据库拿到数据并更新相关数据后返回
*
* @return
*/
@PostMapping
(
"/queryTagByGiUid"
)
public
Model
queryTagsByGiUid
(
@RequestBody
UserTagFrom
userTagFrom
)
{
Map
<
String
,
Object
>
data
=
menuService
.
getUserTags
(
userTagFrom
.
getGiUidList
()
);
Map
<
String
,
Object
>
data
=
menuService
.
getUserTags
(
Arrays
.
asList
(
userTagFrom
.
getGiUidList
()),
null
);
return
Model
.
ok
(
data
);
}
...
...
src/main/java/com/weface/controller/PushController.java
View file @
f047f356
...
...
@@ -10,6 +10,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author Administrator
*/
@RestController
@RequestMapping
(
"push"
)
public
class
PushController
{
...
...
@@ -23,7 +26,7 @@ public class PushController {
}
@PostMapping
(
"single"
)
public
CommonResult
pushSingle
(
@RequestBody
MsgDTO
param
){
public
CommonResult
pushSingle
(
@RequestBody
MsgDTO
param
)
{
return
pushService
.
pushSingle
(
param
);
}
}
src/main/java/com/weface/controller/UserTagsController.java
View file @
f047f356
...
...
@@ -3,7 +3,8 @@ package com.weface.controller;
import
com.weface.common.utils.Model
;
import
com.weface.common.utils.PageUtils
;
import
com.weface.dto.UserTagFrom
;
import
com.weface.service.TUserTagService
;
import
com.weface.service.UserTagService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -16,14 +17,13 @@ import java.util.Map;
/**
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
@RestController
@RequestMapping
(
"/tags/userTags"
)
public
class
UserTagsController
{
@Autowired
private
T
UserTagService
tUserTagService
;
private
UserTagService
tUserTagService
;
/**
* 查询所有用户对应标签信息
...
...
@@ -48,9 +48,11 @@ public class UserTagsController {
*/
@PostMapping
(
"/queryByGid"
)
public
Model
queryByGid
(
@RequestBody
UserTagFrom
userTagFrom
)
{
// String[] userIdList = new String[]{"3917d1037675078ae3a1abb4c6da3ef6", "1231313123"};
// String os = "Android";
Map
<
String
,
Object
>
data
=
tUserTagService
.
getTagByGid
(
userTagFrom
.
getGiUidList
());
String
gid
=
userTagFrom
.
getGiUidList
()[
0
];
if
(
StringUtils
.
isBlank
(
gid
))
{
return
Model
.
error
(
"gid不能为空"
);
}
Map
<
String
,
Object
>
data
=
tUserTagService
.
getTagByGid
(
gid
);
return
Model
.
ok
(
data
);
}
...
...
src/main/java/com/weface/dao/MenuTagsDao.java
View file @
f047f356
...
...
@@ -8,7 +8,6 @@ import org.apache.ibatis.annotations.Mapper;
* 所有标签等级划分
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
@Mapper
...
...
src/main/java/com/weface/dao/TUserTagDao.java
deleted
100644 → 0
View file @
03d0ab85
package
com
.
weface
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.weface.entity.TUserTagEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
/**
* 用户ID标签关联表
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-30 18:57:06
*/
@Mapper
public
interface
TUserTagDao
extends
BaseMapper
<
TUserTagEntity
>
{
//查询用户和标签信息
<
T
>
IPage
<
TUserTagEntity
>
getUserAndTags
(
Page
<
T
>
page
,
String
giUid
,
String
tag
);
//使用limit分页查询
List
<
String
>
findGidByLimit
(
int
pageRecord
,
int
limit
);
//根据标签查询用户gid
List
<
String
>
getGidByTag
(
List
<
String
>
list
);
//根据gid查询用户标签
List
<
TUserTagEntity
>
getTagByGid
(
List
<
String
>
list
);
//查询所有用户标签关联数据
List
<
TUserTagEntity
>
selectAllUserForTags
();
//查询今天更新用户gid
List
<
String
>
findTodayGid
();
}
src/main/java/com/weface/dao/UserMenusDao.java
View file @
f047f356
...
...
@@ -10,16 +10,25 @@ import java.util.List;
* 用户和标签中间表
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
@Mapper
public
interface
UserMenusDao
extends
BaseMapper
<
UserMenusEntity
>
{
//批量插入
/**
* 批量插入
*
* @param list 插入数据
* @return 成功条数
*/
int
batchInsert
(
List
<
UserMenusEntity
>
list
);
//根据uid查询标签id
/**
* 根据uid查询标签id
*
* @param list gid
* @return 标签id
*/
List
<
Long
>
findIdByUserId
(
List
<
String
>
list
);
}
src/main/java/com/weface/dao/UserTagDao.java
0 → 100644
View file @
f047f356
package
com
.
weface
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.weface.entity.UserTagEntity
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 用户ID标签关联表
*
* @author chenshun
* @date 2021-11-30 18:57:06
*/
@Mapper
public
interface
UserTagDao
extends
BaseMapper
<
UserTagEntity
>
{
/**
* 查询今天用户信息
*
* @return 用户信息
*/
List
<
UserTagEntity
>
findUserByTodayAndIdBefore
(
Integer
id
);
/**
* 根据时间查询用户信息
*
* @return 用户信息
*/
List
<
UserTagEntity
>
findUserByIdAfter
(
Integer
id
,
Integer
limit
);
/**
* 查询库中无标签用户
*
* @return 用户信息
*/
List
<
UserTagEntity
>
findNoTagUser
(
@Param
(
"star"
)
Integer
star
,
@Param
(
"end"
)
Integer
end
);
/**
* 查询用户和标签信息
*
* @param page 分页
* @param gid 银行gid
* @param <T> 分页泛型
* @return 用户标签数据
*/
<
T
>
IPage
<
UserTagEntity
>
getUserAndTags
(
Page
<
T
>
page
,
@Param
(
"gid"
)
String
gid
);
/**
* 根据标签查询用户gid
*
* @param list 标签数据
* @return 用户gid
*/
List
<
String
>
getGidByTag
(
List
<
String
>
list
);
/**
* 根据gid查询用户标签
*
* @param gid 用户gid
* @return 用户标签数据
*/
List
<
UserTagEntity
>
getTagByGid
(
String
gid
);
/**
* 查询所有用户标签关联数据
*
* @return 用户标签数据
*/
List
<
UserTagEntity
>
selectAllUserForTags
();
}
src/main/java/com/weface/dto/UserTagFrom.java
View file @
f047f356
...
...
@@ -2,12 +2,16 @@ package com.weface.dto;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @
CreateUser:
Administrator
* @
author
Administrator
* @CreateTime: 2021/11/17
*/
@Data
public
class
UserTagFrom
{
public
class
UserTagFrom
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
[]
giUidList
;
...
...
src/main/java/com/weface/entity/MenuTagsEntity.java
View file @
f047f356
...
...
@@ -12,7 +12,6 @@ import java.util.Date;
* 所有标签等级划分
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
@Data
...
...
src/main/java/com/weface/entity/UserMenusEntity.java
View file @
f047f356
...
...
@@ -10,7 +10,6 @@ import java.util.Date;
* 用户和标签中间表
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
@Data
...
...
@@ -31,9 +30,6 @@ public class UserMenusEntity implements Serializable {
* 标签ID
*/
private
Long
tagsId
;
/**
* 是否删除 1 未删除 0 删除
*/
/**
* 是否有效 1:有效 0 无效
*/
...
...
src/main/java/com/weface/entity/
T
UserTagEntity.java
→
src/main/java/com/weface/entity/UserTagEntity.java
View file @
f047f356
...
...
@@ -16,13 +16,12 @@ import java.util.List;
* 用户ID标签关联表
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-30 18:57:06
*/
@ExcelTarget
(
"tUserTagEntity"
)
@Data
@TableName
(
"t_user_tag"
)
public
class
T
UserTagEntity
implements
Serializable
{
public
class
UserTagEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
...
...
@@ -51,12 +50,6 @@ public class TUserTagEntity implements Serializable {
/**
* 标签数据
*/
// @ExcelCollection(name = "标签列表",orderNum = "3")
// @TableField(exist = false)
// private List<MenuTagsEntity> list;
/**
* 标签数据
*/
@ExcelEntity
(
name
=
"标签列表"
,
id
=
"id"
)
@TableField
(
exist
=
false
)
private
List
<
MenuTagsEntity
>
list
;
...
...
src/main/java/com/weface/service/MenuTagsService.java
View file @
f047f356
...
...
@@ -10,15 +10,25 @@ import java.util.Map;
* 所有标签等级划分
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
public
interface
MenuTagsService
extends
IService
<
MenuTagsEntity
>
{
//列表
/**
* 列表
*
* @param params 参数
* @return 标签分页
*/
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
//根据code和权重查询标签
/**
* 根据code和权重查询标签
*
* @param code 编码
* @param weight 权重
* @return 标签信息
*/
MenuTagsEntity
getOneByCodeOrWeight
(
String
code
,
String
weight
);
}
src/main/java/com/weface/service/TUserTagService.java
deleted
100644 → 0
View file @
03d0ab85
package
com
.
weface
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.weface.entity.TUserTagEntity
;
import
com.weface.common.utils.PageUtils
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户ID标签关联表
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-30 18:57:06
*/
public
interface
TUserTagService
extends
IService
<
TUserTagEntity
>
{
//查询所有用户对应标签信息
PageUtils
getUserAndTags
(
Map
<
String
,
Object
>
params
);
//使用limit分页查询
List
<
String
>
findGidByLimit
(
int
i
,
int
limit
);
//查询当天的数据
List
<
String
>
findTodayGid
();
//根据标签查询用户gid
List
<
String
>
getGidByTag
(
String
[]
tags
);
//根据gid查询用户标签
Map
<
String
,
Object
>
getTagByGid
(
String
[]
userIdList
);
List
<
TUserTagEntity
>
getAllImport
();
}
src/main/java/com/weface/service/UserMenusService.java
View file @
f047f356
...
...
@@ -9,12 +9,15 @@ import java.util.List;
* 用户和标签中间表
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-11-18 16:20:52
*/
public
interface
UserMenusService
extends
IService
<
UserMenusEntity
>
{
//批量插入
/**
* 批量插入
*
* @param list 数据列表
*/
void
batchInsert
(
List
<
UserMenusEntity
>
list
);
}
...
...
src/main/java/com/weface/service/UserTagService.java
0 → 100644
View file @
f047f356
package
com
.
weface
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.weface.entity.UserTagEntity
;
import
com.weface.common.utils.PageUtils
;
import
java.util.List
;
import
java.util.Map
;
/**
* 用户ID标签关联表
*
* @author chenshun
* @date 2021-11-30 18:57:06
*/
public
interface
UserTagService
extends
IService
<
UserTagEntity
>
{
/**
* 查询当天的数据
*
* @return 当天改变的用户
*/
List
<
UserTagEntity
>
findUserByTodayAndIdBefore
(
Integer
id
);
/**
* 根据时间查询用户信息
*
* @return 用户信息
*/
List
<
UserTagEntity
>
findUserByIdAfter
(
Integer
id
,
Integer
limit
);
/**
* 查询库中无标签用户
*
* @param star 起始值
* @param end 每页数据
* @return 用户信息
*/
List
<
UserTagEntity
>
findNoTagUser
(
Integer
star
,
Integer
end
);
/**
* 查询所有用户对应标签信息
*
* @param params 參數
* @return 分頁信息
*/
PageUtils
getUserAndTags
(
Map
<
String
,
Object
>
params
);
/**
* 根据标签查询用户gid
*
* @param tags 标签数组
* @return 用户gid
*/
List
<
String
>
getGidByTag
(
String
[]
tags
);
/**
* 根据gid查询用户标签
*
* @param gid 用户gid数组
* @return 用户信息和标签信息
*/
Map
<
String
,
Object
>
getTagByGid
(
String
gid
);
/**
* 获取所有用户的标签信息 导出
*
* @return 标签信息
*/
List
<
UserTagEntity
>
getAllImport
();
}
src/main/java/com/weface/serviceimpl/MenuTagsServiceImpl.java
View file @
f047f356
...
...
@@ -11,9 +11,13 @@ import com.weface.common.utils.Query;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author Administrator
*/
@Service
(
"menuTagsService"
)
public
class
MenuTagsServiceImpl
extends
ServiceImpl
<
MenuTagsDao
,
MenuTagsEntity
>
implements
MenuTagsService
{
...
...
@@ -42,10 +46,14 @@ public class MenuTagsServiceImpl extends ServiceImpl<MenuTagsDao, MenuTagsEntity
*/
@Override
public
MenuTagsEntity
getOneByCodeOrWeight
(
String
code
,
String
weight
)
{
return
this
.
getOne
(
new
QueryWrapper
<
MenuTagsEntity
>()
List
<
MenuTagsEntity
>
list
=
this
.
list
(
new
QueryWrapper
<
MenuTagsEntity
>()
.
lambda
().
eq
(
MenuTagsEntity:
:
getCode
,
code
)
.
eq
(
MenuTagsEntity:
:
getLevelFirst
,
"Android"
)
.
eq
(
StringUtils
.
isNotBlank
(
weight
),
MenuTagsEntity:
:
getWeight
,
weight
));
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
return
list
.
get
(
0
);
}
else
{
return
null
;
}
}
}
\ No newline at end of file
src/main/java/com/weface/serviceimpl/UserMenusServiceImpl.java
View file @
f047f356
package
com
.
weface
.
serviceimpl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.weface.dao.UserMenusDao
;
import
com.weface.entity.UserMenusEntity
;
...
...
@@ -30,9 +29,6 @@ public class UserMenusServiceImpl extends ServiceImpl<UserMenusDao, UserMenusEnt
//批量插入前全删
List
<
Long
>
ids
=
this
.
baseMapper
.
findIdByUserId
(
deleteUid
);
this
.
removeByIds
(
ids
);
// this.remove(new QueryWrapper<UserMenusEntity>().lambda()
// .eq(UserMenusEntity::getIsValid, 1)
// .in(UserMenusEntity::getUserId, deleteUid));
//获取集合长度
int
count
=
userMenusList
.
size
();
//每次批量插入个数
...
...
@@ -59,6 +55,12 @@ public class UserMenusServiceImpl extends ServiceImpl<UserMenusDao, UserMenusEnt
}
}
/**
* 查询删除的uid
*
* @param userMenusList 用户标签信息
* @return 提取用户uid
*/
private
List
<
String
>
getDeleteUid
(
List
<
UserMenusEntity
>
userMenusList
)
{
return
userMenusList
.
stream
().
map
(
UserMenusEntity:
:
getUserId
).
distinct
().
collect
(
Collectors
.
toList
());
}
...
...
src/main/java/com/weface/serviceimpl/
T
UserTagServiceImpl.java
→
src/main/java/com/weface/serviceimpl/UserTagServiceImpl.java
View file @
f047f356
...
...
@@ -3,10 +3,10 @@ package com.weface.serviceimpl;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.weface.dao.
T
UserTagDao
;
import
com.weface.dao.UserTagDao
;
import
com.weface.dto.MenuTagsForm
;
import
com.weface.entity.
T
UserTagEntity
;
import
com.weface.service.
T
UserTagService
;
import
com.weface.entity.UserTagEntity
;
import
com.weface.service.UserTagService
;
import
com.weface.common.utils.PageUtils
;
import
com.weface.common.utils.Query
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -15,71 +15,47 @@ import org.springframework.stereotype.Service;
import
java.util.*
;
/**
* @author Administrator
*/
@Service
(
"tUserTagService"
)
public
class
TUserTagServiceImpl
extends
ServiceImpl
<
TUserTagDao
,
TUserTagEntity
>
implements
T
UserTagService
{
public
class
UserTagServiceImpl
extends
ServiceImpl
<
UserTagDao
,
UserTagEntity
>
implements
UserTagService
{
@Override
public
List
<
UserTagEntity
>
findUserByTodayAndIdBefore
(
Integer
id
)
{
return
this
.
baseMapper
.
findUserByTodayAndIdBefore
(
id
);
}
/**
* 查询用户和标签信息
*
* @param params 查询参数
* @return 用户和标签数据分页
*/
@Override
public
PageUtils
getUserAndTags
(
Map
<
String
,
Object
>
params
)
{
IPage
<
Object
>
page
=
new
Query
<>().
getPage
(
params
);
String
giUid
=
(
String
)
params
.
get
(
"giUid"
);
String
tag
=
(
String
)
params
.
get
(
"tag"
);
IPage
<
TUserTagEntity
>
userAndTagsByUid
=
this
.
baseMapper
.
getUserAndTags
(
new
Page
<
TUserTagEntity
>(
page
.
getCurrent
(),
page
.
getSize
()),
giUid
,
tag
);
userAndTagsByUid
.
setTotal
(
userAndTagsByUid
.
getRecords
().
size
());
return
new
PageUtils
(
userAndTagsByUid
);
public
List
<
UserTagEntity
>
findUserByIdAfter
(
Integer
id
,
Integer
limit
)
{
return
this
.
baseMapper
.
findUserByIdAfter
(
id
,
limit
);
}
/**
* 使用limit分页查询
*
* @param pageRecord 起始值
* @param limit 每次查询数量
* @return gid
*/
@Override
public
List
<
String
>
findGidByLimit
(
int
pageRecord
,
int
limit
)
{
return
this
.
baseMapper
.
find
GidByLimit
(
pageRecord
,
limit
);
public
List
<
UserTagEntity
>
findNoTagUser
(
Integer
star
,
Integer
end
)
{
return
this
.
baseMapper
.
find
NoTagUser
(
star
,
end
);
}
/**
* 查询当天修改的用户gid
*
* @return
*/
@Override
public
List
<
String
>
findTodayGid
()
{
return
this
.
baseMapper
.
findTodayGid
();
public
PageUtils
getUserAndTags
(
Map
<
String
,
Object
>
params
)
{
IPage
<
Object
>
page
=
new
Query
<>().
getPage
(
params
);
String
gid
=
(
String
)
params
.
get
(
"gid"
);
IPage
<
UserTagEntity
>
userAndTagsByUid
=
this
.
baseMapper
.
getUserAndTags
(
new
Page
<
UserTagEntity
>(
page
.
getCurrent
(),
page
.
getSize
()),
gid
);
userAndTagsByUid
.
setTotal
(
userAndTagsByUid
.
getRecords
().
size
());
return
new
PageUtils
(
userAndTagsByUid
);
}
/**
* 根据标签查询用户gid
*
* @param tags 标签完全匹配
* @return gid
*/
@Override
public
List
<
String
>
getGidByTag
(
String
[]
tags
)
{
return
this
.
baseMapper
.
getGidByTag
(
Arrays
.
asList
(
tags
));
}
/**
* 根据gid查询用户标签
*
* @param userIdList gid
* @return 标签信息
*/
@Override
public
Map
<
String
,
Object
>
getTagByGid
(
String
[]
userIdList
)
{
List
<
TUserTagEntity
>
userByUid
=
this
.
baseMapper
.
getTagByGid
(
Arrays
.
asList
(
userIdList
)
);
public
Map
<
String
,
Object
>
getTagByGid
(
String
gid
)
{
List
<
UserTagEntity
>
userByUid
=
this
.
baseMapper
.
getTagByGid
(
gid
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>(
userByUid
.
size
());
for
(
T
UserTagEntity
tUserTagEntity
:
userByUid
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
for
(
UserTagEntity
tUserTagEntity
:
userByUid
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
2
);
List
<
MenuTagsForm
>
objects
=
new
ArrayList
<>();
tUserTagEntity
.
getList
().
forEach
(
item
->
{
MenuTagsForm
menuTagsForm
=
new
MenuTagsForm
();
...
...
@@ -97,8 +73,9 @@ public class TUserTagServiceImpl extends ServiceImpl<TUserTagDao, TUserTagEntity
}
@Override
public
List
<
T
UserTagEntity
>
getAllImport
()
{
public
List
<
UserTagEntity
>
getAllImport
()
{
return
this
.
baseMapper
.
selectAllUserForTags
();
}
}
\ No newline at end of file
src/main/java/com/weface/task/UserTagsTask.java
View file @
f047f356
package
com
.
weface
.
task
;
import
cn.hutool.core.collection.CollUtil
;
import
com.weface.common.utils.RedisUtil
;
import
com.weface.component.MenuService
;
import
com.weface.entity.MenuTagsEntity
;
import
com.weface.entity.UserTagEntity
;
import
com.weface.entity.UserMenusEntity
;
import
com.weface.service.TUserTagService
;
import
com.weface.service.MenuTagsService
;
import
com.weface.service.UserTagService
;
import
com.weface.service.UserMenusService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
/**
* @author Administrator
* @CreateUser: Administrator
* @CreateTime: 2021/11/4
*/
...
...
@@ -27,55 +35,138 @@ import java.util.concurrent.Executors;
@EnableScheduling
public
class
UserTagsTask
{
@Value
(
"${gexiang.user_tag_id}"
)
private
String
userTagId
;
@Value
(
"${gexiang.push_max_size}"
)
private
String
pushMaxSize
;
@Autowired
private
MenuService
menuService
;
@Autowired
private
TUserTagService
tU
serTagService
;
private
UserTagService
u
serTagService
;
@Autowired
private
UserMenusService
userMenusService
;
@Autowired
private
MenuTagsService
menuTagsService
;
@Scheduled
(
cron
=
"0 0 0 1 * ?"
)
@Autowired
private
ThreadPoolTaskExecutor
asyncServiceExecutor
;
/**
* 更新用户标签
*/
@Scheduled
(
cron
=
"0 0 23 * * ?"
)
public
void
updateUserTags
()
{
try
{
List
<
String
>
todayGid
=
tUserTagService
.
findTodayGid
();
int
size
=
todayGid
.
size
();
int
limit
=
1000
;
//获取每次处理的id起始值
String
userId
=
RedisUtil
.
StringOps
.
get
(
"user_tag_id"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
userId
=
userTagId
;
}
int
id
=
Integer
.
parseInt
(
userId
);
//获取每次处理最大数
String
pushSize
=
RedisUtil
.
StringOps
.
get
(
"push_max_size"
);
if
(
StringUtils
.
isBlank
(
pushSize
))
{
RedisUtil
.
StringOps
.
set
(
"push_max_size"
,
pushMaxSize
);
pushSize
=
pushMaxSize
;
}
int
max
=
Integer
.
parseInt
(
pushSize
);
//存储用户标签信息
List
<
UserMenusEntity
>
userMenusList
=
new
ArrayList
<>();
int
totalPage
=
(
size
%
limit
==
0
)
?
(
size
/
limit
)
:
(
size
/
limit
+
1
);
CountDownLatch
latch
=
new
CountDownLatch
(
totalPage
);
ExecutorService
pool
=
Executors
.
newFixedThreadPool
(
totalPage
);
//收集中间表数据
for
(
int
i
=
0
;
i
<
totalPage
;
i
++)
{
int
finalI
=
i
;
Runnable
runnable
=
()
->
{
List
<
String
>
list
=
new
ArrayList
<>();
if
(
finalI
==
totalPage
-
1
)
{
list
=
todayGid
.
subList
(
finalI
*
limit
,
size
);
}
else
{
list
=
todayGid
.
subList
(
finalI
*
limit
,
(
finalI
+
1
)
*
limit
);
}
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
String
[]
strings
=
list
.
toArray
(
new
String
[
0
]);
Map
<
String
,
Object
>
android
=
menuService
.
getUserTags
(
strings
);
List
<
UserMenusEntity
>
tagUser
=
menuService
.
getTagUser
(
android
);
if
(
CollectionUtils
.
isNotEmpty
(
tagUser
))
{
userMenusList
.
addAll
(
tagUser
);
}
//获取标签列表
List
<
MenuTagsEntity
>
tags
=
menuTagsService
.
list
();
//获取小于起始值,且更新时间为当前时间用户信息
List
<
UserTagEntity
>
beforeUser
=
userTagService
.
findUserByTodayAndIdBefore
(
id
);
//过滤用户gid
List
<
String
>
beforeGid
=
beforeUser
.
stream
().
map
(
UserTagEntity:
:
getGid
).
distinct
().
collect
(
Collectors
.
toList
());
//获取更新总数量
int
size
=
beforeGid
.
size
();
//如果更新数量大于总量,截取每次处理总量的更新用户信息
if
(
size
>
max
)
{
beforeGid
=
beforeGid
.
subList
(
0
,
max
-
1
);
}
else
{
//最大处理数减去当天更新处理数,得到剩余处理数,获取起始值后的新增的用户信息
List
<
UserTagEntity
>
afterUser
=
userTagService
.
findUserByIdAfter
(
Integer
.
parseInt
(
userId
),
max
-
size
);
//如果当天新增数不为空
if
(
CollUtil
.
isNotEmpty
(
afterUser
))
{
//获取用户最后一条信息
UserTagEntity
afterUserInfo
=
afterUser
.
get
(
afterUser
.
size
()
-
1
);
//并覆盖起始值
RedisUtil
.
StringOps
.
set
(
"user_tag_id"
,
String
.
valueOf
(
afterUserInfo
.
getId
()));
//过滤用户gid
List
<
String
>
afterGid
=
afterUser
.
stream
().
map
(
UserTagEntity:
:
getGid
).
distinct
().
collect
(
Collectors
.
toList
());
//调用个像接口获取新增用户标签
List
<
UserMenusEntity
>
afterTag
=
getUserTag
(
afterGid
,
afterUser
,
tags
);
if
(
CollUtil
.
isNotEmpty
(
afterTag
))
{
userMenusList
.
addAll
(
afterTag
);
}
latch
.
countDown
();
};
pool
.
execute
(
runnable
);
}
}
//调用个像接口获取更新用户标签
List
<
UserMenusEntity
>
beforeTag
=
getUserTag
(
beforeGid
,
beforeUser
,
tags
);
if
(
CollUtil
.
isNotEmpty
(
beforeTag
))
{
userMenusList
.
addAll
(
beforeTag
);
}
latch
.
await
();
//批量插入用户标签信息
userMenusService
.
batchInsert
(
userMenusList
);
}
catch
(
InterruptedException
e
)
{
log
.
error
(
"执行结束{}"
,
asyncServiceExecutor
.
getPoolSize
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"执行定时更新标签任务失败!"
);
}
}
// @Scheduled(cron = "* * * * * ?")
// public void updateUser() {
// System.out.println("你好" + System.currentTimeMillis());
// }
/**
* 获取个像用户标签信息
*
* @param gid 用户gid
* @param userInfo 用户信息
* @param tag 标签信息
* @return 查询到的用户标签信息
* @throws InterruptedException 网络异常
*/
private
List
<
UserMenusEntity
>
getUserTag
(
List
<
String
>
gid
,
List
<
UserTagEntity
>
userInfo
,
List
<
MenuTagsEntity
>
tag
)
throws
InterruptedException
{
//存储用户标签信息
List
<
UserMenusEntity
>
userTags
=
new
ArrayList
<>();
//获取用户gid总量
int
size
=
gid
.
size
();
//每个线程处理1000调数据
int
limit
=
200
;
//获取总页数
int
totalPage
=
(
size
%
limit
==
0
)
?
(
size
/
limit
)
:
(
size
/
limit
+
1
);
CountDownLatch
latch
=
new
CountDownLatch
(
totalPage
);
//创建线程
for
(
int
i
=
0
;
i
<
totalPage
;
i
++)
{
int
finalI
=
i
;
Runnable
runnable
=
()
->
{
//截取每次处理数据
List
<
String
>
list
;
if
(
finalI
==
totalPage
-
1
)
{
list
=
gid
.
subList
(
finalI
*
limit
,
size
);
}
else
{
list
=
gid
.
subList
(
finalI
*
limit
,
(
finalI
+
1
)
*
limit
);
}
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
//获取个像数据
Map
<
String
,
Object
>
android
=
menuService
.
getUserTags
(
list
,
tag
);
if
(
android
!=
null
)
{
//解析个像数据
List
<
UserMenusEntity
>
tagUser
=
menuService
.
getTagUser
(
android
,
userInfo
);
userTags
.
addAll
(
tagUser
);
}
}
latch
.
countDown
();
};
asyncServiceExecutor
.
execute
(
runnable
);
}
latch
.
await
();
return
userTags
;
}
}
src/main/resources/application-dev.yml
View file @
f047f356
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
druid
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://172.16.10.33:3306/png?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username
:
root
password
:
wefaceweface
initial-size
:
10
max-active
:
100
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
time-between-eviction-runs-millis
:
60000
min-evictable-idle-time-millis
:
300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle
:
true
test-on-borrow
:
false
test-on-return
:
false
stat-view-servlet
:
enabled
:
true
url-pattern
:
/druid/*
#login-username: admin
#login-password: admin
filter
:
stat
:
log-slow-sql
:
false
slow-sql-millis
:
1000
merge-sql
:
false
wall
:
config
:
multi-statement-allow
:
true
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
druid
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://172.16.10.33:3306/png?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username
:
root
password
:
wefaceweface
initial-size
:
10
max-active
:
100
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
time-between-eviction-runs-millis
:
60000
min-evictable-idle-time-millis
:
300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle
:
true
test-on-borrow
:
false
test-on-return
:
false
stat-view-servlet
:
enabled
:
true
url-pattern
:
/druid/*
#login-username: admin
#login-password: admin
filter
:
stat
:
log-slow-sql
:
false
slow-sql-millis
:
1000
merge-sql
:
false
wall
:
config
:
multi-statement-allow
:
true
##多数据源的配置
...
...
src/main/resources/application-prod.yml
View file @
f047f356
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
druid
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://localhost:3306/renren_fast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username
:
renren
password
:
123456
initial-size
:
10
max-active
:
100
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
time-between-eviction-runs-millis
:
60000
min-evictable-idle-time-millis
:
300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle
:
true
test-on-borrow
:
false
test-on-return
:
false
stat-view-servlet
:
enabled
:
true
url-pattern
:
/druid/*
#login-username: admin
#login-password: admin
filter
:
stat
:
log-slow-sql
:
true
slow-sql-millis
:
1000
merge-sql
:
false
wall
:
config
:
multi-statement-allow
:
true
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
druid
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://localhost:3306/renren_fast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username
:
renren
password
:
123456
initial-size
:
10
max-active
:
100
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
time-between-eviction-runs-millis
:
60000
min-evictable-idle-time-millis
:
300000
#Oracle需要打开注释
#validation-query: SELECT 1 FROM DUAL
test-while-idle
:
true
test-on-borrow
:
false
test-on-return
:
false
stat-view-servlet
:
enabled
:
true
url-pattern
:
/druid/*
#login-username: admin
#login-password: admin
filter
:
stat
:
log-slow-sql
:
true
slow-sql-millis
:
1000
merge-sql
:
false
wall
:
config
:
multi-statement-allow
:
true
##多数据源的配置
...
...
src/main/resources/application.yml
View file @
f047f356
...
...
@@ -26,6 +26,14 @@ spring:
enabled
:
true
mvc
:
throw-exception-if-no-handler-found
:
true
redis
:
host
:
localhost
database
:
0
port
:
6379
maxTotal
:
1000
maxIdle
:
50
minIdle
:
10
timeout
:
1s
getui
:
apps
:
{
...
...
@@ -43,7 +51,7 @@ mybatis-plus:
#数据库相关配置
db-config
:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type
:
AUTO
id-type
:
INPUT
logic-delete-value
:
0
logic-not-delete-value
:
1
banner
:
false
...
...
@@ -54,3 +62,6 @@ mybatis-plus:
call-setters-on-nulls
:
true
jdbc-type-for-null
:
'
null'
gexiang
:
user_tag_id
:
400000
push_max_size
:
30000
src/main/resources/mapper/UserMenusDao.xml
View file @
f047f356
...
...
@@ -19,6 +19,7 @@
(#{item.id},#{item.userId},#{item.tagsId},#{item.isValid},#{item.createTime})
</foreach>
</insert>
<!-- 根据uid查询标签id-->
<select
id=
"findIdByUserId"
resultType=
"long"
>
SELECT id FROM tb_user_menus WHERE is_valid = 1 AND user_id IN
...
...
src/main/resources/mapper/
T
UserTagDao.xml
→
src/main/resources/mapper/UserTagDao.xml
View file @
f047f356
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.weface.dao.
T
UserTagDao"
>
<mapper
namespace=
"com.weface.dao.UserTagDao"
>
<!-- 可根据自己的需求,是否要使用 -->
<resultMap
type=
"com.weface.entity.
TUserTagEntity"
id=
"tU
serTagMap"
>
<resultMap
type=
"com.weface.entity.
UserTagEntity"
id=
"u
serTagMap"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"uid"
column=
"uid"
/>
<result
property=
"tel"
column=
"tel"
/>
<result
property=
"gid"
column=
"gid"
/>
<result
property=
"saveDate"
column=
"save_date"
/>
<collection
property=
"list"
ofType=
"com.weface.entity.MenuTagsEntity"
>
<id
property=
"id"
column=
"tagId"
></id>
<result
property=
"levelFirst"
column=
"level_first"
></result>
...
...
@@ -19,20 +20,35 @@
<result
property=
"weight"
column=
"weight"
></result>
</collection>
</resultMap>
<!-- 使用limit分页查询-->
<select
id=
"findGidByLimit"
resultType=
"string"
>
SELECT gid
<!-- 查询id之前且当天更新的用户 AND id < #{id}-->
<select
id=
"findUserByTodayAndIdBefore"
resultMap=
"userTagMap"
>
SELECT uid, gid
FROM t_user_tag
WHERE gid IS NOT NULL LIMIT #{pageRecord}
, #{limit}
WHERE gid IS NOT NULL
AND id
<
= #{id}
AND TO_DAYS(save_date) = TO_DAYS(NOW())
ORDER BY save_date DESC
</select>
<!-- 查询当天更新用户gid-->
<select
id=
"findTodayGid"
resultType=
"string"
>
SELECT DISTINCT gid
<!-- 查询id之后的用户信息-->
<select
id=
"findUserByIdAfter"
resultMap=
"userTagMap"
>
SELECT id,uid, gid
FROM t_user_tag
WHERE gid IS NOT NULL
AND TO_DAYS( save_date ) = TO_DAYS( NOW() )
AND id > #{id} LIMIT #{limit}
</select>
<!-- 查询无标签用户-->
<select
id=
"findNoTagUser"
resultMap=
"userTagMap"
>
SELECT uid, gid
FROM t_user_tag ut
LEFT JOIN tb_user_menus um ON ut.uid = um.user_id
WHERE um.user_id IS NULL
AND ut.gid IS NOT NULL
ORDER BY save_date LIMIT #{star}, #{end}
</select>
<!-- 将公共片段抽取:只针对个别业务-->
<sql
id=
"common"
>
SELECT ut.uid,
...
...
@@ -47,28 +63,18 @@
FROM t_user_tag ut
LEFT JOIN tb_user_menus um ON ut.uid = um.user_id
LEFT JOIN tb_menu_tags mt ON um.tags_id = mt.id
WHERE mt.level_first = "Android" AND um.is_valid = 1
WHERE mt.level_first = "Android"
AND um.is_valid = 1
</sql>
<!-- 查询用户和标签信息-->
<select
id=
"getUserAndTags"
resultMap=
"tUserTagMap"
>
<!-- 查询用户信息根据gid-->
<select
id=
"getUserAndTags"
resultMap=
"userTagMap"
>
<include
refid=
"common"
/>
<if
test=
"giUid !=null and giUid != ''"
>
AND ut.user_id LIKE CONCAT(CONCAT('%',#{giUid}),'%')
</if>
<if
test=
"tag!=null and tag != ''"
>
AND ut.gid IN (
SELECT
ut.gid
FROM
t_user_tag ut
LEFT JOIN tb_user_menus um ON ut.uid = um.user_id
LEFT JOIN tb_menu_tags mt ON um.tags_id = mt.id
WHERE
mt.level_first = "Android"
AND mt.level_third LIKE CONCAT(CONCAT('%',#{tag}),'%')
)
<if
test=
"gid !=null and gid != ''"
>
AND ut.gid LIKE CONCAT(CONCAT('%',#{gid}),'%')
</if>
</select>
<!-- 根据标签查询用户gid-->
<select
id=
"getGidByTag"
resultType=
"string"
>
SELECT DISTINCT
...
...
@@ -84,16 +90,15 @@
#{item}
</foreach>
</select>
<!-- 根据gid查询用户标签-->
<select
id=
"getTagByGid"
resultMap=
"tUserTagMap"
>
<!-- 根据gid查询用户标签-->
<select
id=
"getTagByGid"
resultMap=
"userTagMap"
>
<include
refid=
"common"
/>
AND ut.gid IN
<foreach
item=
"item"
index=
"index"
collection=
"list"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
AND ut.gid =#{gid}
</select>
<!-- 查询所有用户标签管理数据-->
<select
id=
"selectAllUserForTags"
resultMap=
"tUserTagMap"
>
<!-- 查询所有用户标签管理数据-->
<select
id=
"selectAllUserForTags"
resultMap=
"userTagMap"
>
<include
refid=
"common"
/>
</select>
...
...
src/test/java/com/weface/PushMessageApplicationTests.java
View file @
f047f356
package
com
.
weface
;
import
com.weface.component.GeTuiUtils
;
import
com.weface.component.MenuService
;
import
com.weface.component.MessageTemplate
;
import
com.weface.entity.MenuTagsEntity
;
import
com.weface.entity.UserTagEntity
;
import
com.weface.entity.UserMenusEntity
;
import
com.weface.service.TUserTagService
;
import
com.weface.service.MenuTagsService
;
import
com.weface.service.UserTagService
;
import
com.weface.service.UserMenusService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -15,23 +21,37 @@ import java.util.Map;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
@SpringBootTest
class
PushMessageApplicationTests
{
@Autowired
private
TUserTagService
tU
serTagService
;
private
UserTagService
u
serTagService
;
@Autowired
private
MenuService
menuService
;
@Autowired
private
UserMenusService
userMenusService
;
@Autowired
private
MenuTagsService
menuTagsService
;
@Test
void
contextLoads
()
{
}
/**
* 根据时间同步标签
*/
@Test
public
void
test
()
{
public
void
test
KKSB
()
{
try
{
List
<
String
>
todayGid
=
tUserTagService
.
findTodayGid
();
//77164
//已处理0
//每次处理总条数 20000
int
star
=
10000
;
int
end
=
30000
;
List
<
MenuTagsEntity
>
tags
=
menuTagsService
.
list
();
List
<
UserTagEntity
>
todayUser
=
userTagService
.
findNoTagUser
(
star
,
end
);
List
<
String
>
todayGid
=
todayUser
.
stream
().
map
(
UserTagEntity:
:
getGid
).
distinct
().
collect
(
Collectors
.
toList
());
int
size
=
todayGid
.
size
();
int
limit
=
1000
;
List
<
UserMenusEntity
>
userMenusList
=
new
ArrayList
<>();
...
...
@@ -42,16 +62,15 @@ class PushMessageApplicationTests {
for
(
int
i
=
0
;
i
<
totalPage
;
i
++)
{
int
finalI
=
i
;
Runnable
runnable
=
()
->
{
List
<
String
>
list
=
new
ArrayList
<>()
;
List
<
String
>
list
;
if
(
finalI
==
totalPage
-
1
)
{
list
=
todayGid
.
subList
(
finalI
*
limit
,
size
);
}
else
{
list
=
todayGid
.
subList
(
finalI
*
limit
,
(
finalI
+
1
)
*
limit
);
}
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
String
[]
strings
=
list
.
toArray
(
new
String
[
0
]);
Map
<
String
,
Object
>
android
=
menuService
.
getUserTags
(
strings
);
List
<
UserMenusEntity
>
tagUser
=
menuService
.
getTagUser
(
android
);
Map
<
String
,
Object
>
android
=
menuService
.
getUserTags
(
list
,
tags
);
List
<
UserMenusEntity
>
tagUser
=
menuService
.
getTagUser
(
android
,
todayUser
);
if
(
CollectionUtils
.
isNotEmpty
(
tagUser
))
{
userMenusList
.
addAll
(
tagUser
);
}
...
...
@@ -62,9 +81,36 @@ class PushMessageApplicationTests {
}
latch
.
await
();
userMenusService
.
batchInsert
(
userMenusList
);
}
catch
(
Interrupted
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
void
testConventTemplate
()
{
// String[] alias = {"kksh_10255318"};
// String[] alias = {"kksh_10131492"};
String
[]
alias
=
{
"kksh_59354"
};
String
token
=
GeTuiUtils
.
getAuthToken
(
"kk_sh_token_ge_tui"
);
MessageTemplate
messageTemplate
=
new
MessageTemplate
();
MessageTemplate
.
Settings
settings
=
new
MessageTemplate
.
Settings
();
settings
.
setTtl
(
3600000
);
messageTemplate
.
setSettings
(
settings
);
MessageTemplate
.
PushMessage
pushMessage
=
new
MessageTemplate
.
PushMessage
();
MessageTemplate
.
PushMessage
.
Notification
notification
=
new
MessageTemplate
.
PushMessage
.
Notification
();
notification
.
setTitle
(
"看看生活提醒"
);
notification
.
setBody
(
"看看生活->让领钱更简单"
);
notification
.
setClick_type
(
"url"
);
notification
.
setUrl
(
"https://www.baidu.com/"
);
notification
.
setChannel_level
(
4
);
pushMessage
.
setNotification
(
notification
);
messageTemplate
.
setPush_message
(
pushMessage
);
String
s
=
GeTuiUtils
.
singlePushAlias
(
alias
,
messageTemplate
,
token
);
System
.
out
.
println
(
s
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment