<?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="com.api.manage.dao.businessManagement.SysSalaryDao">

    <select id="list" parameterType="com.api.model.businessManagement.SearchSalary" resultType="com.api.vo.businessManagement.VoSalary">
        select ss.id,so.name as organization_name,su.actual_name as name,su.sex,su.tel,ss.wage_card_number,ss.salary
        from sys_salary as ss,sys_organization as so,sys_user as su
        <where>
            ss.salary_person = su.id
            and ss.organization_id = so.id
            <if test="organizationId != null">
                and ss.organization_id = #{organizationId}
            </if>
            <if test="tel != null and tel != ''">
                and su.tel like concat('%',#{tel},'%')
            </if>
            <if test="wageCardNumber != null and wageCardNumber != ''">
                and ss.wage_card_number like concat('%',#{wageCardNumber},'%')
            </if>
        </where>
        order by ss.create_date desc
    </select>

    <insert id="insert" parameterType="com.api.model.businessManagement.SysSalary">
        insert into sys_salary(
            organization_id,
            salary_person,
            wage_card_number,
            salary,
            create_id,
            create_date
        )values (
            #{organizationId},
            #{salaryPerson},
            #{wageCardNumber},
            #{salary},
            #{createId},
            #{createDate}
        )
    </insert>

    <delete id="delete" parameterType="com.api.model.businessManagement.SysSalary">
        delete from sys_salary where id = #{id}
    </delete>

    <update id="update" parameterType="com.api.model.businessManagement.SysSalary">
        update sys_salary
        <set>
            <if test="wageCardNumber != null and wageCardNumber != ''">
                wage_card_number = #{wageCardNumber},
            </if>
            <if test="salary != null">
                salary = #{salary},
            </if>
            modify_id = #{modifyId},
            modify_date = #{modifyDate}
        </set>
        where id = #{id}
    </update>

</mapper>