mirror of
https://gitee.com/gz-yami/mall4j.git
synced 2026-10-06 06:12:57 +08:00
补充商品详情接口商品id设为必填参数和ip工具类部分判断完善修改
This commit is contained in:
@@ -69,7 +69,7 @@ public class ProdController {
|
||||
@GetMapping("/prodInfo")
|
||||
@Operation(summary = "商品详情信息" , description = "根据商品ID(prodId)获取商品信息")
|
||||
@Parameter(name = "prodId", description = "商品ID" , required = true)
|
||||
public ServerResponseEntity<ProductDto> prodInfo(Long prodId) {
|
||||
public ServerResponseEntity<ProductDto> prodInfo(@RequestParam(value = "prodId") Long prodId) {
|
||||
|
||||
Product product = prodService.getProductByProdId(prodId);
|
||||
if (product == null) {
|
||||
|
||||
@@ -35,13 +35,13 @@ public class IpHelper {
|
||||
return null;
|
||||
}
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
if (isUnknown(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
if (isUnknown(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
if (isUnknown(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
String[] ips = ip.split(",");
|
||||
@@ -60,8 +60,9 @@ public class IpHelper {
|
||||
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
|
||||
while (inetAddresses.hasMoreElements()) {
|
||||
InetAddress inetAddress = inetAddresses.nextElement();
|
||||
if (inetAddress.isSiteLocalAddress() && !inetAddress.isLoopbackAddress() && inetAddress.getHostAddress().indexOf(":") == -1) {
|
||||
return inetAddress.getHostAddress();
|
||||
String hostAddress = inetAddress.getHostAddress();
|
||||
if (inetAddress.isSiteLocalAddress() && !inetAddress.isLoopbackAddress() && !hostAddress.contains(":")) {
|
||||
return hostAddress;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,4 +71,8 @@ public class IpHelper {
|
||||
}
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
private static boolean isUnknown(String ip) {
|
||||
return ip == null || ip.isEmpty() || UNKNOWN.equalsIgnoreCase(ip);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user