InspectionAssetManagementMapper.xml
5.31 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
113
114
115
116
117
<?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.com.glsx.dj.mindworkplate.mapper.InspectionAssetManagementMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.InspectionAssetManagement" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="badge_code" property="badgeCode" jdbcType="VARCHAR" />
<result column="app_code" property="appCode" jdbcType="VARCHAR" />
<result column="custodian" property="custodian" jdbcType="VARCHAR" />
<result column="custodian_phone" property="custodianPhone" jdbcType="VARCHAR" />
<result column="supervision" property="supervision" jdbcType="VARCHAR" />
<result column="brand_id" property="brandId" jdbcType="VARCHAR" />
<result column="brand_name" property="brandName" jdbcType="VARCHAR" />
<result column="direct_sales_flag" property="directSalesFlag" jdbcType="TINYINT" />
<result column="business_scene" property="businessScene" jdbcType="VARCHAR" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP" />
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP" />
<result column="dis_date" property="disDate" jdbcType="TIMESTAMP" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="responseMap" type="cn.com.glsx.dj.mindworkplate.dto.InspectionAssetRpcResponse" extends="BaseResultMap">
<result column="last_used_merchant_id" property="lastUsedMerchantId" jdbcType="INTEGER" />
<result column="last_used_merchant_name" property="lastUsedMerchantName" jdbcType="VARCHAR" />
<result column="last_used_name" property="lastUsedName" jdbcType="VARCHAR" />
<result column="last_used_phone" property="lastUsedPhone" jdbcType="VARCHAR" />
<result column="app_version" property="appVersion" jdbcType="VARCHAR" />
<result column="last_used_time" property="lastUsedTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, badge_code, app_code, custodian, custodian_phone, supervision, brand_id, brand_name,
direct_sales_flag, business_scene, deleted_flag, created_time, updated_time, created_by,
updated_by
</sql>
<select id="findByAppCodeOrBadgeCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from inspection_asset_management
where 1=1
<if test="appCode != null and appCode != ''">
and app_code= #{appCode,jdbcType=VARCHAR}
</if>
<if test="badgeCode != null and badgeCode != ''">
and badge_code= #{badgeCode,jdbcType=VARCHAR}
</if>
and deleted_flag = 'N'
</select>
<select id="page" resultMap="responseMap">
select
t.id, t.badge_code, t.app_code, t.custodian, t.custodian_phone, t.supervision, t.brand_id, t.brand_name,t.dis_date,t.remark,
t.direct_sales_flag, t.business_scene, t.deleted_flag, t.created_time, t.updated_time, t.created_by,
t.updated_by,
t1.last_used_merchant_id,t1.last_used_merchant_name,t1.last_used_name,t1.last_used_phone,t1.last_used_time,t1.app_version
FROM
inspection_asset_management t
LEFT JOIN inspection_badge_used_record t1 ON t.app_code = t1.app_code
AND t1.id = ( SELECT max( id ) FROM inspection_badge_used_record WHERE deleted_flag = 'N' AND app_code = t.app_code )
WHERE t.deleted_flag = 'N'
<if test="badgeCode != null and badgeCode != ''">
and t.badge_code like concat('%',#{badgeCode},'%')
</if>
<if test="custodian != null and custodian != ''">
and t.custodian like concat('%',#{custodian},'%')
</if>
<if test="supervision != null and supervision != ''">
and t.supervision like concat('%',#{supervision},'%')
</if>
<if test="directSalesFlag != null">
and t.direct_sales_flag = #{directSalesFlag}
</if>
<if test="custodianPhone != null and custodianPhone != ''">
and t.custodian_phone = #{custodianPhone}
</if>
<if test="businessSceneList != null and businessSceneList.size()>0">
and
<foreach collection="businessSceneList" item="businessScene" separator=" or " open="(" close=")">
t.business_scene like concat('%',#{businessScene},'%')
</foreach>
</if>
<if test="brandId != null and brandId != ''">
and t.brand_id = #{brandId}
</if>
<if test="beginDate != null">
and to_days(t1.last_used_time) >= to_days(#{beginDate})
</if>
<if test="endDate != null">
and to_days(t1.last_used_time) <= to_days(#{endDate})
</if>
<choose>
<when test="orderByType == 0">
order by t1.last_used_time desc
</when>
<when test="orderByType == 1">
order by t1.last_used_time asc
</when>
<when test="orderByType == 2">
order by t.updated_time desc
</when>
<when test="orderByType == 3">
order by t.updated_time asc
</when>
<otherwise>
order by t1.last_used_time desc
</otherwise>
</choose>
</select>
</mapper>