All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.shoulder.security.ResponseUtil Maven / Gradle / Ivy

Go to download

Shoulder 基础模块,基于 Spring Security + Spring Boot Web的安全模块,除了提供用户认证、授权、会话管理等基础功能,还允许轻松更换认证模式,如 Session / Token(JWT) 模式切换。

There is a newer version: 0.8.1
Show newest version
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\"}";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy