package jnpf.cultivate.controller.web.position;

import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.cultivate.service.FtbCultivatePositionMemberService;
import jnpf.model.cultivate.CultivatePage;
import jnpf.model.cultivate.resp.AppExamListVo;
import jnpf.model.cultivate.vo.identify.UserIdentifyPageVo;
import jnpf.model.cultivate.vo.position.FtbCultivateCourseListVO;
import jnpf.model.cultivate.vo.position.FtbCultivatePositionUserInfoVo;
import jnpf.permission.dto.v2.user.QueryPageUserDTO;
import jnpf.util.FtbUtil;
import jnpf.util.StringUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @Title: web岗位学习成员培训进展
 * @Author: peng.hao
 * @create: 2023/12/2819:18
 */
@RestController
@RequestMapping("/position-member")
public class FtbCultivatePositionMemberController {

    @Resource
    FtbCultivatePositionMemberService service;

    /**
     * 成员列表
     * @return
     */
    @Operation(summary = "成员列表")
    @PostMapping("/listUser")
    public ActionResult<PageListVO<FtbCultivatePositionUserInfoVo>> listUser(@Valid @RequestBody QueryPageUserDTO dto) {
        PageListVO<FtbCultivatePositionUserInfoVo> listVO = service.listUser(dto);
        return ActionResult.success(listVO);
    }
    /**
     * 课程列表
     * @param userId
     * @param page
     * @return
     */
    @Operation(summary = "课程列表")
    @GetMapping("/listCourse")
    public ActionResult<PageListVO<FtbCultivateCourseListVO>> listCourse(String userId ,CultivatePage page) {
        PageListVO<FtbCultivateCourseListVO> listVO =service.listCourse(userId,page);
        return ActionResult.success(listVO);
    }
    /**
     * 考试列表
     * @param userId 用户ID
     * @param page
     * @return
     */
    @Operation(summary = "考试列表")
    @GetMapping("/list_exam_user")
    public ActionResult<PageListVO<AppExamListVo>> listExam(String userId, CultivatePage page) {
        if (StringUtil.isEmpty(userId)) {
            throw new RuntimeException("用户ID不能为空");
        }
        PageInfo<AppExamListVo> pageVo = service.listExam(userId, page);
        return ActionResult.page(pageVo.getList(), FtbUtil.getPagination(pageVo));
    }

    /**
     * 鉴定列表
     * @param userId
     * @param page
     * @return
     */
    @Operation(summary = "鉴定列表")
    @GetMapping("/listIdentify")
    public ActionResult<PageListVO<UserIdentifyPageVo>> listIdentify(String userId , CultivatePage page) {
        PageListVO<UserIdentifyPageVo> listVO = service.listIdentify(userId,page);
        return ActionResult.success(listVO);
    }

}
