Commit befa51aa by fudahua

gic跳转登录

parent c7bf90ba
......@@ -20,6 +20,8 @@ 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;
......@@ -187,9 +189,9 @@ public void sendMessage() {
@Test
public void extensionList2() {
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());
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));
}
......@@ -201,7 +203,7 @@ public void sendMessage() {
// JSONResponse response = qywxSuiteApiService.uploadMedia("ww9ede832a84b7ae5f", "ww2c34dc56739bb105", aByte, QywxMediaTypeEnum.IMAGE.getCode());
// System.out.println(JSONObject.toJSONString(response));
QywxImageExternalMessageDTO messageDTO=new QywxImageExternalMessageDTO();
messageDTO.setMediaId("3U5qDJRn46ZPUCQk3h2-7iqESryRICPLv6XHFEGy0r7MIJMVNkzpDjpPOo6k-R2uB");
messageDTO.setMediaId("msg59NLDQAANPwzc9aMWNCBky8EElovyg");
messageDTO.setSenderUserId("9ae4c4f1277340a186b16a17d937c72c");
List<String> list=new ArrayList<>();
list.add("wm59NLDQAAL0fHb-QEbx-U9pdtRFA1bg");
......@@ -252,4 +254,30 @@ public void sendMessage() {
}
}
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 cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.api.dto.SyncSingleDealDTO;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Setest {
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Test
public void test() {
Map<String,String> ret=new HashMap<>();
ret.put("test","test");
ret.put("name","name11");
AES aes = SecureUtil.aes("test111111111113".getBytes());
String code = aes.encryptHex(JSONObject.toJSONString(ret));
System.out.println(code);
String str = aes.decryptStr(code);
System.out.println(str);
}
}
package com.gic.haoban.manage.web.controller;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
......@@ -45,6 +47,9 @@ import javax.servlet.http.HttpServletResponse;
public class LoginController extends WebBaseController{
private static Logger logger= LoggerFactory.getLogger(LoginController.class);
private static final String LOGIN_KEY="haoban#login$key";
@Autowired
StaffApiService staffApiService;
......@@ -145,7 +150,8 @@ public class LoginController extends WebBaseController{
@RequestMapping("gic-login")
public HaobanResponse ywLogin(String random,HttpServletResponse response) {
//判断是否存在random
String o = (String) RedisUtil.getCache(random);
AES aes = SecureUtil.aes(LOGIN_KEY.getBytes());
String o = aes.decryptStr(random);
if(o == null){
return resultResponse(HaoBanErrCode.ERR_4);
}
......@@ -157,6 +163,7 @@ public class LoginController extends WebBaseController{
logger.info("登录用户不存在!");
return resultResponse(HaoBanErrCode.ERR_6);
}
SecureUtil.aes()
//TODO 获取超级管理员账号接口
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(detailDTO.getWxEnterpriseId(), "86", loginPhoneNumber);
if (null == staff) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment