Filter business blocks by page scope
This commit is contained in:
@@ -17,6 +17,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.generator.domain.front.FrontProject;
|
||||
import com.ruoyi.generator.domain.front.dto.DatabaseDesignResponse;
|
||||
import com.ruoyi.generator.domain.front.dto.AiGenerationTaskCreateRequest;
|
||||
@@ -25,10 +26,14 @@ import com.ruoyi.generator.domain.front.dto.FrontProjectUpdateRequest;
|
||||
import com.ruoyi.generator.domain.front.dto.GenerateAppBlueprintRequest;
|
||||
import com.ruoyi.generator.domain.front.dto.GenerateBusinessBlueprintRequest;
|
||||
import com.ruoyi.generator.domain.front.dto.GenerateDatabaseRequest;
|
||||
import com.ruoyi.generator.domain.front.dto.FrontendPageDesignRequest;
|
||||
import com.ruoyi.generator.domain.front.dto.PreviewFileRequest;
|
||||
import com.ruoyi.generator.service.front.IAiGenerateService;
|
||||
import com.ruoyi.generator.service.front.IAiGenerationTaskService;
|
||||
import com.ruoyi.generator.service.front.BusinessBlockRegistryService;
|
||||
import com.ruoyi.generator.service.front.FrontendPageDesignService;
|
||||
import com.ruoyi.generator.service.front.IFrontProjectPreviewService;
|
||||
import com.ruoyi.generator.service.front.IFrontProjectRunPreviewService;
|
||||
import com.ruoyi.generator.service.front.IFrontProjectService;
|
||||
|
||||
@RestController
|
||||
@@ -42,7 +47,13 @@ public class FrontProjectController extends BaseController
|
||||
@Autowired
|
||||
private IAiGenerationTaskService aiGenerationTaskService;
|
||||
@Autowired
|
||||
private FrontendPageDesignService frontendPageDesignService;
|
||||
@Autowired
|
||||
private BusinessBlockRegistryService businessBlockRegistryService;
|
||||
@Autowired
|
||||
private IFrontProjectPreviewService frontProjectPreviewService;
|
||||
@Autowired
|
||||
private IFrontProjectRunPreviewService frontProjectRunPreviewService;
|
||||
|
||||
@PostMapping("/create")
|
||||
public AjaxResult create(@RequestBody FrontProjectCreateRequest request)
|
||||
@@ -99,6 +110,66 @@ public class FrontProjectController extends BaseController
|
||||
return AjaxResult.success(frontProjectService.saveDatabase(userId, projectId, request));
|
||||
}
|
||||
|
||||
@GetMapping("/{projectId}/page-designs")
|
||||
public AjaxResult pageDesigns(@PathVariable Long projectId,
|
||||
@RequestParam(defaultValue = "frontend") String scope)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return AjaxResult.success(frontendPageDesignService.listPageDesigns(userId, projectId, scope));
|
||||
}
|
||||
|
||||
@GetMapping("/{projectId}/business-blocks")
|
||||
public AjaxResult businessBlocks(@PathVariable Long projectId,
|
||||
@RequestParam(defaultValue = "frontend") String scope)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
frontProjectService.getProject(userId, projectId);
|
||||
return AjaxResult.success(businessBlockRegistryService.listDefinitions(scope));
|
||||
}
|
||||
|
||||
@PostMapping("/{projectId}/page-designs/init")
|
||||
public AjaxResult initPageDesigns(@PathVariable Long projectId,
|
||||
@RequestParam(defaultValue = "frontend") String scope)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return AjaxResult.success(frontendPageDesignService.initializePageDesigns(userId, projectId, scope));
|
||||
}
|
||||
|
||||
@PostMapping("/{projectId}/page-designs")
|
||||
public AjaxResult createPageDesign(@PathVariable Long projectId,
|
||||
@RequestParam(defaultValue = "frontend") String scope,
|
||||
@RequestBody FrontendPageDesignRequest request)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return AjaxResult.success(frontendPageDesignService.createPageDesign(userId, projectId, request, scope));
|
||||
}
|
||||
|
||||
@GetMapping("/{projectId}/page-designs/{designId}")
|
||||
public AjaxResult pageDesign(@PathVariable Long projectId, @PathVariable Long designId,
|
||||
@RequestParam(defaultValue = "frontend") String scope)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return AjaxResult.success(frontendPageDesignService.getPageDesign(userId, projectId, designId, scope));
|
||||
}
|
||||
|
||||
@PutMapping("/{projectId}/page-designs/{designId}")
|
||||
public AjaxResult savePageDesign(@PathVariable Long projectId, @PathVariable Long designId,
|
||||
@RequestParam(defaultValue = "frontend") String scope,
|
||||
@RequestBody FrontendPageDesignRequest request)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return AjaxResult.success(frontendPageDesignService.updatePageDesign(userId, projectId, designId, request, scope));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{projectId}/page-designs/{designId}")
|
||||
public AjaxResult deletePageDesign(@PathVariable Long projectId, @PathVariable Long designId,
|
||||
@RequestParam(defaultValue = "frontend") String scope)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
frontendPageDesignService.deletePageDesign(userId, projectId, designId, scope);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/{projectId}/generate-database")
|
||||
public AjaxResult generateDatabase(@PathVariable Long projectId, @RequestBody GenerateDatabaseRequest request)
|
||||
{
|
||||
@@ -173,9 +244,31 @@ public class FrontProjectController extends BaseController
|
||||
frontProjectPreviewService.getStructure(userId, projectId, "frontend");
|
||||
}
|
||||
frontProjectPreviewService.getStructure(userId, projectId, "admin_frontend");
|
||||
frontProjectPreviewService.getStructure(userId, projectId, "sql");
|
||||
return toAjax(frontProjectPreviewService.markPreviewReady(userId, projectId));
|
||||
}
|
||||
|
||||
@PostMapping("/{projectId}/run-preview")
|
||||
public AjaxResult startRunPreview(@PathVariable Long projectId)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return success(frontProjectRunPreviewService.start(userId, projectId));
|
||||
}
|
||||
|
||||
@GetMapping("/{projectId}/run-preview")
|
||||
public AjaxResult runPreviewStatus(@PathVariable Long projectId)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return success(frontProjectRunPreviewService.status(userId, projectId));
|
||||
}
|
||||
|
||||
@PostMapping("/{projectId}/run-preview/stop")
|
||||
public AjaxResult stopRunPreview(@PathVariable Long projectId)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return success(frontProjectRunPreviewService.stop(userId, projectId));
|
||||
}
|
||||
|
||||
@GetMapping("/{projectId}/structure")
|
||||
public AjaxResult structure(@PathVariable Long projectId, @RequestParam String templateType)
|
||||
{
|
||||
@@ -194,13 +287,28 @@ public class FrontProjectController extends BaseController
|
||||
public void download(@PathVariable Long projectId, @RequestParam(required = false) String templateType, HttpServletResponse response) throws IOException
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
FrontProject project = frontProjectService.getProject(userId, projectId);
|
||||
byte[] data = StringUtils.isNotEmpty(templateType)
|
||||
? frontProjectPreviewService.download(userId, projectId, templateType)
|
||||
: frontProjectPreviewService.downloadAll(userId, projectId);
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"project.zip\"");
|
||||
FileUtils.setAttachmentResponseHeader(response, sourceZipName(project));
|
||||
response.addHeader("Content-Length", "" + data.length);
|
||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||
IOUtils.write(data, response.getOutputStream());
|
||||
}
|
||||
|
||||
private String sourceZipName(FrontProject project)
|
||||
{
|
||||
String fallback = project != null && project.getProjectId() != null
|
||||
? "project-" + project.getProjectId()
|
||||
: "easycode-project";
|
||||
String rawName = project == null ? null : project.getProjectName();
|
||||
String safeName = StringUtils.isEmpty(rawName) ? fallback : rawName.trim().replaceAll("[\\\\/:*?\"<>|]", "_");
|
||||
if (StringUtils.isEmpty(safeName))
|
||||
{
|
||||
safeName = fallback;
|
||||
}
|
||||
return safeName + ".zip";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user