正在显示
4 个修改的文件
包含
31 行增加
和
13 行删除
| @@ -21,6 +21,7 @@ import org.slf4j.Logger; | @@ -21,6 +21,7 @@ import org.slf4j.Logger; | ||
| 21 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
| 22 | import com.ruoyi.common.constant.Constants; | 22 | import com.ruoyi.common.constant.Constants; |
| 23 | import com.ruoyi.common.utils.StringUtils; | 23 | import com.ruoyi.common.utils.StringUtils; |
| 24 | +import org.springframework.http.MediaType; | ||
| 24 | 25 | ||
| 25 | /** | 26 | /** |
| 26 | * 通用http发送方法 | 27 | * 通用http发送方法 |
| @@ -126,6 +127,19 @@ public class HttpUtils | @@ -126,6 +127,19 @@ public class HttpUtils | ||
| 126 | */ | 127 | */ |
| 127 | public static String sendPost(String url, String param) | 128 | public static String sendPost(String url, String param) |
| 128 | { | 129 | { |
| 130 | + return sendPost(url, param, MediaType.APPLICATION_FORM_URLENCODED_VALUE); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * 向指定 URL 发送POST方法的请求 | ||
| 135 | + * | ||
| 136 | + * @param url 发送请求的 URL | ||
| 137 | + * @param param 请求参数 | ||
| 138 | + * @param contentType 内容类型 | ||
| 139 | + * @return 所代表远程资源的响应结果 | ||
| 140 | + */ | ||
| 141 | + public static String sendPost(String url, String param, String contentType) | ||
| 142 | + { | ||
| 129 | PrintWriter out = null; | 143 | PrintWriter out = null; |
| 130 | BufferedReader in = null; | 144 | BufferedReader in = null; |
| 131 | StringBuilder result = new StringBuilder(); | 145 | StringBuilder result = new StringBuilder(); |
| @@ -138,7 +152,7 @@ public class HttpUtils | @@ -138,7 +152,7 @@ public class HttpUtils | ||
| 138 | conn.setRequestProperty("connection", "Keep-Alive"); | 152 | conn.setRequestProperty("connection", "Keep-Alive"); |
| 139 | conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); | 153 | conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); |
| 140 | conn.setRequestProperty("Accept-Charset", "utf-8"); | 154 | conn.setRequestProperty("Accept-Charset", "utf-8"); |
| 141 | - conn.setRequestProperty("contentType", "utf-8"); | 155 | + conn.setRequestProperty("Content-Type", contentType); |
| 142 | conn.setDoOutput(true); | 156 | conn.setDoOutput(true); |
| 143 | conn.setDoInput(true); | 157 | conn.setDoInput(true); |
| 144 | out = new PrintWriter(conn.getOutputStream()); | 158 | out = new PrintWriter(conn.getOutputStream()); |
| @@ -191,6 +205,11 @@ public class HttpUtils | @@ -191,6 +205,11 @@ public class HttpUtils | ||
| 191 | 205 | ||
| 192 | public static String sendSSLPost(String url, String param) | 206 | public static String sendSSLPost(String url, String param) |
| 193 | { | 207 | { |
| 208 | + return sendSSLPost(url, param, MediaType.APPLICATION_FORM_URLENCODED_VALUE); | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + public static String sendSSLPost(String url, String param, String contentType) | ||
| 212 | + { | ||
| 194 | StringBuilder result = new StringBuilder(); | 213 | StringBuilder result = new StringBuilder(); |
| 195 | String urlNameString = url + "?" + param; | 214 | String urlNameString = url + "?" + param; |
| 196 | try | 215 | try |
| @@ -204,7 +223,7 @@ public class HttpUtils | @@ -204,7 +223,7 @@ public class HttpUtils | ||
| 204 | conn.setRequestProperty("connection", "Keep-Alive"); | 223 | conn.setRequestProperty("connection", "Keep-Alive"); |
| 205 | conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); | 224 | conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); |
| 206 | conn.setRequestProperty("Accept-Charset", "utf-8"); | 225 | conn.setRequestProperty("Accept-Charset", "utf-8"); |
| 207 | - conn.setRequestProperty("contentType", "utf-8"); | 226 | + conn.setRequestProperty("Content-Type", contentType); |
| 208 | conn.setDoOutput(true); | 227 | conn.setDoOutput(true); |
| 209 | conn.setDoInput(true); | 228 | conn.setDoInput(true); |
| 210 | 229 |
| @@ -55,7 +55,6 @@ public class ResourcesConfig implements WebMvcConfigurer | @@ -55,7 +55,6 @@ public class ResourcesConfig implements WebMvcConfigurer | ||
| 55 | public CorsFilter corsFilter() | 55 | public CorsFilter corsFilter() |
| 56 | { | 56 | { |
| 57 | CorsConfiguration config = new CorsConfiguration(); | 57 | CorsConfiguration config = new CorsConfiguration(); |
| 58 | - config.setAllowCredentials(true); | ||
| 59 | // 设置访问源地址 | 58 | // 设置访问源地址 |
| 60 | config.addAllowedOriginPattern("*"); | 59 | config.addAllowedOriginPattern("*"); |
| 61 | // 设置访问源请求头 | 60 | // 设置访问源请求头 |
| @@ -25,7 +25,7 @@ import io.jsonwebtoken.SignatureAlgorithm; | @@ -25,7 +25,7 @@ import io.jsonwebtoken.SignatureAlgorithm; | ||
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | * token验证处理 | 27 | * token验证处理 |
| 28 | - * | 28 | + * |
| 29 | * @author ruoyi | 29 | * @author ruoyi |
| 30 | */ | 30 | */ |
| 31 | @Component | 31 | @Component |
| @@ -49,14 +49,14 @@ public class TokenService | @@ -49,14 +49,14 @@ public class TokenService | ||
| 49 | 49 | ||
| 50 | protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND; | 50 | protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND; |
| 51 | 51 | ||
| 52 | - private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L; | 52 | + private static final Long MILLIS_MINUTE_TWENTY = 20 * 60 * 1000L; |
| 53 | 53 | ||
| 54 | @Autowired | 54 | @Autowired |
| 55 | private RedisCache redisCache; | 55 | private RedisCache redisCache; |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
| 58 | * 获取用户身份信息 | 58 | * 获取用户身份信息 |
| 59 | - * | 59 | + * |
| 60 | * @return 用户信息 | 60 | * @return 用户信息 |
| 61 | */ | 61 | */ |
| 62 | public LoginUser getLoginUser(HttpServletRequest request) | 62 | public LoginUser getLoginUser(HttpServletRequest request) |
| @@ -107,7 +107,7 @@ public class TokenService | @@ -107,7 +107,7 @@ public class TokenService | ||
| 107 | 107 | ||
| 108 | /** | 108 | /** |
| 109 | * 创建令牌 | 109 | * 创建令牌 |
| 110 | - * | 110 | + * |
| 111 | * @param loginUser 用户信息 | 111 | * @param loginUser 用户信息 |
| 112 | * @return 令牌 | 112 | * @return 令牌 |
| 113 | */ | 113 | */ |
| @@ -126,15 +126,15 @@ public class TokenService | @@ -126,15 +126,15 @@ public class TokenService | ||
| 126 | 126 | ||
| 127 | /** | 127 | /** |
| 128 | * 验证令牌有效期,相差不足20分钟,自动刷新缓存 | 128 | * 验证令牌有效期,相差不足20分钟,自动刷新缓存 |
| 129 | - * | ||
| 130 | - * @param loginUser | 129 | + * |
| 130 | + * @param loginUser 登录信息 | ||
| 131 | * @return 令牌 | 131 | * @return 令牌 |
| 132 | */ | 132 | */ |
| 133 | public void verifyToken(LoginUser loginUser) | 133 | public void verifyToken(LoginUser loginUser) |
| 134 | { | 134 | { |
| 135 | long expireTime = loginUser.getExpireTime(); | 135 | long expireTime = loginUser.getExpireTime(); |
| 136 | long currentTime = System.currentTimeMillis(); | 136 | long currentTime = System.currentTimeMillis(); |
| 137 | - if (expireTime - currentTime <= MILLIS_MINUTE_TEN) | 137 | + if (expireTime - currentTime <= MILLIS_MINUTE_TWENTY) |
| 138 | { | 138 | { |
| 139 | refreshToken(loginUser); | 139 | refreshToken(loginUser); |
| 140 | } | 140 | } |
| @@ -142,7 +142,7 @@ public class TokenService | @@ -142,7 +142,7 @@ public class TokenService | ||
| 142 | 142 | ||
| 143 | /** | 143 | /** |
| 144 | * 刷新令牌有效期 | 144 | * 刷新令牌有效期 |
| 145 | - * | 145 | + * |
| 146 | * @param loginUser 登录信息 | 146 | * @param loginUser 登录信息 |
| 147 | */ | 147 | */ |
| 148 | public void refreshToken(LoginUser loginUser) | 148 | public void refreshToken(LoginUser loginUser) |
| @@ -156,7 +156,7 @@ public class TokenService | @@ -156,7 +156,7 @@ public class TokenService | ||
| 156 | 156 | ||
| 157 | /** | 157 | /** |
| 158 | * 设置用户代理信息 | 158 | * 设置用户代理信息 |
| 159 | - * | 159 | + * |
| 160 | * @param loginUser 登录信息 | 160 | * @param loginUser 登录信息 |
| 161 | */ | 161 | */ |
| 162 | public void setUserAgent(LoginUser loginUser) | 162 | public void setUserAgent(LoginUser loginUser) |
| @@ -365,7 +365,7 @@ public class SysMenuServiceImpl implements ISysMenuService | @@ -365,7 +365,7 @@ public class SysMenuServiceImpl implements ISysMenuService | ||
| 365 | /** | 365 | /** |
| 366 | * 获取路由名称,如没有配置路由名称则取路由地址 | 366 | * 获取路由名称,如没有配置路由名称则取路由地址 |
| 367 | * | 367 | * |
| 368 | - * @param routerName 路由名称 | 368 | + * @param name 路由名称 |
| 369 | * @param path 路由地址 | 369 | * @param path 路由地址 |
| 370 | * @return 路由名称(驼峰格式) | 370 | * @return 路由名称(驼峰格式) |
| 371 | */ | 371 | */ |
-
请 注册 或 登录 后发表评论