package com.ruoyi.ccdi.project.controller;

import com.ruoyi.ccdi.project.domain.dto.CcdiProjectExtendedPurchaseDetailQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectExtendedPurchaseQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectExtendedRecruitmentDetailQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectExtendedRecruitmentQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectExtendedTransferDetailQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectExtendedTransferQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectFamilyAssetLiabilityDetailQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectFamilyAssetLiabilityListQueryDTO;
import com.ruoyi.ccdi.project.domain.dto.CcdiProjectIncreaseLendingQueryDTO;
import com.ruoyi.ccdi.project.domain.excel.CcdiProjectIncreaseLendingExcel;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedPurchaseDetailVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedPurchaseListVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedRecruitmentDetailVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedRecruitmentListVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedTransferDetailVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectExtendedTransferListVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetLiabilityDetailVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectFamilyAssetLiabilityListVO;
import com.ruoyi.ccdi.project.domain.vo.CcdiProjectIncreaseLendingListVO;
import com.ruoyi.ccdi.project.service.CcdiProjectAccessService;
import com.ruoyi.ccdi.project.service.ICcdiProjectSpecialCheckService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目专项核查控制器
 */
@RestController
@RequestMapping("/ccdi/project/special-check")
@Tag(name = "项目专项核查")
public class CcdiProjectSpecialCheckController extends BaseController {

    @Resource
    private ICcdiProjectSpecialCheckService specialCheckService;

    @Resource
    private CcdiProjectAccessService projectAccessService;

    /**
     * 查询员工家庭资产负债列表
     */
    @GetMapping("/family-asset-liability/list")
    @Operation(summary = "查询员工家庭资产负债列表")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getFamilyAssetLiabilityList(@Validated CcdiProjectFamilyAssetLiabilityListQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectFamilyAssetLiabilityListVO result = specialCheckService.getFamilyAssetLiabilityList(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询员工家庭资产负债详情
     */
    @GetMapping("/family-asset-liability/detail")
    @Operation(summary = "查询员工家庭资产负债详情")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getFamilyAssetLiabilityDetail(@Validated CcdiProjectFamilyAssetLiabilityDetailQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectFamilyAssetLiabilityDetailVO result = specialCheckService.getFamilyAssetLiabilityDetail(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询采购拓展列表
     */
    @GetMapping("/extended-query/purchase/list")
    @Operation(summary = "查询采购拓展列表")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getExtendedPurchaseList(@Validated CcdiProjectExtendedPurchaseQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectExtendedPurchaseListVO result = specialCheckService.getExtendedPurchaseList(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询采购拓展详情
     */
    @GetMapping("/extended-query/purchase/detail")
    @Operation(summary = "查询采购拓展详情")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getExtendedPurchaseDetail(@Validated CcdiProjectExtendedPurchaseDetailQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectExtendedPurchaseDetailVO result = specialCheckService.getExtendedPurchaseDetail(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询招聘拓展列表
     */
    @GetMapping("/extended-query/recruitment/list")
    @Operation(summary = "查询招聘拓展列表")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getExtendedRecruitmentList(@Validated CcdiProjectExtendedRecruitmentQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectExtendedRecruitmentListVO result = specialCheckService.getExtendedRecruitmentList(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询招聘拓展详情
     */
    @GetMapping("/extended-query/recruitment/detail")
    @Operation(summary = "查询招聘拓展详情")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getExtendedRecruitmentDetail(@Validated CcdiProjectExtendedRecruitmentDetailQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectExtendedRecruitmentDetailVO result = specialCheckService.getExtendedRecruitmentDetail(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询调动拓展列表
     */
    @GetMapping("/extended-query/transfer/list")
    @Operation(summary = "查询调动拓展列表")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getExtendedTransferList(@Validated CcdiProjectExtendedTransferQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectExtendedTransferListVO result = specialCheckService.getExtendedTransferList(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询调动拓展详情
     */
    @GetMapping("/extended-query/transfer/detail")
    @Operation(summary = "查询调动拓展详情")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getExtendedTransferDetail(@Validated CcdiProjectExtendedTransferDetailQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectExtendedTransferDetailVO result = specialCheckService.getExtendedTransferDetail(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 查询新增贷款列表
     */
    @GetMapping("/increase-lending/list")
    @Operation(summary = "查询新增贷款列表")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public AjaxResult getIncreaseLendingList(@Validated CcdiProjectIncreaseLendingQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        CcdiProjectIncreaseLendingListVO result = specialCheckService.getIncreaseLendingList(queryDTO);
        return AjaxResult.success(result);
    }

    /**
     * 导出新增贷款列表
     */
    @PostMapping("/increase-lending/export")
    @Operation(summary = "导出新增贷款列表")
    @PreAuthorize("@ss.hasPermi('ccdi:project:query')")
    public void exportIncreaseLending(HttpServletResponse response, @Validated CcdiProjectIncreaseLendingQueryDTO queryDTO) {
        projectAccessService.assertCanRead(queryDTO.getProjectId());
        List<CcdiProjectIncreaseLendingExcel> rows = specialCheckService.exportIncreaseLendingList(queryDTO);
        ExcelUtil<CcdiProjectIncreaseLendingExcel> util = new ExcelUtil<>(CcdiProjectIncreaseLendingExcel.class);
        util.exportExcel(response, rows, "新增贷款查询");
    }
}
