package com.yccrc.kede.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yccrc.kede.domain.Enterprise;
import com.yccrc.kede.domain.Project;
import com.yccrc.kede.vo.IndexRptVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 项目信息Mapper接口
 *
 * @author yccrc
 * @date 2022-04-25
 */
public interface ProjectMapper extends BaseMapper<Project> {
    @Select("SELECT a.*,b.license from project a left join enterprise b on a.ent_id = b.id  ${ew.customSqlSegment}")
    Page<Project> selectPage(Page<Project> page, @Param(Constants.WRAPPER) Wrapper<Project> queryWrapper);

    @Select("select count(*) as pro_sum_cnt,sum(case when report_state=2 then 1 else 0 end) as pro_finish_cnt,sum(case when report_state!=2 then 1 else 0 end) as pro_unfinish_cnt from project a left join enterprise b on a.ent_id=b.id ${ew.customSqlSegment}")
    IndexRptVO rptProject(@Param(Constants.WRAPPER) Wrapper<Enterprise> queryWrapper);
}
