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 org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.yccrc.kede.domain.Enterprise;
import com.yccrc.kede.vo.IndexRptVO;

/**
 * 企业信息Mapper接口
 * 
 * @author yccrc
 * @date 2022-04-25
 */
public interface EnterpriseMapper  extends BaseMapper<Enterprise> 
{
	@Select("SELECT b.user_name,b.nick_name,b.phonenumber,b.email,a.* from enterprise a left join sys_user b on a.id=b.scope_id ${ew.customSqlSegment}")
	Page<Enterprise>  selectEnterprisePage(Page<Enterprise> page, @Param(Constants.WRAPPER) Wrapper<Enterprise> queryWrapper);
	
	@Select("select count(*) as ent_sum_cnt,sum(case when ent_state=2 then 1 else 0 end) as ent_valid_cnt ,sum(case when ent_state=3 then 1 else 0 end) as ent_expired_cnt from enterprise e\n " +
			"LEFT JOIN sys_user u ON u.scope_id = e.id ${ew.customSqlSegment}")
	public IndexRptVO rptEnterprise(@Param(Constants.WRAPPER) Wrapper<Enterprise> queryWrapper);
}
