1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-04 22:41:24 +08:00

Added unauthorized access response. Added logout.

This commit is contained in:
2023-05-05 02:31:35 +08:00
parent ac39f886b6
commit 3c8adffe42
7 changed files with 78 additions and 6 deletions

View File

@@ -0,0 +1,26 @@
package com.cfive.pinnacle.utils;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
public class WebUtil {
public static String convert2json(Object object) throws JsonProcessingException {
return new ObjectMapper().writeValueAsString(object);
}
public static String objectResponse(int resultCode, String msg, Object object) throws JsonProcessingException {
ResponseResult result = ResponseResult.build(resultCode, msg, object);
return convert2json(result);
}
public static void renderString(HttpServletResponse response, String string) throws IOException {
response.setStatus(200);
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().print(string);
}
}