|
|
@@ -187,6 +187,23 @@ public class AssessmentService extends ServiceImpl<AssessmentMaterialMapper, Ass
|
|
|
}
|
|
|
|
|
|
public AssessmentRecord createRecord(Long familyId, Long memberId, Long materialId) {
|
|
|
+ // 必填参数守卫:测评记录必须归属明确家庭成员并绑定测评材料(dan.assessment.recordCreate 契约)
|
|
|
+ if (memberId == null) {
|
|
|
+ throw new IllegalArgumentException("memberId 不能为空,测评记录必须归属明确家庭成员");
|
|
|
+ }
|
|
|
+ if (materialId == null) {
|
|
|
+ throw new IllegalArgumentException("materialId 不能为空,测评记录必须绑定测评材料");
|
|
|
+ }
|
|
|
+ // 材料有效性校验:仅允许基于存在且启用的测评材料创建记录
|
|
|
+ AssessmentMaterial material = baseMapper.selectById(materialId);
|
|
|
+ if (material == null || !"active".equals(material.getStatus())) {
|
|
|
+ throw new IllegalArgumentException("测评材料不存在或未启用,无法创建测评记录");
|
|
|
+ }
|
|
|
+ // 成员-家庭归属校验:禁止为其他家庭家庭成员创建记录(防跨家庭越权,参照 SC-T-13)
|
|
|
+ com.etotem.cfc.entity.FamilyMember member = familyMemberMapper.selectById(memberId);
|
|
|
+ if (member == null || familyId == null || !familyId.equals(member.getFamilyId())) {
|
|
|
+ throw new IllegalArgumentException("家庭成员不属于当前家庭,无法创建测评记录");
|
|
|
+ }
|
|
|
AssessmentRecord record = new AssessmentRecord();
|
|
|
record.setFamilyId(familyId);
|
|
|
record.setMemberId(memberId);
|