package com.microservices.dms.common.controller;

import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.page.TableDataInfo;
import com.microservices.dms.achievementLibrary.domain.AchQueryVo;
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary;
import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author otto
 */
@RestController
@Api(tags = "数据管理体系-公开接口")
@RequestMapping("/open")
@RefreshScope
public class OpenController extends BaseController {

    @Autowired
    private IAchievementsService achievementsService;

    @Autowired
    private IExpertResourceLibraryService expertResourceLibraryService;

    /**
     * 获取精选成果
     *
     * @return
     */
    @ApiOperation("获取精选成果")
    @GetMapping("/achievements/getChoiceImport")
    public AjaxResult getChoiceImport() {
        return success(achievementsService.getChoiceImport());
    }

    /**
     * 根据成果来源对成果数据进行分类统计
     *
     * @return
     */
    @ApiOperation("根据成果来源对成果数据进行分类统计")
    @GetMapping("/achievements/getTjBySources")
    public AjaxResult getTjBySources() {
        return success(achievementsService.getTjBySources());
    }

    /**
     * 根据成果领域对成功数据进行汇总
     *
     * @return
     */
    @ApiOperation("根据成果领域对成果数据进行汇总")
    @GetMapping("/achievements/getTjByAreas")
    public AjaxResult getTjByAreas() {
        return success(achievementsService.getTjByAreas());
    }

    /**
     * 根据领域分类名称，获取领域相关数据
     */
    @ApiOperation("根据领域分类名称，获取领域相关数据")
    @GetMapping("/achievements/getAreasByName")
    public AjaxResult getAreasByName(String areaName) {
        return success(achievementsService.getAreasByName(areaName));
    }

    @ApiOperation("根据领域分类名称，获取项目领域")
    @GetMapping("/achievements/getProjectAreasByName")
    public AjaxResult getProjectAreasByName(String areaName) {
        return success(achievementsService.getProjectAreasByName(areaName));
    }

    @ApiOperation("根据领域分类名称，获取专家领域")
    @GetMapping("/achievements/getExpertAreasByName")
    public AjaxResult getExpertAreasByName(String areaName) {
        return success(achievementsService.getExpertAreasByName(areaName));
    }

    /* 获取全部成果,根据成果名称、成果领域、成果来源进行查询
     * @return
     */
    @ApiOperation("获取全部成果,根据成果名称、成果领域、成果来源进行查询")
    @GetMapping("/achievements/getAllResult")
    public TableDataInfo getAllResult(AchQueryVo achQueryVo) {
        startPage();
        return getDataTable(achievementsService.getAllResult(achQueryVo));
    }

    @ApiOperation("近七日用户行为数据")
    @GetMapping("/achievements/getUerActionData")
    public AjaxResult getUerActionData() {
        return success(achievementsService.getUerActionData());
    }

    @ApiOperation("热门成果")
    @GetMapping("/achievements/getHotAchievement")
    public AjaxResult getHotAchievement() {
        return success(achievementsService.getHotAchievement());
    }

    @ApiOperation("七日新增")
    @GetMapping("/achievements/get7DayAdd")
    public AjaxResult get7DayAdd(AchQueryVo achQueryVo) {
        return success(achievementsService.get7DayAdd(achQueryVo));
    }


    @ApiOperation("首页项目统计")
    @GetMapping("/achievements/indexProjectStatistic")
    public AjaxResult indexProjectStatistic() {
        return success(achievementsService.indexProjectStatistic());
    }

    @ApiOperation("首页task统计")
    @GetMapping("/achievements/indexTaskStatistic")
    public AjaxResult indexTaskStatistic() {
        return success(achievementsService.indexTaskStatistic());
    }

    @ApiOperation("首页Competition统计")
    @GetMapping("/achievements/indexCompetitionStatistic")
    public AjaxResult indexCompetitionStatistic() {
        return success(achievementsService.indexCompetitionStatistic());
    }

    @ApiOperation("首页SchoolEnterprise统计")
    @GetMapping("/achievements/indexSchoolEnterpriseStatistic")
    public AjaxResult indexSchoolEnterpriseStatistic() {
        return success(achievementsService.indexSchoolEnterpriseStatistic());
    }


    @ApiOperation("首页专家统计")
    @GetMapping("/achievements/indexExpertStatistic")
    public AjaxResult indexExpertStatistic() {
        return success(achievementsService.indexExpertStatistic());
    }

    /**
     * 查询专家资源库列表
     */
    @GetMapping("/expertResourceLibrary/listFront")
    public TableDataInfo listFront(ExpertResourceLibrary expertResourceLibrary)
    {
        startPage();
        List<ExpertResourceLibrary> list = expertResourceLibraryService.selectExpertResourceLibraryList2(expertResourceLibrary);
        return getDataTable(list);
    }

}
