package com.sky.ioc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.ioc.entity.domain.parking.IllegalParking;
import com.sky.ioc.entity.params.IocParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface IllegalParkingMapper extends BaseMapper<IllegalParking> {


    @Select("<script>" +
            "SELECT count(*) as number,dept_id from illegal_parking where 1=1 " +
            "<if test='iocParam!=null and iocParam.companyId != null '>" +
            " and company_id=#{iocParam.companyId} " +
            "</if>"+
            "<if test='iocParam!=null '>" +
            " <![CDATA[ and illegal_time > #{iocParam.timeRange.startDate} " +
            "and illegal_time < #{iocParam.timeRange.endDate} ]]>" +
            "</if>"+
            " GROUP BY dept_id" +
            "</script>")
    List<Map<String,Object>> listByTimeAndDeptId(@Param("iocParam")IocParam iocParam);
}
