Files
jsowell-charger-web/jsowell-pile/src/main/resources/mapper/pile/CarVinInfoMapper.xml
2023-06-09 18:31:54 +08:00

130 lines
5.7 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.jsowell.pile.mapper.CarVinInfoMapper">
<resultMap type="com.jsowell.pile.domain.CarVinInfo" id="CarVinInfoResult">
<result property="id" column="id" />
<result property="vinCode" column="vin_code" />
<result property="status" column="status" />
<result property="memberId" column="member_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectCarVinInfoVo">
select id, vin_code, status, member_id, create_by, create_time, update_by, update_time, del_flag from car_vin_info
</sql>
<sql id="Base_Column_List">
id, vin_code, status, member_id, create_by, create_time, update_by, update_time, del_flag
</sql>
<select id="selectCarVinInfoList" parameterType="com.jsowell.pile.domain.CarVinInfo" resultMap="CarVinInfoResult">
<include refid="selectCarVinInfoVo"/>
<where>
<if test="vinCode != null and vinCode != ''"> and vin_code = #{vinCode}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="memberId != null and memberId != ''"> and member_id = #{memberId}</if>
</where>
</select>
<select id="selectCarVinInfoById" parameterType="Long" resultMap="CarVinInfoResult">
<include refid="selectCarVinInfoVo"/>
where id = #{id}
</select>
<insert id="insertCarVinInfo" parameterType="com.jsowell.pile.domain.CarVinInfo" useGeneratedKeys="true" keyProperty="id">
insert into car_vin_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="vinCode != null">vin_code,</if>
<if test="status != null">status,</if>
<if test="memberId != null">member_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="vinCode != null">#{vinCode},</if>
<if test="status != null">#{status},</if>
<if test="memberId != null">#{memberId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateCarVinInfo" parameterType="com.jsowell.pile.domain.CarVinInfo">
update car_vin_info
<trim prefix="SET" suffixOverrides=",">
<if test="vinCode != null">vin_code = #{vinCode},</if>
<if test="status != null">status = #{status},</if>
<if test="memberId != null">member_id = #{memberId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCarVinInfoById" parameterType="Long">
delete from car_vin_info where id = #{id}
</delete>
<delete id="deleteCarVinInfoByIds" parameterType="String">
delete from car_vin_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectVinInfoByVin" resultMap="CarVinInfoResult">
select <include refid="Base_Column_List"/>
from car_vin_info
where vin_code = #{vinCode,jdbcType=VARCHAR}
and del_flag = '0'
</select>
<select id="getMemberInfoByVinCode" resultType="com.jsowell.pile.vo.CarVinInfoVO">
select
t1.id,
t1.vin_code as vinCode,
t1.status,
t1.member_id as memberId,
t2.mobile_number as phoneNumber,
t3.principal_balance as principalBalance,
t3.gift_balance as giftBalance
from
car_vin_info t1
join member_basic_info t2 on t1.member_id = t2.member_id and t1.del_flag = '0'
join member_wallet_info t3 on t2.member_id = t3.member_id and t2.status = '1'
where t1.vin_code = #{vinCode,jdbcType=VARCHAR}
</select>
<select id="getCarVinListByMemberId" resultType="com.jsowell.pile.vo.CarVinInfoVO">
select
t1.id,
t1.vin_code as vinCode,
t1.status,
t1.member_id as memberId,
t2.mobile_number as phoneNumber,
t3.principal_balance as principalBalance,
t3.gift_balance as giftBalance
from
car_vin_info t1
join member_basic_info t2 on t1.member_id = t2.member_id and t1.del_flag = '0'
join member_wallet_info t3 on t2.member_id = t3.member_id and t2.status = '1'
where t1.member_id = #{memberId,jdbcType=VARCHAR}
and del_flag = '0'
</select>
</mapper>