235 lines
7.3 KiB
XML
235 lines
7.3 KiB
XML
<?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.haitongauto.mapper.base.TruckMapper">
|
|
<!--BaseSql-->
|
|
<!--添加数据-->
|
|
<select id="insert" parameterType="com.haitongauto.models.pojo.Truck" resultType="String">
|
|
insert into applet_truck
|
|
(
|
|
id,
|
|
wx_openid,
|
|
users_id,
|
|
truck_number,
|
|
driving_license_id,
|
|
tel_number,
|
|
head_frame_number,
|
|
vehicle_weight,
|
|
vehicle_frame_weight,
|
|
driving_license,
|
|
truck_state,
|
|
create_time,
|
|
update_time,
|
|
is_del
|
|
)
|
|
values
|
|
(
|
|
#{id},
|
|
#{wx_openid},
|
|
#{users_id},
|
|
#{truck_number},
|
|
#{driving_license_id},
|
|
#{tel_number},
|
|
#{head_frame_number},
|
|
#{vehicle_weight},
|
|
#{vehicle_frame_weight},
|
|
#{driving_license},
|
|
#{truck_state},
|
|
current_timestamp,
|
|
current_timestamp,
|
|
0
|
|
)
|
|
returning id
|
|
</select>
|
|
<!--软删除-->
|
|
<update id="logicDel" parameterType="String">
|
|
update applet_truck set is_del=1 where id=#{id}
|
|
</update>
|
|
<!--硬删除-->
|
|
<delete id="delete" parameterType="String">
|
|
delete from applet_truck where id=#{id}
|
|
</delete>
|
|
<delete id="deleteTruckByUsersId">
|
|
delete from applet_truck where users_id=#{users_id}
|
|
</delete>
|
|
<!--数据更新-->
|
|
<update id="update" parameterType="com.haitongauto.models.pojo.Truck">
|
|
update applet_truck
|
|
<set>
|
|
<if test="id != null and id != ''">
|
|
id = #{id},
|
|
</if>
|
|
<if test="wx_openid != null and wx_openid != ''">
|
|
wx_openid = #{wx_openid},
|
|
</if>
|
|
<if test="users_id != null and users_id != ''">
|
|
users_id = #{users_id},
|
|
</if>
|
|
<if test="truck_number != null and truck_number != ''">
|
|
truck_number = #{truck_number},
|
|
</if>
|
|
<if test="driving_license_id != null and driving_license_id != ''">
|
|
driving_license_id = #{driving_license_id},
|
|
</if>
|
|
<if test="tel_number != null and tel_number != ''">
|
|
tel_number = #{tel_number},
|
|
</if>
|
|
<if test="head_frame_number != null and head_frame_number != ''">
|
|
head_frame_number = #{head_frame_number},
|
|
</if>
|
|
<if test="vehicle_weight != null">
|
|
vehicle_weight = #{vehicle_weight},
|
|
</if>
|
|
<if test="vehicle_frame_weight != null">
|
|
vehicle_frame_weight = #{vehicle_frame_weight},
|
|
</if>
|
|
<if test="driving_license != null and driving_license != ''">
|
|
driving_license = #{driving_license},
|
|
</if>
|
|
<if test="truck_state != null">
|
|
truck_state = #{truck_state},
|
|
</if>
|
|
<if test="create_time != null and create_time != ''">
|
|
create_time = #{create_time}::timestamp,
|
|
</if>
|
|
<if test="is_del != null">
|
|
is_del = #{is_del},
|
|
</if>
|
|
update_time = current_timestamp
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!--特殊情况更新-->
|
|
<update id="updateEX" parameterType="com.haitongauto.models.pojo.Truck">
|
|
update applet_truck
|
|
<set>
|
|
<if test="wx_openid != null and wx_openid != ''">
|
|
wx_openid = #{wx_openid},
|
|
</if>
|
|
<if test="users_id != null and users_id != ''">
|
|
users_id = #{users_id},
|
|
</if>
|
|
<if test="truck_number != null and truck_number != ''">
|
|
truck_number = #{truck_number},
|
|
</if>
|
|
<choose>
|
|
<when test="driving_license_id != null and driving_license_id != ''">
|
|
driving_license_id = #{driving_license_id},
|
|
</when>
|
|
<otherwise>
|
|
driving_license_id ='',
|
|
</otherwise>
|
|
</choose>
|
|
<if test="tel_number != null and tel_number != ''">
|
|
tel_number = #{tel_number},
|
|
</if>
|
|
<if test="head_frame_number != null and head_frame_number != ''">
|
|
head_frame_number = #{head_frame_number},
|
|
</if>
|
|
<choose>
|
|
<when test="vehicle_weight != null">
|
|
vehicle_weight = #{vehicle_weight},
|
|
</when>
|
|
<otherwise>
|
|
vehicle_weight = null,
|
|
</otherwise>
|
|
</choose>
|
|
<choose>
|
|
<when test="vehicle_frame_weight != null">
|
|
vehicle_frame_weight = #{vehicle_frame_weight},
|
|
</when>
|
|
<otherwise>
|
|
vehicle_frame_weight =null,
|
|
</otherwise>
|
|
</choose>
|
|
<choose>
|
|
<when test="driving_license != null">
|
|
driving_license = #{driving_license},
|
|
</when>
|
|
<otherwise>
|
|
driving_license =null,
|
|
</otherwise>
|
|
</choose>
|
|
<if test="truck_state != null">
|
|
truck_state = #{truck_state},
|
|
</if>
|
|
<if test="is_del != null">
|
|
is_del = #{is_del},
|
|
</if>
|
|
update_time = current_timestamp
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
|
|
<!--指定Id的记录-->
|
|
<select id="getById" parameterType="String" resultType="com.haitongauto.models.pojo.Truck">
|
|
select *
|
|
from applet_truck
|
|
where id=#{id}
|
|
and is_del=0
|
|
</select>
|
|
<!--数据列表-->
|
|
<select id="getList" resultType="com.haitongauto.models.pojo.Truck">
|
|
select
|
|
id,
|
|
wx_openid,
|
|
users_id,
|
|
truck_number,
|
|
driving_license_id,
|
|
tel_number,
|
|
head_frame_number,
|
|
vehicle_weight,
|
|
vehicle_frame_weight,
|
|
driving_license,
|
|
truck_state,
|
|
create_time,
|
|
update_time,
|
|
is_del
|
|
from applet_truck
|
|
where is_del=0
|
|
order by create_time desc
|
|
</select>
|
|
|
|
<!--根据用户id查询板车信息-->
|
|
<select id="getTruckByUsersId" parameterType="String" resultType="com.haitongauto.models.pojo.Truck">
|
|
select
|
|
id,
|
|
wx_openid,
|
|
users_id,
|
|
truck_number,
|
|
driving_license_id,
|
|
tel_number,
|
|
head_frame_number,
|
|
vehicle_weight,
|
|
vehicle_frame_weight,
|
|
driving_license,
|
|
truck_state,
|
|
create_time,
|
|
update_time,
|
|
is_del
|
|
from applet_truck
|
|
where is_del=0
|
|
and users_id=#{users_id}
|
|
limit 1
|
|
</select>
|
|
|
|
<!--根据微信openid查询板车信息-->
|
|
<select id="getTruckByOpenId" parameterType="String" resultType="com.haitongauto.models.pojo.Truck">
|
|
select *
|
|
from applet_truck
|
|
where is_del=0
|
|
and wx_openid=#{wx_openid}
|
|
limit 1
|
|
</select>
|
|
<select id="getPalletTruckByTruckNo" resultType="com.haitongauto.models.pojo.Truck">
|
|
select *
|
|
from applet_truck
|
|
where is_del=0
|
|
and truck_number=#{truck_number}
|
|
limit 1
|
|
</select>
|
|
|
|
</mapper> |