TContractorPersonMapper.xml 5.59 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
<?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.zehong.system.mapper.TContractorPersonMapper">
    
    <resultMap type="TContractorPersonVo" id="TContractorPersonResult">
        <result property="id"    column="id"    />
        <result property="contractorId"    column="contractor_id"    />
        <result property="contractorName"    column="contractor_name"    />
        <result property="name"    column="name"    />
        <result property="age"    column="age"    />
        <result property="sex"    column="sex"    />
        <result property="phone"    column="phone"    />
        <result property="certificateName"    column="certificate_name"    />
        <result property="certificateUrl"    column="certificate_url"    />
        <result property="status"    column="status"    />
        <result property="isDel"    column="is_del"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectTContractorPersonVo">
        select t.id, t.contractor_id, t.name, t.age, t.sex, t.phone, t.certificate_name, t.certificate_url, t.status, t.is_del, t.create_time, t.update_time,
        c.contractor_name
        from t_contractor_person t left join t_contractor c on t.contractor_id = c.id
    </sql>

    <select id="selectTContractorPersonList" parameterType="TContractorPerson" resultMap="TContractorPersonResult">
        <include refid="selectTContractorPersonVo"/>
        <where>  t.is_del = '0'
            <if test="name != null  and name != ''"> and t.name like concat('%', #{name}, '%')</if>
            <if test="contractorId != null and contractorId != ''"> and t.contractor_id = #{contractorId}</if>
            <if test="age != null "> and t.age = #{age}</if>
            <if test="sex != null "> and t.sex = #{sex}</if>
            <if test="phone != null  and phone != ''"> and t.phone like concat('%', #{phone}, '%')</if>
            <if test="status != null  and status != ''"> and t.status = #{status}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(t.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND date_format(t.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
    </select>
    
    <select id="selectTContractorPersonById" parameterType="Long" resultMap="TContractorPersonResult">
        <include refid="selectTContractorPersonVo"/>
        where t.id = #{id}
    </select>
        
    <insert id="insertTContractorPerson" parameterType="TContractorPerson">
        insert into t_contractor_person
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="contractorId != null">contractor_id,</if>
            <if test="name != null">name,</if>
            <if test="age != null">age,</if>
            <if test="sex != null">sex,</if>
            <if test="phone != null">phone,</if>
            <if test="certificateName != null">certificate_name,</if>
            <if test="certificateUrl != null">certificate_url,</if>
            <if test="status != null">status,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="contractorId != null">#{contractorId},</if>
            <if test="name != null">#{name},</if>
            <if test="age != null">#{age},</if>
            <if test="sex != null">#{sex},</if>
            <if test="phone != null">#{phone},</if>
            <if test="certificateName != null">#{certificateName},</if>
            <if test="certificateUrl != null">#{certificateUrl},</if>
            <if test="status != null">#{status},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTContractorPerson" parameterType="TContractorPerson">
        update t_contractor_person
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="age != null">age = #{age},</if>
            <if test="sex != null">sex = #{sex},</if>
            contractor_id = #{contractorId},
            phone = #{phone},
            certificate_name = #{certificateName},
            certificate_url = #{certificateUrl},
            <if test="status != null">status = #{status},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTContractorPersonById" parameterType="Long">
        delete from t_contractor_person where id = #{id}
    </delete>

    <delete id="deleteTContractorPersonByIds" parameterType="String">
        delete from t_contractor_person where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>