mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增内网ip判断,内网返回所属地为"未知"
This commit is contained in:
+5
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.framework.ip.core.service.imp;
|
||||
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
@@ -35,6 +36,10 @@ public class IPQueryServiceImpl implements IPQueryService {
|
||||
|
||||
@Override
|
||||
public IPQueryDataRespDTO querySource(String ip) {
|
||||
// 校验是否内部ip
|
||||
if (NetUtil.isInnerIP(ip)) {
|
||||
return new IPQueryDataRespDTO().setIp(ip).setProv("未知");
|
||||
}
|
||||
ErrorCode queryError = ErrorCodeConstants.IP_QUERY_ERROR;
|
||||
try {
|
||||
String apiUrl = ipQueryProperties.getApiUrl();
|
||||
|
||||
+12
-1
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.convert.auth;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.ip.core.service.dto.IPQueryDataRespDTO;
|
||||
import com.cf.imes.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
|
||||
@@ -36,11 +37,21 @@ public interface AuthConvert {
|
||||
|
||||
default AuthPermissionInfoRespVO convert(AdminUserDO user, OrganizationDO organizationDO, IPQueryDataRespDTO ipQueryDataRespDTO, List<RoleDO> roleList, List<MenuDO> menuList) {
|
||||
boolean ipQuerySuccess = ObjectUtil.isNotNull(ipQueryDataRespDTO);
|
||||
String region = null;
|
||||
if (ipQuerySuccess) {
|
||||
String prov = ipQueryDataRespDTO.getProv();
|
||||
if (CharSequenceUtil.contains(prov, "未知")) {
|
||||
region = prov;
|
||||
} else {
|
||||
region = StringUtils.join(List.of(prov, ipQueryDataRespDTO.getCity(), ipQueryDataRespDTO.getArea()), "/");
|
||||
}
|
||||
}
|
||||
|
||||
return AuthPermissionInfoRespVO.builder()
|
||||
.user(AuthPermissionInfoRespVO.UserVO.builder()
|
||||
.id(user.getId()).nickname(user.getNickname()).avatar(user.getAvatar()).organId(user.getOrganId()).needSetPwd(StringUtils.isEmpty(user.getPassword()))
|
||||
.expireTime(organizationDO.getExpireTime()).ip(ipQuerySuccess ? ipQueryDataRespDTO.getIp() : "")
|
||||
.region(ipQuerySuccess ? ipQueryDataRespDTO.getProv() + "/" + ipQueryDataRespDTO.getCity() + "/" + ipQueryDataRespDTO.getArea() : "")
|
||||
.region(region)
|
||||
.build())
|
||||
.roles(convertSet(roleList, RoleDO::getCode))
|
||||
// 权限标识信息
|
||||
|
||||
Reference in New Issue
Block a user