<?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.panzhihua.service_community.dao.ComChangeCarModelRelationMapper">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComChangeCarModelRelation"
|
id="ComChangeCarModelRelationMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="modelId" column="model_id" jdbcType="INTEGER"/>
|
<result property="modelSpecsId" column="model_specs_id" jdbcType="INTEGER"/>
|
<result property="modelSpecsChildrenId" column="model_specs_children_id" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!--查询单个-->
|
<select id="queryById" resultType="com.panzhihua.common.model.vos.common.ComChangeCarModelRelationVo">
|
SELECT
|
cccmr.id,
|
cccmr.model_id,
|
cccmr.model_specs_id,
|
cccmr.model_specs_children_id,
|
cccm.`name` as modelName,
|
cccm.`min_price` as minPrice,
|
cccm.`images`,
|
cccb.`name` as brandName,
|
cccms.`name` as specsName,
|
cccmsc.`name` as specsChildrenName
|
FROM
|
com_change_car_model_relation as cccmr
|
left join com_change_car_model as cccm on cccm.id = cccmr.model_id
|
left join com_change_car_model_specs as cccms on cccms.id = cccmr.model_specs_id
|
left join com_change_car_model_specs_children as cccmsc on cccmsc.id = cccmr.model_specs_children_id
|
left join com_change_car_brand as cccb on cccb.id = cccm.brand_id
|
where cccmr.id = #{id}
|
</select>
|
|
<!--查询指定行数据-->
|
<select id="queryAllByLimit" resultType="com.panzhihua.common.model.vos.common.ComChangeCarModelRelationVo">
|
SELECT
|
cccmr.id,
|
cccmr.model_id,
|
cccmr.model_specs_id,
|
cccmr.model_specs_children_id,
|
cccm.`name` as modelName,
|
cccm.`min_price` as minPrice,
|
cccm.`images`,
|
cccb.`name` as brandName,
|
cccms.`name` as specsName,
|
cccmsc.`name` as specsChildrenName
|
FROM
|
com_change_car_model_relation as cccmr
|
left join com_change_car_model as cccm on cccm.id = cccmr.model_id
|
left join com_change_car_model_specs as cccms on cccms.id = cccmr.model_specs_id
|
left join com_change_car_model_specs_children as cccmsc on cccmsc.id = cccmr.model_specs_children_id
|
left join com_change_car_brand as cccb on cccb.id = cccm.brand_id
|
<where>
|
<if test="dto.id != null">
|
and cccmr.id = #{dto.id}
|
</if>
|
<if test="dto.modelId != null">
|
and cccmr.model_id = #{dto.modelId}
|
</if>
|
<if test="dto.modelSpecsId != null">
|
and cccmr.model_specs_id = #{dto.modelSpecsId}
|
</if>
|
<if test="dto.modelSpecsChildrenId != null">
|
and cccmr.model_specs_children_id = #{dto.modelSpecsChildrenId}
|
</if>
|
</where>
|
order by cccmr.id desc
|
</select>
|
|
<!--查询所有数据-->
|
<select id="queryAllByList" resultType="com.panzhihua.common.model.vos.common.ComChangeCarModelRelationVo">
|
SELECT
|
cccmr.id,
|
cccmr.model_id,
|
cccmr.model_specs_id,
|
cccmr.model_specs_children_id,
|
cccm.`name` as modelName,
|
cccm.`min_price` as minPrice,
|
cccm.`images`,
|
cccb.`name` as brandName,
|
cccms.`name` as specsName,
|
cccmsc.`name` as specsChildrenName
|
FROM
|
com_change_car_model_relation as cccmr
|
left join com_change_car_model as cccm on cccm.id = cccmr.model_id
|
left join com_change_car_model_specs as cccms on cccms.id = cccmr.model_specs_id
|
left join com_change_car_model_specs_children as cccmsc on cccmsc.id = cccmr.model_specs_children_id
|
left join com_change_car_brand as cccb on cccb.id = cccm.brand_id
|
<where>
|
<if test="dto.id != null">
|
and id = #{dto.id}
|
</if>
|
<if test="dto.modelId != null">
|
and model_id = #{dto.modelId}
|
</if>
|
<if test="dto.modelSpecsId != null">
|
and model_specs_id = #{dto.modelSpecsId}
|
</if>
|
<if test="dto.modelSpecsChildrenId != null">
|
and model_specs_children_id = #{dto.modelSpecsChildrenId}
|
</if>
|
</where>
|
order by cccmr.id desc
|
</select>
|
|
<select id="queryAllByModelId" resultType="com.panzhihua.common.model.vos.common.ComChangeCarModelRelationVo">
|
SELECT
|
cccmr.id,
|
cccmr.model_id,
|
cccmr.model_specs_id,
|
cccmr.model_specs_children_id,
|
cccm.`name` as modelName,
|
cccm.`min_price` as minPrice,
|
cccm.`images`,
|
cccb.`name` as brandName,
|
cccms.`name` as specsName,
|
cccmsc.`name` as specsChildrenName
|
FROM
|
com_change_car_model_relation as cccmr
|
left join com_change_car_model as cccm on cccm.id = cccmr.model_id
|
left join com_change_car_model_specs as cccms on cccms.id = cccmr.model_specs_id
|
left join com_change_car_model_specs_children as cccmsc on cccmsc.id = cccmr.model_specs_children_id
|
left join com_change_car_brand as cccb on cccb.id = cccm.brand_id
|
where cccmr.model_id = #{modelId}
|
</select>
|
|
<select id="queryAllByAppletsLimit" resultType="com.panzhihua.common.model.vos.common.ComChangeCarModelVo">
|
SELECT
|
cccm.`name`,
|
cccm.`min_price`,
|
cccm.`images`,
|
cccb.`name` AS brandName,
|
cccm.id
|
FROM
|
com_change_car_model AS cccm
|
LEFT JOIN com_change_car_model_relation AS cccmr ON cccm.id = cccmr.model_id
|
LEFT JOIN com_change_car_model_specs AS cccms ON cccms.id = cccmr.model_specs_id
|
LEFT JOIN com_change_car_model_specs_children AS cccmsc ON cccmsc.id = cccmr.model_specs_children_id
|
LEFT JOIN com_change_car_brand AS cccb ON cccb.id = cccm.brand_id
|
<where>
|
and cccm.is_del = 2 and cccm.status = 1
|
<if test="dto.brandIds != null and dto.brandIds.size > 0">
|
and cccm.brand_id in
|
<foreach collection='dto.brandIds' item='id' index='index' open='(' close=')' separator=',' >
|
#{id}
|
</foreach>
|
</if>
|
<if test="dto.specsChildrenIds != null and dto.specsChildrenIds.size > 0">
|
and cccmr.model_specs_children_id in
|
<foreach collection='dto.specsChildrenIds' item='id' index='index' open='(' close=')' separator=',' >
|
#{id}
|
</foreach>
|
</if>
|
<if test="dto.keyWord != null and dto.keyWord !=''">
|
and cccm.`name` like concat('%',#{dto.keyWord},'%')
|
</if>
|
</where>
|
group by cccm.id
|
<if test="dto.priceSort != null and dto.priceSort == 1">
|
order by cccm.`min_price` asc
|
</if>
|
<if test="dto.priceSort != null and dto.priceSort == 2">
|
order by cccm.`min_price` desc
|
</if>
|
</select>
|
|
</mapper>
|