This commit is contained in:
string 2025-04-26 09:39:47 +05:30
parent 4ed27c9019
commit 68d0a29758
2 changed files with 59 additions and 2 deletions

View File

@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -20,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.realnet.OpenAi.Services.ScriptRunnerService;
import com.realnet.OpenAi.Services.Script_Making;
import com.realnet.OpenAi.Services.SureopsService;
import com.realnet.fnd.response.EntityResponse;
@RestController
@ -34,11 +34,15 @@ public class SureOpsController {
@Autowired
private ScriptRunnerService scriptRunnerService;
@Autowired
private SureopsService sureopsService;
@Value("${projectPath}")
private String projectPath;
@GetMapping("/deploy")
public ResponseEntity<?> makeScript(@RequestParam Integer projId) throws IOException, InterruptedException {
public ResponseEntity<?> makeScript(@RequestParam Integer projId, @RequestBody Map<String, String> pageHtmlMap)
throws IOException, InterruptedException {
String workflow_id = "56"; // pull script
int status_code = 500;
@ -67,6 +71,9 @@ public class SureOpsController {
if (script.getStatusCodeValue() <= 209) {
System.out.println(" Run Pull script successfullt now make all file");
sureopsService.createHtmlFiles(projId, pageHtmlMap);
System.out.println(" All file created...");
workflow_id = "58";
ResponseEntity<?> pushScript = script_serviceMaking.CreateFiles(projId, workflow_id,
Deployment_profile);

View File

@ -0,0 +1,50 @@
package com.realnet.OpenAi.Services;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Service
public class SureopsService {
@Value("${projectPath}")
private String projectPath;
public void createHtmlFiles(Integer projId, Map<String, String> pageHtmlMap) throws IOException {
int i = 0;
for (Map.Entry<String, String> entry : pageHtmlMap.entrySet()) {
String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name
String htmlContent = entry.getValue();
String folderPath = projectPath + File.separator + projId + File.separator + "index";
File file = new File(folderPath + "/" + pageName + ".html");
// Ensure directory exists
File parentDir = file.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
// Create new file
if (!file.exists()) {
file.createNewFile();
}
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
writer.write(htmlContent);
i++;
System.out.println(i + " file created ");
}
System.out.println("✅ File created: " + file.getAbsolutePath());
}
}
}