package com.zhentao.controller;

import com.zhentao.common.Result;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 红娘工作台控制器
 */
@RestController
@RequestMapping("/matchmaker")
@CrossOrigin(origins = "*")
public class MatchmakerWorkbenchController {

    /**
     * 获取工作台数据
     */
    @GetMapping("/workbench/data")
    public Result<Map<String, Object>> getWorkbenchData() {
        try {
            Map<String, Object> data = new HashMap<>();
            
            // 统计数据
            Map<String, Object> stats = new HashMap<>();
            stats.put("successCount", 520);
            stats.put("points", 23);
            data.put("stats", stats);
            
            // 公告
            Map<String, Object> announcement = new HashMap<>();
            announcement.put("title", "恭喜高红娘成功助力丁先生和贾女士牵手成功！");
            announcement.put("content", "恭喜高红娘成功助力丁先生和贾女士牵手成功！");
            data.put("announcement", announcement);
            
            // 本周最佳红娘
            List<Map<String, Object>> bestMatchmakers = new ArrayList<>();
            Map<String, Object> matchmaker1 = new HashMap<>();
            matchmaker1.put("rank", 1);
            matchmaker1.put("name", "小超超");
            matchmaker1.put("successCount", 12);
            matchmaker1.put("likes", 28);
            bestMatchmakers.add(matchmaker1);
            
            Map<String, Object> matchmaker2 = new HashMap<>();
            matchmaker2.put("rank", 2);
            matchmaker2.put("name", "小颖颖");
            matchmaker2.put("successCount", 11);
            matchmaker2.put("likes", 25);
            bestMatchmakers.add(matchmaker2);
            
            Map<String, Object> matchmaker3 = new HashMap<>();
            matchmaker3.put("rank", 3);
            matchmaker3.put("name", "小魏魏");
            matchmaker3.put("successCount", 10);
            matchmaker3.put("likes", 22);
            bestMatchmakers.add(matchmaker3);
            
            data.put("bestMatchmakers", bestMatchmakers);
            
            return Result.success(data);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("获取工作台数据失败：" + e.getMessage());
        }
    }

    /**
     * 获取我的资源
     */
    @GetMapping("/resources")
    public Result<List<Map<String, Object>>> getMyResources(@RequestParam(required = false) String keyword) {
        try {
            List<Map<String, Object>> resources = new ArrayList<>();
            
            // 模拟数据 - 小高
            Map<String, Object> resource1 = new HashMap<>();
            resource1.put("id", 1);
            resource1.put("avatar", "https://example.com/avatar1.jpg");
            resource1.put("name", "小高");
            resource1.put("gender", "男");
            resource1.put("status", "已审核");
            resource1.put("isPlus", true);
            List<String> labels1 = new ArrayList<>();
            labels1.add("气质男");
            labels1.add("小清新");
            resource1.put("labels", labels1);
            resource1.put("requirement", "165+ 本科");
            resource1.put("contact", "123****8912");
            resource1.put("isQuality", false);
            resources.add(resource1);
            
            // 模拟数据 - 小美
            Map<String, Object> resource2 = new HashMap<>();
            resource2.put("id", 2);
            resource2.put("avatar", "https://example.com/avatar2.jpg");
            resource2.put("name", "小美");
            resource2.put("gender", "女");
            resource2.put("status", "已审核");
            resource2.put("isPlus", true);
            List<String> labels2 = new ArrayList<>();
            labels2.add("温柔");
            labels2.add("知性");
            labels2.add("爱读书");
            resource2.put("labels", labels2);
            resource2.put("requirement", "175+ 硕士 有房");
            resource2.put("contact", "138****6543");
            resource2.put("isQuality", false);
            resources.add(resource2);
            
            // 模拟数据 - 阿强
            Map<String, Object> resource3 = new HashMap<>();
            resource3.put("id", 3);
            resource3.put("avatar", "https://example.com/avatar3.jpg");
            resource3.put("name", "阿强");
            resource3.put("gender", "男");
            resource3.put("status", "待审核");
            resource3.put("isPlus", false);
            List<String> labels3 = new ArrayList<>();
            labels3.add("阳光");
            labels3.add("运动型");
            resource3.put("labels", labels3);
            resource3.put("requirement", "160+ 大专以上");
            resource3.put("contact", "159****2234");
            resource3.put("isQuality", true);
            resources.add(resource3);
            
            return Result.success(resources);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("获取资源失败：" + e.getMessage());
        }
    }

