package jnpf.cultivate.controller.app.apply;

import io.swagger.v3.oas.annotations.Operation;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.cultivate.service.FtbCultivatePromotionPostApplyService;
import jnpf.model.cultivate.CultivatePage;
import jnpf.model.cultivate.dto.apply.FtbCultivatePromotionPostApplyCreateDto;
import jnpf.model.cultivate.dto.apply.FtbCultivatePromotionPostApplyDto;
import jnpf.model.cultivate.vo.apply.FtbCultivatePromotionPostApplyVO;
import jnpf.model.cultivate.vo.apply.FtbCultivatePromotionPostApplyWithPerVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *  app 岗位晋升申请模块
 * @author penghao
 */
@RestController
@RequestMapping("/cul-post-apply-app")
public class FtbCultivatePromotionPostApplyForAppController {


    @Resource
    FtbCultivatePromotionPostApplyService postApplyService;


    /**
     * 获取岗位申请列表
     * @param dto 岗位申请查询参数
     * @param page 分页信息
     * @return 岗位申请列表结果
     */
    @GetMapping("/getList")
    @Operation(summary ="查看岗位申请列表")
    public ActionResult<PageListVO<FtbCultivatePromotionPostApplyVO>> getList(FtbCultivatePromotionPostApplyDto dto, CultivatePage page) {
        PageListVO<FtbCultivatePromotionPostApplyVO> voPageListVO = postApplyService.getList(dto, page);
        return ActionResult.success(voPageListVO);
    }


    /**
     * 初始化岗位申请
     *
     * @param createDto 岗位申请创建数据传输对象
     * @return
     */
    @PostMapping("/initPromApplication")
    @Operation(summary = "初始化岗位申请")
    public ActionResult<String> initiateAPromotionApplication(@Validated @RequestBody FtbCultivatePromotionPostApplyCreateDto createDto) {
        createDto.setSource(1);
        postApplyService.initiateAPromotionApplication(createDto);
        return ActionResult.success();
    }


    /**
     * 查询岗位申请详情
     * @param dto 岗位申请数据传输对象
     * @return ActionResult<FtbCultivatePromotionPostApplyWithPerVO> 响应结果对象，包含岗位申请及相关信息
     */
    @GetMapping("/viewPromApplication")
    @Operation(summary = "查询岗位申请详情")
    public ActionResult<FtbCultivatePromotionPostApplyWithPerVO> viewPromotionApplications(FtbCultivatePromotionPostApplyDto dto) {
        FtbCultivatePromotionPostApplyWithPerVO withPerVO =  postApplyService.viewPromotionApplications(dto,"1");
        return ActionResult.success(withPerVO);
    }


}
