package com.jeeplus.assess.workContract.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.assess.program.configuration.projectList.domain.ProgramProjectListInfo;
import com.jeeplus.assess.workContract.domain.WorkContractInfo;
import com.jeeplus.assess.workContract.service.dto.WorkContractInfoDto;
import com.jeeplus.sys.domain.WorkAttachmentInfo;
import com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface WorkContractInfoMapper extends BaseMapper<WorkContractInfo> {

    IPage<WorkContractInfo> findPageList(Page<WorkContractInfo> page, @Param(Constants.WRAPPER)QueryWrapper queryWrapper);

    WorkContractInfo findById (@Param("id") String id);

    @InterceptorIgnore(tenantLine = "true")
    Integer findIsExit(@Param("id") String id, @Param("name")String name);

    @InterceptorIgnore(tenantLine = "true")
    List<WorkAttachmentInfo> findList(@Param("id") String id);

    /**
     * 根据AttachmentFla 和AttachmentId 查询附件信息
     * @param id
     * @param attachmentFlag
     * @return
     */
    List<WorkAttachmentInfo> findListByIdAndAttachmentFlag(@Param("id") String id, @Param("attachmentFlag")String attachmentFlag);

    @InterceptorIgnore(tenantLine = "true")
    List<WorkAttachmentInfo> findDtos(@Param("id") String id);

    @InterceptorIgnore(tenantLine = "true")
    List<WorkAttachmentInfoDTO> findByAttachmentIdAndFlag(@Param("attachmentId") String id,@Param("attachmentFlag") String attachmentFlag);

    void updateStatusById(@Param("id") String id, @Param("status")String status);

    IPage<ProgramProjectListInfo> relationProjectList(@Param("id") String id, Page<ProgramProjectListInfo> page);

    /**
     * 根据客户id查询合同信息
     * @param clientId
     * @return
     */
    List<WorkContractInfoDto> getInfoByClientId (@Param("clientId") String clientId);
    //查找合同中与项目编号年份一致的最后一条评估合同的编号
    String getNoByYear(@Param("projectYear")String projectYear, @Param("contractNum")String contractNum);
}
