feat: validate product development process step four
parent
46fa9321be
commit
eada1aef10
@ -0,0 +1,14 @@
|
|||||||
|
package com.sztzjy.linkCommerce.entity.dto;
|
||||||
|
|
||||||
|
public class ProductDevelopmentProcessStepFourValidationRequest {
|
||||||
|
private String parallelWorkAnalysis;
|
||||||
|
private String aiScenarioOne;
|
||||||
|
private String aiScenarioTwo;
|
||||||
|
|
||||||
|
public String getParallelWorkAnalysis() { return parallelWorkAnalysis; }
|
||||||
|
public void setParallelWorkAnalysis(String parallelWorkAnalysis) { this.parallelWorkAnalysis = parallelWorkAnalysis; }
|
||||||
|
public String getAiScenarioOne() { return aiScenarioOne; }
|
||||||
|
public void setAiScenarioOne(String aiScenarioOne) { this.aiScenarioOne = aiScenarioOne; }
|
||||||
|
public String getAiScenarioTwo() { return aiScenarioTwo; }
|
||||||
|
public void setAiScenarioTwo(String aiScenarioTwo) { this.aiScenarioTwo = aiScenarioTwo; }
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.sztzjy.linkCommerce.entity.dto;
|
||||||
|
|
||||||
|
public class ProductDevelopmentProcessStepFourValidationResult {
|
||||||
|
private boolean valid;
|
||||||
|
private String message;
|
||||||
|
public boolean isValid() { return valid; }
|
||||||
|
public void setValid(boolean valid) { this.valid = valid; }
|
||||||
|
public String getMessage() { return message; }
|
||||||
|
public void setMessage(String message) { this.message = message; }
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.sztzjy.linkCommerce.service;
|
||||||
|
|
||||||
|
import com.sztzjy.linkCommerce.config.security.JwtUser;
|
||||||
|
import com.sztzjy.linkCommerce.entity.dto.ProductDevelopmentProcessStepFourValidationRequest;
|
||||||
|
import com.sztzjy.linkCommerce.entity.dto.ProductDevelopmentProcessStepFourValidationResult;
|
||||||
|
|
||||||
|
public interface ProductDevelopmentProcessStepFourService {
|
||||||
|
ProductDevelopmentProcessStepFourValidationResult validate(ProductDevelopmentProcessStepFourValidationRequest request, JwtUser user);
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.sztzjy.linkCommerce.service.impl;
|
||||||
|
|
||||||
|
import com.sztzjy.linkCommerce.config.exception.handler.ServiceException;
|
||||||
|
import com.sztzjy.linkCommerce.config.security.JwtUser;
|
||||||
|
import com.sztzjy.linkCommerce.entity.StudentTrainingAnswer;
|
||||||
|
import com.sztzjy.linkCommerce.entity.dto.ProductDevelopmentProcessStepFourValidationRequest;
|
||||||
|
import com.sztzjy.linkCommerce.entity.dto.ProductDevelopmentProcessStepFourValidationResult;
|
||||||
|
import com.sztzjy.linkCommerce.service.ProductDevelopmentProcessStepFourService;
|
||||||
|
import com.sztzjy.linkCommerce.service.StudentTrainingAnswerService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ProductDevelopmentProcessStepFourServiceImpl implements ProductDevelopmentProcessStepFourService {
|
||||||
|
private static final String TASK_KEY = "product-development-process";
|
||||||
|
private final StudentTrainingAnswerService studentTrainingAnswerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ProductDevelopmentProcessStepFourServiceImpl(StudentTrainingAnswerService studentTrainingAnswerService) {
|
||||||
|
this.studentTrainingAnswerService = studentTrainingAnswerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProductDevelopmentProcessStepFourValidationResult validate(ProductDevelopmentProcessStepFourValidationRequest request, JwtUser user) {
|
||||||
|
requireStudent(user);
|
||||||
|
requireStepThreeCompleted(user);
|
||||||
|
if (StringUtils.isBlank(request == null ? null : request.getParallelWorkAnalysis())) {
|
||||||
|
throw new ServiceException(HttpStatus.BAD_REQUEST, "请填写可提前介入并同步完成的电商运营工作");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(request.getAiScenarioOne()) || StringUtils.isBlank(request.getAiScenarioTwo())) {
|
||||||
|
throw new ServiceException(HttpStatus.BAD_REQUEST, "请至少填写 2 个 AI 工具提效应用场景");
|
||||||
|
}
|
||||||
|
ProductDevelopmentProcessStepFourValidationResult result = new ProductDevelopmentProcessStepFourValidationResult();
|
||||||
|
result.setValid(true);
|
||||||
|
result.setMessage("校验通过");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requireStudent(JwtUser user) {
|
||||||
|
if (user == null || StringUtils.isBlank(user.getUserId())) throw new ServiceException(HttpStatus.UNAUTHORIZED, "请先登录后再校验");
|
||||||
|
if (user.getRoleId() != 4) throw new ServiceException(HttpStatus.FORBIDDEN, "仅学生可进行实训校验");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requireStepThreeCompleted(JwtUser user) {
|
||||||
|
StudentTrainingAnswer answer = studentTrainingAnswerService.get(TASK_KEY, null, user);
|
||||||
|
if (answer == null || StringUtils.isBlank(answer.getStep3Answer())) {
|
||||||
|
throw new ServiceException(HttpStatus.BAD_REQUEST, "请先上传并保存第三步甘特图");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue