From a0bed51d966ab5d161d3fdd5423ba84f59fb60ff Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期四, 13 一月 2022 09:58:16 +0800 Subject: [PATCH] update 格式化代码 统一间隔符 --- ruoyi-extend/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java | 164 +++++++++++++++++++++++++++--------------------------- 1 files changed, 82 insertions(+), 82 deletions(-) diff --git a/ruoyi-extend/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java b/ruoyi-extend/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java index a1523aa..297e97a 100644 --- a/ruoyi-extend/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java +++ b/ruoyi-extend/ruoyi-xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java @@ -11,88 +11,88 @@ */ public class CookieUtil { - // 榛樿缂撳瓨鏃堕棿,鍗曚綅/绉�, 2H - private static final int COOKIE_MAX_AGE = Integer.MAX_VALUE; - // 淇濆瓨璺緞,鏍硅矾寰� - private static final String COOKIE_PATH = "/"; - - /** - * 淇濆瓨 - * - * @param response - * @param key - * @param value - * @param ifRemember - */ - public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) { - int age = ifRemember?COOKIE_MAX_AGE:-1; - set(response, key, value, null, COOKIE_PATH, age, true); - } + // 榛樿缂撳瓨鏃堕棿,鍗曚綅/绉�, 2H + private static final int COOKIE_MAX_AGE = Integer.MAX_VALUE; + // 淇濆瓨璺緞,鏍硅矾寰� + private static final String COOKIE_PATH = "/"; - /** - * 淇濆瓨 - * - * @param response - * @param key - * @param value - * @param maxAge - */ - private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) { - Cookie cookie = new Cookie(key, value); - if (domain != null) { - cookie.setDomain(domain); - } - cookie.setPath(path); - cookie.setMaxAge(maxAge); - cookie.setHttpOnly(isHttpOnly); - response.addCookie(cookie); - } - - /** - * 鏌ヨvalue - * - * @param request - * @param key - * @return - */ - public static String getValue(HttpServletRequest request, String key) { - Cookie cookie = get(request, key); - if (cookie != null) { - return cookie.getValue(); - } - return null; - } + /** + * 淇濆瓨 + * + * @param response + * @param key + * @param value + * @param ifRemember + */ + public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) { + int age = ifRemember ? COOKIE_MAX_AGE : -1; + set(response, key, value, null, COOKIE_PATH, age, true); + } - /** - * 鏌ヨCookie - * - * @param request - * @param key - */ - private static Cookie get(HttpServletRequest request, String key) { - Cookie[] arr_cookie = request.getCookies(); - if (arr_cookie != null && arr_cookie.length > 0) { - for (Cookie cookie : arr_cookie) { - if (cookie.getName().equals(key)) { - return cookie; - } - } - } - return null; - } - - /** - * 鍒犻櫎Cookie - * - * @param request - * @param response - * @param key - */ - public static void remove(HttpServletRequest request, HttpServletResponse response, String key) { - Cookie cookie = get(request, key); - if (cookie != null) { - set(response, key, "", null, COOKIE_PATH, 0, true); - } - } + /** + * 淇濆瓨 + * + * @param response + * @param key + * @param value + * @param maxAge + */ + private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) { + Cookie cookie = new Cookie(key, value); + if (domain != null) { + cookie.setDomain(domain); + } + cookie.setPath(path); + cookie.setMaxAge(maxAge); + cookie.setHttpOnly(isHttpOnly); + response.addCookie(cookie); + } -} \ No newline at end of file + /** + * 鏌ヨvalue + * + * @param request + * @param key + * @return + */ + public static String getValue(HttpServletRequest request, String key) { + Cookie cookie = get(request, key); + if (cookie != null) { + return cookie.getValue(); + } + return null; + } + + /** + * 鏌ヨCookie + * + * @param request + * @param key + */ + private static Cookie get(HttpServletRequest request, String key) { + Cookie[] arr_cookie = request.getCookies(); + if (arr_cookie != null && arr_cookie.length > 0) { + for (Cookie cookie : arr_cookie) { + if (cookie.getName().equals(key)) { + return cookie; + } + } + } + return null; + } + + /** + * 鍒犻櫎Cookie + * + * @param request + * @param response + * @param key + */ + public static void remove(HttpServletRequest request, HttpServletResponse response, String key) { + Cookie cookie = get(request, key); + if (cookie != null) { + set(response, key, "" , null, COOKIE_PATH, 0, true); + } + } + +} -- Gitblit v1.9.3