|
|
@@ -36,6 +36,7 @@ import com.ejlchina.searcher.param.Operator;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -85,6 +86,8 @@ public class GroupRelationController {
|
|
|
|
|
|
private final QuestionnairePromotionMapper questionnairePromotionMapper;
|
|
|
|
|
|
+ private final QuestionnairePromotionMapper promotionMapper;
|
|
|
+
|
|
|
private final GlobalThreadPoolTaskExecutor THREAD_POOL;
|
|
|
|
|
|
@RequestMapping("/get/renewal")
|
|
|
@@ -406,14 +409,19 @@ public class GroupRelationController {
|
|
|
/**
|
|
|
* 记录问卷
|
|
|
*/
|
|
|
- @PostMapping("/record/questionnaire")
|
|
|
- public Result<String> recordQuestionnaire(@RequestBody @Validated FormFieldsData data) {
|
|
|
- Long promotionId = data.getPromotionId();
|
|
|
- if (promotionId == null){
|
|
|
- //默认问卷
|
|
|
- data.setPromotionId(1l);
|
|
|
- }
|
|
|
- formFieldsDataMapper.insert(data);
|
|
|
+ @PostMapping("/record/questionnaire/{promotionId}")
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Result<String> recordQuestionnaire(@PathVariable Long promotionId, @RequestBody List<FormFieldsData> answers) {
|
|
|
+ QuestionnairePromotion promotion = promotionMapper.selectById(promotionId);
|
|
|
+ if (promotion == null) throw BusinessRuntimeException.getInstance("问卷不存在");
|
|
|
+ answers.forEach(answer -> {
|
|
|
+ Long fieldsId = answer.getFieldsId();
|
|
|
+ String content = answer.getContent();
|
|
|
+ if (fieldsId == null || StrUtil.isBlank(content)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("必填项为空");
|
|
|
+ }
|
|
|
+ formFieldsDataMapper.insert(answer);
|
|
|
+ });
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
}
|