Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
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 50386d7d
authored
Dec 25, 2020
by
水库浪子
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
https://gitee.com/LinkWeChat/link-wechat
2 parents
f9817cab
77943d6d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
33 deletions
linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java
linkwe-framework/pom.xml
linkwe-ui/src/views/drainageCode/staff/add.vue
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMediaClient.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/factory/impl/WeEventChangeExternalContactImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeAccessTokenInterceptor.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMaterialServiceImpl.java
pom.xml
linkwe-common/src/main/java/com/tencent/wework/FinanceUtils.java
View file @
50386d7
...
...
@@ -19,6 +19,7 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
/**
* @author sxw
...
...
@@ -82,6 +83,27 @@ public class FinanceUtils {
JSONObject
jsonObject
=
decryptChatRecord
(
sdk
,
data
.
getString
(
"encrypt_random_key"
),
data
.
getString
(
"encrypt_chat_msg"
),
privateKey
);
jsonObject
.
put
(
"seq"
,
LocalSEQ
);
jsonObject
.
put
(
"totype"
,
"0"
);
if
(
StringUtils
.
isEmpty
(
jsonObject
.
getString
(
"roomid"
))){
JSONArray
tolist
=
jsonObject
.
getJSONArray
(
"tolist"
);
Optional
.
ofNullable
(
tolist
).
ifPresent
(
itemList
->{
List
<
String
>
isEType
=
itemList
.
stream
().
map
(
item
->
(
String
)
item
).
filter
(
item
->
StringUtils
.
isNotEmpty
(
item
)
&&
(
"wo"
.
equals
(
item
.
substring
(
0
,
2
))
||
"wm"
.
equals
(
item
.
substring
(
0
,
2
))))
.
collect
(
Collectors
.
toList
());
List
<
String
>
isExtype
=
itemList
.
stream
().
map
(
item
->
(
String
)
item
).
filter
(
item
->
StringUtils
.
isNotEmpty
(
item
)
&&
"wb"
.
equals
(
item
.
substring
(
0
,
2
)))
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isNotEmpty
(
isEType
)){
jsonObject
.
put
(
"totype"
,
"1"
);
return
;
}
if
(
CollectionUtil
.
isNotEmpty
(
isExtype
)){
jsonObject
.
put
(
"totype"
,
"2"
);
return
;
}
});
}
elasticSearchEntity
.
setData
(
jsonObject
);
elasticSearchEntity
.
setId
(
jsonObject
.
getString
(
"msgid"
));
resList
.
add
(
elasticSearchEntity
);
...
...
@@ -94,16 +116,6 @@ public class FinanceUtils {
return
resList
;
}
public
static
void
main
(
String
[]
args
)
{
String
secret
=
"_Ruv_TD_GzE4wJLvhMv4MeYkjM81_IJFDPcsUiss9fw"
;
initSDK
(
"ww24262ce93851488f"
,
secret
);
//getChatData(0,"","");
// getMediaData("CiBkZDk3ZmJjMTlhYjU1YWJiNDQ4MjI3NWRlMzk1NmMzYxI4TkRkZk56ZzRNVE13TURVNU5Ua3lOVFEyTlY4NU5ERTBOekUwTWpaZk1UWXdOemt4TkRrMU1BPT0aIDBiMzY3YjkyNzE5ZDE3ZWU4NjkyNTVlYzJkNTlmNjI3",
// "", "", "");
}
/**
* @param sdk 初始化时候获取到的值
* @param ncrypt_random_key 企业微信返回的随机密钥
...
...
linkwe-framework/pom.xml
View file @
50386d7
...
...
@@ -56,11 +56,13 @@
<dependency>
<groupId>
net.java.dev.jna
</groupId>
<artifactId>
jna
</artifactId>
<version>
5.6.0
</version>
</dependency>
<dependency>
<groupId>
net.java.dev.jna
</groupId>
<artifactId>
jna-platform
</artifactId>
<version>
5.6.0
</version>
</dependency>
<!-- 系统模块-->
...
...
linkwe-ui/src/views/drainageCode/staff/add.vue
View file @
50386d7
...
...
@@ -41,7 +41,7 @@ export default {
this
.
loading
=
true
getDetail
(
id
).
then
(({
data
})
=>
{
this
.
form
=
data
this
.
materialSelected
=
data
.
weMaterial
.
materialUrl
this
.
materialSelected
=
data
.
weMaterial
==
null
?
""
:
data
.
weMaterial
.
materialUrl
this
.
loading
=
false
})
},
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMediaClient.java
View file @
50386d7
...
...
@@ -6,6 +6,7 @@ import com.dtflys.forest.annotation.Query;
import
com.linkwechat.wecom.domain.dto.WeMediaDto
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.InputStream
;
/**
...
...
@@ -18,12 +19,12 @@ public interface WeMediaClient {
/**
* 上传临时素材
* @param
multipartF
ile
* @param
f
ile
* @param type
* @return
*/
@Post
(
url
=
"/media/upload"
)
WeMediaDto
upload
(
@DataFile
(
value
=
"
file"
)
MultipartFile
multipartF
ile
,
@Query
(
"type"
)
String
type
);
WeMediaDto
upload
(
@DataFile
(
value
=
"
media"
)
File
f
ile
,
@Query
(
"type"
)
String
type
);
/**
* 上传图片
...
...
@@ -40,6 +41,6 @@ public interface WeMediaClient {
* 使用byte数组和Inputstream对象时一定要定义fileName属性
*/
@Post
(
url
=
"/media/upload"
)
WeMediaDto
upload
(
@DataFile
(
value
=
"
file"
,
fileName
=
"${1}"
)
InputStream
in
,
String
filename
,
@Query
(
"type"
)
String
type
);
WeMediaDto
upload
(
@DataFile
(
value
=
"
media"
,
fileName
=
"${1}"
)
InputStream
file
,
String
filename
,
@Query
(
"type"
)
String
type
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/factory/impl/WeEventChangeExternalContactImpl.java
View file @
50386d7
...
...
@@ -181,7 +181,7 @@ public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory
}
if
(
StringUtils
.
isNotEmpty
(
messageMap
.
getCategoryId
())){
WeMediaDto
weMediaDto
=
weMaterialService
.
uploadTemporaryMaterial
(
messageMap
.
getMaterialUrl
(),
MediaType
.
IMAGE
.
getMediaType
());
.
uploadTemporaryMaterial
(
messageMap
.
getMaterialUrl
(),
messageMap
.
getMaterialName
(),
MediaType
.
IMAGE
.
getMediaType
());
Optional
.
ofNullable
(
weMediaDto
).
ifPresent
(
media
->{
weWelcomeMsgBuilder
.
image
(
WeWelcomeMsg
.
Image
.
builder
().
media_id
(
media
.
getMedia_id
())
.
pic_url
(
media
.
getUrl
()).
build
());
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeAccessTokenInterceptor.java
View file @
50386d7
...
...
@@ -5,6 +5,7 @@ import com.dtflys.forest.exceptions.ForestRuntimeException;
import
com.dtflys.forest.http.ForestRequest
;
import
com.dtflys.forest.http.ForestResponse
;
import
com.dtflys.forest.interceptor.Interceptor
;
import
com.dtflys.forest.multipart.ForestMultipart
;
import
com.dtflys.forest.utils.ForestDataType
;
import
com.linkwechat.common.config.WeComeConfig
;
import
com.linkwechat.common.constant.WeConstans
;
...
...
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @description: 微信token拦截器
...
...
@@ -38,16 +40,15 @@ public class WeAccessTokenInterceptor implements Interceptor{
*/
@Override
public
boolean
beforeExecute
(
ForestRequest
request
)
{
request
.
setDataType
(
ForestDataType
.
JSON
);
String
uri
=
request
.
getUrl
().
replace
(
"http://"
,
""
);
request
.
setContentType
(
"application/json"
);
// if(Arrays.asList(weComeConfig.getFileUplodUrl()).contains(uri)){
// request.setContentType("application/json");
// }else{
// request.setContentType("multipart/form-data");
// }
//request.setContentType("application/json");
if
(!
Arrays
.
asList
(
weComeConfig
.
getFileUplodUrl
()).
contains
(
uri
)){
request
.
setDataType
(
ForestDataType
.
JSON
);
request
.
setContentType
(
"application/json"
);
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMaterialServiceImpl.java
View file @
50386d7
...
...
@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.config.ServerConfig
;
import
com.linkwechat.common.constant.WeConstans
;
...
...
@@ -17,9 +18,19 @@ import com.linkwechat.wecom.domain.vo.WeMaterialFileVO;
import
com.linkwechat.wecom.mapper.WeMaterialMapper
;
import
com.linkwechat.wecom.service.IWeMaterialService
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.error.WxError
;
import
me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.fileupload.FileItemFactory
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.mime.HttpMultipartMode
;
import
org.apache.http.entity.mime.MultipartEntityBuilder
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.mock.web.MockMultipartFile
;
...
...
@@ -135,32 +146,30 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
public
WeMediaDto
uploadTemporaryMaterial
(
String
url
,
String
type
)
{
try
{
File
file
=
new
File
(
url
);
FileItemFactory
factory
=
new
DiskFileItemFactory
(
16
,
null
);
FileItem
item
=
factory
.
createItem
(
file
.
getName
(),
"text/plain"
,
true
,
file
.
getName
());
MultipartFile
multipartFile
=
new
CommonsMultipartFile
(
item
);
return
weMediaClient
.
upload
(
multipartFile
,
type
);
return
weMediaClient
.
upload
(
file
,
type
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"上传临时文件失败......url:{},type:{},ex:{},st:{}"
,
url
,
type
,
e
.
getMessage
(),
e
.
getStackTrace
());
}
return
null
;
}
@Override
public
WeMediaDto
uploadTemporaryMaterial
(
String
url
,
String
type
,
String
name
)
{
HttpURLConnection
conn
=
null
;
try
{
URL
materialUrl
=
new
URL
(
url
);
conn
=
(
HttpURLConnection
)
materialUrl
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
// conn.setConnectTimeout(20 * 1000);
InputStream
inputStream
=
conn
.
getInputStream
();
return
weMediaClient
.
upload
(
inputStream
,
name
,
type
);
conn
.
setConnectTimeout
(
20
*
1000
);
return
weMediaClient
.
upload
(
conn
.
getInputStream
(),
name
,
type
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
log
.
error
(
"上传临时文件失败......url:{},type:{},name:{},ex:{},st:{}"
,
url
,
type
,
name
,
e
.
getMessage
(),
e
.
getStackTrace
());
}
finally
{
if
(
conn
!=
null
){
conn
=
null
;
}
}
return
null
;
}
...
...
pom.xml
View file @
50386d7
...
...
@@ -13,7 +13,7 @@
<description>
若依管理系统
</description>
<properties>
<springboot.vaerion>
2.
2.1
.RELEASE
</springboot.vaerion>
<springboot.vaerion>
2.
3.7
.RELEASE
</springboot.vaerion>
<linkwe.version>
3.1.0
</linkwe.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
...
...
@@ -31,7 +31,7 @@
<poi.version>
3.17
</poi.version>
<velocity.version>
1.7
</velocity.version>
<jwt.version>
0.9.0
</jwt.version>
<forest.version>
1.
4.0
</forest.version>
<forest.version>
1.
5.0-RC1
</forest.version>
<lombok.version>
1.18.16
</lombok.version>
<reflectasm.version>
1.11.9
</reflectasm.version>
<hutool.version>
5.4.1
</hutool.version>
...
...
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