org.shoulder.security.ResponseUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shoulder-security Show documentation
Show all versions of shoulder-security Show documentation
Shoulder 基础模块,基于 Spring Security + Spring Boot Web的安全模块,除了提供用户认证、授权、会话管理等基础功能,还允许轻松更换认证模式,如
Session / Token(JWT) 模式切换。
package org.shoulder.security;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* 默认的响应格式
* {"msg":"xxx"}
*
* @author lym
* @deprecated use BaseResponse
*/
public class ResponseUtil {
private static final ObjectMapper objectMapper = new ObjectMapper();
public static String jsonMsg(String msg) {
return "{\"msg\":\"" + msg + "\"}";
}
/**
* 写成 json 形式
*
* @param obj not null
*/
public static String jsonMsg(Object obj) throws JsonProcessingException {
return jsonMsg(objectMapper.writeValueAsString(obj));
}
public static String success() {
return "{\"msg\":\"success\"}";
}
}