Browse Source

提交

mine
袁强 3 months ago
parent
commit
be32cd4a92
  1. 7
      yq-admin/src/main/java/yq/web/controller/mine/MineFaceController.java
  2. 6
      yq-common/src/main/java/yq/common/utils/FaceEnginUtil.java
  3. 14
      yq-framework/src/main/java/yq/framework/config/ServerConfig.java

7
yq-admin/src/main/java/yq/web/controller/mine/MineFaceController.java

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
; ;
import java.net.InetAddress;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -94,7 +95,7 @@ public class MineFaceController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody MineFace mineFace) throws IOException { public AjaxResult add(@Validated @RequestBody MineFace mineFace) throws IOException {
if(StrUtil.isNotEmpty(mineFace.getFaceUrl())){ if(StrUtil.isNotEmpty(mineFace.getFaceUrl())){
String faceUrl = serverConfig.getUrl()+ mineFace.getFaceUrl(); String faceUrl = serverConfig.getLocalUrl()+ mineFace.getFaceUrl();
URL url = new URL(faceUrl); URL url = new URL(faceUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
@ -116,14 +117,16 @@ public class MineFaceController extends BaseController
public AjaxResult edit(@RequestBody MineFace mineFace) throws IOException { public AjaxResult edit(@RequestBody MineFace mineFace) throws IOException {
MineFace face = mineFaceService.selectMineFaceById(mineFace.getId()); MineFace face = mineFaceService.selectMineFaceById(mineFace.getId());
if(StrUtil.isNotEmpty(mineFace.getFaceUrl())&& !ObjectUtil.equals(mineFace.getFaceUrl(),face.getFaceUrl())){ if(StrUtil.isNotEmpty(mineFace.getFaceUrl())&& !ObjectUtil.equals(mineFace.getFaceUrl(),face.getFaceUrl())){
String faceUrl = serverConfig.getUrl()+mineFace.getFaceUrl(); String faceUrl = serverConfig.getLocalUrl()+mineFace.getFaceUrl();
URL url = new URL(faceUrl); URL url = new URL(faceUrl);
System.out.println("url = " + url);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
connection.setConnectTimeout(5000); // 设置超时时间(毫秒) connection.setConnectTimeout(5000); // 设置超时时间(毫秒)
connection.setReadTimeout(5000); // 设置读取超时时间(毫秒) connection.setReadTimeout(5000); // 设置读取超时时间(毫秒)
InputStream inputStream = connection.getInputStream(); InputStream inputStream = connection.getInputStream();
byte[] bytes = FaceEnginUtil.uploadInput(inputStream); byte[] bytes = FaceEnginUtil.uploadInput(inputStream);
System.out.println("bytes = " + bytes);
mineFace.setFaceByte(bytes); mineFace.setFaceByte(bytes);
} }
return toAjax(mineFaceService.updateMineFace(mineFace)); return toAjax(mineFaceService.updateMineFace(mineFace));

6
yq-common/src/main/java/yq/common/utils/FaceEnginUtil.java

@ -35,14 +35,14 @@ import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
@Configuration @Configuration
public class FaceEnginUtil { public class FaceEnginUtil {
@Value(value = "${arcsoft.appId}") @Value(value = "${arcsoft.appId}")
private static String appId = "7MtFQZ9S9Ue2UC7koYxJbeL5iEHhqGtp3d5SJbJ4ou92"; private static String appId = "vbuPdMEs9ABB4wXD1p6xZZQw3ZJj2VNVw7L4YvFBHhu";
@Value(value = "${arcsoft.sdkKey}") @Value(value = "${arcsoft.sdkKey}")
private static String sdkKey = "4VM5rVL8eKmmELhRi8ZoopH33GzsgPoptA94zSXyHvzz"; private static String sdkKey = "CPioDzEs73ocHUs5WUWvpDaxXWntuytpSb8oJYz8JdvW";
@Value(value = "${arcsoft.faceEngine}") @Value(value = "${arcsoft.faceEngine}")
private static String faceEngineUrl = "D:\\yq\\arcsoft_lib\\LINUX64"; private static String faceEngineUrl = "/home/dk/桌面/jar/arcsoft_lib/LINUX64";
public static FaceEngine init() { public static FaceEngine init() {

14
yq-framework/src/main/java/yq/framework/config/ServerConfig.java

@ -4,6 +4,9 @@ import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import yq.common.utils.ServletUtils; import yq.common.utils.ServletUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;
/** /**
* 服务相关配置 * 服务相关配置
* *
@ -29,4 +32,15 @@ public class ServerConfig
String contextPath = request.getServletContext().getContextPath(); String contextPath = request.getServletContext().getContextPath();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(":"+request.getLocalPort()).append(contextPath).toString(); return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(":"+request.getLocalPort()).append(contextPath).toString();
} }
public String getLocalUrl() throws UnknownHostException {
// 获取本机的 InetAddress 对象
InetAddress localHost = InetAddress.getLocalHost();
// 获取本机的 IP 地址
String ipAddress = localHost.getHostAddress();
return "http://"+ipAddress+":7777";
}
} }

Loading…
Cancel
Save