package jnpf.cultivate.controller.app.position;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.cultivate.service.FtbCultivatePositionForAppService;
import jnpf.cultivate.utils.UserApiV2Util;
import jnpf.model.cultivate.CultivatePage;
import jnpf.model.cultivate.dto.position.app.FtbCultivatePositionForAppNewDTO;
import jnpf.model.cultivate.vo.identify.IdentifyApplyInfoApiVo;
import jnpf.model.cultivate.vo.position.app.FtbPopUpPromptVO;
import jnpf.model.cultivate.vo.position.app.FtbSubordinateLearningCoursesVO;
import jnpf.model.cultivate.vo.position.app.OnTheJobLearningCourseVO;
import jnpf.permission.vo.v2.user.UserBoundVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * app岗位学习模块
 *
 * @author penghao
 */
@RestController
@RequestMapping("/position-app")
@Validated
public class FtbCultivatePositionForAppController {

    @Resource
    private FtbCultivatePositionForAppService service;
    @Autowired
    private UserApiV2Util userApiV2Util;

    /**
     * 岗位学习本岗课程
     */
    @GetMapping("/on-job-learning-course")
    public ActionResult<OnTheJobLearningCourseVO> onTheJobLearningCourse(FtbCultivatePositionForAppNewDTO dto) {
        OnTheJobLearningCourseVO result = service.onTheJobLearningCourse(dto);
        return ActionResult.success(result);
    }

    /**
     * 岗位学习-下属学习课程
     */
    @GetMapping("/subordinate-learning-courses")
    public ActionResult<PageListVO<FtbSubordinateLearningCoursesVO>> subordinateLearningCourses(FtbCultivatePositionForAppNewDTO dto, CultivatePage page) {
        Page<FtbSubordinateLearningCoursesVO> result = page.coverCultivatePage();
        result = service.subordinateLearningCoursess(dto, result);
        return ActionResult.success(CultivatePage.coverPageList(result));
    }

    /**
     * 岗位学习-下属实操鉴定
     */
    @GetMapping("/subordinate-practical-appraisal")
    public ActionResult<PageListVO<IdentifyApplyInfoApiVo>> subordinatePracticalAppraisal(FtbCultivatePositionForAppNewDTO dto, CultivatePage page) {
        PageListVO<IdentifyApplyInfoApiVo>   result = service.subordinatePracticalAppraisal(dto, page);
        return ActionResult.success(result);
    }

    /**
     * 弹出提示
     *
     * @param userId     用户id(必传)
     * @param positionId 岗位id(必传)
     * @return {@link ActionResult }
     */
    @GetMapping("/pop-up-prompt")
    public ActionResult<FtbPopUpPromptVO> popUpPrompt(String userId, String positionId) {
        FtbPopUpPromptVO ftbPopUpPromptVO = service.popUpPrompt(userId, positionId);
        return ActionResult.success(ftbPopUpPromptVO);
    }

    /**
     * 获取当前登录的用户信息
     * @return {@link ActionResult }
     */
    @GetMapping("/get-curr-login-user-info")
    public ActionResult<UserBoundVO> getCurrLoginUserInfo() {
        return ActionResult.success(userApiV2Util.getUserPrimaryBoundOne(userApiV2Util.getCurrentLoginUserId(), null));
    }

}
