|
@@ -5,6 +5,7 @@ import com.etotem.cfc.dto.GenerateQuestionnaireDTO;
|
|
|
import com.etotem.cfc.dto.QuestionnaireSnapshotVO;
|
|
import com.etotem.cfc.dto.QuestionnaireSnapshotVO;
|
|
|
import com.etotem.cfc.dto.SubmitQuestionnaireDTO;
|
|
import com.etotem.cfc.dto.SubmitQuestionnaireDTO;
|
|
|
import com.etotem.cfc.entity.RelationshipQuestionnaireResponse;
|
|
import com.etotem.cfc.entity.RelationshipQuestionnaireResponse;
|
|
|
|
|
+import com.etotem.cfc.service.FamilyMemberService;
|
|
|
import com.etotem.cfc.service.RelationshipQuestionnaireService;
|
|
import com.etotem.cfc.service.RelationshipQuestionnaireService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -22,6 +23,9 @@ public class RelationshipQuestionnaireController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private RelationshipQuestionnaireService questionnaireService;
|
|
private RelationshipQuestionnaireService questionnaireService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private FamilyMemberService familyMemberService;
|
|
|
|
|
+
|
|
|
@Operation(summary = "AI 生成关系问卷")
|
|
@Operation(summary = "AI 生成关系问卷")
|
|
|
@PostMapping("/generate")
|
|
@PostMapping("/generate")
|
|
|
public Result<QuestionnaireSnapshotVO> generateQuestionnaire(@RequestBody GenerateQuestionnaireDTO dto,
|
|
public Result<QuestionnaireSnapshotVO> generateQuestionnaire(@RequestBody GenerateQuestionnaireDTO dto,
|
|
@@ -30,6 +34,9 @@ public Result<QuestionnaireSnapshotVO> generateQuestionnaire(@RequestBody Genera
|
|
|
return Result.error("请先登录");
|
|
return Result.error("请先登录");
|
|
|
}
|
|
}
|
|
|
dto.setRespondentId(userId);
|
|
dto.setRespondentId(userId);
|
|
|
|
|
+ if (dto.getMemberId() != null && !familyMemberService.isCallerInSameFamily(dto.getMemberId(), userId)) {
|
|
|
|
|
+ return Result.error("无权操作其他家庭成员");
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
QuestionnaireSnapshotVO vo = questionnaireService.generateQuestionnaire(dto);
|
|
QuestionnaireSnapshotVO vo = questionnaireService.generateQuestionnaire(dto);
|
|
|
return Result.success(vo);
|
|
return Result.success(vo);
|
|
@@ -48,6 +55,12 @@ public Result<RelationshipQuestionnaireResponse> submitQuestionnaire(@RequestBod
|
|
|
return Result.error("请先登录");
|
|
return Result.error("请先登录");
|
|
|
}
|
|
}
|
|
|
dto.setRespondentId(userId);
|
|
dto.setRespondentId(userId);
|
|
|
|
|
+ if (dto.getSnapshotId() != null) {
|
|
|
|
|
+ RelationshipQuestionnaireSnapshot snapshot = questionnaireService.getSnapshotById(dto.getSnapshotId());
|
|
|
|
|
+ if (snapshot != null && !familyMemberService.isCallerInSameFamily(snapshot.getFamilyMemberId(), userId)) {
|
|
|
|
|
+ return Result.error("无权操作其他家庭的问卷");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
RelationshipQuestionnaireResponse resp = questionnaireService.submitQuestionnaire(dto);
|
|
RelationshipQuestionnaireResponse resp = questionnaireService.submitQuestionnaire(dto);
|
|
|
return Result.success(resp);
|
|
return Result.success(resp);
|
|
@@ -65,6 +78,9 @@ public Result<QuestionnaireSnapshotVO> getSnapshot(@PathVariable Long memberId,
|
|
|
if (userId == null) {
|
|
if (userId == null) {
|
|
|
return Result.error("请先登录");
|
|
return Result.error("请先登录");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!familyMemberService.isCallerInSameFamily(memberId, userId)) {
|
|
|
|
|
+ return Result.error("无权查看其他家庭的问卷");
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
QuestionnaireSnapshotVO vo = questionnaireService.getSnapshot(memberId);
|
|
QuestionnaireSnapshotVO vo = questionnaireService.getSnapshot(memberId);
|
|
|
return Result.success(vo);
|
|
return Result.success(vo);
|
|
@@ -80,6 +96,9 @@ public Result<List<RelationshipQuestionnaireResponse>> getHistory(@PathVariable
|
|
|
if (userId == null) {
|
|
if (userId == null) {
|
|
|
return Result.error("请先登录");
|
|
return Result.error("请先登录");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!familyMemberService.isCallerInSameFamily(memberId, userId)) {
|
|
|
|
|
+ return Result.error("无权查看其他家庭的问卷历史");
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
List<RelationshipQuestionnaireResponse> history = questionnaireService.getHistory(memberId);
|
|
List<RelationshipQuestionnaireResponse> history = questionnaireService.getHistory(memberId);
|
|
|
return Result.success(history);
|
|
return Result.success(history);
|