xiangpei
2024-04-07 1d14ba39daf0422199c44b5b2ffc67d2364b2be2
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
<?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.ycl.platform.mapper.YwUnitMapper">
 
    <resultMap type="YwUnitVo" id="YwUnitResult">
        <result property="id"    column="id"    />
        <result property="unitCode"    column="unit_code"    />
        <result property="unitName"    column="unit_name"    />
        <result property="unitContact"    column="unit_contact"    />
        <result property="unitContactPhone"    column="unit_contact_phone"    />
        <result property="unitAdminAccount"    column="unit_admin_account"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>
 
    <sql id="selectYwUnitVo">
        select id, unit_code, unit_name, unit_contact, unit_contact_phone, unit_admin_account, remark, create_time, update_time, deleted from t_yw_unit
    </sql>
 
    <select id="selectYwUnitList" parameterType="YwUnit" resultMap="YwUnitResult">
        <include refid="selectYwUnitVo"/>
        <where>
            <if test="unitCode != null  and unitCode != ''"> and unit_code = #{unitCode}</if>
            <if test="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
        </where>
    </select>
 
    <select id="selectYwUnitById" parameterType="Long" resultMap="YwUnitResult">
        <include refid="selectYwUnitVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertYwUnit" parameterType="YwUnit" useGeneratedKeys="true" keyProperty="id">
        insert into t_yw_unit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="unitCode != null and unitCode != ''">unit_code,</if>
            <if test="unitName != null and unitName != ''">unit_name,</if>
            <if test="unitContact != null and unitContact != ''">unit_contact,</if>
            <if test="unitContactPhone != null and unitContactPhone != ''">unit_contact_phone,</if>
            <if test="unitAdminAccount != null and unitAdminAccount != ''">unit_admin_account,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deleted != null">deleted,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="unitCode != null and unitCode != ''">#{unitCode},</if>
            <if test="unitName != null and unitName != ''">#{unitName},</if>
            <if test="unitContact != null and unitContact != ''">#{unitContact},</if>
            <if test="unitContactPhone != null and unitContactPhone != ''">#{unitContactPhone},</if>
            <if test="unitAdminAccount != null and unitAdminAccount != ''">#{unitAdminAccount},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deleted != null">#{deleted},</if>
         </trim>
    </insert>
 
    <update id="updateYwUnit" parameterType="YwUnit">
        update t_yw_unit
        <trim prefix="SET" suffixOverrides=",">
            <if test="unitCode != null and unitCode != ''">unit_code = #{unitCode},</if>
            <if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
            <if test="unitContact != null and unitContact != ''">unit_contact = #{unitContact},</if>
            <if test="unitContactPhone != null and unitContactPhone != ''">unit_contact_phone = #{unitContactPhone},</if>
            <if test="unitAdminAccount != null and unitAdminAccount != ''">unit_admin_account = #{unitAdminAccount},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="deleted != null">deleted = #{deleted},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteYwUnitById" parameterType="Long">
        delete from t_yw_unit where id = #{id}
    </delete>
 
    <delete id="deleteYwUnitByIds" parameterType="String">
        delete from t_yw_unit where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>