    /**
     * 获取排行榜数据
     */
    @GetMapping("/ranking")
    public Result<List<Map<String, Object>>> getRankingData() {
        try {
            List<Map<String, Object>> rankingList = new ArrayList<>();
            
            // 模拟数据
            Map<String, Object> item1 = new HashMap<>();
            item1.put("name", "小华华");
            item1.put("successCount", 9);
            item1.put("userRating", 25);
            rankingList.add(item1);
            
            Map<String, Object> item2 = new HashMap<>();
            item2.put("name", "小蒋蒋");
            item2.put("successCount", 8);
            item2.put("userRating", 24);
            rankingList.add(item2);
            
            Map<String, Object> item3 = new HashMap<>();
            item3.put("name", "小明明");
            item3.put("successCount", 7);
            item3.put("userRating", 23);
            rankingList.add(item3);
            
            Map<String, Object> item4 = new HashMap<>();
            item4.put("name", "小信信");
            item4.put("successCount", 6);
            item4.put("userRating", 23);
            rankingList.add(item4);
            
            Map<String, Object> item5 = new HashMap<>();
            item5.put("name", "小莉莉");
            item5.put("successCount", 6);
            item5.put("userRating", 22);
            rankingList.add(item5);
            
            Map<String, Object> item6 = new HashMap<>();
            item6.put("name", "小圆圆");
            item6.put("successCount", 5);
            item6.put("userRating", 21);
            rankingList.add(item6);
            
            Map<String, Object> item7 = new HashMap<>();
            item7.put("name", "小方方");
            item7.put("successCount", 5);
            item7.put("userRating", 20);
            rankingList.add(item7);
            
            Map<String, Object> item8 = new HashMap<>();
            item8.put("name", "小香香");
            item8.put("successCount", 4);
            item8.put("userRating", 19);
            rankingList.add(item8);
            
            Map<String, Object> item9 = new HashMap<>();
            item9.put("name", "小甜甜");
            item9.put("successCount", 4);
            item9.put("userRating", 18);
            rankingList.add(item9);
            
            Map<String, Object> item10 = new HashMap<>();
            item10.put("name", "小美美");
            item10.put("successCount", 4);
            item10.put("userRating", 18);
            rankingList.add(item10);
            
            Map<String, Object> item11 = new HashMap<>();
            item11.put("name", "小柔柔");
            item11.put("successCount", 3);
            item11.put("userRating", 17);
            rankingList.add(item11);
            
            Map<String, Object> item12 = new HashMap<>();
            item12.put("name", "小静静");
            item12.put("successCount", 3);
            item12.put("userRating", 16);
            rankingList.add(item12);
            
            Map<String, Object> item13 = new HashMap<>();
            item13.put("name", "小聪聪");
            item13.put("successCount", 3);
            item13.put("userRating", 15);
            rankingList.add(item13);
            
            Map<String, Object> item14 = new HashMap<>();
            item14.put("name", "小慧慧");
            item14.put("successCount", 3);
            item14.put("userRating", 15);
            rankingList.add(item14);
            
            Map<String, Object> item15 = new HashMap<>();
            item15.put("name", "小欢欢");
            item15.put("successCount", 2);
            item15.put("userRating", 14);
            rankingList.add(item15);
            
            Map<String, Object> item16 = new HashMap<>();
            item16.put("name", "小乐乐");
            item16.put("successCount", 2);
            item16.put("userRating", 13);
            rankingList.add(item16);
            
            Map<String, Object> item17 = new HashMap<>();
            item17.put("name", "小笑笑");
            item17.put("successCount", 2);
            item17.put("userRating", 12);
            rankingList.add(item17);
            
            Map<String, Object> item18 = new HashMap<>();
            item18.put("name", "小闹闹");
            item18.put("successCount", 1);
            item18.put("userRating", 11);
            rankingList.add(item18);
            
            Map<String, Object> item19 = new HashMap<>();
            item19.put("name", "小跳跳");
            item19.put("successCount", 1);
            item19.put("userRating", 10);
            rankingList.add(item19);
            
            Map<String, Object> item20 = new HashMap<>();
            item20.put("name", "小跑跑");
            item20.put("successCount", 1);
            item20.put("userRating", 9);
            rankingList.add(item20);
            
            return Result.success(rankingList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("获取排行榜数据失败：" + e.getMessage());
        }
    }
}