package com.ruoyi.web.controller.portal;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SysAchievement;
import com.ruoyi.system.service.ISysAchievementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping("/portal/achievement")
public class PortalAchievementController extends BaseController {

    @Autowired
    private ISysAchievementService achievementService;

    @GetMapping("/list")
    public TableDataInfo getAchievementList(SysAchievement achievement) {
        startPage();
        List<SysAchievement> list = achievementService.selectSysAchievementList(achievement);
        return getDataTable(list);
    }

    @Anonymous
    @GetMapping("/sdgsat1")
    public TableDataInfo getSdgsat1AchievementList(SysAchievement achievement) {
        startPage();
        List<SysAchievement> list = achievementService.selectSysAchievementList(achievement);
        return getDataTable(list);
    }

    @GetMapping("/papers")
    public TableDataInfo getPaperList(SysAchievement achievement) {
        startPage();
        achievement.setAchievementCategory("论文");
        List<SysAchievement> list = achievementService.selectSysAchievementList(achievement);
        return getDataTable(list);
    }

    @GetMapping("/patents")
    public TableDataInfo getPatentList(SysAchievement achievement) {
        startPage();
        achievement.setAchievementCategory("专利");
        List<SysAchievement> list = achievementService.selectSysAchievementList(achievement);
        return getDataTable(list);
    }

    @GetMapping("/awards")
    public TableDataInfo getAwardList(SysAchievement achievement) {
        startPage();
        achievement.setAchievementCategory("获奖");
        List<SysAchievement> list = achievementService.selectSysAchievementList(achievement);
        return getDataTable(list);
    }

    @GetMapping("/{id}")
    public AjaxResult getAchievementDetail(@PathVariable("id") Long id) {
        SysAchievement achievement = achievementService.selectSysAchievementById(id);
        return AjaxResult.success(achievement);
    }

    @GetMapping("/stats")
    public AjaxResult getAchievementStats() {
        Map<String, Object> stats = new HashMap<>();
        stats.put("papers", 500);
        stats.put("patents", 120);
        stats.put("reports", 50);
        stats.put("awards", 30);
        return AjaxResult.success(stats);
    }
}
