package com.sky.ioc.mapper.carbon;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.ioc.entity.domain.carbon.CarbonQuota;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CarbonQuotaMapper extends BaseMapper<CarbonQuota> {
    @Select("SELECT company from carbon_quota where year = #{year} GROUP BY company")
    List<String> getCompanys(@Param("year") String year);
    @Select("<script> " +
            "select coalesce(sum(quota),0) from carbon_quota where  year = #{year} " +
            "<if test='company!=null and company!=\"\"'>" +
            "and company=#{company} " +
            "</if>" +
            "</script>")
    Long getQuotaByCompany(@Param("company") String company,@Param("year") String year);

    @Select("<script> " +
            "select coalesce(sum(expend),0) from carbon_quota where  year = #{year} " +
            "<if test='company!=null and company!=\"\"'>" +
            "and company=#{company} " +
            "</if>" +
            "</script>")
    Long getExpendByCompany(@Param("company") String company,@Param("year") String year);
}
