Przeglądaj źródła

feat: 家庭端管家自助选择接口

iwt 3 tygodni temu
rodzic
commit
8521180d9c

+ 46 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/butler/FamilyButlerSelectController.java

@@ -0,0 +1,46 @@
+package com.etotem.cfc.controller.butler;
+
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.service.ButlerService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 家庭端管家自助选择(仅 L2 绑定受限,浏览开放)
+ */
+@RestController
+@RequestMapping("/api/butler")
+public class FamilyButlerSelectController {
+
+    @Resource
+    private ButlerService butlerService;
+
+    @PostMapping("/available-list")
+    public Result<List<Map<String, Object>>> availableList() {
+        return butlerService.getAvailableButlers();
+    }
+
+    @PostMapping("/my-butler")
+    public Result<Map<String, Object>> myButler(@RequestAttribute("userId") Long userId) {
+        return butlerService.getMyButler(userId);
+    }
+
+    @PostMapping("/select")
+    public Result<Map<String, Object>> select(
+            @RequestAttribute("userId") Long userId,
+            @RequestBody Map<String, Object> params) {
+        Object butlerUserIdObj = params.get("butlerUserId");
+        if (butlerUserIdObj == null || butlerUserIdObj.toString().trim().isEmpty()) {
+            return Result.error("缺少 butlerUserId 参数");
+        }
+        Long butlerUserId = Long.valueOf(butlerUserIdObj.toString());
+        return butlerService.selectButler(userId, butlerUserId);
+    }
+}