Persist front project requirement keyword

This commit is contained in:
王鹏
2026-05-23 16:49:02 +08:00
parent dfbae3387f
commit ecdc015c2f
13 changed files with 72 additions and 11 deletions

View File

@@ -14,6 +14,7 @@ public class FrontProject extends BaseEntity
private String packageName;
private String version;
private String projectDesc;
private String requirementKeyword;
private String industryTemplate;
private String frontFramework;
private String backFramework;
@@ -39,6 +40,8 @@ public class FrontProject extends BaseEntity
public void setVersion(String version) { this.version = version; }
public String getProjectDesc() { return projectDesc; }
public void setProjectDesc(String projectDesc) { this.projectDesc = projectDesc; }
public String getRequirementKeyword() { return requirementKeyword; }
public void setRequirementKeyword(String requirementKeyword) { this.requirementKeyword = requirementKeyword; }
public String getIndustryTemplate() { return industryTemplate; }
public void setIndustryTemplate(String industryTemplate) { this.industryTemplate = industryTemplate; }
public String getFrontFramework() { return frontFramework; }

View File

@@ -4,6 +4,7 @@ public class FrontProjectCreateRequest
{
private String projectName;
private String projectDesc;
private String requirementKeyword;
private String industryTemplate;
private String packageName;
private String version;
@@ -12,6 +13,8 @@ public class FrontProjectCreateRequest
public void setProjectName(String projectName) { this.projectName = projectName; }
public String getProjectDesc() { return projectDesc; }
public void setProjectDesc(String projectDesc) { this.projectDesc = projectDesc; }
public String getRequirementKeyword() { return requirementKeyword; }
public void setRequirementKeyword(String requirementKeyword) { this.requirementKeyword = requirementKeyword; }
public String getIndustryTemplate() { return industryTemplate; }
public void setIndustryTemplate(String industryTemplate) { this.industryTemplate = industryTemplate; }
public String getPackageName() { return packageName; }

View File

@@ -4,6 +4,7 @@ public class FrontProjectUpdateRequest
{
private String projectName;
private String projectDesc;
private String requirementKeyword;
private String industryTemplate;
private String packageName;
private String version;
@@ -12,6 +13,8 @@ public class FrontProjectUpdateRequest
public void setProjectName(String projectName) { this.projectName = projectName; }
public String getProjectDesc() { return projectDesc; }
public void setProjectDesc(String projectDesc) { this.projectDesc = projectDesc; }
public String getRequirementKeyword() { return requirementKeyword; }
public void setRequirementKeyword(String requirementKeyword) { this.requirementKeyword = requirementKeyword; }
public String getIndustryTemplate() { return industryTemplate; }
public void setIndustryTemplate(String industryTemplate) { this.industryTemplate = industryTemplate; }
public String getPackageName() { return packageName; }

View File

@@ -76,7 +76,7 @@ public class AiGenerateServiceImpl implements IAiGenerateService
String aiContent = deepSeekClient.chat(prompt);
AppBlueprintDesign blueprint = parseAppBlueprintResponse(aiContent);
normalizeAppBlueprint(blueprint);
markAppBlueprintGenerated(projectId, blueprint);
markAppBlueprintGenerated(projectId, blueprint, request);
generation.setResponsePayload(aiContent);
generation.setSuccess("1");
generation.setElapsedMs(System.currentTimeMillis() - start);
@@ -113,7 +113,7 @@ public class AiGenerateServiceImpl implements IAiGenerateService
validator.validate(response, maxTables(), maxColumnsPerTable());
businessBlueprintValidator.validate(response);
persistDatabase(userId, projectId, response);
markDatabaseGenerated(projectId, response, confirmedAppBlueprint);
markDatabaseGenerated(projectId, response, confirmedAppBlueprint, request);
generation.setResponsePayload(aiContent);
generation.setSuccess("1");
generation.setElapsedMs(System.currentTimeMillis() - start);
@@ -1068,7 +1068,7 @@ public class AiGenerateServiceImpl implements IAiGenerateService
}
}
private void markDatabaseGenerated(Long projectId, DatabaseDesignResponse response, String confirmedAppBlueprint)
private void markDatabaseGenerated(Long projectId, DatabaseDesignResponse response, String confirmedAppBlueprint, GenerateDatabaseRequest request)
{
FrontProject project = new FrontProject();
project.setProjectId(projectId);
@@ -1078,17 +1078,23 @@ public class AiGenerateServiceImpl implements IAiGenerateService
{
project.setAppBlueprint(confirmedAppBlueprint);
}
project.setRequirementKeyword(request == null ? null : request.getExtraRequirements());
project.setProjectDesc(request == null ? null : request.getProjectDesc());
project.setIndustryTemplate(request == null ? null : request.getIndustryTemplate());
project.setBusinessBlueprint(JSON.toJSONString(response.getBusinessActions()));
frontProjectMapper.updateFrontProject(project);
}
private void markAppBlueprintGenerated(Long projectId, AppBlueprintDesign blueprint)
private void markAppBlueprintGenerated(Long projectId, AppBlueprintDesign blueprint, GenerateAppBlueprintRequest request)
{
FrontProject project = new FrontProject();
project.setProjectId(projectId);
project.setGenerateStatus("0");
project.setPreviewStatus("0");
project.setAppBlueprint(JSON.toJSONString(blueprint));
project.setRequirementKeyword(request == null ? null : request.getExtraRequirements());
project.setProjectDesc(request == null ? null : request.getProjectDesc());
project.setIndustryTemplate(request == null ? null : request.getIndustryTemplate());
frontProjectMapper.updateFrontProject(project);
}

