DriverMapper.xml
10.9 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?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.trash.driver.mapper.DriverMapper">
<resultMap type="Driver" id="DriverResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="identityCard" column="identity_card"/>
<result property="companyId" column="company_id"/>
<result property="professionalQualificationBeginDate" column="professional_qualification_begin_date"/>
<result property="professionalQualificationEndDate" column="professional_qualification_end_date"/>
<result property="drivingLicenceBeginDate" column="driving_licence_begin_date"/>
<result property="drivingLicenceEndDate" column="driving_licence_end_date"/>
<result property="safetyTrainingDate" column="safety_training_date"/>
<result property="safetyTrainingContent" column="safety_training_content"/>
<result property="remark" column="remark"/>
<result property="drivingLicence" column="driving_licence"/>
<result property="professionalQualification" column="professional_qualification"/>
<result property="safetyTraining" column="safety_training"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="photographOne" column="photograph_one"/>
<result property="photographTwo" column="photograph_two"/>
<result property="phoneNo" column="phoneNo"/>
</resultMap>
<resultMap type="DriverVo" id="DriverVoResult" extends="DriverResult">
<result property="companyName" column="companyName"/>
</resultMap>
<sql id="selectDriverVo">
select id, name, identity_card, company_id, professional_qualification_begin_date, professional_qualification_end_date, driving_licence_begin_date, driving_licence_end_date, safety_training_date, safety_training_content, remark, driving_licence, professional_qualification, safety_training, status, create_time, create_by, update_time, update_by, photograph_one, photograph_two,phoneNo from driver
</sql>
<sql id="selectDriverCompanyVo">
select d.id, d.name,c.name companyName, identity_card, company_id, professional_qualification_begin_date, professional_qualification_end_date, driving_licence_begin_date, driving_licence_end_date, safety_training_date, safety_training_content, d.remark, driving_licence, professional_qualification, safety_training, d.status, d.create_time, d.create_by, d.update_time, d.update_by, photograph_one, photograph_two,phoneNo from driver d
left join transportation_enterprise c on d.company_id = c.id
</sql>
<select id="selectDriverList" parameterType="DriverVo" resultMap="DriverVoResult">
<include refid="selectDriverCompanyVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="companyName != null and companyName != ''"> and c.name like concat('%', #{companyName}, '%')</if>
<if test="identityCard != null and identityCard != ''"> and identity_card = #{identityCard}</if>
<if test="companyId != null "> and company_id = #{companyId}</if>
<if test="professionalQualificationBeginDate != null "> and professional_qualification_begin_date = #{professionalQualificationBeginDate}</if>
<if test="professionalQualificationEndDate != null "> and professional_qualification_end_date = #{professionalQualificationEndDate}</if>
<if test="drivingLicenceBeginDate != null "> and driving_licence_begin_date = #{drivingLicenceBeginDate}</if>
<if test="drivingLicenceEndDate != null "> and driving_licence_end_date = #{drivingLicenceEndDate}</if>
<if test="safetyTrainingDate != null "> and safety_training_date = #{safetyTrainingDate}</if>
<if test="safetyTrainingContent != null and safetyTrainingContent != ''"> and safety_training_content = #{safetyTrainingContent}</if>
<if test="drivingLicence != null and drivingLicence != ''"> and driving_licence = #{drivingLicence}</if>
<if test="professionalQualification != null and professionalQualification != ''"> and professional_qualification = #{professionalQualification}</if>
<if test="safetyTraining != null and safetyTraining != ''"> and safety_training = #{safetyTraining}</if>
<if test="status != null "> and status = #{status}</if>
<if test="photographOne != null and photographOne != ''"> and photograph_one = #{photographOne}</if>
<if test="photographTwo != null and photographTwo != ''"> and photograph_two = #{photographTwo}</if>
<if test="phoneNo != null and phoneNo != ''"> and phoneNo = #{phoneNo}</if>
</where>
</select>
<select id="selectDriverListByCompanyId" parameterType="String" resultType="map">
select id,name as label from driver where company_id = #{companyId}
</select>
<select id="selectDriverById" parameterType="Long" resultMap="DriverResult">
<include refid="selectDriverVo"/>
where id = #{id}
</select>
<insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id">
insert into driver
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="identityCard != null">identity_card,</if>
<if test="companyId != null">company_id,</if>
<if test="professionalQualificationBeginDate != null">professional_qualification_begin_date,</if>
<if test="professionalQualificationEndDate != null">professional_qualification_end_date,</if>
<if test="drivingLicenceBeginDate != null">driving_licence_begin_date,</if>
<if test="drivingLicenceEndDate != null">driving_licence_end_date,</if>
<if test="safetyTrainingDate != null">safety_training_date,</if>
<if test="safetyTrainingContent != null">safety_training_content,</if>
<if test="remark != null">remark,</if>
<if test="drivingLicence != null">driving_licence,</if>
<if test="professionalQualification != null">professional_qualification,</if>
<if test="safetyTraining != null">safety_training,</if>
<if test="status != null">status,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="photographOne != null">photograph_one,</if>
<if test="photographTwo != null">photograph_two,</if>
<if test="phoneNo != null">phoneNo,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="identityCard != null">#{identityCard},</if>
<if test="companyId != null">#{companyId},</if>
<if test="professionalQualificationBeginDate != null">#{professionalQualificationBeginDate},</if>
<if test="professionalQualificationEndDate != null">#{professionalQualificationEndDate},</if>
<if test="drivingLicenceBeginDate != null">#{drivingLicenceBeginDate},</if>
<if test="drivingLicenceEndDate != null">#{drivingLicenceEndDate},</if>
<if test="safetyTrainingDate != null">#{safetyTrainingDate},</if>
<if test="safetyTrainingContent != null">#{safetyTrainingContent},</if>
<if test="remark != null">#{remark},</if>
<if test="drivingLicence != null">#{drivingLicence},</if>
<if test="professionalQualification != null">#{professionalQualification},</if>
<if test="safetyTraining != null">#{safetyTraining},</if>
<if test="status != null">#{status},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="photographOne != null">#{photographOne},</if>
<if test="photographTwo != null">#{photographTwo},</if>
<if test="phoneNo != null">#{phoneNo},</if>
</trim>
</insert>
<update id="updateDriver" parameterType="Driver">
update driver
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="identityCard != null">identity_card = #{identityCard},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="professionalQualificationBeginDate != null">professional_qualification_begin_date = #{professionalQualificationBeginDate},</if>
<if test="professionalQualificationEndDate != null">professional_qualification_end_date = #{professionalQualificationEndDate},</if>
<if test="drivingLicenceBeginDate != null">driving_licence_begin_date = #{drivingLicenceBeginDate},</if>
<if test="drivingLicenceEndDate != null">driving_licence_end_date = #{drivingLicenceEndDate},</if>
<if test="safetyTrainingDate != null">safety_training_date = #{safetyTrainingDate},</if>
<if test="safetyTrainingContent != null">safety_training_content = #{safetyTrainingContent},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="drivingLicence != null">driving_licence = #{drivingLicence},</if>
<if test="professionalQualification != null">professional_qualification = #{professionalQualification},</if>
<if test="safetyTraining != null">safety_training = #{safetyTraining},</if>
<if test="status != null">status = #{status},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="photographOne != null">photograph_one = #{photographOne},</if>
<if test="photographTwo != null">photograph_two = #{photographTwo},</if>
<if test="phoneNo != null">phoneNo = #{phoneNo},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDriverById" parameterType="Long">
delete
from driver
where id = #{id}
</delete>
<delete id="deleteDriverByIds" parameterType="String">
delete from driver where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach>
</delete>
</mapper>