From 19244eb61f00e442d754e42db1aa23f690ad644f Mon Sep 17 00:00:00 2001 From: qi Date: Tue, 31 Mar 2020 09:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lq/cms/emun/FileTypeEnum.java | 6 ++++ .../service/impl/SysUserRoleServiceImpl.java | 2 +- .../java/com/lq/code/util/HttpsClient.java | 33 +++++++++++-------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/lq/cms/emun/FileTypeEnum.java b/src/main/java/com/lq/cms/emun/FileTypeEnum.java index e345fe9..ab4b7fb 100755 --- a/src/main/java/com/lq/cms/emun/FileTypeEnum.java +++ b/src/main/java/com/lq/cms/emun/FileTypeEnum.java @@ -2,11 +2,17 @@ package com.lq.cms.emun; /** * Created by qi_liang on 2018/4/1. + * @author qi + * 文件类型枚举 */ public enum FileTypeEnum { + //图片类型 FILE_TYPE_IMAGE("IMAGE","图片"), + //视频类型 FILE_TYPE_VIEDO("VIEDO","视频"), + //pdf类型 FILE_TYPE_PDF("PDF","电子书"), + //其他类型 FILE_TYPE_OTHER("OTHER","其他") ; diff --git a/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java b/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java index ea5ffc4..b57dfb2 100755 --- a/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/SysUserRoleServiceImpl.java @@ -54,7 +54,7 @@ public class SysUserRoleServiceImpl implements SysUserRoleService { } public SysUserRole findByRoleIdAndUserId(Long userId,Long roleId){ - Map map=new HashMap(); + Map map=new HashMap(2); map.put("userId",userId); map.put("roleId",roleId); List list=sysUserRoleDao.findByUserIdAndRoleId(map); diff --git a/src/main/java/com/lq/code/util/HttpsClient.java b/src/main/java/com/lq/code/util/HttpsClient.java index 0c2a874..42b4b4f 100755 --- a/src/main/java/com/lq/code/util/HttpsClient.java +++ b/src/main/java/com/lq/code/util/HttpsClient.java @@ -5,6 +5,7 @@ import org.apache.http.HttpEntity; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.HttpMultipartMode; @@ -68,9 +69,11 @@ public class HttpsClient { context); // 建立连接器 client = HttpClients.custom() - .setSSLSocketFactory(factory).build(); + .setSSLSocketFactory(factory).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); + // 得到一个post请求的实体 - HttpPost post = getMultipartPost(url, boundary); + HttpPost post = getMultipartPost(url, boundary); + // 给请求添加参数 post.setEntity(he); // 执行请求并获得结果 @@ -152,17 +155,21 @@ public class HttpsClient { return context; } - public static void main(String[] args) throws IOException { - File file =new File("/Users/qi_liang/Downloads/timg.jpeg"); - String url = "https://api.weixin.qq.com/cgi-bin/media/upload"; - Map params = new HashMap(); - params.put("access_token", "10_0oKKCsF9JL30JeGZDyfNWDhiaRvivAL9vs9ihvaledzBuPVM6IMvwcFUc58AFwlETRdvEBAFXOYbF2GoKmbtMmopCs78m9UE8whgrYU4kJww4mSooMcq8el-qnU4JdjPGKruZLjdNS246hXyWOHbAAAHZS"); - params.put("type", "image"); - if(file.exists()){ - params.put("media", file); - } - String resultStr = post(url,params); - System.out.println(resultStr); +// public static void main(String[] args) throws IOException { +// File file =new File("/Users/qi_liang/Downloads/timg.jpeg"); +// String url = "https://api.weixin.qq.com/cgi-bin/media/upload"; +// Map params = new HashMap(); +// params.put("access_token", "10_0oKKCsF9JL30JeGZDyfNWDhiaRvivAL9vs9ihvaledzBuPVM6IMvwcFUc58AFwlETRdvEBAFXOYbF2GoKmbtMmopCs78m9UE8whgrYU4kJww4mSooMcq8el-qnU4JdjPGKruZLjdNS246hXyWOHbAAAHZS"); +// params.put("type", "image"); +// if(file.exists()){ +// params.put("media", file); +// } +// String resultStr = post(url,params); +// System.out.println(resultStr); +// } + + public static void main(String[] args) { + } }