<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.sky.scientific.mapper.SalaryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="salaryResultMap" type="org.sky.scientific.pojo.entity.SalaryEntity">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="name" property="name"/>
        <result column="number" property="number"/>
        <result column="identity_card" property="identityCard"/>
        <result column="year_and_month" property="yearAndMonth"/>
        <result column="department" property="department"/>
        <result column="personnel_type" property="personnelType"/>
        <result column="average_monthly_salary" property="averageMonthlySalary"/>
        <result column="pension_insurance" property="pensionInsurance"/>
        <result column="medical_insurance" property="medicalInsurance"/>
        <result column="unemployment_insurance" property="unemploymentInsurance"/>
        <result column="injury_insurance" property="injuryInsurance"/>
        <result column="maternity_insurance" property="maternityInsurance"/>
        <result column="provident_fund" property="providentFund"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>


    <select id="selectSalaryPage" resultMap="salaryResultMap">
        select * from kd_salary
        where is_deleted = 0 and year_and_month = #{salary.yearAndMonth}
        <if test="salary.name != null">
            and name like concat('%',#{salary.name},'%')
        </if>
        <if test="salary.number != null">
            and number like concat('%',#{salary.number},'%')
        </if>
        <if test="salary.identityCard != null">
            and identity_card like concat('%',#{salary.identityCard},'%')
        </if>
        <if test="salary.department != null">
            and department like concat('%',#{salary.department},'%')
        </if>
        <if test="salary.personnelType != null">
            and personnel_type = #{salary.personnelType}
        </if>
    </select>


    <select id="exportSalary" resultType="org.sky.scientific.excel.SalaryExcel">
        SELECT * FROM kd_salary ${ew.customSqlSegment}
    </select>

</mapper>
