| | |
| | | package com.se.simu.helper; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | |
| | | |
| | | /** |
| | | * 获取主机IP |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getHostIp() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 输出str至前端 |
| | | * 输出JSON至页面 |
| | | */ |
| | | public static boolean writeJson2Page(HttpServletResponse res, HttpStatus status, String str) { |
| | | res.setStatus(status.value()); |
| | | |
| | | Map<String, Object> map = new HashMap(2); |
| | | map.put("code", status.value() >= 400 ? -1 : 0); |
| | | map.put("msg", str); |
| | | |
| | | return writeStr2Page(res, JSON.toJSONString(map)); |
| | | } |
| | | |
| | | /** |
| | | * 输出str至页面 |
| | | */ |
| | | public static boolean writeStr2Page(HttpServletResponse res, HttpStatus status, String str) { |
| | | res.setStatus(status.value()); |
| | | |
| | | return writeStr2Page(res, str); |
| | | } |
| | | |
| | | /** |
| | | * 输出str至页面 |
| | | */ |
| | | public static boolean writeStr2Page(HttpServletResponse res, String str) { |
| | | try { |