From 9787d186cc5d936e8ac87e80606ea8f91976fa0e Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Fri, 16 May 2025 15:07:26 +0530 Subject: [PATCH] build --- .../Controllers/Design_lbraryController.java | 20 +++++ .../dlf/Controllers/Dlf_headerController.java | 90 +++++++++++++++++++ .../com/realnet/dlf/Entity/Design_lbrary.java | 2 +- .../com/realnet/dlf/Entity/Dlf_header.java | 36 ++++++++ .../Repository/Design_lbraryRepository.java | 15 +++- .../dlf/Repository/Dlf_headerRepository.java | 21 +++++ .../dlf/Services/Design_lbraryService.java | 30 +++++-- .../dlf/Services/Dlf_headerService.java | 76 ++++++++++++++++ .../vpspack/Services/SiteBuilderService.java | 16 +++- 9 files changed, 295 insertions(+), 11 deletions(-) create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Dlf_headerController.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Dlf_header.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Dlf_headerRepository.java create mode 100644 visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Dlf_headerService.java diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java index b055902..7fa186f 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Design_lbraryController.java @@ -71,6 +71,13 @@ public class Design_lbraryController { List get = designLibraryService.getdetails(); return get; } + + @GetMapping("/Design_lbrary/line/{id}") + public List getAllDlf(@PathVariable Integer id) { + List get = designLibraryService.getAllDlfByhedId(id); + return get; + } + // get all without authentication @GetMapping("/token/Design_lbrary") @@ -136,6 +143,19 @@ public class Design_lbraryController { return new ResponseEntity(flf_line, HttpStatus.OK); } + @GetMapping("/Design_lbrary/line/unique") + public ResponseEntity getallByHeaderId(@RequestParam Integer headerId, @RequestParam String operationType, + @RequestParam String fieldType) { + Design_lbrary flf_line = designLibraryService.getallByHeaderId(headerId, operationType, fieldType); + + if (flf_line == null) { + + return new ResponseEntity<>("not found", HttpStatus.EXPECTATION_FAILED); + } + + return new ResponseEntity(flf_line, HttpStatus.OK); + } + @GetMapping("/Design_lbrary/list/template") public ResponseEntity listOfTemplate(@RequestParam String operationType, @RequestParam String fieldType) { List flf_line = designLibraryService.listOfTemplate(operationType, fieldType); diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Dlf_headerController.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Dlf_headerController.java new file mode 100644 index 0000000..1ccfd77 --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Controllers/Dlf_headerController.java @@ -0,0 +1,90 @@ +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.Dlf_header; +import com.realnet.dlf.Services.Dlf_headerService; +import com.realnet.fnd.response.EntityResponse; + +@RequestMapping(value = "/Dlf_header") +@CrossOrigin("*") +@RestController +public class Dlf_headerController { + @Autowired + private Dlf_headerService Service; + + @Value("${projectPath}") + private String projectPath; + + @PostMapping("/Dlf_header") + public Dlf_header Savedata(@RequestBody Dlf_header data) { + Dlf_header save = Service.Savedata(data); + + System.out.println("data saved..." + save); + + return save; + } + + @PutMapping("/Dlf_header/{id}") + public Dlf_header update(@RequestBody Dlf_header data, @PathVariable Integer id) { + Dlf_header update = Service.update(data, id); + System.out.println("data update..." + update); + return update; + } + +// get all with pagination + @GetMapping("/Dlf_header/getall/page") + public Page getall(@RequestParam(value = "page", required = false) Integer page, + @RequestParam(value = "size", required = false) Integer size) { + Pageable paging = PageRequest.of(page, size); + Page get = Service.getAllWithPagination(paging); + + return get; + + } + + @GetMapping("/Dlf_header") + public List getdetails() { + List get = Service.getdetails(); + return get; + } +// get all without authentication + + @GetMapping("/token/Dlf_header") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; + } + + @GetMapping("/Dlf_header/{id}") + public Dlf_header getdetailsbyId(@PathVariable Integer id) { + Dlf_header get = Service.getdetailsbyId(id); + return get; + } + + @DeleteMapping("/Dlf_header/{id}") + public ResponseEntity delete_by_id(@PathVariable Integer id) { + Service.delete_by_id(id); + return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); + + } + +} \ No newline at end of file diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java index 9a7a097..bc1ad28 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Design_lbrary.java @@ -48,6 +48,6 @@ public class Design_lbrary extends Extension { private String typerender; - private String techstack; + private Integer hedaer_id; } diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Dlf_header.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Dlf_header.java new file mode 100644 index 0000000..d411f03 --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Entity/Dlf_header.java @@ -0,0 +1,36 @@ +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 com.realnet.WhoColumn.Entity.Extension; + +import lombok.Data; + +@Entity +@Data +public class Dlf_header 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; + + private String type; + + private String techstack; + +} diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java index 2ebc3b1..8ea095a 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Design_lbraryRepository.java @@ -20,13 +20,20 @@ public interface Design_lbraryRepository extends JpaRepository findAll(Pageable page, Long creayedBy); - @Query(value = "SELECT * from design_lbrary WHERE active=:active && templatetype=:operation_type && uitype=:fieldtype limit 1", nativeQuery = true) - Design_lbrary getallByHeaderIdAndFieldType(@Param("active") boolean active, - @Param("operation_type") String operation_type, @Param("fieldtype") String fieldtype); + @Query(value = "select * from design_lbrary where created_by=?1 && hedaer_id=?2 ", nativeQuery = true) + List getAllByhedId(Long creayedBy, Integer hedaer_id); + + @Query(value = "SELECT * from design_lbrary WHERE active=:active && templatetype=:templatetype && uitype=:fieldtype limit 1", nativeQuery = true) + Design_lbrary getallByFieldType(@Param("active") boolean active, @Param("templatetype") String templatetype, + @Param("fieldtype") String fieldtype); + + @Query(value = "SELECT * from design_lbrary WHERE active=:active && hedaer_id=:hedaer_id && templatetype=:templatetype AND LOWER(uitype) = LOWER(:fieldtype) limit 1", nativeQuery = true) + Design_lbrary getallByHeaderId(@Param("hedaer_id") Integer hedaer_id, @Param("active") boolean active, + @Param("templatetype") String templatetype, @Param("fieldtype") String fieldtype); @Query(value = "SELECT * FROM design_lbrary " + "WHERE active=:active && templatetype = :operation_type " + "AND LOWER(uitype) LIKE CONCAT(LOWER(:fieldtype), '%')", nativeQuery = true) - List getallFlfLine(@Param("active") boolean active, @Param("operation_type") String operationType, + List getallDlfLine(@Param("active") boolean active, @Param("operation_type") String operationType, @Param("fieldtype") String fieldtype); @Query(value = "select * from design_lbrary WHERE id BETWEEN :startId AND :endId", nativeQuery = true) diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Dlf_headerRepository.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Dlf_headerRepository.java new file mode 100644 index 0000000..b79bfcc --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Repository/Dlf_headerRepository.java @@ -0,0 +1,21 @@ +package com.realnet.dlf.Repository; + +import java.util.List; + +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 com.realnet.dlf.Entity.Dlf_header; + +@Repository +public interface Dlf_headerRepository extends JpaRepository { + + @Query(value = "select * from dlf_header where created_by=?1", nativeQuery = true) + List findAll(Long creayedBy); + + @Query(value = "select * from dlf_header where created_by=?1", nativeQuery = true) + Page findAll(Pageable page, Long creayedBy); +} \ No newline at end of file diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java index c9ae549..11c1938 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Design_lbraryService.java @@ -57,6 +57,13 @@ public class Design_lbraryService { return all; } + public List getAllDlfByhedId(Integer id) { + // TODO Auto-generated method stub + List all = designLibraryRepository.getAllByhedId(getUser().getUserId(), id); + return all; + + } + public Design_lbrary getdetailsbyId(Integer id) { return designLibraryRepository.findById(id).get(); } @@ -83,7 +90,6 @@ public class Design_lbraryService { old.setUitype(data.getUitype()); old.setTyperender(data.getTyperender()); - old.setTechstack(data.getTechstack()); old.setHtml(data.getHtml()); @@ -127,7 +133,7 @@ public class Design_lbraryService { // GET LINE BY header id, operation type, field type public Design_lbrary getflflinerandom(String operationType, String fieldType) { - List flf = designLibraryRepository.getallFlfLine(true, operationType.toLowerCase().trim(), + List flf = designLibraryRepository.getallDlfLine(true, operationType.toLowerCase().trim(), fieldType.toLowerCase().trim()); if (flf == null || flf.isEmpty()) { @@ -141,8 +147,21 @@ public class Design_lbraryService { // GET LINE BY header id, operation type, field type public Design_lbrary getLinestraight(String operationType, String fieldType) { - Design_lbrary flf = designLibraryRepository.getallByHeaderIdAndFieldType(true, - operationType.toLowerCase().trim(), fieldType.toLowerCase().trim()); + Design_lbrary flf = designLibraryRepository.getallByFieldType(true, operationType.toLowerCase().trim(), + fieldType.toLowerCase().trim()); + + if (flf == null) { + return null; // ya throw new RuntimeException("No data found"); + } + + // Random index pick + return flf; + } + + // GET LINE BY header id, operation type, field type + public Design_lbrary getallByHeaderId(Integer headerId, String operationType, String fieldType) { + Design_lbrary flf = designLibraryRepository.getallByHeaderId(headerId, true, operationType.toLowerCase().trim(), + fieldType.toLowerCase().trim()); if (flf == null) { return null; // ya throw new RuntimeException("No data found"); @@ -153,7 +172,7 @@ public class Design_lbraryService { } public List listOfTemplate(String operationType, String fieldType) { - List flf = designLibraryRepository.getallFlfLine(true, operationType.toLowerCase().trim(), + List flf = designLibraryRepository.getallDlfLine(true, operationType.toLowerCase().trim(), fieldType.toLowerCase().trim()); if (flf == null || flf.isEmpty()) { @@ -261,4 +280,5 @@ public class Design_lbraryService { return user; } + } diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Dlf_headerService.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Dlf_headerService.java new file mode 100644 index 0000000..95b4b8c --- /dev/null +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/dlf/Services/Dlf_headerService.java @@ -0,0 +1,76 @@ +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.dlf.Entity.Dlf_header; +import com.realnet.dlf.Repository.Dlf_headerRepository; +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 Dlf_headerService { + @Autowired + private Dlf_headerRepository Repository; + @Autowired + private AppUserServiceImpl userService; + @Autowired + private RealmService realmService; + + public Dlf_header Savedata(Dlf_header data) { + + data.setUpdatedBy(getUser().getUserId()); + data.setCreatedBy(getUser().getUserId()); + data.setAccountId(getUser().getAccount().getAccount_id()); + Dlf_header save = Repository.save(data); + return save; + } + +// get all with pagination + public Page getAllWithPagination(Pageable page) { + return Repository.findAll(page, getUser().getUserId()); + } + + public List getdetails() { + List realm = realmService.findByUserId(getUser().getUserId()); + List all = Repository.findAll(getUser().getUserId()); + + return all; + } + + public Dlf_header getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + public void delete_by_id(Integer id) { + Repository.deleteById(id); + } + + public Dlf_header update(Dlf_header data, Integer id) { + Dlf_header old = Repository.findById(id).get(); + old.setName(data.getName()); + + old.setDescription(data.getDescription()); + + old.setActive(data.isActive()); + + old.setType(data.getType()); + old.setTechstack(data.getTechstack()); + + final Dlf_header test = Repository.save(old); + data.setUpdatedBy(getUser().getUserId()); + return test; + } + + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + } +} diff --git a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/SiteBuilderService.java b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/SiteBuilderService.java index 7747c5e..57fc2ce 100644 --- a/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/SiteBuilderService.java +++ b/visaproject-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/SiteBuilderService.java @@ -98,11 +98,25 @@ public class SiteBuilderService { String folderPath = projectPath + File.separator + "Files" + File.separator + siteBuilderName; int i = 0; + String startindex = "\n" + "\n" + "\n" + " Welcome\n" + "\n" + + "\n"; + + String endindex = "\n" + ""; + for (Map.Entry entry : pageHtmlMap.entrySet()) { + String pageName = entry.getKey().trim().replaceAll("\\s+", "_") + ".html"; // remove spaces from name String htmlContent = entry.getValue(); - fileHelper.createFile(folderPath, pageName, htmlContent); + if (pageName.equalsIgnoreCase("home.html")) { + + pageName = "index.html"; + + htmlContent = startindex + " \n" + htmlContent + endindex; + + } + + fileHelper.createFile(folderPath, pageName.toLowerCase(), htmlContent); i++; System.out.println(i + " file created "); }