package com.koobietech.eas.common.utils;

import cn.hutool.json.JSONUtil;
import com.koobietech.eas.common.result.JsonResult;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lc
 */
public class ResponseManager {
    public static void printResponse(HttpServletResponse response, String message, int code) {
        response.setHeader("Cache-Control","no-cache");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json");
        try {
            response.getWriter().println(JSONUtil.parse(JsonResult.fail(message, code)));
            response.getWriter().flush();
            response.getWriter().close();
            response.flushBuffer();
        } catch (IOException ignored) {}
    }
}
