mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-15 11:35:06 +08:00
1. APP增加终端Header[terminal]
2. 订单、会员注册记录来源终端
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.common.util.servlet;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
@ -27,7 +28,7 @@ public class ServletUtils {
|
||||
* 返回 JSON 字符串
|
||||
*
|
||||
* @param response 响应
|
||||
* @param object 对象,会序列化成 JSON 字符串
|
||||
* @param object 对象,会序列化成 JSON 字符串
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码
|
||||
public static void writeJSON(HttpServletResponse response, Object object) {
|
||||
@ -40,7 +41,7 @@ public class ServletUtils {
|
||||
*
|
||||
* @param response 响应
|
||||
* @param filename 文件名
|
||||
* @param content 附件内容
|
||||
* @param content 附件内容
|
||||
*/
|
||||
public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException {
|
||||
// 设置 header 和 contentType
|
||||
@ -88,6 +89,18 @@ public class ServletUtils {
|
||||
return ServletUtil.getClientIP(request);
|
||||
}
|
||||
|
||||
public static Integer getTerminal() {
|
||||
return getHeaderInt("terminal");
|
||||
}
|
||||
|
||||
public static String getHeader(String header) {
|
||||
return getHeader(getRequest(), header);
|
||||
}
|
||||
|
||||
public static Integer getHeaderInt(String header) {
|
||||
return Convert.toInt(getHeader(header));
|
||||
}
|
||||
|
||||
public static boolean isJsonRequest(ServletRequest request) {
|
||||
return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
@ -107,4 +120,12 @@ public class ServletUtils {
|
||||
public static Map<String, String> getParamMap(HttpServletRequest request) {
|
||||
return ServletUtil.getParamMap(request);
|
||||
}
|
||||
|
||||
public static String getHeader(HttpServletRequest request, String header) {
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
return request.getHeader(header);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user