package jnpf.cultivate.v2.controller.app.identify;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.constant.MsgCode;
import jnpf.cultivate.service.CultivateIdentifyApplyService;
import jnpf.cultivate.v2.service.V2CultivateIdentifyApplyService;
import jnpf.enums.cultivate.ApplySourceEnum;
import jnpf.model.cultivate.CultivatePage;
import jnpf.model.cultivate.dto.identify.IdentifyApplySubmitDto;
import jnpf.model.cultivate.v2.apply.req.V2IdentifyApplySaveReq;
import jnpf.model.cultivate.v2.apply.req.V2MyIdentifyApplyListAppReq;
import jnpf.model.cultivate.v2.apply.vo.V2IdentifyApplyListAppVo;
import jnpf.model.cultivate.v2.identify.vo.V2IdentifyTableListVo;
import jnpf.model.cultivate.vo.identify.IdentifyApplyListAppVo;
import jnpf.personnels.service.FtbPersonnelsPermissionsService;
import jnpf.util.UserProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * app我的鉴定模块
 */
@Slf4j
@RestController
@RequestMapping(value = "/v2/app/apply/my")
public class V2CultivateMyIdentifyAppController {
    @Autowired
    private V2CultivateIdentifyApplyService applyService;



    /**
     * 我的实操鉴定
     *
     * @param req 帅选条件
     * @return
     * @
     */
    @Operation(summary = "列表")
    @GetMapping(value = "/list")
    public ActionResult<PageListVO<V2IdentifyApplyListAppVo>> queryMyIdentifyApplyList(@Valid V2MyIdentifyApplyListAppReq req) {
        return ActionResult.success(CultivatePage.coverPageList(applyService.queryMyIdentifyApplyList(req)));
    }


    /**
     * 我申请鉴定
     *
     * @param req 实操鉴定申请保存请求对象，包含申请相关信息
     * @return 操作结果的ActionResult对象
     */
    @PostMapping(value = "/submit-apply")
    public ActionResult<Void> applyDataSave(@Valid @RequestBody V2IdentifyApplySaveReq req) {
        req.setSource(ApplySourceEnum.APPLY_IN_PERSON.getCode());
        req.setBeIdentifyUserIds(List.of(UserProvider.getUser().getUserId()));
        applyService.applyDataSaveBatch(req);
        return ActionResult.success(MsgCode.SU018.get());
    }

}
