PlatTenantMapper.xml
3.67 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
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.diligrp.mqtt.web.mapper.PlatTenantMapper">
<resultMap type="com.diligrp.mqtt.web.model.PlatTenant" id="PlatTenantMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="privateKey" column="private_key" jdbcType="VARCHAR"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="PlatTenantMap">
select id,
name,
private_key,
public_key
from plat_tenant
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="PlatTenantMap">
select
id, name, private_key
from plat_tenant
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="privateKey != null and privateKey != ''">
and private_key = #{privateKey}
</if>
<if test="publicKey != null and publicKey != ''">
and public_key = #{publicKey}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from plat_tenant
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="privateKey != null and privateKey != ''">
and private_key = #{privateKey}
</if>
<if test="publicKey != null and publicKey != ''">
and public_key = #{publicKey}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into plat_tenant(name, private_key, public_key)
values (#{name}, #{privateKey}, #{publicKey})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into plat_tenant(name, private_key, public_key)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name}, #{entity.privateKey}, #{entity.publicKey})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into plat_tenant(name, private_key, public_key)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name}, #{entity.privateKey}, #{entity.publicKey})
</foreach>
on duplicate key update
name = values(name),
private_key = values(private_key),
public_key = values(public_key)
</insert>
<!--通过主键修改数据-->
<update id="update">
update plat_tenant
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="privateKey != null and privateKey != ''">
private_key = #{privateKey},
</if>
<if test="publicKey != null and publicKey != ''">
public_key = #{publicKey},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from plat_tenant where id = #{id}
</delete>
</mapper>