site
This commit is contained in:
parent
5866b0bac3
commit
e6fc9a0bba
@ -18,7 +18,7 @@ public class PhotoSearchController {
|
||||
private UnsplashService unsplashService;
|
||||
|
||||
@GetMapping("/search")
|
||||
public List<String> searchPhotos(@RequestParam String keyword) {
|
||||
return unsplashService.getImageUrls(keyword);
|
||||
public List<String> searchPhotos(@RequestParam String keyword, @RequestParam Integer pageNumber) {
|
||||
return unsplashService.getImageUrls(keyword, pageNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@ -122,13 +121,42 @@ public class HtmlBuilder5 {
|
||||
|
||||
// Handle children
|
||||
Object children = node.get("children");
|
||||
// if (children instanceof List) {
|
||||
// for (Object child : (List<Object>) children) {
|
||||
// if (child instanceof Map) {
|
||||
// html.append(buildHtml((Map<String, Object>) child, jsonInput));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (children instanceof List) {
|
||||
for (Object child : (List<Object>) children) {
|
||||
if (child instanceof Map) {
|
||||
html.append(buildHtml((Map<String, Object>) child, jsonInput));
|
||||
Map<String, Object> childMap = (Map<String, Object>) child;
|
||||
|
||||
// 🟨 Special case: Dropdown <li> handling
|
||||
if ("li".equals(tag) && "dropdown".equals(node.get("type"))) {
|
||||
html.append(buildHtml(childMap, jsonInput));
|
||||
|
||||
// Look for nested <ul> dropdown menu inside children
|
||||
for (Object dropdownChild : (List<Object>) children) {
|
||||
if (dropdownChild instanceof Map) {
|
||||
Map<String, Object> dropdownChildMap = (Map<String, Object>) dropdownChild;
|
||||
Object dropdownUl = dropdownChildMap.get("ul");
|
||||
if (dropdownUl instanceof Map) {
|
||||
html.append(buildHtml((Map<String, Object>) dropdownUl, jsonInput));
|
||||
}
|
||||
}
|
||||
}
|
||||
break; // dropdown handled, exit
|
||||
} else {
|
||||
html.append(buildHtml(childMap, jsonInput));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (children instanceof Map) {
|
||||
}
|
||||
|
||||
else if (children instanceof Map) {
|
||||
html.append(buildHtml((Map<String, Object>) children, jsonInput));
|
||||
}
|
||||
|
||||
@ -175,11 +203,11 @@ public class HtmlBuilder5 {
|
||||
return "🔗";
|
||||
if (label.contains("youtube"))
|
||||
return "▶️";
|
||||
if (label.contains("fas fa-cube"))
|
||||
return "📦";
|
||||
|
||||
if (label.contains("cube"))
|
||||
if (label.contains("fas fa-cube") || label.contains("cube"))
|
||||
return "📦";
|
||||
// ✅ New: Dropdown / Chevron icon
|
||||
if (label.contains("dropdown") || label.contains("chevron-down") || label.contains("fas fa-chevron-down"))
|
||||
return "🔽"; // downward arrow
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -248,7 +276,7 @@ public class HtmlBuilder5 {
|
||||
String query = keywords.trim().replace(" ", ",");
|
||||
|
||||
// 1. Get list of image URLs from Unsplash
|
||||
List<String> imageUrls = unsplashService.getImageUrls(keywords);
|
||||
List<String> imageUrls = unsplashService.getImageUrls(keywords, 10);
|
||||
|
||||
// 2. Prepare prompt for Gemini
|
||||
StringBuilder promptBuilder = new StringBuilder();
|
||||
|
||||
@ -19,10 +19,10 @@ public class UnsplashService {
|
||||
@Value("${unsplash.access.key}")
|
||||
private String accessKey;
|
||||
|
||||
public List<String> getImageUrls(String keyword) {
|
||||
public List<String> getImageUrls(String keyword, int i) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String uri = UriComponentsBuilder.fromHttpUrl(apiUrl).queryParam("query", keyword)
|
||||
.queryParam("client_id", accessKey).queryParam("per_page", 10).toUriString();
|
||||
.queryParam("client_id", accessKey).queryParam("per_page", i).toUriString();
|
||||
|
||||
UnsplashPhotoResponse response = restTemplate.getForObject(uri, UnsplashPhotoResponse.class);
|
||||
|
||||
@ -37,4 +37,5 @@ public class UnsplashService {
|
||||
|
||||
return imageUrls;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -168,4 +168,17 @@ public class Design_lbraryController {
|
||||
return new ResponseEntity<>(flf_line, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// get flf by tag
|
||||
@GetMapping("/Design_lbrary/tag")
|
||||
public ResponseEntity<?> getFlfByRandom(@RequestParam String operationType, @RequestParam String fieldType) {
|
||||
Design_lbrary flf_line = designLibraryService.getflflinerandom(operationType, fieldType);
|
||||
|
||||
if (flf_line == null) {
|
||||
|
||||
return new ResponseEntity<>("not found", HttpStatus.EXPECTATION_FAILED);
|
||||
}
|
||||
|
||||
return new ResponseEntity<Design_lbrary>(flf_line, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@ -134,13 +134,31 @@ public class Design_lbraryService {
|
||||
|
||||
if (flf == null || flf.isEmpty()) {
|
||||
|
||||
flf = designLibraryRepository.searchByTag(true, operationType.toLowerCase().trim(),
|
||||
fieldType.toLowerCase().trim());
|
||||
// flf = designLibraryRepository.searchByTag(true, operationType.toLowerCase().trim(),
|
||||
// fieldType.toLowerCase().trim());
|
||||
//
|
||||
// if (flf == null || flf.isEmpty()) {
|
||||
// return null; // ya throw new RuntimeException("No data found");
|
||||
//
|
||||
// }
|
||||
return null; // ya throw new RuntimeException("No data found");
|
||||
|
||||
if (flf == null || flf.isEmpty()) {
|
||||
return null; // ya throw new RuntimeException("No data found");
|
||||
}
|
||||
|
||||
// Random index pick
|
||||
int randomIndex = ThreadLocalRandom.current().nextInt(flf.size());
|
||||
return flf.get(randomIndex);
|
||||
}
|
||||
|
||||
// get flf by tag
|
||||
public Design_lbrary getflfByTag(String operationType, String fieldType) {
|
||||
|
||||
List<Design_lbrary> flf = designLibraryRepository.searchByTag(true, operationType.toLowerCase().trim(),
|
||||
fieldType.toLowerCase().trim());
|
||||
|
||||
if (flf == null || flf.isEmpty()) {
|
||||
return null; // ya throw new RuntimeException("No data found");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Random index pick
|
||||
|
||||
@ -343,15 +343,18 @@ public class SessionController {
|
||||
@PostMapping("/user/send_email")
|
||||
public ResponseEntity<?> userviaadmin(HttpServletRequest request, @RequestBody Registration reg) {
|
||||
String email = reg.getEmail();
|
||||
AppUser appUser = new AppUser();
|
||||
// AppUser appUser = new AppUser();
|
||||
|
||||
AppUser user = userService.findUserByEmail(email);
|
||||
if (user != null && user.isIsComplete()) {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse(email + " already exist"));
|
||||
} else {
|
||||
if (user != null && !user.isIsComplete()) {
|
||||
appUser = user;
|
||||
}
|
||||
// if (user != null && !user.isIsComplete()) {
|
||||
// appUser = user;
|
||||
// }
|
||||
|
||||
AppUser appUser = (user != null && !user.isIsComplete()) ? user : new AppUser();
|
||||
|
||||
// Random random = new Random();
|
||||
SecureRandom random = new SecureRandom();
|
||||
|
||||
|
||||
@ -617,6 +617,9 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
||||
user.setRandom_no(token);
|
||||
user.setUsername(email);
|
||||
user.setEmail(email);
|
||||
if (user.getCreatedate() == null) {
|
||||
user.setCreatedate(LocalDateTime.now());
|
||||
}
|
||||
|
||||
appUserRepository.save(user);
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
@ -23,18 +25,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.Heplers.FileHelper;
|
||||
import com.realnet.OpenAi.Services.SureopsService;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import com.realnet.vpspack.Entity.SiteBuilder;
|
||||
import com.realnet.vpspack.Entity.SiteBuilderDto;
|
||||
import com.realnet.vpspack.Services.SiteBuilderService;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@RequestMapping(value = "/SiteTree")
|
||||
@CrossOrigin("*")
|
||||
@ -50,8 +44,6 @@ public class SiteBuilderController {
|
||||
@Autowired
|
||||
private FileHelper fileHelper;
|
||||
|
||||
@Autowired
|
||||
private SureopsService sureopsService;
|
||||
|
||||
@PostMapping("/SiteTree")
|
||||
public SiteBuilder Savedata(@RequestBody SiteBuilder data) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user