Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
1
Merge Requests
1
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
haoban3.0
haoban-manage3.0
Commits
4e486e8d
Commit
4e486e8d
authored
May 21, 2020
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gic跳转登录
parent
64a8c58b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
302 additions
and
284 deletions
+302
-284
WxEnterpriseRelatedMapper.xml
...e/src/main/resources/mapper/WxEnterpriseRelatedMapper.xml
+2
-1
ServiceTest.java
haoban-manage3-service/src/test/java/ServiceTest.java
+300
-283
No files found.
haoban-manage3-service/src/main/resources/mapper/WxEnterpriseRelatedMapper.xml
View file @
4e486e8d
...
...
@@ -154,7 +154,7 @@
<include
refid=
"Base_Column_List"
/>
from tab_haoban_wx_enterprise_related
where status_flag = 1
AND
update_time >
#{time}
AND
AND DATE_FORMAT(update_time,'%Y-%m-%d') =
#{time}
</select>
</mapper>
\ No newline at end of file
haoban-manage3-service/src/test/java/ServiceTest.java
View file @
4e486e8d
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.JSONResponse
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.*
;
import
com.gic.wechat.api.enums.QywxMediaTypeEnum
;
import
com.gic.wechat.api.service.qywx.QywxDepartmentApiService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath:applicationContext-conf.xml"
})
public
class
ServiceTest
{
@Autowired
private
WxEnterpriseRelatedApiService
wxEnterpriseRelatedApiService
;
@Autowired
private
QywxUserApiService
qywxUserApiService
;
@Autowired
private
QywxDepartmentApiService
qywxDepartmentApiService
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
StaffApiService
staffApiService
;
@Test
public
void
test
()
{
System
.
err
.
println
(
RedisUtil
.
getCache
(
"init-enterprise-ca66a01b79474c40b3e7c7f93daf1a3b"
));
}
// @Test
// public void test1() {
// String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000);
// JSONArray jsonArray = JSONArray.parseArray(res);
// jsonArray.forEach(o -> {
// JSONObject mid = (JSONObject) o;
// qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid")
// , mid.getString("handover_userid"), mid.getString("external_userid"));
// });
// System.out.println(res);
// }
//
// @Test
// public void test2() {
// UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong");
// userDTO.setName("空闻大师");
// userDTO.setDepartment(new Integer[]{4});
// userDTO.setMobile("17605628855");
// userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27");
// System.out.println(JSONObject.toJSONString(workWxUser));
// }
//
// @Test
// public void list() {
//
// List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f"
// , "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1);
// Iterator<DepartmentDTO> iterator = list.iterator();
//// while (iterator.hasNext()) {
//// DepartmentDTO next = iterator.next();
//// if(!next.getParentid().equals("1")) {
//// iterator.remove();
//// }
//// }
// System.out.println(JSONObject.toJSONString(list));
// }
//
@Test
public
void
addDepart
()
{
DepartmentDTO
dto
=
new
DepartmentDTO
();
dto
.
setName
(
"测试order"
);
dto
.
setOrder
(
2147484447L
);
dto
.
setParentid
(
1
);
JSONResponse
department
=
qywxDepartmentApiService
.
createSelfDepartment
(
"ww9ede832a84b7ae5f"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
,
dto
);
// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
System
.
out
.
println
(
JSONObject
.
toJSONString
(
department
));
}
//
// @Test
// public void getUser() {
// DepartmentDTO dto = new DepartmentDTO();
//// dto.set
// UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
// , "ww7d6566614055cf27", "13735457631");
//// String phonenumber = phonenumber;
//// UserDTO phonenumber = (UserDTO) useridBymobile;
// System.out.println(JSONObject.toJSONString(phonenumber));
// }
//
@Test
public
void
createSelfUser
()
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setUserid
(
"niweizhong2"
);
userDTO
.
setName
(
"空闻大师2"
);
userDTO
.
setDepartment
(
new
Integer
[]{
5072
});
userDTO
.
setMobile
(
"17605628851"
);
userDTO
.
setCorpid
(
"ww9ede832a84b7ae5f"
);
JSONResponse
workWxUser
=
qywxUserApiService
.
createSelfWorkWxUser
(
userDTO
,
"n"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
workWxUser
));
}
@Test
public
void
sendMessage
()
{
QywxXcxSendMessageDTO
messageDTO
=
new
QywxXcxSendMessageDTO
();
messageDTO
.
setAppid
(
"wx6054e7be35015afc"
);
ArrayList
<
String
>
userIDs
=
new
ArrayList
<>();
userIDs
.
add
(
"9ae4c4f1277340a186b16a17d937c72c"
);
messageDTO
.
setUserIds
(
userIDs
);
messageDTO
.
setTitle
(
"我的测试test"
);
messageDTO
.
setDescription
(
"我的测试test11111"
);
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"名称"
,
"hua"
);
// messageDTO.setItems(map);
boolean
ret
=
qywxSuiteApiService
.
sendMessage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
messageDTO
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
ret
));
}
@Test
public
void
listExternalUserid
()
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setUserid
(
"niweizhong2"
);
userDTO
.
setName
(
"空闻大师2"
);
userDTO
.
setDepartment
(
new
Integer
[]{
5072
});
userDTO
.
setMobile
(
"17605628851"
);
userDTO
.
setCorpid
(
"ww9ede832a84b7ae5f"
);
String
s
=
qywxUserApiService
.
listExternalUserid
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
"qiuwenmin"
);
System
.
out
.
println
(
s
);
}
@Test
public
void
getQrcode
()
{
UserDTO
workWxUser
=
qywxUserApiService
.
getSelfWorkWxUser
(
"ww9ede832a84b7ae5f"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
,
"lining"
);
ServiceResponse
<
String
>
qrcode
=
staffApiService
.
getStaffQrcode
(
"167442"
,
"ff8080817181d322017182737b16021f"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
qrcode
));
}
@Test
public
void
extensionList
()
{
String
s
=
qywxUserApiService
.
listSelfExternalUserid
(
"ww9ede832a84b7ae5f"
,
"01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk"
,
"de2c33f2e8924ff884e0073ca2f2f711"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
s
));
}
@Test
public
void
extensionList1
()
{
UserDTO
selfWorkWxUser
=
qywxUserApiService
.
getSelfWorkWxUser
(
"ww9ede832a84b7ae5f"
,
"65zze159pYb4ofbFsIREZ5X7d7iaZ-bWsVIQk2y5kTU"
,
"de2c33f2e8924ff884e0073ca2f2f711"
);
// String s = qywxUserApiService.listSelfExternalUserid("ww9ede832a84b7ae5f", "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", "de2c33f2e8924ff884e0073ca2f2f711");
System
.
out
.
println
(
JSONObject
.
toJSONString
(
selfWorkWxUser
));
}
@Test
public
void
extensionList2
()
{
String
img
=
"d:/test2.jpg"
;
byte
[]
aByte
=
getFileByteArray
(
new
File
(
img
));
JSONResponse
response
=
qywxSuiteApiService
.
uploadMedia
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
aByte
,
"测试文件"
,
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response
));
}
@Test
public
void
extensionList3
()
{
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
// String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
// byte[] aByte = getByte(img);
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
QywxImageExternalMessageDTO
messageDTO
=
new
QywxImageExternalMessageDTO
();
messageDTO
.
setMediaId
(
"msg59NLDQAANPwzc9aMWNCBky8EElovyg"
);
messageDTO
.
setSenderUserId
(
"9ae4c4f1277340a186b16a17d937c72c"
);
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"wm59NLDQAAL0fHb-QEbx-U9pdtRFA1bg"
);
messageDTO
.
setExternalUserid
(
list
);
JSONResponse
response1
=
qywxSuiteApiService
.
sendExternalMessage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
messageDTO
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response1
));
}
@Test
public
void
extensionList4
()
{
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
// String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
// byte[] aByte = getByte(img);
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
JSONResponse
response1
=
qywxSuiteApiService
.
resultExternalMessage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
"msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response1
));
}
private
byte
[]
getByte
(
String
strUrl
){
ByteArrayOutputStream
baos
=
null
;
try
{
URL
u
=
new
URL
(
strUrl
);
BufferedImage
image
=
ImageIO
.
read
(
u
);
//convert BufferedImage to byte array
baos
=
new
ByteArrayOutputStream
();
ImageIO
.
write
(
image
,
"jpg"
,
baos
);
baos
.
flush
();
return
baos
.
toByteArray
();
}
catch
(
Exception
e
)
{
}
finally
{
if
(
baos
!=
null
)
{
try
{
baos
.
close
();
}
catch
(
IOException
e
)
{
}
return
baos
.
toByteArray
();
}
return
null
;
}
}
public
static
byte
[]
getFileByteArray
(
File
file
)
{
long
fileSize
=
file
.
length
();
if
(
fileSize
>
Integer
.
MAX_VALUE
)
{
System
.
out
.
println
(
"file too big..."
);
return
null
;
}
byte
[]
buffer
=
null
;
try
(
FileInputStream
fi
=
new
FileInputStream
(
file
))
{
buffer
=
new
byte
[(
int
)
fileSize
];
int
offset
=
0
;
int
numRead
=
0
;
while
(
offset
<
buffer
.
length
&&
(
numRead
=
fi
.
read
(
buffer
,
offset
,
buffer
.
length
-
offset
))
>=
0
)
{
offset
+=
numRead
;
}
// 确保所有数据均被读取
if
(
offset
!=
buffer
.
length
)
{
throw
new
IOException
(
"Could not completely read file "
+
file
.
getName
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
buffer
;
}
}
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.JSONResponse
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.*
;
import
com.gic.wechat.api.enums.QywxMediaTypeEnum
;
import
com.gic.wechat.api.service.qywx.QywxDepartmentApiService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath:applicationContext-conf.xml"
})
public
class
ServiceTest
{
@Autowired
private
WxEnterpriseRelatedApiService
wxEnterpriseRelatedApiService
;
@Autowired
private
QywxUserApiService
qywxUserApiService
;
@Autowired
private
QywxDepartmentApiService
qywxDepartmentApiService
;
@Autowired
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
StaffApiService
staffApiService
;
@Test
public
void
test
()
{
System
.
err
.
println
(
RedisUtil
.
getCache
(
"init-enterprise-ca66a01b79474c40b3e7c7f93daf1a3b"
));
}
// @Test
// public void test1() {
// String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000);
// JSONArray jsonArray = JSONArray.parseArray(res);
// jsonArray.forEach(o -> {
// JSONObject mid = (JSONObject) o;
// qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid")
// , mid.getString("handover_userid"), mid.getString("external_userid"));
// });
// System.out.println(res);
// }
//
// @Test
// public void test2() {
// UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong");
// userDTO.setName("空闻大师");
// userDTO.setDepartment(new Integer[]{4});
// userDTO.setMobile("17605628855");
// userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27");
// System.out.println(JSONObject.toJSONString(workWxUser));
// }
//
// @Test
// public void list() {
//
// List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f"
// , "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1);
// Iterator<DepartmentDTO> iterator = list.iterator();
//// while (iterator.hasNext()) {
//// DepartmentDTO next = iterator.next();
//// if(!next.getParentid().equals("1")) {
//// iterator.remove();
//// }
//// }
// System.out.println(JSONObject.toJSONString(list));
// }
//
@Test
public
void
addDepart
()
{
DepartmentDTO
dto
=
new
DepartmentDTO
();
dto
.
setName
(
"测试order"
);
dto
.
setOrder
(
2147484447L
);
dto
.
setParentid
(
1
);
JSONResponse
department
=
qywxDepartmentApiService
.
createSelfDepartment
(
"ww9ede832a84b7ae5f"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
,
dto
);
// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
System
.
out
.
println
(
JSONObject
.
toJSONString
(
department
));
}
//
// @Test
// public void getUser() {
// DepartmentDTO dto = new DepartmentDTO();
//// dto.set
// UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
// , "ww7d6566614055cf27", "13735457631");
//// String phonenumber = phonenumber;
//// UserDTO phonenumber = (UserDTO) useridBymobile;
// System.out.println(JSONObject.toJSONString(phonenumber));
// }
//
@Test
public
void
createSelfUser
()
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setUserid
(
"niweizhong2"
);
userDTO
.
setName
(
"空闻大师2"
);
userDTO
.
setDepartment
(
new
Integer
[]{
5072
});
userDTO
.
setMobile
(
"17605628851"
);
userDTO
.
setCorpid
(
"ww9ede832a84b7ae5f"
);
JSONResponse
workWxUser
=
qywxUserApiService
.
createSelfWorkWxUser
(
userDTO
,
"n"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
workWxUser
));
}
@Test
public
void
sendMessage
()
{
QywxXcxSendMessageDTO
messageDTO
=
new
QywxXcxSendMessageDTO
();
messageDTO
.
setAppid
(
"wx6054e7be35015afc"
);
ArrayList
<
String
>
userIDs
=
new
ArrayList
<>();
userIDs
.
add
(
"9ae4c4f1277340a186b16a17d937c72c"
);
messageDTO
.
setUserIds
(
userIDs
);
messageDTO
.
setTitle
(
"我的测试test"
);
messageDTO
.
setDescription
(
"我的测试test11111"
);
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"名称"
,
"hua"
);
// messageDTO.setItems(map);
boolean
ret
=
qywxSuiteApiService
.
sendMessage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
messageDTO
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
ret
));
}
@Test
public
void
listExternalUserid
()
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setUserid
(
"niweizhong2"
);
userDTO
.
setName
(
"空闻大师2"
);
userDTO
.
setDepartment
(
new
Integer
[]{
5072
});
userDTO
.
setMobile
(
"17605628851"
);
userDTO
.
setCorpid
(
"ww9ede832a84b7ae5f"
);
String
s
=
qywxUserApiService
.
listExternalUserid
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
"qiuwenmin"
);
System
.
out
.
println
(
s
);
}
@Test
public
void
getQrcode
()
{
UserDTO
workWxUser
=
qywxUserApiService
.
getSelfWorkWxUser
(
"ww9ede832a84b7ae5f"
,
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8"
,
"lining"
);
ServiceResponse
<
String
>
qrcode
=
staffApiService
.
getStaffQrcode
(
"167442"
,
"ff8080817181d322017182737b16021f"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
qrcode
));
}
@Test
public
void
extensionList
()
{
String
s
=
qywxUserApiService
.
listSelfExternalUserid
(
"ww9ede832a84b7ae5f"
,
"01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk"
,
"de2c33f2e8924ff884e0073ca2f2f711"
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
s
));
}
@Test
public
void
extensionList1
()
{
UserDTO
selfWorkWxUser
=
qywxUserApiService
.
getSelfWorkWxUser
(
"ww9ede832a84b7ae5f"
,
"65zze159pYb4ofbFsIREZ5X7d7iaZ-bWsVIQk2y5kTU"
,
"de2c33f2e8924ff884e0073ca2f2f711"
);
// String s = qywxUserApiService.listSelfExternalUserid("ww9ede832a84b7ae5f", "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", "de2c33f2e8924ff884e0073ca2f2f711");
System
.
out
.
println
(
JSONObject
.
toJSONString
(
selfWorkWxUser
));
}
@Test
public
void
extensionList2
()
{
String
img
=
"d:/test2.jpg"
;
byte
[]
aByte
=
getFileByteArray
(
new
File
(
img
));
JSONResponse
response
=
qywxSuiteApiService
.
uploadMedia
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
aByte
,
"测试文件"
,
QywxMediaTypeEnum
.
IMAGE
.
getCode
());
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response
));
}
@Test
public
void
extensionList3
()
{
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
// String img="https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106";
// byte[] aByte = getByte(img);
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
QywxImageExternalMessageDTO
messageDTO
=
new
QywxImageExternalMessageDTO
();
messageDTO
.
setMediaId
(
"msg59NLDQAANPwzc9aMWNCBky8EElovyg"
);
messageDTO
.
setSenderUserId
(
"9ae4c4f1277340a186b16a17d937c72c"
);
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"wm59NLDQAAL0fHb-QEbx-U9pdtRFA1bg"
);
messageDTO
.
setExternalUserid
(
list
);
JSONResponse
response1
=
qywxSuiteApiService
.
sendExternalMessage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
messageDTO
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response1
));
}
@Test
public
void
extensionList4
()
{
// msg59NLDQAAKvRi-fguFcKRVOjeoJKRJw
String
img
=
"https://pic01-10001430.image.myqcloud.com/53205d69-01f1-4706-a258-014d59d8d106"
;
byte
[]
aByte
=
getByte
(
img
);
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
JSONResponse
response1
=
qywxSuiteApiService
.
uploadImage
(
"ww9ede832a84b7ae5f"
,
"ww2c34dc56739bb105"
,
aByte
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
response1
));
}
@Test
public
void
redis
()
{
long
key
=
111
;
RedisUtil
.
setCache
(
"test-key-11"
,
key
);
Long
key2
=
111L
;
RedisUtil
.
setCache
(
"test-key-112"
,
key2
);
RedisUtil
.
setCache
(
"test-key-113"
,
1
);
int
ke22y
=
22
;
RedisUtil
.
setCache
(
"test-key-115"
,
ke22y
);
RedisUtil
.
setCache
(
"test-key-114"
,
"1"
);
}
private
byte
[]
getByte
(
String
strUrl
){
ByteArrayOutputStream
baos
=
null
;
try
{
URL
u
=
new
URL
(
strUrl
);
BufferedImage
image
=
ImageIO
.
read
(
u
);
//convert BufferedImage to byte array
baos
=
new
ByteArrayOutputStream
();
ImageIO
.
write
(
image
,
"jpg"
,
baos
);
baos
.
flush
();
return
baos
.
toByteArray
();
}
catch
(
Exception
e
)
{
}
finally
{
if
(
baos
!=
null
)
{
try
{
baos
.
close
();
}
catch
(
IOException
e
)
{
}
return
baos
.
toByteArray
();
}
return
null
;
}
}
public
static
byte
[]
getFileByteArray
(
File
file
)
{
long
fileSize
=
file
.
length
();
if
(
fileSize
>
Integer
.
MAX_VALUE
)
{
System
.
out
.
println
(
"file too big..."
);
return
null
;
}
byte
[]
buffer
=
null
;
try
(
FileInputStream
fi
=
new
FileInputStream
(
file
))
{
buffer
=
new
byte
[(
int
)
fileSize
];
int
offset
=
0
;
int
numRead
=
0
;
while
(
offset
<
buffer
.
length
&&
(
numRead
=
fi
.
read
(
buffer
,
offset
,
buffer
.
length
-
offset
))
>=
0
)
{
offset
+=
numRead
;
}
// 确保所有数据均被读取
if
(
offset
!=
buffer
.
length
)
{
throw
new
IOException
(
"Could not completely read file "
+
file
.
getName
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
buffer
;
}
}
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