CarBrandMapper.xml
2.98 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
<?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.bs.cardata.mapper.CarBrandMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="com.bs.cardata.entity.Carbrand">
<id column="bid" property="bid"/>
<result column="brand" property="brand"/>
<result column="brand_code" property="brandCode"/>
<result column="bra_country" property="braCountry"/>
<result column="identifying_photo" property="identifyingPhoto"/>
<result column="bra_letter" property="braLetter"/>
<result column="last_operator_name" property="lastOperatorName"/>
<result column="last_operator_id" property="lastOperatorId"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="autohome_id" property="autohomeId"/>
<result column="operator_type" property="operatorType"/>
<result column="is_used" property="isUsed"/>
<result column="parent_id" property="parentId"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
bid, brand, brand_code, bra_country, identifying_photo, bra_letter,
last_operator_name, last_operator_id, create_time, update_time,
autohome_id, operator_type, is_used, parent_id
</sql>
<select id="getCarBrandInfo" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM bs_carbrand
WHERE parent_id > 0
<if test="autohomeId != null and autohomeId != ''">
AND autohome_id = #{autohomeId}
</if>
<if test="brand != null and brand != ''">
AND brand = #{brand}
</if>
LIMIT 1
</select>
<select id="getCarBrandForParent" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM bs_carbrand
WHERE parent_id = -2
AND autohome_id = #{autohomeId}
AND is_used = 0
LIMIT 1
</select>
<!-- 根据指定SQL查询所有品牌车型数据 -->
<select id="selectAllBrandHierarchyData" resultType="com.bs.cardata.dto.CarBrandRawDataDto">
SELECT
pb.brand AS parentName, pb.bid as parentId, pb.bra_letter as parentLetter, pb.identifying_photo as parentPhoto,
chb.brand AS childName, chb.bid AS childId, chb.bra_letter as childLetter,
pcs.carseries, pcs.csid, pcs.series_letter
FROM
bs_carbrand AS chb
INNER JOIN
bs_carbrand AS pb ON chb.parent_id = pb.bid and pb.is_used = 0
LEFT JOIN
platform_carseries AS pcs ON chb.bid = pcs.brand_id and pcs.is_used = 0
WHERE
chb.parent_id > 0 and chb.is_used = 0
AND pb.parent_id = -2
ORDER BY
pb.bra_letter,
chb.brand,
pcs.carseries
</select>
</mapper>