dlf
This commit is contained in:
		
							parent
							
								
									796d8cfe50
								
							
						
					
					
						commit
						c7a14fbb23
					
				@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 | 
				
			|||||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
					import org.springframework.web.bind.annotation.RequestMapping;
 | 
				
			||||||
import org.springframework.web.bind.annotation.RestController;
 | 
					import org.springframework.web.bind.annotation.RestController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.realnet.OpenAi.Services.HtmlBuilder3;
 | 
					import com.realnet.OpenAi.Services.HtmlBuilder4;
 | 
				
			||||||
import com.realnet.OpenAi.Services.HtmlGenerTorService;
 | 
					import com.realnet.OpenAi.Services.HtmlGenerTorService;
 | 
				
			||||||
import com.realnet.fnd.response.EntityResponse;
 | 
					import com.realnet.fnd.response.EntityResponse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -47,7 +47,7 @@ public class HtmlGeneratorController {
 | 
				
			|||||||
				return ResponseEntity.badRequest().body("Missing 'jsonStructure' in request.");
 | 
									return ResponseEntity.badRequest().body("Missing 'jsonStructure' in request.");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			String html = HtmlBuilder3.buildHtml(jsonStructure);
 | 
								String html = HtmlBuilder4.buildHtml(jsonStructure);
 | 
				
			||||||
			return ResponseEntity.ok(new EntityResponse(html));
 | 
								return ResponseEntity.ok(new EntityResponse(html));
 | 
				
			||||||
		} catch (Exception e) {
 | 
							} catch (Exception e) {
 | 
				
			||||||
			e.printStackTrace();
 | 
								e.printStackTrace();
 | 
				
			||||||
 | 
				
			|||||||
@ -133,30 +133,31 @@ public class SureOpsController {
 | 
				
			|||||||
	public void createHtmlFiles(@RequestParam Integer projId, @RequestBody Map<String, String> pageHtmlMap)
 | 
						public void createHtmlFiles(@RequestParam Integer projId, @RequestBody Map<String, String> pageHtmlMap)
 | 
				
			||||||
			throws IOException {
 | 
								throws IOException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (Map.Entry<String, String> entry : pageHtmlMap.entrySet()) {
 | 
							sureopsService.createHtmlFiles(projId, pageHtmlMap);
 | 
				
			||||||
			String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name
 | 
					//		for (Map.Entry<String, String> entry : pageHtmlMap.entrySet()) {
 | 
				
			||||||
			String htmlContent = entry.getValue();
 | 
					//			String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name
 | 
				
			||||||
 | 
					//			String htmlContent = entry.getValue();
 | 
				
			||||||
			String folderPath = projectPath + "/cns-portal/code-extractor/builders/" + projId;
 | 
					//
 | 
				
			||||||
			File file = new File(folderPath + "/" + pageName + ".html");
 | 
					//			String folderPath = projectPath + "/cns-portal/code-extractor/builders/" + projId;
 | 
				
			||||||
 | 
					//			File file = new File(folderPath + "/" + pageName + ".html");
 | 
				
			||||||
			// Ensure directory exists
 | 
					//
 | 
				
			||||||
			File parentDir = file.getParentFile();
 | 
					//			// Ensure directory exists
 | 
				
			||||||
			if (!parentDir.exists()) {
 | 
					//			File parentDir = file.getParentFile();
 | 
				
			||||||
				parentDir.mkdirs();
 | 
					//			if (!parentDir.exists()) {
 | 
				
			||||||
			}
 | 
					//				parentDir.mkdirs();
 | 
				
			||||||
 | 
					//			}
 | 
				
			||||||
			// Create new file
 | 
					//
 | 
				
			||||||
			if (!file.exists()) {
 | 
					//			// Create new file
 | 
				
			||||||
				file.createNewFile();
 | 
					//			if (!file.exists()) {
 | 
				
			||||||
			}
 | 
					//				file.createNewFile();
 | 
				
			||||||
 | 
					//			}
 | 
				
			||||||
			try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
 | 
					//
 | 
				
			||||||
				writer.write(htmlContent);
 | 
					//			try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
 | 
				
			||||||
			}
 | 
					//				writer.write(htmlContent);
 | 
				
			||||||
 | 
					//			}
 | 
				
			||||||
			System.out.println("✅ File created: " + file.getAbsolutePath());
 | 
					//
 | 
				
			||||||
		}
 | 
					//			System.out.println("✅ File created: " + file.getAbsolutePath());
 | 
				
			||||||
 | 
					//		}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -9,8 +9,6 @@ import java.util.Map;
 | 
				
			|||||||
import java.util.function.Function;
 | 
					import java.util.function.Function;
 | 
				
			||||||
import java.util.stream.Collectors;
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.realnet.OpenAi.Renders.HtmlRenderer;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class HtmlBuilder3 {
 | 
					public class HtmlBuilder3 {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static String buildHtml(Object node) {
 | 
						public static String buildHtml(Object node) {
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -0,0 +1,100 @@
 | 
				
			|||||||
 | 
					package com.realnet.dlf.Controllers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Value;
 | 
				
			||||||
 | 
					import org.springframework.data.domain.Page;
 | 
				
			||||||
 | 
					import org.springframework.data.domain.PageRequest;
 | 
				
			||||||
 | 
					import org.springframework.data.domain.Pageable;
 | 
				
			||||||
 | 
					import org.springframework.http.HttpStatus;
 | 
				
			||||||
 | 
					import org.springframework.http.ResponseEntity;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.CrossOrigin;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.DeleteMapping;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.GetMapping;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.PathVariable;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.PostMapping;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.PutMapping;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.RequestBody;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.RequestMapping;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.RequestParam;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.RestController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.realnet.dlf.Entity.Design_lbrary;
 | 
				
			||||||
 | 
					import com.realnet.dlf.Services.Design_lbraryService;
 | 
				
			||||||
 | 
					import com.realnet.dlf.Services.DlfService;
 | 
				
			||||||
 | 
					import com.realnet.fnd.response.EntityResponse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@RequestMapping(value = "/Design_lbrary")
 | 
				
			||||||
 | 
					@CrossOrigin("*")
 | 
				
			||||||
 | 
					@RestController
 | 
				
			||||||
 | 
					public class Design_lbraryController {
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private Design_lbraryService designLibraryService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private DlfService dlfService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Value("${projectPath}")
 | 
				
			||||||
 | 
						private String projectPath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@PostMapping("/Design_lbrary")
 | 
				
			||||||
 | 
						public Design_lbrary Savedata(@RequestBody Design_lbrary data) {
 | 
				
			||||||
 | 
							Design_lbrary save = designLibraryService.Savedata(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							System.out.println("data saved..." + save);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return save;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@PutMapping("/Design_lbrary/{id}")
 | 
				
			||||||
 | 
						public Design_lbrary update(@RequestBody Design_lbrary data, @PathVariable Integer id) {
 | 
				
			||||||
 | 
							Design_lbrary update = designLibraryService.update(data, id);
 | 
				
			||||||
 | 
							System.out.println("data update..." + update);
 | 
				
			||||||
 | 
							return update;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	get all with pagination
 | 
				
			||||||
 | 
						@GetMapping("/Design_lbrary/getall/page")
 | 
				
			||||||
 | 
						public Page<Design_lbrary> getall(@RequestParam(value = "page", required = false) Integer page,
 | 
				
			||||||
 | 
								@RequestParam(value = "size", required = false) Integer size) {
 | 
				
			||||||
 | 
							Pageable paging = PageRequest.of(page, size);
 | 
				
			||||||
 | 
							Page<Design_lbrary> get = designLibraryService.getAllWithPagination(paging);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return get;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@GetMapping("/Design_lbrary")
 | 
				
			||||||
 | 
						public List<Design_lbrary> getdetails() {
 | 
				
			||||||
 | 
							List<Design_lbrary> get = designLibraryService.getdetails();
 | 
				
			||||||
 | 
							return get;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					// get all without authentication 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@GetMapping("/token/Design_lbrary")
 | 
				
			||||||
 | 
						public List<Design_lbrary> getallwioutsec() {
 | 
				
			||||||
 | 
							List<Design_lbrary> get = designLibraryService.getdetails();
 | 
				
			||||||
 | 
							return get;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@GetMapping("/Design_lbrary/{id}")
 | 
				
			||||||
 | 
						public Design_lbrary getdetailsbyId(@PathVariable Integer id) {
 | 
				
			||||||
 | 
							Design_lbrary get = designLibraryService.getdetailsbyId(id);
 | 
				
			||||||
 | 
							return get;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@DeleteMapping("/Design_lbrary/{id}")
 | 
				
			||||||
 | 
						public ResponseEntity<?> delete_by_id(@PathVariable Integer id) {
 | 
				
			||||||
 | 
							designLibraryService.delete_by_id(id);
 | 
				
			||||||
 | 
							return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@GetMapping("/preview/{id}")
 | 
				
			||||||
 | 
						public ResponseEntity<String> getDesignPreview(@PathVariable Integer id) {
 | 
				
			||||||
 | 
							String htmlWithCss = dlfService.generateHtmlWithCss(id);
 | 
				
			||||||
 | 
							return ResponseEntity.ok(htmlWithCss);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					package com.realnet.dlf.Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.persistence.Column;
 | 
				
			||||||
 | 
					import javax.persistence.Entity;
 | 
				
			||||||
 | 
					import javax.persistence.GeneratedValue;
 | 
				
			||||||
 | 
					import javax.persistence.GenerationType;
 | 
				
			||||||
 | 
					import javax.persistence.Id;
 | 
				
			||||||
 | 
					import javax.persistence.Lob;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.realnet.WhoColumn.Entity.Extension;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Entity
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					public class Design_lbrary extends Extension {
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private static final long serialVersionUID = 1L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Id
 | 
				
			||||||
 | 
						@GeneratedValue(strategy = GenerationType.IDENTITY)
 | 
				
			||||||
 | 
						private Integer id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private String name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Column(length = 2000)
 | 
				
			||||||
 | 
						private String description;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private boolean active;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Lob
 | 
				
			||||||
 | 
						private String htmljson;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Column(length = 2000)
 | 
				
			||||||
 | 
						private String css;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Column(columnDefinition = "TEXT")
 | 
				
			||||||
 | 
						private String javacode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private String templatetype;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private String uitype;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					package com.realnet.dlf.Repository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.data.domain.Page;
 | 
				
			||||||
 | 
					import org.springframework.data.domain.Pageable;
 | 
				
			||||||
 | 
					import org.springframework.data.jpa.repository.JpaRepository;
 | 
				
			||||||
 | 
					import org.springframework.data.jpa.repository.Query;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Repository; 
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.realnet.dlf.Entity.Design_lbrary;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Repository
 | 
				
			||||||
 | 
					public interface  Design_lbraryRepository  extends  JpaRepository<Design_lbrary, Integer>  { 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Query(value = "select * from design_lbrary where  created_by=?1", nativeQuery = true)
 | 
				
			||||||
 | 
						List<Design_lbrary> findAll(Long creayedBy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Query(value = "select * from design_lbrary where  created_by=?1", nativeQuery = true)
 | 
				
			||||||
 | 
						Page<Design_lbrary> findAll(Pageable page, Long creayedBy);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,100 @@
 | 
				
			|||||||
 | 
					package com.realnet.dlf.Services;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.data.domain.Page;
 | 
				
			||||||
 | 
					import org.springframework.data.domain.Pageable;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.realnet.OpenAi.Services.HtmlBuilder3;
 | 
				
			||||||
 | 
					import com.realnet.dlf.Entity.Design_lbrary;
 | 
				
			||||||
 | 
					import com.realnet.dlf.Repository.Design_lbraryRepository;
 | 
				
			||||||
 | 
					import com.realnet.realm.Entity.Realm;
 | 
				
			||||||
 | 
					import com.realnet.realm.Services.RealmService;
 | 
				
			||||||
 | 
					import com.realnet.users.entity1.AppUser;
 | 
				
			||||||
 | 
					import com.realnet.users.service1.AppUserServiceImpl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class Design_lbraryService {
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private Design_lbraryRepository designLibraryRepository;
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private AppUserServiceImpl userService;
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private RealmService realmService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Design_lbrary Savedata(Design_lbrary data) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							data.setUpdatedBy(getUser().getUserId());
 | 
				
			||||||
 | 
							data.setCreatedBy(getUser().getUserId());
 | 
				
			||||||
 | 
							data.setAccountId(getUser().getAccount().getAccount_id());
 | 
				
			||||||
 | 
							Design_lbrary save = designLibraryRepository.save(data);
 | 
				
			||||||
 | 
							return save;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	get all with pagination
 | 
				
			||||||
 | 
						public Page<Design_lbrary> getAllWithPagination(Pageable page) {
 | 
				
			||||||
 | 
							return designLibraryRepository.findAll(page, getUser().getUserId());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public List<Design_lbrary> getdetails() {
 | 
				
			||||||
 | 
							List<Realm> realm = realmService.findByUserId(getUser().getUserId());
 | 
				
			||||||
 | 
							List<Design_lbrary> all = designLibraryRepository.findAll(getUser().getUserId());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return all;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Design_lbrary getdetailsbyId(Integer id) {
 | 
				
			||||||
 | 
							return designLibraryRepository.findById(id).get();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void delete_by_id(Integer id) {
 | 
				
			||||||
 | 
							designLibraryRepository.deleteById(id);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Design_lbrary update(Design_lbrary data, Integer id) {
 | 
				
			||||||
 | 
							Design_lbrary old = designLibraryRepository.findById(id).get();
 | 
				
			||||||
 | 
							old.setName(data.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							old.setDescription(data.getDescription());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							old.setActive(data.isActive());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							old.setHtmljson(data.getHtmljson());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							old.setCss(data.getCss());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							old.setJavacode(data.getJavacode());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							old.setTemplatetype(data.getTemplatetype());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							old.setUitype(data.getUitype());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							final Design_lbrary test = designLibraryRepository.save(old);
 | 
				
			||||||
 | 
							data.setUpdatedBy(getUser().getUserId());
 | 
				
			||||||
 | 
							return test;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public String generatePreviewHtml(Integer id) {
 | 
				
			||||||
 | 
							// 1. Record uthao
 | 
				
			||||||
 | 
							Design_lbrary design = designLibraryRepository.findById(id)
 | 
				
			||||||
 | 
									.orElseThrow(() -> new RuntimeException("Design not found with ID: " + id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 2. JSON se HTML banao
 | 
				
			||||||
 | 
							String htmljson = design.getHtmljson();
 | 
				
			||||||
 | 
							String generatedHtml = HtmlBuilder3.buildHtml(htmljson); // Tumhara existing method ka call
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 3. CSS inject karo
 | 
				
			||||||
 | 
							String css = design.getCss();
 | 
				
			||||||
 | 
							String finalHtml = "<html><head><style>" + css + "</style></head><body>" + generatedHtml + "</body></html>";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return finalHtml;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public AppUser getUser() {
 | 
				
			||||||
 | 
							AppUser user = userService.getLoggedInUser();
 | 
				
			||||||
 | 
							return user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,281 @@
 | 
				
			|||||||
 | 
					package com.realnet.dlf.Services;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Collections;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fasterxml.jackson.core.type.TypeReference;
 | 
				
			||||||
 | 
					import com.fasterxml.jackson.databind.ObjectMapper;
 | 
				
			||||||
 | 
					import com.realnet.dlf.Entity.Design_lbrary;
 | 
				
			||||||
 | 
					import com.realnet.dlf.Repository.Design_lbraryRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class DlfService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Autowired
 | 
				
			||||||
 | 
						private Design_lbraryRepository designLibraryRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public String generateHtmlWithCss(Integer id) {
 | 
				
			||||||
 | 
							Design_lbrary design = designLibraryRepository.findById(id)
 | 
				
			||||||
 | 
									.orElseThrow(() -> new RuntimeException("Design not found with id: " + id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							String htmlJson = design.getHtmljson();
 | 
				
			||||||
 | 
							String javacode = design.getJavacode();
 | 
				
			||||||
 | 
							String css = design.getCss();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Map<String, Object> dataMap = parseJsonToMap(htmlJson);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							String generatedHtml = replacePlaceholders(javacode, dataMap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							String finalHtml = "<html><head><style>" + css + "</style></head><body>" + generatedHtml + "</body></html>";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return finalHtml;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private Map<String, Object> parseJsonToMap(String json) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								ObjectMapper mapper = new ObjectMapper();
 | 
				
			||||||
 | 
								return mapper.readValue(json, new TypeReference<Map<String, Object>>() {
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							} catch (Exception e) {
 | 
				
			||||||
 | 
								e.printStackTrace();
 | 
				
			||||||
 | 
								return Collections.emptyMap();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private String replacePlaceholders(String template, Map<String, Object> dataMap) {
 | 
				
			||||||
 | 
							if (template == null || dataMap == null) {
 | 
				
			||||||
 | 
								return template;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							String result = template;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
 | 
				
			||||||
 | 
								String placeholder = "{{" + entry.getKey() + "}}";
 | 
				
			||||||
 | 
								String value = entry.getValue() != null ? entry.getValue().toString() : "";
 | 
				
			||||||
 | 
								result = result.replace(placeholder, value);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return result;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	public static String buildHtml(Object node) {
 | 
				
			||||||
 | 
					//		if (node instanceof Map) {
 | 
				
			||||||
 | 
					//			Map<String, Object> map = (Map<String, Object>) node;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//			// Handle raw section container
 | 
				
			||||||
 | 
					//			if (!map.containsKey("type") && !map.containsKey("tag")) {
 | 
				
			||||||
 | 
					//				StringBuilder html = new StringBuilder();
 | 
				
			||||||
 | 
					//				for (Map.Entry<String, Object> entry : map.entrySet()) {
 | 
				
			||||||
 | 
					//					String sectionName = entry.getKey();
 | 
				
			||||||
 | 
					//					Object sectionContent = entry.getValue();
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("teamSlider".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderTeamSlider((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("teamSectionTemplate".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderTeamSectionTemplate((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("teamSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderTeamSection((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("logoGuidelines".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderLogoGuidelines((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("logoGrid".equalsIgnoreCase(sectionName) && sectionContent instanceof List) {
 | 
				
			||||||
 | 
					//						html.append(renderLogoGrid((List<Map<String, Object>>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("brandGuideline".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBrandGuideline((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("logoShowcase".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderLogoShowcase((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("logoCloud".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderLogoCloud((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("ecommerceFAQs".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderEcommerceFAQs((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("dashboardLayout".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderDashboardLayout((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("FAQIllustratedSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderFaqIllustrated((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("FAQSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderFaqSection((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("FAQTwoColumn".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderFaqTwoColumn((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("TestimonialLanding".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderTestimonialLanding((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("ClientTestimonialSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderClientTestimonial((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("TestimonialSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderSimpleTestimonial((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("SubSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderSubSectionCentered((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("HeroSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						Map<String, Object> heroMap = (Map<String, Object>) sectionContent;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//						if ("centered".equalsIgnoreCase(getString(heroMap, "layout", ""))
 | 
				
			||||||
 | 
					//								&& heroMap.containsKey("artwork")) {
 | 
				
			||||||
 | 
					//							html.append(renderHeroCenteredWithArt(heroMap));
 | 
				
			||||||
 | 
					//							continue;
 | 
				
			||||||
 | 
					//						}
 | 
				
			||||||
 | 
					//						if ("left-text-right-cards".equalsIgnoreCase(getString(heroMap, "layout", ""))) {
 | 
				
			||||||
 | 
					//							html.append(renderHeroLeftCards(heroMap));
 | 
				
			||||||
 | 
					//							continue;
 | 
				
			||||||
 | 
					//						}
 | 
				
			||||||
 | 
					//						// Smart internal layout-based routing to correct renderer
 | 
				
			||||||
 | 
					//						String layout = getString(heroMap, "layout", "").toLowerCase();
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//						if (layout.equals("two-column") || heroMap.containsKey("leftColumn")) {
 | 
				
			||||||
 | 
					//							html.append(renderTwoColumnHeroSection(heroMap));
 | 
				
			||||||
 | 
					//						} else if (layout.equals("centered") || heroMap.containsKey("heading")) {
 | 
				
			||||||
 | 
					//							html.append(renderCenteredHeroSection(heroMap));
 | 
				
			||||||
 | 
					//						} else {
 | 
				
			||||||
 | 
					//							// fallback to older generic renderHeroSection
 | 
				
			||||||
 | 
					//							html.append(renderHeroSection(heroMap));
 | 
				
			||||||
 | 
					//						}
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("Blog".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogCardSection((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("blogPage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogPage((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("blogPreviewSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogPreviewSection((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("blogHomePage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogHomePage((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("blogListSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogListSection((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("ContactSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderContactSection((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("Navbar".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderNavbarBlock((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("Footer".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						Map<String, Object> footerMap = (Map<String, Object>) sectionContent;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//						// Smart switch based on keys like 'columns', 'topBar', 'bottom'
 | 
				
			||||||
 | 
					//						if (footerMap.containsKey("columns") || footerMap.containsKey("topBar")
 | 
				
			||||||
 | 
					//								|| footerMap.containsKey("bottom")) {
 | 
				
			||||||
 | 
					//							html.append(renderMdBootstrapFooter(footerMap));
 | 
				
			||||||
 | 
					//						} else if (footerMap.containsKey("linkColumns") || footerMap.containsKey("socialIcons")) {
 | 
				
			||||||
 | 
					//							html.append(renderCompactFooter(footerMap));
 | 
				
			||||||
 | 
					//						} else {
 | 
				
			||||||
 | 
					//							html.append(renderFooterBlock(footerMap));
 | 
				
			||||||
 | 
					//						}
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("how-to-blog-post".equalsIgnoreCase(getString(map, "type", ""))) {
 | 
				
			||||||
 | 
					//						html.append(renderHowToBlogPost(map));
 | 
				
			||||||
 | 
					//						return html.toString();
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					if ("blogThumbnailGrid".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogThumbnailGrid((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("blogSection".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogSection((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("articlePage".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderArticlePage((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("templateLibrary".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderTemplateLibrary((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//					if ("blogHeader".equalsIgnoreCase(sectionName) && sectionContent instanceof Map) {
 | 
				
			||||||
 | 
					//						html.append(renderBlogHeader((Map<String, Object>) sectionContent));
 | 
				
			||||||
 | 
					//						continue;
 | 
				
			||||||
 | 
					//					}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					// Wrap each section in a <section> tag with class derived from key
 | 
				
			||||||
 | 
					//					html.append("<section class=\"").append(sectionName.toLowerCase().replace(" ", "-")).append("\">");
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					html.append(buildHtml(sectionContent));
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//					html.append("</section>");
 | 
				
			||||||
 | 
					//				}
 | 
				
			||||||
 | 
					//				return html.toString();
 | 
				
			||||||
 | 
					//			}
 | 
				
			||||||
 | 
					//			// Check if a universal TYPE_RENDERER exists for this block
 | 
				
			||||||
 | 
					//			String type = getString(map, "type", "");
 | 
				
			||||||
 | 
					//			if (TYPE_RENDERERS.containsKey(type.toLowerCase())) {
 | 
				
			||||||
 | 
					//				return TYPE_RENDERERS.get(type.toLowerCase()).apply(map);
 | 
				
			||||||
 | 
					//			}
 | 
				
			||||||
 | 
					//			// Normal map block
 | 
				
			||||||
 | 
					//			return renderFromMap(map);
 | 
				
			||||||
 | 
					//		} else if (node instanceof List) {
 | 
				
			||||||
 | 
					//			return renderFromList((List<Object>) node);
 | 
				
			||||||
 | 
					//		} else if (node != null) {
 | 
				
			||||||
 | 
					//			return node.toString();
 | 
				
			||||||
 | 
					//		} else {
 | 
				
			||||||
 | 
					//			return "";
 | 
				
			||||||
 | 
					//		}
 | 
				
			||||||
 | 
					//	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -9,7 +9,6 @@ import org.springframework.web.client.RestTemplate;
 | 
				
			|||||||
@Component
 | 
					@Component
 | 
				
			||||||
public class PortConstant {
 | 
					public class PortConstant {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static String LOCAL_HOST;
 | 
					 | 
				
			||||||
	public final static String FRONTEND_PORT_9191 = "30165";
 | 
						public final static String FRONTEND_PORT_9191 = "30165";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public final static String GITEA_IP_ADDRESS = "try.gitea";
 | 
						public final static String GITEA_IP_ADDRESS = "try.gitea";
 | 
				
			||||||
@ -36,6 +35,8 @@ public class PortConstant {
 | 
				
			|||||||
	public static String GITEA_DOMAIN;
 | 
						public static String GITEA_DOMAIN;
 | 
				
			||||||
	public static String GITEA_USERNAME;
 | 
						public static String GITEA_USERNAME;
 | 
				
			||||||
	public static String SITE_BUILDER;
 | 
						public static String SITE_BUILDER;
 | 
				
			||||||
 | 
						public static String LOCAL_HOST;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static String PROTOCOL;
 | 
						public static String PROTOCOL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user