fixed incorrect mapping

This commit is contained in:
heyethereum
2024-08-14 00:56:12 +08:00
parent 8665693642
commit 5f55b073f3
3 changed files with 66 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
package com.safeqr.app.prediction.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.safeqr.app.prediction.model.URLFeatures;
import com.safeqr.app.prediction.model.URLFeaturesMapper;
import com.safeqr.app.qrcode.model.URLModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,15 +29,32 @@ public class PredictionService {
public String predict(URLModel urlModel) {
// Convert URLModel to URLFeatures
URLFeatures features = URLFeatures.fromEntity(urlModel);
URLFeaturesMapper features = URLFeaturesMapper.fromEntity(urlModel);
logger.info("Prediction request: {}", features);
logger.info("feature contents : {}", features.getContents());
logger.info("feature domain : {}", features.getDomain());
logger.info("feature sub-domain : {}", features.getSubdomain());
logger.info("feature tld : {}", features.getTopLevelDomain());
logger.info("feature path : {}", features.getPath());
logger.info("feature query : {}", features.getQuery());
logger.info("feature fragment : {}", features.getFragment());
logger.info("feature redirect : {}", features.getRedirect());
logger.info("feature redirect chain: {}", features.getRedirectChain());
logger.info("feature shortening service: {}", features.getShorteningService());
logger.info("feature hasExecutable: {}", features.getHasExecutable());
logger.info("feature hasIP: {}", features.getHasIpAddress());
logger.info("feature hostname embedding: {}", features.getHostnameEmbedding());
logger.info("feature hsts header: {}", features.getHstsHeader());
logger.info("feature javascript check: {}", features.getJavascriptCheck());
logger.info("feature tracking: {}", features.getTrackingDescriptions());
logger.info("feature urlencoding: {}", features.getUrlEncoding());
// Prepare the HTTP headers
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
// Create the HTTP entity containing the features and headers
HttpEntity<URLFeatures> requestEntity = new HttpEntity<>(features, headers);
HttpEntity<URLFeaturesMapper> requestEntity = new HttpEntity<>(features, headers);
// Make the HTTP POST request to the FastAPI prediction endpoint
ResponseEntity<String> response = restTemplate.exchange(