|
|
@@ -11,6 +11,7 @@ import com.etotem.cfc.entity.User;
|
|
|
import com.etotem.cfc.mapper.UserMapper;
|
|
|
import com.etotem.cfc.service.EnergyService;
|
|
|
import com.etotem.cfc.service.FiveDimensionScoreService;
|
|
|
+import com.etotem.cfc.service.MembershipService;
|
|
|
import com.etotem.cfc.service.UnlockGateService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
@@ -37,6 +38,9 @@ public class EnergyController {
|
|
|
@Resource
|
|
|
private UnlockGateService unlockGateService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MembershipService membershipService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取能量沙盘数据(个人/全家两层,受通关门禁控制)
|
|
|
* view=personal: 当前登录用户个人五维(需通过 SELF_CHECK 关卡)
|
|
|
@@ -85,10 +89,18 @@ public class EnergyController {
|
|
|
boolean familyUnlocked = inviteGate == null
|
|
|
|| unlockGateService.isGateUnlocked(user.getFamilyId(), inviteGate);
|
|
|
|
|
|
+ // SOP-HIDE:FREE 用户隐藏 富/行/心 分项值 + familyData 家庭聚合,响应加 masked 标志
|
|
|
+ boolean freeUser = "FREE".equals(membershipService.getMemberLevel(userId));
|
|
|
+ if (freeUser) {
|
|
|
+ maskEnergySandbox(personalData);
|
|
|
+ familyData = null;
|
|
|
+ }
|
|
|
+
|
|
|
result.put("locked", false);
|
|
|
result.put("view", "family".equals(view) ? "family" : "personal");
|
|
|
result.put("personalData", personalData);
|
|
|
result.put("familyData", familyData);
|
|
|
+ result.put("masked", freeUser);
|
|
|
result.put("familyUnlocked", familyUnlocked);
|
|
|
if (!familyUnlocked && inviteGate != null) {
|
|
|
result.put("familyGate", gateToMap(inviteGate));
|
|
|
@@ -96,6 +108,102 @@ public class EnergyController {
|
|
|
return Result.success(result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * SOP-HIDE:FREE 用户五维沙盘数据脱敏。
|
|
|
+ * 保留 overallScore + 身/智基础值,隐藏 富/行/心 分项值。
|
|
|
+ */
|
|
|
+ private void maskEnergySandbox(EnergySandboxDTO dto) {
|
|
|
+ if (dto == null) return;
|
|
|
+ dto.setMindScore(null);
|
|
|
+ dto.setActionScore(null);
|
|
|
+ dto.setWealthScore(null);
|
|
|
+ if (dto.getMembers() != null) {
|
|
|
+ for (MemberEnergyDTO m : dto.getMembers()) {
|
|
|
+ if (m == null) continue;
|
|
|
+ m.setMindScore(null);
|
|
|
+ m.setActionScore(null);
|
|
|
+ m.setWealthScore(null);
|
|
|
+ // 富·利他创富模型
|
|
|
+ m.setWealthSkill(null);
|
|
|
+ m.setWealthAltruism(null);
|
|
|
+ m.setWealthIncome(null);
|
|
|
+ m.setWealthFx(null);
|
|
|
+ m.setWealthAchievement(null);
|
|
|
+ m.setWealthNetwork(null);
|
|
|
+ m.setWealthEducation(null);
|
|
|
+ m.setWealthSocial(null);
|
|
|
+ m.setWealthPoints(null);
|
|
|
+ m.setWealthLegacy(null);
|
|
|
+ m.setWealthChildLegacy(null);
|
|
|
+ // 心·大五人格
|
|
|
+ m.setBigFiveOpenness(null);
|
|
|
+ m.setBigFiveConscientiousness(null);
|
|
|
+ m.setBigFiveExtraversion(null);
|
|
|
+ m.setBigFiveAgreeableness(null);
|
|
|
+ m.setBigFiveNeuroticism(null);
|
|
|
+ // 心·情绪稳定
|
|
|
+ m.setEmotionEmotion(null);
|
|
|
+ m.setEmotionResilience(null);
|
|
|
+ m.setEmotionStressCoping(null);
|
|
|
+ m.setEmotionSelfAwareness(null);
|
|
|
+ m.setEmotionStability(null);
|
|
|
+ // 心·自驱力
|
|
|
+ m.setDriveAutonomy(null);
|
|
|
+ m.setDriveCompetence(null);
|
|
|
+ m.setDriveRelatedness(null);
|
|
|
+ // 心·自我概念
|
|
|
+ m.setSelfConceptOverall(null);
|
|
|
+ // 行·本人版
|
|
|
+ m.setActionParentChild(null);
|
|
|
+ m.setActionMarital(null);
|
|
|
+ m.setActionParental(null);
|
|
|
+ m.setActionLeadership(null);
|
|
|
+ m.setActionSociality(null);
|
|
|
+ m.setActionInterpersonal(null);
|
|
|
+ // 行·家庭成员版
|
|
|
+ m.setActionChildParentChild(null);
|
|
|
+ m.setActionSibling(null);
|
|
|
+ m.setActionRelative(null);
|
|
|
+ m.setActionTeacherStudent(null);
|
|
|
+ m.setActionChildSociality(null);
|
|
|
+ m.setActionChildInterpersonal(null);
|
|
|
+ // 克态标记(涉及富/行/心维度)
|
|
|
+ m.setBodyWealthStatus(null);
|
|
|
+ m.setBodyWealthMessage(null);
|
|
|
+ m.setActionBodyStatus(null);
|
|
|
+ m.setActionBodyMessage(null);
|
|
|
+ m.setWealthHeartStatus(null);
|
|
|
+ m.setWealthHeartMessage(null);
|
|
|
+ m.setMindWisdomStatus(null);
|
|
|
+ m.setMindWisdomMessage(null);
|
|
|
+ m.setWisdomActionStatus(null);
|
|
|
+ m.setWisdomActionMessage(null);
|
|
|
+ // 旧心子维度兼容
|
|
|
+ m.setHeartEmotionStable(null);
|
|
|
+ m.setHeartUnderstanding(null);
|
|
|
+ m.setHeartLegacy(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SOP-HIDE:FREE 用户五维概览脱敏(保留 身/智 分项,隐藏 富/行/心 分项)。
|
|
|
+ */
|
|
|
+ private void maskEnergyOverview(Map<String, Object> data) {
|
|
|
+ if (data == null) return;
|
|
|
+ Object dimsObj = data.get("dimensions");
|
|
|
+ if (!(dimsObj instanceof List)) return;
|
|
|
+ List<Map<String, Object>> dims = (List<Map<String, Object>>) dimsObj;
|
|
|
+ for (Map<String, Object> d : dims) {
|
|
|
+ if (d == null) continue;
|
|
|
+ String code = String.valueOf(d.get("code"));
|
|
|
+ if ("mind".equals(code) || "action".equals(code) || "wealth".equals(code)) {
|
|
|
+ d.put("energy", null);
|
|
|
+ d.put("healthIndex", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private EnergySandboxDTO resolvePersonalData(Long userId, Long familyId, Long targetMemberId) {
|
|
|
if (targetMemberId != null) {
|
|
|
EnergySandboxDTO family = energyService.calculateFamilyEnergy(familyId);
|
|
|
@@ -157,6 +265,7 @@ public class EnergyController {
|
|
|
@PostMapping("/overview")
|
|
|
public Result<Map<String, Object>> getEnergyOverview(
|
|
|
@RequestBody(required = false) Map<String, Object> params,
|
|
|
+ @RequestAttribute("userId") Long userId,
|
|
|
@RequestAttribute(value = "familyId", required = false) Long familyId,
|
|
|
@RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
|
|
|
if (params == null) {
|
|
|
@@ -170,6 +279,11 @@ public class EnergyController {
|
|
|
return Result.noFamily("请先创建或加入家庭");
|
|
|
}
|
|
|
Map<String, Object> data = energyService.getOverview(memberId);
|
|
|
+ boolean freeUser = "FREE".equals(membershipService.getMemberLevel(userId));
|
|
|
+ if (freeUser) {
|
|
|
+ maskEnergyOverview(data);
|
|
|
+ }
|
|
|
+ data.put("masked", freeUser);
|
|
|
return Result.success(data);
|
|
|
}
|
|
|
|