Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
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
徐少华
midjourney-proxy
Commits
c327e35a
Commit
c327e35a
authored
Feb 05, 2020
by
桂前礼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished append wxid
parent
bfc1fdc2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
3 deletions
+60
-3
BookKeywordBiz.java
...ain/java/com/pcloud/book/keywords/biz/BookKeywordBiz.java
+10
-0
BookKeywordBizImpl.java
...com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
+50
-3
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/BookKeywordBiz.java
View file @
c327e35a
...
...
@@ -12,6 +12,7 @@ import com.pcloud.wechatgroup.message.dto.SendTextDTO;
import
com.sdk.wxgroup.SendMessageTypeEnum
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author lily
...
...
@@ -135,4 +136,13 @@ public interface BookKeywordBiz {
* 按照书处理暗号回复,推送资源
*/
void
dealByBookGroup
(
SendTextDTO
sendTextDTO
,
Long
bookGroupId
,
Boolean
isPushUpdate
);
/**
* 对文本中的URL进行参数拼接
* @param content 文本
* @param map 参数集合
* @return 拼接后的URL
*/
String
appendUrlParams
(
String
content
,
Map
<
String
,
String
>
map
);
}
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
View file @
c327e35a
package
com
.
pcloud
.
book
.
keywords
.
biz
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.pcloud.appcenter.app.dto.AppDto
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.book.biz.BookKeywordWarehouseBiz
;
import
com.pcloud.book.book.dto.BookGuideDelayDto
;
import
com.pcloud.book.consumer.app.AppConsr
;
import
com.pcloud.book.consumer.channel.QrcodeSceneConsr
;
import
com.pcloud.book.consumer.content.ResourceConsr
;
...
...
@@ -67,6 +65,7 @@ import com.pcloud.channelcenter.qrcode.vo.MessageBookVO;
import
com.pcloud.channelcenter.qrcode.vo.QrWeixinParamVO
;
import
com.pcloud.channelcenter.wechat.dto.AccountSettingDto
;
import
com.pcloud.common.constant.CacheConstant
;
import
com.pcloud.common.constant.UrlConstant
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
...
...
@@ -112,7 +111,10 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -615,7 +617,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
Integer
type
=
keywordReply
.
getType
();
if
(
ReplyTypeEnum
.
TEXT
.
value
.
equals
(
type
))
{
SendTextMessageVO
sendTextMessageVO
=
new
SendTextMessageVO
();
sendTextMessageVO
.
setContent
(
keywordReply
.
getContent
());
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"wxId"
,
userWxId
);
paramMap
.
put
(
"robotWxId"
,
robotId
);
sendTextMessageVO
.
setContent
(
appendUrlParams
(
keywordReply
.
getContent
(),
paramMap
));
sendTextMessageVO
.
setAltId
(
robotId
);
sendTextMessageVO
.
setWxGroupId
(
userWxId
);
sendTextMessageVO
.
setIp
(
ip
);
...
...
@@ -718,6 +723,48 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
}
}
/**
* 关键词 补充wxid
*/
public
String
appendUrlParams
(
String
content
,
Map
<
String
,
String
>
map
)
{
String
suffix
=
appendParams
(
map
);
Pattern
pattern
=
Pattern
.
compile
(
"(https?)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
while
(
matcher
.
find
())
{
String
group
=
matcher
.
group
();
if
(
StringUtil
.
isEmpty
(
group
))
{
continue
;
}
// 短链接
if
(
group
.
startsWith
(
"https://s.5rs.me/"
)
&&
group
.
length
()
==
24
)
{
String
hex
=
group
.
replaceAll
(
UrlConstant
.
OWN_SHORT_URL
,
""
);
String
originLink
=
UrlUtils
.
getUrl4Own
(
hex
);
if
(!
StringUtil
.
isEmpty
(
originLink
)
&&
originLink
.
contains
(
"?"
))
{
content
=
content
.
replace
(
group
,
UrlUtils
.
getShortUrl
(
originLink
+
"&"
+
suffix
));
}
else
if
(!
StringUtil
.
isEmpty
(
originLink
)
&&
!
originLink
.
contains
(
"?"
))
{
content
=
content
.
replace
(
group
,
UrlUtils
.
getShortUrl
(
originLink
+
"?"
+
suffix
));
}
}
if
(
group
.
contains
(
"?"
))
{
content
=
content
.
replace
(
group
,
UrlUtils
.
getShortUrl
(
group
+
"&"
+
suffix
));
}
else
{
content
=
content
.
replace
(
group
,
UrlUtils
.
getShortUrl
(
group
+
"?"
+
suffix
));
}
}
return
content
;
}
private
String
appendParams
(
Map
<
String
,
String
>
map
)
{
Set
<
String
>
keys
=
map
.
keySet
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
key
:
keys
)
{
sb
.
append
(
"&"
).
append
(
key
).
append
(
"="
).
append
(
map
.
get
(
key
));
}
return
sb
.
toString
().
replaceFirst
(
"&"
,
""
);
}
@ParamLog
(
"获取的关键词是否为社群书的简称"
)
private
void
dealSelfShortBookName
(
SendTextDTO
sendTextDTO
)
{
String
content
=
sendTextDTO
.
getTextContent
();
...
...
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