UserBaseInfoMapper.xml
4.3 KB
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
<?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.zhonglai.luhui.user.mapper.UserBaseInfoMapper">
<resultMap type="UserBaseInfo" id="UserBaseInfoResult">
<result property="id" column="id" />
<result property="loginName" column="login_name" />
<result property="name" column="name" />
<result property="nickname" column="nickname" />
<result property="gender" column="gender" />
<result property="phone" column="phone" />
<result property="email" column="email" />
<result property="imgUrl" column="img_url" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectUserBaseInfoVo">
select id, login_name, name, nickname, gender, phone, email, img_url, create_time from user_base_info
</sql>
<select id="selectUserBaseInfoList" parameterType="UserBaseInfo" resultMap="UserBaseInfoResult">
<include refid="selectUserBaseInfoVo"/>
<where>
<if test="loginName != null and loginName != ''"> and login_name like concat('%', #{loginName}, '%')</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="nickname != null and nickname != ''"> and nickname like concat('%', #{nickname}, '%')</if>
<if test="gender != null "> and gender = #{gender}</if>
<if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
<if test="email != null and email != ''"> and email like concat('%', #{email}, '%')</if>
<if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
</where>
</select>
<select id="selectUserBaseInfoById" parameterType="Integer" resultMap="UserBaseInfoResult">
<include refid="selectUserBaseInfoVo"/>
where id = #{id}
</select>
<insert id="insertUserBaseInfo" parameterType="UserBaseInfo" useGeneratedKeys="true" keyProperty="id">
insert into user_base_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="loginName != null and loginName != ''">login_name,</if>
<if test="name != null">name,</if>
<if test="nickname != null">nickname,</if>
<if test="gender != null">gender,</if>
<if test="phone != null">phone,</if>
<if test="email != null">email,</if>
<if test="imgUrl != null">img_url,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="loginName != null and loginName != ''">#{loginName},</if>
<if test="name != null">#{name},</if>
<if test="nickname != null">#{nickname},</if>
<if test="gender != null">#{gender},</if>
<if test="phone != null">#{phone},</if>
<if test="email != null">#{email},</if>
<if test="imgUrl != null">#{imgUrl},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateUserBaseInfo" parameterType="UserBaseInfo">
update user_base_info
<trim prefix="SET" suffixOverrides=",">
<if test="loginName != null and loginName != ''">login_name = #{loginName},</if>
<if test="name != null">name = #{name},</if>
<if test="nickname != null">nickname = #{nickname},</if>
<if test="gender != null">gender = #{gender},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUserBaseInfoById" parameterType="Integer">
delete from user_base_info where id = #{id}
</delete>
<delete id="deleteUserBaseInfoByIds" parameterType="String">
delete from user_base_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>