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
<?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="cn.wisenergy.chnmuseum.party.mapper.TBoxOperationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.chnmuseum.party.model.TBoxOperation">
<id column="id" property="id"/>
<result column="organ_id" property="organId"/>
<result column="mac" property="mac"/>
<result column="status" property="status"/>
<result column="area_id" property="areaId"/>
<result column="public_key" property="publicKey" />
<result column="private_key" property="privateKey" />
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="organ_name" property="organName"/>
<result column="area_name" property="areaName"/>
<result column="permanent" property="permanent"/>
<result column="effective_date" property="effectiveDate"/>
<result column="exired_date" property="exiredDate"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, organ_id, mac, status, area_id, public_key, private_key, create_time, update_time
</sql>
<select id="getList" resultMap="BaseResultMap">
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.`user_name` organ_name
FROM t_box_operation b
left join t_user r on r.org_id = b.organ_id and r.type = '3'
where 1=1
<if test="status!= null and status != '' ">
and b.status =#{status}
</if>
<if test="areaId!= null and areaId != '' ">
and r.area_id like concat(#{areaId}, '%')
</if>
order by b.create_time desc
</select>
<select id="selectBoxPage" resultMap="BaseResultMap">
select b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name,a.full_name area_name,u.permanent permanent,
u.effective_date effective_date,u.exired_date exired_date
from t_box_operation b
left join t_organ o on b.organ_id = o.id
left join t_user u on u.org_id = b.organ_id and u.type = '3' and u.is_deleted = false
left join t_area a on u.area_id = a.id
where 1=1
<if test="user.orgId!= null and user.orgId != '' ">
and b.organ_id =#{user.orgId}
</if>
<if test="user.areaId!= null and user.areaId != '' ">
and b.area_id =#{user.areaId}
</if>
<if test="user.orgCode != null and user.orgCode != '' ">
and o.code LIKE concat(#{user.orgCode}, '%')
</if>
<if test="user.areaName != null and user.areaName != '' ">
and b.area_id LIKE concat(#{user.areaName}, '%')
</if>
order by b.create_time desc
</select>
<select id="selectPageList" resultMap="BaseResultMap">
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name
FROM t_box_operation b
left join t_organ r on r.id = b.organ_id
left join t_user u on u.org_id = b.organ_id and u.type = '3'
where 1=1
<if test="tBoxOperation.organId != null and tBoxOperation.organId != '' ">
and b.organ_id =#{tBoxOperation.organId}
</if>
<if test="tBoxOperation.status != null">
and b.status =#{tBoxOperation.status}
</if>
<if test="tBoxOperation.areaId != null and tBoxOperation.areaId != '' ">
and b.area_id = #{tBoxOperation.areaId}
</if>
<if test="tBoxOperation.areaName != null and tBoxOperation.areaName != '' ">
and b.area_id LIKE concat(#{tBoxOperation.areaName}, '%')
</if>
<if test="tBoxOperation.organCode != null and tBoxOperation.organCode != '' ">
and r.code LIKE concat(#{tBoxOperation.organCode}, '%')
</if>
order by b.create_time desc
</select>
</mapper>