package jnpf.cultivate.controller.web.position;

import jnpf.base.ActionResult;
import jnpf.cultivate.service.FtbCultivatePositionCopyService;
import jnpf.model.cultivate.dto.position.web.FtbCultivateAssociatedExamsCoursesDTO;
import jnpf.model.cultivate.dto.position.web.FtbCultivatePositionCopyDTO;
import jnpf.model.cultivate.dto.position.web.FtbCultivatePositionPassExaminationDTO;
import jnpf.model.cultivate.vo.position.web.FtbCultivatePositionCopyVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
 * web岗位学习复制模块
 *
 * @author wangchunxiang
 * @date 2024/07/22
 */
@RestController
@RequestMapping("/web/position")
public class FtbCultivatePositionCopyController {

    @Resource
    private FtbCultivatePositionCopyService ftbCultivatePositionCopyService;

    /**
     * 岗位学习复制
     */
    @PostMapping("/copy-position")
    public ActionResult<FtbCultivatePositionCopyVO> copyPosition(@Validated @RequestBody FtbCultivatePositionCopyDTO data) {
        FtbCultivatePositionCopyVO ftbCultivatePositionCopyVO = ftbCultivatePositionCopyService.copyPosition(data);
        return ActionResult.success(ftbCultivatePositionCopyVO);
    }

    /**
     * 岗位考试合格后才能进行鉴定修改
     */
    @PutMapping("/passing-examination-revised")
    public ActionResult passingTheJobExaminationRevised(@Validated @RequestBody FtbCultivatePositionPassExaminationDTO data) {
        ftbCultivatePositionCopyService.passingTheJobExaminationRevised(data);
        return ActionResult.success();
    }

    /**
     * 复制岗位关联考试和课程
     */
    @PostMapping
    public ActionResult associatedExamsAndCourses(@Validated @RequestBody FtbCultivateAssociatedExamsCoursesDTO data) {
        ftbCultivatePositionCopyService.associatedExamsAndCourses(data);
        return ActionResult.success();
    }

    /**
     * 已存在的岗位学习，返回岗位id
     *
     * @return {@link ActionResult }
     */
    @GetMapping("/learning-from-existing-positions")
    public ActionResult<List<String>> learningFromExistingPositions() {
        List<String> result = ftbCultivatePositionCopyService.learningFromExistingPositions();
        return ActionResult.success(result);
    }

}