|
|
@@ -3,7 +3,9 @@ package com.etotem.cfc.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.etotem.cfc.common.Result;
|
|
|
import com.etotem.cfc.dto.FamilyMemberInfoDTO;
|
|
|
+import com.etotem.cfc.dto.LoginResultDTO;
|
|
|
import com.etotem.cfc.dto.ProfileBackfillDTO;
|
|
|
+import com.etotem.cfc.dto.SwitchRoleDTO;
|
|
|
import com.etotem.cfc.entity.AssessmentOrder;
|
|
|
import com.etotem.cfc.entity.FamilyMember;
|
|
|
import com.etotem.cfc.entity.Family;
|
|
|
@@ -434,4 +436,36 @@ public class UserController {
|
|
|
}
|
|
|
return Result.success(accountCleanupService.exportUserData(userId));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 成员视图切换回家庭主账号视图(别名端点,委托 UserService.switchBackToParent)
|
|
|
+ */
|
|
|
+ @PostMapping("/switch-back-to-parent")
|
|
|
+ @Operation(summary = "成员切换回本人身份")
|
|
|
+ public Result<Boolean> switchBackToParent(HttpServletRequest request) {
|
|
|
+ Long userId = (Long) request.getAttribute("userId");
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.error("用户未登录");
|
|
|
+ }
|
|
|
+ boolean result = userService.switchBackToParent(userId);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 切换用户角色(别名端点,委托 UserService.switchRoleForLogin,异常口径与 AuthController 一致)
|
|
|
+ */
|
|
|
+ @PostMapping("/switch-role")
|
|
|
+ @Operation(summary = "切换用户角色 (支持 parent/child/teacher)")
|
|
|
+ public Result<LoginResultDTO> switchRole(HttpServletRequest request, @RequestBody SwitchRoleDTO dto) {
|
|
|
+ Long userId = (Long) request.getAttribute("userId");
|
|
|
+ if (userId == null) {
|
|
|
+ return Result.error("未登录");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ LoginResultDTO result = userService.switchRoleForLogin(userId, dto.getRole());
|
|
|
+ return Result.success(result);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|