View File

@@ -62,6 +62,7 @@ public class FrontProjectServiceImpl implements IFrontProjectService
project.setUserId(userId);
project.setProjectName(request.getProjectName());
project.setProjectDesc(request.getProjectDesc());
project.setRequirementKeyword(request.getRequirementKeyword());
project.setIndustryTemplate(request.getIndustryTemplate());
project.setPackageName(StringUtils.defaultIfEmpty(request.getPackageName(), "com.easycode.generated"));
project.setVersion(StringUtils.defaultIfEmpty(request.getVersion(), "1.0.0"));
@@ -110,6 +111,7 @@ public class FrontProjectServiceImpl implements IFrontProjectService
project.setUserId(userId);
project.setProjectName(request.getProjectName());
project.setProjectDesc(request.getProjectDesc());
project.setRequirementKeyword(request.getRequirementKeyword());
project.setIndustryTemplate(request.getIndustryTemplate());
project.setPackageName(request.getPackageName());
project.setVersion(request.getVersion());

View File

@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="packageName" column="package_name" />
<result property="version" column="version" />
<result property="projectDesc" column="project_desc" />
<result property="requirementKeyword" column="requirement_keyword" />
<result property="industryTemplate" column="industry_template" />
<result property="frontFramework" column="front_framework" />
<result property="backFramework" column="back_framework" />
@@ -27,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectFrontProjectVo">
select project_id, user_id, project_name, project_file_name, package_name, version, project_desc, industry_template, front_framework, back_framework, generate_status, preview_status, app_blueprint, er_diagram, business_blueprint, status, create_time, update_time, remark from front_project
select project_id, user_id, project_name, project_file_name, package_name, version, project_desc, requirement_keyword, industry_template, front_framework, back_framework, generate_status, preview_status, app_blueprint, er_diagram, business_blueprint, status, create_time, update_time, remark from front_project
</sql>
<select id="selectFrontProjectById" parameterType="Long" resultMap="FrontProjectResult">
@@ -62,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="packageName != null">package_name,</if>
<if test="version != null">version,</if>
<if test="projectDesc != null">project_desc,</if>
<if test="requirementKeyword != null">requirement_keyword,</if>
<if test="industryTemplate != null">industry_template,</if>
<if test="frontFramework != null">front_framework,</if>
<if test="backFramework != null">back_framework,</if>
@@ -81,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="packageName != null">#{packageName},</if>
<if test="version != null">#{version},</if>
<if test="projectDesc != null">#{projectDesc},</if>
<if test="requirementKeyword != null">#{requirementKeyword},</if>
<if test="industryTemplate != null">#{industryTemplate},</if>
<if test="frontFramework != null">#{frontFramework},</if>
<if test="backFramework != null">#{backFramework},</if>
@@ -103,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="packageName != null">package_name = #{packageName},</if>
<if test="version != null">version = #{version},</if>
<if test="projectDesc != null">project_desc = #{projectDesc},</if>
<if test="requirementKeyword != null">requirement_keyword = #{requirementKeyword},</if>
<if test="industryTemplate != null">industry_template = #{industryTemplate},</if>
<if test="frontFramework != null">front_framework = #{frontFramework},</if>
<if test="backFramework != null">back_framework = #{backFramework},</if>

View File

@@ -135,6 +135,22 @@ public class AiGenerateServiceImplTest
assertEquals("1", generationCaptor.getValue().getSuccess());
}
@Test
public void generateDatabasePersistsRequirementKeywordFromRequest()
{
when(frontProjectMapper.selectFrontProjectByUserAndId(7L, 10L)).thenReturn(project());
when(frontProjectTableMapper.selectTablesByProjectId(10L)).thenReturn(Collections.<FrontProjectTable>emptyList());
when(deepSeekClient.chat(anyString())).thenReturn(mockResponse());
GenerateDatabaseRequest request = request();
request.setExtraRequirements("library borrow return keyword");
service.generateDatabase(7L, 10L, request);
ArgumentCaptor<FrontProject> projectCaptor = ArgumentCaptor.forClass(FrontProject.class);
verify(frontProjectMapper).updateFrontProject(projectCaptor.capture());
assertEquals("library borrow return keyword", projectCaptor.getValue().getRequirementKeyword());
}
@Test
public void generateDatabaseIncludesConfirmedAppBlueprintConstraintsInPrompt()
{

View File

@@ -63,9 +63,12 @@ public class FrontProjectServiceImplTest
FrontProjectCreateRequest request = new FrontProjectCreateRequest();
request.setProjectName("车辆管理系统");
request.setRequirementKeyword("borrow return books");
FrontProject project = service.createProject(7L, request);
assertEquals(Long.valueOf(7L), project.getUserId());
assertEquals("borrow return books", project.getRequirementKeyword());
assertEquals("com.easycode.generated", project.getPackageName());
assertEquals("1.0.0", project.getVersion());
assertEquals("Vue3 + Element Plus", project.getFrontFramework());