package jnpf.cultivate.controller.app.learn;

import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.cultivate.service.FtbCultivateLearnTaskInfoService;
import jnpf.model.cultivate.CultivatePage;
import jnpf.model.cultivate.dto.learn.FtbCultivateLearnTaskListDto;
import jnpf.model.cultivate.vo.learn.FtbCultivateLearnTaskFinishInfoVO;
import jnpf.model.cultivate.vo.learn.FtbCultivateLearnTaskFinishStatisticsVO;
import jnpf.model.cultivate.vo.learn.FtbCultivateLearnTaskInfoVO;
import jnpf.model.cultivate.vo.learn.FtbCultivateLearnTaskListVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * app培训任务管理
 * @Author: peng.hao
 * @create: 2024/9/9:11:21
 */
@Slf4j
@RestController
@RequestMapping("/app/learn-task")
public class FtbCultivateLearnTaskForAppController {

    @Resource
    private FtbCultivateLearnTaskInfoService cultivateLearnTaskInfoService;

    /**
     * 培训任务列表
     */
    @GetMapping("/getTaskList")
    public ActionResult<PageListVO<FtbCultivateLearnTaskListVO>> getTaskList(FtbCultivateLearnTaskListDto taskListDto) {
        return ActionResult.success(cultivateLearnTaskInfoService.getTaskList(taskListDto));
    }


    /**
     * 培训任务列表列表小气泡计数
     */
    @GetMapping("/getTaskCount")
    public ActionResult<Map<String,Integer>> getTaskCount(@RequestParam(value = "keyWords",defaultValue = "",required = false) String keyWords) {
        return ActionResult.success(cultivateLearnTaskInfoService.getTaskCount(keyWords));
    }


    /**
     * 任务详情展示
     */
    @GetMapping("/getLearnTaskInfo")
    public ActionResult<FtbCultivateLearnTaskInfoVO> getLearnTaskInfo(@RequestParam("taskId") String taskId) {
        return ActionResult.success(cultivateLearnTaskInfoService.getLearnTaskInfo(taskId));
    }

    /**
     * 完成情况统计
     * @param taskId 任务id
     * @return
     */
    @GetMapping("/getCompletionStatistics")
    public ActionResult<FtbCultivateLearnTaskFinishStatisticsVO> getCompletionStatistics(@RequestParam("taskId") String taskId) {
        return ActionResult.success(cultivateLearnTaskInfoService.getCompletionStatistics(taskId));
    }
    /**
     * 完成情况列表
     * @param taskId 任务id
     * @return
     */
    @GetMapping("/getListOfCompletions")
    public ActionResult<PageListVO<FtbCultivateLearnTaskFinishInfoVO>> getListOfCompletions(@RequestParam("taskId") String taskId,
                                                                                            CultivatePage page) {
        PageListVO<FtbCultivateLearnTaskFinishInfoVO> listOfCompletions = cultivateLearnTaskInfoService.getListOfCompletions(taskId, page, null);
        return ActionResult.success(listOfCompletions);
    }
}
