com.ruoyi.common.json.JSON Java Examples

The following examples show how to use com.ruoyi.common.json.JSON. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepeatSubmitInterceptor.java    From supplierShop with MIT License 6 votes vote down vote up
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
    if (handler instanceof HandlerMethod)
    {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
        RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
        if (annotation != null)
        {
            if (this.isRepeatSubmit(request))
            {
                AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试");
                ServletUtils.renderString(response, JSON.marshal(ajaxResult));
                return false;
            }
        }
        return true;
    }
    else
    {
        return super.preHandle(request, response, handler);
    }
}
 
Example #2
Source File: ColumnInfo.java    From ruoyiplus with MIT License 6 votes vote down vote up
public void setColumnComment(String columnComment)
{
    // 根据列描述解析列的配置信息
    if (StringUtils.isNotEmpty(columnComment) && columnComment.startsWith("{"))
    {
        try {
            this.configInfo = JSON.unmarshal(columnComment, ColumnConfigInfo.class);
        }catch(Exception ex){
            ex.printStackTrace();
        }
        this.columnComment = configInfo.getTitle();
    }
    else
    {
        this.columnComment = columnComment;
    }
}
 
Example #3
Source File: AddressUtils.java    From RuoYi with Apache License 2.0 6 votes vote down vote up
public static String getRealAddressByIp(String ip) {
    String address = "XX XX" ;

    // 内网不查询
    if (IpUtils.internalIp(ip)) {
        return "内网IP" ;
    }
    if (Global.isAddressEnabled()) {
        String rspStr = HttpUtil.post(IP_URL, "ip=" + ip);
        if (StrUtil.isEmpty(rspStr)) {
            log.error("获取地理位置异常 {}" , ip);
            return address;
        }
        JSONObject obj;
        try {
            obj = JSON.unmarshal(rspStr, JSONObject.class);
            JSONObject data = obj.getObj("data");
            String region = data.getStr("region");
            String city = data.getStr("city");
            address = region + " " + city;
        } catch (Exception e) {
            log.error("获取地理位置异常 {}" , ip);
        }
    }
    return address;
}
 
Example #4
Source File: LogAspect.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 获取请求的参数,放到log中
 * 
 * @param operLog 操作日志
 * @throws Exception 异常
 */
private void setRequestValue(SysOperLog operLog) throws Exception
{
    Map<String, String[]> map = ServletUtils.getRequest().getParameterMap();
    String params = JSON.marshal(map);
    operLog.setOperParam(StringUtils.substring(params, 0, 2000));
}
 
Example #5
Source File: AddressUtils.java    From supplierShop with MIT License 5 votes vote down vote up
public static String getRealAddressByIP(String ip)
{
    String address = "XX XX";

    // 内网不查询
    if (IpUtils.internalIp(ip))
    {
        return "内网IP";
    }
    if (Global.isAddressEnabled())
    {
        String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip);
        if (StringUtils.isEmpty(rspStr))
        {
            log.error("获取地理位置异常 {}", ip);
            return address;
        }
        JSONObject obj;
        try
        {
            obj = JSON.unmarshal(rspStr, JSONObject.class);
            JSONObject data = obj.getObj("data");
            String region = data.getStr("region");
            String city = data.getStr("city");
            address = region + " " + city;
        }
        catch (Exception e)
        {
            log.error("获取地理位置异常 {}", ip);
        }
    }
    return address;
}
 
Example #6
Source File: LogAspect.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 获取请求的参数,放到log中
 * 
 * @param operLog 操作日志
 * @throws Exception 异常
 */
private void setRequestValue(SysOperLog operLog) throws Exception
{
    Map<String, String[]> map = ServletUtils.getRequest().getParameterMap();
    String params = JSON.marshal(map);
    operLog.setOperParam(StringUtils.substring(params, 0, 255));
}
 
Example #7
Source File: AddressUtils.java    From ruoyiplus with MIT License 5 votes vote down vote up
public static String getRealAddressByIP(String ip)
{
    String address = "XX XX";

    // 内网不查询
    if (IpUtils.internalIp(ip))
    {
        return "内网IP";
    }
    if (Global.isAddressEnabled())
    {
        String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip);
        if (StringUtils.isEmpty(rspStr))
        {
            log.error("获取地理位置异常 {}", ip);
            return address;
        }
        JSONObject obj;
        try
        {
            obj = JSON.unmarshal(rspStr, JSONObject.class);
            JSONObject data = obj.getObj("data");
            String region = data.getStr("region");
            String city = data.getStr("city");
            address = region + " " + city;
        }
        catch (Exception e)
        {
            log.error("获取地理位置异常 {}", ip);
        }
    }
    return address;
}
 
Example #8
Source File: ColumnInfo.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
public void setColumnComment(String columnComment) throws IOException {
    // 根据列描述解析列的配置信息
    if (StrUtil.isNotEmpty(columnComment) && columnComment.startsWith("{")) {
        this.configInfo = JSON.unmarshal(columnComment, ColumnConfigInfo.class);
        this.columnComment = configInfo.getTitle();
    } else {
        this.columnComment = columnComment;
    }
}
 
Example #9
Source File: LogUtils.java    From supplierShop with MIT License 4 votes vote down vote up
protected static String getParams(HttpServletRequest request) throws Exception
{
    Map<String, String[]> params = request.getParameterMap();
    return JSON.marshal(params);
}
 
Example #10
Source File: LogUtils.java    From ruoyiplus with MIT License 4 votes vote down vote up
protected static String getParams(HttpServletRequest request) throws Exception
{
    Map<String, String[]> params = request.getParameterMap();
    return JSON.marshal(params);
}
 
Example #11
Source File: LogUtils.java    From RuoYi with Apache License 2.0 4 votes vote down vote up
protected static String getParams(HttpServletRequest request) throws Exception {
    Map<String, String[]> params = request.getParameterMap();
    return JSON.marshal(params);
}
 
Example #12
Source File: LogAspect.java    From RuoYi with Apache License 2.0 2 votes vote down vote up
/**
 * 获取请求的参数,放到log中
 *
 * @param operLog 操作日志
 * @throws Exception 异常
 */
private void setRequestValue(SysOperLog operLog) throws Exception {
    Map<String, String[]> map = ServletUtils.getRequest().getParameterMap();
    String params = JSON.marshal(map);
    operLog.setOperParam(params);
}