| 12
 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
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 
 | <?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.liuyehcf.mybatis.CrmUserDAO">
 <sql id="columns">
 id AS id,
 first_name AS firstName,
 last_name AS lastName,
 age AS age,
 sex AS sex
 </sql>
 
 <select id="selectById" resultType="crmUserDO">
 SELECT
 <include refid="columns"/>
 FROM crm_user
 WHERE id = #{anotherName}
 </select>
 
 <insert id="insert" useGeneratedKeys="true" keyProperty="id">
 INSERT INTO crm_user(
 first_name,
 last_name,
 age,
 sex
 )
 VALUES(
 #{firstName},
 #{lastName},
 #{age},
 #{sex}
 )
 </insert>
 
 <update id="update" parameterType="crmUserDO">
 UPDATE crm_user
 <set>
 <if test="firstName != null and firstName != ''">
 first_name = #{firstName},
 </if>
 
 <if test="lastName != null and lastName != ''">
 last_name = #{lastName},
 </if>
 <if test="age != null">
 age = #{age},
 </if>
 <if test="sex != null">
 sex= #{sex},
 </if>
 </set>
 WHERE id = #{id}
 </update>
 
 <select id="selectByFirstName" resultType="crmUserDO">
 SELECT
 <include refid="columns"/>
 FROM crm_user
 <where>
 <if test="_parameter != null and _parameter !=''">
 AND first_name = #{anotherName}
 </if>
 </where>
 </select>
 
 <select id="selectByFirstNameAndLastName" resultType="crmUserDO">
 SELECT
 <include refid="columns"/>
 FROM crm_user
 <where>
 <if test="param1 != null and arg0 !=''">
 AND first_name = #{arg0}
 </if>
 <if test="arg1 != null and param2 !=''">
 AND last_name = #{param2}
 </if>
 </where>
 </select>
 
 <select id="selectByIdWithParam" resultType="crmUserDO">
 SELECT
 <include refid="columns"/>
 FROM crm_user
 WHERE id = #{specificName}
 </select>
 
 <insert id="insertWithParam" useGeneratedKeys="true" keyProperty="specificName.id">
 INSERT INTO crm_user(
 first_name,
 last_name,
 age,
 sex
 )
 VALUES(
 #{specificName.firstName},
 #{specificName.lastName},
 #{param1.age},
 #{param1.sex}
 )
 </insert>
 
 <update id="updateWithParam" parameterType="crmUserDO">
 UPDATE crm_user
 <set>
 <if test="specificName.firstName != null and param1.firstName != ''">
 first_name = #{specificName.firstName},
 </if>
 
 <if test="param1.lastName != null and specificName.lastName != ''">
 last_name = #{specificName.lastName},
 </if>
 <if test="specificName.age != null">
 age = #{param1.age},
 </if>
 <if test="param1.sex != null">
 sex= #{param1.sex},
 </if>
 </set>
 WHERE id = #{specificName.id}
 </update>
 
 <select id="selectByFirstNameWithParam" resultType="crmUserDO">
 SELECT
 <include refid="columns"/>
 FROM crm_user
 <where>
 <if test="param1 != null and specificName !=''">
 AND first_name = #{specificName}
 </if>
 </where>
 </select>
 
 <select id="selectByFirstNameAndLastNameWithParam" resultType="crmUserDO">
 SELECT
 <include refid="columns"/>
 FROM crm_user
 <where>
 <if test="param1 != null and param1 !=''">
 AND first_name = #{specificName1}
 </if>
 <if test="specificName2 != null and specificName2 !=''">
 AND last_name = #{param2}
 </if>
 </where>
 </select>
 
 </mapper>
 
 |