ride-lease/ridelease-system/src/main/resources/mapper/system/RlModelMapper.xml

137 lines
6.1 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.ruoyi.system.mapper.RlModelMapper">
<resultMap type="RlModelVO" id="EModelResult" autoMapping="true" />
<sql id="selectEModelVo">
select model_id, model, full_voltage, low_voltage, full_endurance, create_by, create_time, update_by, update_time, remark, intro, agent_id, deposit, picture from rl_model
</sql>
<select id="selectEModelList" parameterType="RlModel" resultMap="EModelResult">
select m.model_id, m.model, m.full_voltage, m.low_voltage,
m.full_endurance, m.create_by, m.create_time,
m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture from rl_model m
where 1 = 1
<if test="model != null and model != ''"> and m.model = #{model}</if>
<!-- 数据范围过滤 <if test="operator != null and operator != ''"> and m.operator = #{operator}</if> -->
${params.dataScope}
</select>
<select id="selectEModelListByAgentId" parameterType="RlModel" resultMap="EModelResult">
select m.model_id, m.model, m.full_voltage, m.low_voltage,
m.full_endurance, m.create_by, m.create_time,
m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture from rl_model m
where m.agent_id = #{agentId}
</select>
<select id="selectEModelByModelId" parameterType="Long" resultMap="EModelResult">
select m.model_id, m.model, m.full_voltage, m.low_voltage,
m.full_endurance, m.create_by, m.create_time,
m.update_by, m.update_time, m.remark, m.intro, m.agent_id, m.deposit, m.picture from rl_model m
where m.model_id = #{modelId}
</select>
<select id="selectAllCount" resultType="java.lang.Integer">
select count(1) from rl_model
</select>
<select id="selectEModelListByStoreId" parameterType="RlModelVO" resultMap="EModelResult">
SELECT
m.model_id,
m.model,
m.full_voltage,
m.low_voltage,
m.full_endurance,
m.create_by,
m.create_time,
m.update_by,
m.update_time,
m.remark,
m.intro,
m.agent_id,
m.deposit,
m.picture,
fr.price,
fr.rental_unit
FROM
rl_model m
LEFT JOIN rl_model_store ms ON ms.mode_id = m.model_id
LEFT JOIN rl_fee_rule fr ON fr.model_id = m.model_id
WHERE
ms.store_id = #{storeId}
AND fr.price = ( SELECT MIN( fr2.price ) FROM rl_fee_rule fr2 WHERE fr2.model_id = m.model_id )
GROUP BY
m.model_id
</select>
<insert id="insertEModel" parameterType="RlModel" keyProperty="modelId" useGeneratedKeys="true">
insert into rl_model
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="modelId != null">model_id,</if>
<if test="model != null">model,</if>
<if test="fullVoltage != null">full_voltage,</if>
<if test="lowVoltage != null">low_voltage,</if>
<if test="fullEndurance != null">full_endurance,</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="remark != null">remark,</if>
<if test="intro != null">intro,</if>
<if test="agentId != null">agent_id,</if>
<if test="deposit != null">deposit,</if>
<if test="picture != null">picture,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="modelId != null">#{modelId},</if>
<if test="model != null">#{model},</if>
<if test="fullVoltage != null">#{fullVoltage},</if>
<if test="lowVoltage != null">#{lowVoltage},</if>
<if test="fullEndurance != null">#{fullEndurance},</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="remark != null">#{remark},</if>
<if test="intro != null">#{intro},</if>
<if test="agentId != null">#{agentId},</if>
<if test="deposit != null">#{deposit},</if>
<if test="picture != null">#{picture},</if>
</trim>
</insert>
<update id="updateEModel" parameterType="RlModel">
update rl_model
<trim prefix="SET" suffixOverrides=",">
<if test="model != null">model = #{model},</if>
<if test="fullVoltage != null">full_voltage = #{fullVoltage},</if>
<if test="lowVoltage != null">low_voltage = #{lowVoltage},</if>
<if test="fullEndurance != null">full_endurance = #{fullEndurance},</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="remark != null">remark = #{remark},</if>
<if test="intro != null">intro = #{intro},</if>
<if test="agentId != null">agent_id = #{agentId},</if>
<if test="deposit != null">deposit = #{deposit},</if>
<if test="picture != null">picture = #{picture},</if>
</trim>
where model_id = #{modelId}
</update>
<delete id="deleteEModelByModelId" parameterType="Long">
delete from rl_model where model_id = #{modelId}
</delete>
<delete id="deleteEModelByModelIds" parameterType="String">
delete from rl_model where model_id in
<foreach item="modelId" collection="array" open="(" separator="," close=")">
#{modelId}
</foreach>
</delete>
</mapper>