use of cn.hutool.core.lang.Dict in project RuoYi-Vue-Plus by JavaLionLi.
the class AddressUtils method getRealAddressByIP.
public static String getRealAddressByIP(String ip) {
String address = UNKNOWN;
if (StringUtils.isBlank(ip)) {
return address;
}
// 内网不查询
ip = "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : HtmlUtil.cleanHtmlTag(ip);
if (NetUtil.isInnerIP(ip)) {
return "内网IP";
}
if (RuoYiConfig.isAddressEnabled()) {
try {
String rspStr = HttpUtil.createGet(IP_URL).body("ip=" + ip + "&json=true", Constants.GBK).execute().body();
if (StringUtils.isEmpty(rspStr)) {
log.error("获取地理位置异常 {}", ip);
return UNKNOWN;
}
Dict obj = JsonUtils.parseMap(rspStr);
String region = obj.getStr("pro");
String city = obj.getStr("city");
return String.format("%s %s", region, city);
} catch (Exception e) {
log.error("获取地理位置异常 {}", ip);
}
}
return UNKNOWN;
}
use of cn.hutool.core.lang.Dict in project RuoYi-Vue-Plus by JavaLionLi.
the class GenTableServiceImpl method validateEdit.
/**
* 修改保存参数校验
*
* @param genTable 业务信息
*/
@Override
public void validateEdit(GenTable genTable) {
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
String options = JsonUtils.toJsonString(genTable.getParams());
Dict paramsObj = JsonUtils.parseMap(options);
if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_CODE))) {
throw new ServiceException("树编码字段不能为空");
} else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_PARENT_CODE))) {
throw new ServiceException("树父编码字段不能为空");
} else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_NAME))) {
throw new ServiceException("树名称字段不能为空");
} else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
if (StringUtils.isEmpty(genTable.getSubTableName())) {
throw new ServiceException("关联子表的表名不能为空");
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
throw new ServiceException("子表关联的外键名不能为空");
}
}
}
}
use of cn.hutool.core.lang.Dict in project RuoYi-Vue-Plus by JavaLionLi.
the class GenTableServiceImpl method setTableFromOptions.
/**
* 设置代码生成其他选项值
*
* @param genTable 设置后的生成对象
*/
public void setTableFromOptions(GenTable genTable) {
Dict paramsObj = JsonUtils.parseMap(genTable.getOptions());
if (ObjectUtil.isNotNull(paramsObj)) {
String treeCode = paramsObj.getStr(GenConstants.TREE_CODE);
String treeParentCode = paramsObj.getStr(GenConstants.TREE_PARENT_CODE);
String treeName = paramsObj.getStr(GenConstants.TREE_NAME);
String parentMenuId = paramsObj.getStr(GenConstants.PARENT_MENU_ID);
String parentMenuName = paramsObj.getStr(GenConstants.PARENT_MENU_NAME);
genTable.setTreeCode(treeCode);
genTable.setTreeParentCode(treeParentCode);
genTable.setTreeName(treeName);
genTable.setParentMenuId(parentMenuId);
genTable.setParentMenuName(parentMenuName);
}
}
use of cn.hutool.core.lang.Dict in project RuoYi-Vue-Plus by JavaLionLi.
the class VelocityUtils method getExpandColumn.
/**
* 获取需要在哪一列上面显示展开按钮
*
* @param genTable 业务表对象
* @return 展开按钮列序号
*/
public static int getExpandColumn(GenTable genTable) {
String options = genTable.getOptions();
Dict paramsObj = JsonUtils.parseMap(options);
String treeName = paramsObj.getStr(GenConstants.TREE_NAME);
int num = 0;
for (GenTableColumn column : genTable.getColumns()) {
if (column.isList()) {
num++;
String columnName = column.getColumnName();
if (columnName.equals(treeName)) {
break;
}
}
}
return num;
}
use of cn.hutool.core.lang.Dict in project onex-boot by zhangchaoxu.
the class BaseExceptionHandler method saveLog.
/**
* 保存异常日志
*/
protected void saveLog(HttpServletRequest request, Exception ex) {
LogBody logEntity = new LogBody();
logEntity.setStoreType("db");
logEntity.setType("error");
logEntity.setState(0);
// 请求相关信息
if (request == null) {
request = HttpContextUtils.getHttpServletRequest();
}
if (null != request) {
logEntity.setUri(request.getRequestURI());
// 记录内容
Dict requestParams = Dict.create();
requestParams.set("ip", HttpContextUtils.getIpAddr(request));
requestParams.set("ua", request.getHeader(HttpHeaders.USER_AGENT));
requestParams.set("queryString", request.getQueryString());
requestParams.set("url", request.getRequestURL());
requestParams.set("method", request.getMethod());
requestParams.set("contentType", request.getContentType());
if (HttpMethod.POST.name().equalsIgnoreCase(request.getMethod())) {
try {
requestParams.set("params", IoUtil.read(request.getInputStream()).toString());
} catch (IOException e) {
log.error("读取流失败", e);
}
}
logEntity.setRequestParams(requestParams);
}
// 异常信息
logEntity.setContent(ExceptionUtil.stacktraceToString(ex));
// 保存
try {
logService.saveLog(logEntity);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations