Merge branch 'ge_attributeNames' into 0310
Showing
14 changed files
with
1032 additions
and
0 deletions
1 | +package com.yoho.search.dal; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | +import java.util.Set; | ||
5 | + | ||
6 | +import org.apache.ibatis.annotations.Param; | ||
7 | + | ||
8 | +import com.yoho.search.dal.model.ProductAttribute; | ||
9 | + | ||
10 | +public interface ProductAttributeMapper { | ||
11 | + int deleteByPrimaryKey(Integer attributeId); | ||
12 | + | ||
13 | + int insert(ProductAttribute record); | ||
14 | + | ||
15 | + int insertSelective(ProductAttribute record); | ||
16 | + | ||
17 | + ProductAttribute selectByPrimaryKey(Integer attributeId); | ||
18 | + | ||
19 | + int updateByPrimaryKeySelective(ProductAttribute record); | ||
20 | + | ||
21 | + int updateByPrimaryKey(ProductAttribute record); | ||
22 | + | ||
23 | + List<ProductAttribute> selectByAttributeIds(@Param(value="ids") Set<Integer> attributeIds); | ||
24 | + | ||
25 | +} |
1 | +package com.yoho.search.dal; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import org.apache.ibatis.annotations.Param; | ||
6 | + | ||
7 | +import com.yoho.search.dal.model.ProductAttributePropertyValues; | ||
8 | + | ||
9 | +public interface ProductAttributePropertyValuesMapper { | ||
10 | + int deleteByPrimaryKey(Integer id); | ||
11 | + | ||
12 | + int insert(ProductAttributePropertyValues record); | ||
13 | + | ||
14 | + int insertSelective(ProductAttributePropertyValues record); | ||
15 | + | ||
16 | + ProductAttributePropertyValues selectByPrimaryKey(Integer id); | ||
17 | + | ||
18 | + int updateByPrimaryKeySelective(ProductAttributePropertyValues record); | ||
19 | + | ||
20 | + int updateByPrimaryKey(ProductAttributePropertyValues record); | ||
21 | + | ||
22 | + List<ProductAttributePropertyValues> selectBySkns(@Param(value="skns")List<Integer> skns); | ||
23 | + | ||
24 | +} |
1 | +package com.yoho.search.dal.model; | ||
2 | + | ||
3 | +import com.yoho.search.base.utils.EnumUtil; | ||
4 | + | ||
5 | +public class ProductAttribute { | ||
6 | + private Integer attributeId; | ||
7 | + | ||
8 | + private String attributeName; | ||
9 | + | ||
10 | + private Integer categoryId; | ||
11 | + | ||
12 | + private Integer saleType; | ||
13 | + | ||
14 | + private String inputType; | ||
15 | + | ||
16 | + private Byte attributeType; | ||
17 | + | ||
18 | + private String isMust; | ||
19 | + | ||
20 | + private String isSearch; | ||
21 | + | ||
22 | + private Short maxValueLen; | ||
23 | + | ||
24 | + private String isColor; | ||
25 | + | ||
26 | + private String isAllowAlias; | ||
27 | + | ||
28 | + private Integer orderBy; | ||
29 | + | ||
30 | + private Byte state; | ||
31 | + | ||
32 | + private String remark; | ||
33 | + | ||
34 | + private String attributeValues; | ||
35 | + | ||
36 | + private Byte belong; | ||
37 | + | ||
38 | + private Integer createTime; | ||
39 | + | ||
40 | + private Integer displayPosition; | ||
41 | + | ||
42 | + public Integer getAttributeId() { | ||
43 | + return attributeId; | ||
44 | + } | ||
45 | + | ||
46 | + public void setAttributeId(Integer attributeId) { | ||
47 | + this.attributeId = attributeId; | ||
48 | + } | ||
49 | + | ||
50 | + public String getAttributeName() { | ||
51 | + return attributeName; | ||
52 | + } | ||
53 | + | ||
54 | + public void setAttributeName(String attributeName) { | ||
55 | + this.attributeName = attributeName == null ? null : attributeName.trim(); | ||
56 | + } | ||
57 | + | ||
58 | + public Integer getCategoryId() { | ||
59 | + return categoryId; | ||
60 | + } | ||
61 | + | ||
62 | + public void setCategoryId(Integer categoryId) { | ||
63 | + this.categoryId = categoryId; | ||
64 | + } | ||
65 | + | ||
66 | + public Integer getSaleType() { | ||
67 | + return saleType; | ||
68 | + } | ||
69 | + | ||
70 | + public void setSaleType(Integer saleType) { | ||
71 | + this.saleType = saleType; | ||
72 | + } | ||
73 | + | ||
74 | + public String getInputType() { | ||
75 | + return EnumUtil.filterEmptyStr(inputType); | ||
76 | + } | ||
77 | + | ||
78 | + public void setInputType(String inputType) { | ||
79 | + this.inputType = inputType == null ? null : inputType.trim(); | ||
80 | + } | ||
81 | + | ||
82 | + public Byte getAttributeType() { | ||
83 | + return attributeType; | ||
84 | + } | ||
85 | + | ||
86 | + public void setAttributeType(Byte attributeType) { | ||
87 | + this.attributeType = attributeType; | ||
88 | + } | ||
89 | + | ||
90 | + public String getIsMust() { | ||
91 | + return EnumUtil.filterEmptyStr(isMust); | ||
92 | + } | ||
93 | + | ||
94 | + public void setIsMust(String isMust) { | ||
95 | + this.isMust = isMust == null ? null : isMust.trim(); | ||
96 | + } | ||
97 | + | ||
98 | + public String getIsSearch() { | ||
99 | + return EnumUtil.filterEmptyStr(isSearch); | ||
100 | + } | ||
101 | + | ||
102 | + public void setIsSearch(String isSearch) { | ||
103 | + this.isSearch = isSearch == null ? null : isSearch.trim(); | ||
104 | + } | ||
105 | + | ||
106 | + public Short getMaxValueLen() { | ||
107 | + return maxValueLen; | ||
108 | + } | ||
109 | + | ||
110 | + public void setMaxValueLen(Short maxValueLen) { | ||
111 | + this.maxValueLen = maxValueLen; | ||
112 | + } | ||
113 | + | ||
114 | + public String getIsColor() { | ||
115 | + return EnumUtil.filterEmptyStr(isColor); | ||
116 | + } | ||
117 | + | ||
118 | + public void setIsColor(String isColor) { | ||
119 | + this.isColor = isColor == null ? null : isColor.trim(); | ||
120 | + } | ||
121 | + | ||
122 | + public String getIsAllowAlias() { | ||
123 | + return EnumUtil.filterEmptyStr(isAllowAlias); | ||
124 | + } | ||
125 | + | ||
126 | + public void setIsAllowAlias(String isAllowAlias) { | ||
127 | + this.isAllowAlias = isAllowAlias == null ? null : isAllowAlias.trim(); | ||
128 | + } | ||
129 | + | ||
130 | + public Integer getOrderBy() { | ||
131 | + return orderBy; | ||
132 | + } | ||
133 | + | ||
134 | + public void setOrderBy(Integer orderBy) { | ||
135 | + this.orderBy = orderBy; | ||
136 | + } | ||
137 | + | ||
138 | + public Byte getState() { | ||
139 | + return state; | ||
140 | + } | ||
141 | + | ||
142 | + public void setState(Byte state) { | ||
143 | + this.state = state; | ||
144 | + } | ||
145 | + | ||
146 | + public String getRemark() { | ||
147 | + return remark; | ||
148 | + } | ||
149 | + | ||
150 | + public void setRemark(String remark) { | ||
151 | + this.remark = remark == null ? null : remark.trim(); | ||
152 | + } | ||
153 | + | ||
154 | + public String getAttributeValues() { | ||
155 | + return attributeValues; | ||
156 | + } | ||
157 | + | ||
158 | + public void setAttributeValues(String attributeValues) { | ||
159 | + this.attributeValues = attributeValues == null ? null : attributeValues.trim(); | ||
160 | + } | ||
161 | + | ||
162 | + public Byte getBelong() { | ||
163 | + return belong; | ||
164 | + } | ||
165 | + | ||
166 | + public void setBelong(Byte belong) { | ||
167 | + this.belong = belong; | ||
168 | + } | ||
169 | + | ||
170 | + public Integer getCreateTime() { | ||
171 | + return createTime; | ||
172 | + } | ||
173 | + | ||
174 | + public void setCreateTime(Integer createTime) { | ||
175 | + this.createTime = createTime; | ||
176 | + } | ||
177 | + | ||
178 | + public Integer getDisplayPosition() { | ||
179 | + return displayPosition; | ||
180 | + } | ||
181 | + | ||
182 | + public void setDisplayPosition(Integer displayPosition) { | ||
183 | + this.displayPosition = displayPosition; | ||
184 | + } | ||
185 | +} |
1 | +package com.yoho.search.dal.model; | ||
2 | + | ||
3 | +public class ProductAttributePropertyValues { | ||
4 | + private Integer id; | ||
5 | + | ||
6 | + private Integer productSkn; | ||
7 | + | ||
8 | + private Integer attributeId; | ||
9 | + | ||
10 | + private String attributeValueId; | ||
11 | + | ||
12 | + private Integer displayPosition; | ||
13 | + | ||
14 | + public Integer getId() { | ||
15 | + return id; | ||
16 | + } | ||
17 | + | ||
18 | + public void setId(Integer id) { | ||
19 | + this.id = id; | ||
20 | + } | ||
21 | + | ||
22 | + public Integer getProductSkn() { | ||
23 | + return productSkn; | ||
24 | + } | ||
25 | + | ||
26 | + public void setProductSkn(Integer productSkn) { | ||
27 | + this.productSkn = productSkn; | ||
28 | + } | ||
29 | + | ||
30 | + public Integer getAttributeId() { | ||
31 | + return attributeId; | ||
32 | + } | ||
33 | + | ||
34 | + public void setAttributeId(Integer attributeId) { | ||
35 | + this.attributeId = attributeId; | ||
36 | + } | ||
37 | + | ||
38 | + public String getAttributeValueId() { | ||
39 | + return attributeValueId; | ||
40 | + } | ||
41 | + | ||
42 | + public void setAttributeValueId(String attributeValueId) { | ||
43 | + this.attributeValueId = attributeValueId == null ? null : attributeValueId.trim(); | ||
44 | + } | ||
45 | + | ||
46 | + public Integer getDisplayPosition() { | ||
47 | + return displayPosition; | ||
48 | + } | ||
49 | + | ||
50 | + public void setDisplayPosition(Integer displayPosition) { | ||
51 | + this.displayPosition = displayPosition; | ||
52 | + } | ||
53 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.search.dal.ProductAttributeMapper" > | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductAttribute" > | ||
5 | + <id column="attribute_id" property="attributeId" jdbcType="INTEGER" /> | ||
6 | + <result column="attribute_name" property="attributeName" jdbcType="VARCHAR" /> | ||
7 | + <result column="category_id" property="categoryId" jdbcType="INTEGER" /> | ||
8 | + <result column="sale_type" property="saleType" jdbcType="INTEGER" /> | ||
9 | + <result column="input_type" property="inputType" jdbcType="CHAR" /> | ||
10 | + <result column="attribute_type" property="attributeType" jdbcType="TINYINT" /> | ||
11 | + <result column="is_must" property="isMust" jdbcType="CHAR" /> | ||
12 | + <result column="is_search" property="isSearch" jdbcType="CHAR" /> | ||
13 | + <result column="max_value_len" property="maxValueLen" jdbcType="SMALLINT" /> | ||
14 | + <result column="is_color" property="isColor" jdbcType="CHAR" /> | ||
15 | + <result column="is_allow_alias" property="isAllowAlias" jdbcType="CHAR" /> | ||
16 | + <result column="order_by" property="orderBy" jdbcType="INTEGER" /> | ||
17 | + <result column="state" property="state" jdbcType="TINYINT" /> | ||
18 | + <result column="remark" property="remark" jdbcType="VARCHAR" /> | ||
19 | + <result column="attribute_values" property="attributeValues" jdbcType="VARCHAR" /> | ||
20 | + <result column="belong" property="belong" jdbcType="TINYINT" /> | ||
21 | + <result column="create_time" property="createTime" jdbcType="INTEGER" /> | ||
22 | + <result column="display_position" property="displayPosition" jdbcType="INTEGER" /> | ||
23 | + </resultMap> | ||
24 | + <sql id="Base_Column_List" > | ||
25 | + attribute_id, attribute_name, category_id, sale_type, input_type, attribute_type, | ||
26 | + is_must, is_search, max_value_len, is_color, is_allow_alias, order_by, state, remark, | ||
27 | + attribute_values, belong, create_time, display_position | ||
28 | + </sql> | ||
29 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > | ||
30 | + select | ||
31 | + <include refid="Base_Column_List" /> | ||
32 | + from product_attribute | ||
33 | + where attribute_id = #{attributeId,jdbcType=INTEGER} | ||
34 | + </select> | ||
35 | + <select id="selectByAttributeIds" resultMap="BaseResultMap"> | ||
36 | + select | ||
37 | + <include refid="Base_Column_List" /> | ||
38 | + from product_attribute | ||
39 | + where attribute_id in | ||
40 | + <foreach item="item" index="index" collection="ids" | ||
41 | + open="(" separator="," close=")"> | ||
42 | + #{item} | ||
43 | + </foreach> | ||
44 | + </select> | ||
45 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | ||
46 | + delete from product_attribute | ||
47 | + where attribute_id = #{attributeId,jdbcType=INTEGER} | ||
48 | + </delete> | ||
49 | + <insert id="insert" parameterType="com.yoho.search.dal.model.ProductAttribute" > | ||
50 | + insert into product_attribute (attribute_id, attribute_name, category_id, | ||
51 | + sale_type, input_type, attribute_type, | ||
52 | + is_must, is_search, max_value_len, | ||
53 | + is_color, is_allow_alias, order_by, | ||
54 | + state, remark, attribute_values, | ||
55 | + belong, create_time, display_position | ||
56 | + ) | ||
57 | + values (#{attributeId,jdbcType=INTEGER}, #{attributeName,jdbcType=VARCHAR}, #{categoryId,jdbcType=INTEGER}, | ||
58 | + #{saleType,jdbcType=INTEGER}, #{inputType,jdbcType=CHAR}, #{attributeType,jdbcType=TINYINT}, | ||
59 | + #{isMust,jdbcType=CHAR}, #{isSearch,jdbcType=CHAR}, #{maxValueLen,jdbcType=SMALLINT}, | ||
60 | + #{isColor,jdbcType=CHAR}, #{isAllowAlias,jdbcType=CHAR}, #{orderBy,jdbcType=INTEGER}, | ||
61 | + #{state,jdbcType=TINYINT}, #{remark,jdbcType=VARCHAR}, #{attributeValues,jdbcType=VARCHAR}, | ||
62 | + #{belong,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER}, #{displayPosition,jdbcType=INTEGER} | ||
63 | + ) | ||
64 | + </insert> | ||
65 | + <insert id="insertSelective" parameterType="com.yoho.search.dal.model.ProductAttribute" > | ||
66 | + insert into product_attribute | ||
67 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
68 | + <if test="attributeId != null" > | ||
69 | + attribute_id, | ||
70 | + </if> | ||
71 | + <if test="attributeName != null" > | ||
72 | + attribute_name, | ||
73 | + </if> | ||
74 | + <if test="categoryId != null" > | ||
75 | + category_id, | ||
76 | + </if> | ||
77 | + <if test="saleType != null" > | ||
78 | + sale_type, | ||
79 | + </if> | ||
80 | + <if test="inputType != null" > | ||
81 | + input_type, | ||
82 | + </if> | ||
83 | + <if test="attributeType != null" > | ||
84 | + attribute_type, | ||
85 | + </if> | ||
86 | + <if test="isMust != null" > | ||
87 | + is_must, | ||
88 | + </if> | ||
89 | + <if test="isSearch != null" > | ||
90 | + is_search, | ||
91 | + </if> | ||
92 | + <if test="maxValueLen != null" > | ||
93 | + max_value_len, | ||
94 | + </if> | ||
95 | + <if test="isColor != null" > | ||
96 | + is_color, | ||
97 | + </if> | ||
98 | + <if test="isAllowAlias != null" > | ||
99 | + is_allow_alias, | ||
100 | + </if> | ||
101 | + <if test="orderBy != null" > | ||
102 | + order_by, | ||
103 | + </if> | ||
104 | + <if test="state != null" > | ||
105 | + state, | ||
106 | + </if> | ||
107 | + <if test="remark != null" > | ||
108 | + remark, | ||
109 | + </if> | ||
110 | + <if test="attributeValues != null" > | ||
111 | + attribute_values, | ||
112 | + </if> | ||
113 | + <if test="belong != null" > | ||
114 | + belong, | ||
115 | + </if> | ||
116 | + <if test="createTime != null" > | ||
117 | + create_time, | ||
118 | + </if> | ||
119 | + <if test="displayPosition != null" > | ||
120 | + display_position, | ||
121 | + </if> | ||
122 | + </trim> | ||
123 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
124 | + <if test="attributeId != null" > | ||
125 | + #{attributeId,jdbcType=INTEGER}, | ||
126 | + </if> | ||
127 | + <if test="attributeName != null" > | ||
128 | + #{attributeName,jdbcType=VARCHAR}, | ||
129 | + </if> | ||
130 | + <if test="categoryId != null" > | ||
131 | + #{categoryId,jdbcType=INTEGER}, | ||
132 | + </if> | ||
133 | + <if test="saleType != null" > | ||
134 | + #{saleType,jdbcType=INTEGER}, | ||
135 | + </if> | ||
136 | + <if test="inputType != null" > | ||
137 | + #{inputType,jdbcType=CHAR}, | ||
138 | + </if> | ||
139 | + <if test="attributeType != null" > | ||
140 | + #{attributeType,jdbcType=TINYINT}, | ||
141 | + </if> | ||
142 | + <if test="isMust != null" > | ||
143 | + #{isMust,jdbcType=CHAR}, | ||
144 | + </if> | ||
145 | + <if test="isSearch != null" > | ||
146 | + #{isSearch,jdbcType=CHAR}, | ||
147 | + </if> | ||
148 | + <if test="maxValueLen != null" > | ||
149 | + #{maxValueLen,jdbcType=SMALLINT}, | ||
150 | + </if> | ||
151 | + <if test="isColor != null" > | ||
152 | + #{isColor,jdbcType=CHAR}, | ||
153 | + </if> | ||
154 | + <if test="isAllowAlias != null" > | ||
155 | + #{isAllowAlias,jdbcType=CHAR}, | ||
156 | + </if> | ||
157 | + <if test="orderBy != null" > | ||
158 | + #{orderBy,jdbcType=INTEGER}, | ||
159 | + </if> | ||
160 | + <if test="state != null" > | ||
161 | + #{state,jdbcType=TINYINT}, | ||
162 | + </if> | ||
163 | + <if test="remark != null" > | ||
164 | + #{remark,jdbcType=VARCHAR}, | ||
165 | + </if> | ||
166 | + <if test="attributeValues != null" > | ||
167 | + #{attributeValues,jdbcType=VARCHAR}, | ||
168 | + </if> | ||
169 | + <if test="belong != null" > | ||
170 | + #{belong,jdbcType=TINYINT}, | ||
171 | + </if> | ||
172 | + <if test="createTime != null" > | ||
173 | + #{createTime,jdbcType=INTEGER}, | ||
174 | + </if> | ||
175 | + <if test="displayPosition != null" > | ||
176 | + #{displayPosition,jdbcType=INTEGER}, | ||
177 | + </if> | ||
178 | + </trim> | ||
179 | + </insert> | ||
180 | + <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductAttribute" > | ||
181 | + update product_attribute | ||
182 | + <set > | ||
183 | + <if test="attributeName != null" > | ||
184 | + attribute_name = #{attributeName,jdbcType=VARCHAR}, | ||
185 | + </if> | ||
186 | + <if test="categoryId != null" > | ||
187 | + category_id = #{categoryId,jdbcType=INTEGER}, | ||
188 | + </if> | ||
189 | + <if test="saleType != null" > | ||
190 | + sale_type = #{saleType,jdbcType=INTEGER}, | ||
191 | + </if> | ||
192 | + <if test="inputType != null" > | ||
193 | + input_type = #{inputType,jdbcType=CHAR}, | ||
194 | + </if> | ||
195 | + <if test="attributeType != null" > | ||
196 | + attribute_type = #{attributeType,jdbcType=TINYINT}, | ||
197 | + </if> | ||
198 | + <if test="isMust != null" > | ||
199 | + is_must = #{isMust,jdbcType=CHAR}, | ||
200 | + </if> | ||
201 | + <if test="isSearch != null" > | ||
202 | + is_search = #{isSearch,jdbcType=CHAR}, | ||
203 | + </if> | ||
204 | + <if test="maxValueLen != null" > | ||
205 | + max_value_len = #{maxValueLen,jdbcType=SMALLINT}, | ||
206 | + </if> | ||
207 | + <if test="isColor != null" > | ||
208 | + is_color = #{isColor,jdbcType=CHAR}, | ||
209 | + </if> | ||
210 | + <if test="isAllowAlias != null" > | ||
211 | + is_allow_alias = #{isAllowAlias,jdbcType=CHAR}, | ||
212 | + </if> | ||
213 | + <if test="orderBy != null" > | ||
214 | + order_by = #{orderBy,jdbcType=INTEGER}, | ||
215 | + </if> | ||
216 | + <if test="state != null" > | ||
217 | + state = #{state,jdbcType=TINYINT}, | ||
218 | + </if> | ||
219 | + <if test="remark != null" > | ||
220 | + remark = #{remark,jdbcType=VARCHAR}, | ||
221 | + </if> | ||
222 | + <if test="attributeValues != null" > | ||
223 | + attribute_values = #{attributeValues,jdbcType=VARCHAR}, | ||
224 | + </if> | ||
225 | + <if test="belong != null" > | ||
226 | + belong = #{belong,jdbcType=TINYINT}, | ||
227 | + </if> | ||
228 | + <if test="createTime != null" > | ||
229 | + create_time = #{createTime,jdbcType=INTEGER}, | ||
230 | + </if> | ||
231 | + <if test="displayPosition != null" > | ||
232 | + display_position = #{displayPosition,jdbcType=INTEGER}, | ||
233 | + </if> | ||
234 | + </set> | ||
235 | + where attribute_id = #{attributeId,jdbcType=INTEGER} | ||
236 | + </update> | ||
237 | + <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.ProductAttribute" > | ||
238 | + update product_attribute | ||
239 | + set attribute_name = #{attributeName,jdbcType=VARCHAR}, | ||
240 | + category_id = #{categoryId,jdbcType=INTEGER}, | ||
241 | + sale_type = #{saleType,jdbcType=INTEGER}, | ||
242 | + input_type = #{inputType,jdbcType=CHAR}, | ||
243 | + attribute_type = #{attributeType,jdbcType=TINYINT}, | ||
244 | + is_must = #{isMust,jdbcType=CHAR}, | ||
245 | + is_search = #{isSearch,jdbcType=CHAR}, | ||
246 | + max_value_len = #{maxValueLen,jdbcType=SMALLINT}, | ||
247 | + is_color = #{isColor,jdbcType=CHAR}, | ||
248 | + is_allow_alias = #{isAllowAlias,jdbcType=CHAR}, | ||
249 | + order_by = #{orderBy,jdbcType=INTEGER}, | ||
250 | + state = #{state,jdbcType=TINYINT}, | ||
251 | + remark = #{remark,jdbcType=VARCHAR}, | ||
252 | + attribute_values = #{attributeValues,jdbcType=VARCHAR}, | ||
253 | + belong = #{belong,jdbcType=TINYINT}, | ||
254 | + create_time = #{createTime,jdbcType=INTEGER}, | ||
255 | + display_position = #{displayPosition,jdbcType=INTEGER} | ||
256 | + where attribute_id = #{attributeId,jdbcType=INTEGER} | ||
257 | + </update> | ||
258 | +</mapper> |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.search.dal.ProductAttributePropertyValuesMapper" > | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductAttributePropertyValues" > | ||
5 | + <id column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="product_skn" property="productSkn" jdbcType="INTEGER" /> | ||
7 | + <result column="attribute_id" property="attributeId" jdbcType="INTEGER" /> | ||
8 | + <result column="attribute_value_id" property="attributeValueId" jdbcType="VARCHAR" /> | ||
9 | + <result column="display_position" property="displayPosition" jdbcType="INTEGER" /> | ||
10 | + </resultMap> | ||
11 | + <sql id="Base_Column_List" > | ||
12 | + id, product_skn, attribute_id, attribute_value_id, display_position | ||
13 | + </sql> | ||
14 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > | ||
15 | + select | ||
16 | + <include refid="Base_Column_List" /> | ||
17 | + from product_attribute_property_values | ||
18 | + where id = #{id,jdbcType=INTEGER} | ||
19 | + </select> | ||
20 | + <select id="selectBySkns" resultMap="BaseResultMap"> | ||
21 | + select | ||
22 | + <include refid="Base_Column_List" /> | ||
23 | + from product_attribute_property_values | ||
24 | + where product_skn in | ||
25 | + <foreach item="item" index="index" collection="skns" | ||
26 | + open="(" separator="," close=")"> | ||
27 | + #{item} | ||
28 | + </foreach> | ||
29 | + </select> | ||
30 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | ||
31 | + delete from product_attribute_property_values | ||
32 | + where id = #{id,jdbcType=INTEGER} | ||
33 | + </delete> | ||
34 | + <insert id="insert" parameterType="com.yoho.search.dal.model.ProductAttributePropertyValues" > | ||
35 | + insert into product_attribute_property_values (id, product_skn, attribute_id, | ||
36 | + attribute_value_id, display_position) | ||
37 | + values (#{id,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{attributeId,jdbcType=INTEGER}, | ||
38 | + #{attributeValueId,jdbcType=VARCHAR}, #{displayPosition,jdbcType=INTEGER}) | ||
39 | + </insert> | ||
40 | + <insert id="insertSelective" parameterType="com.yoho.search.dal.model.ProductAttributePropertyValues" > | ||
41 | + insert into product_attribute_property_values | ||
42 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
43 | + <if test="id != null" > | ||
44 | + id, | ||
45 | + </if> | ||
46 | + <if test="productSkn != null" > | ||
47 | + product_skn, | ||
48 | + </if> | ||
49 | + <if test="attributeId != null" > | ||
50 | + attribute_id, | ||
51 | + </if> | ||
52 | + <if test="attributeValueId != null" > | ||
53 | + attribute_value_id, | ||
54 | + </if> | ||
55 | + <if test="displayPosition != null" > | ||
56 | + display_position, | ||
57 | + </if> | ||
58 | + </trim> | ||
59 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
60 | + <if test="id != null" > | ||
61 | + #{id,jdbcType=INTEGER}, | ||
62 | + </if> | ||
63 | + <if test="productSkn != null" > | ||
64 | + #{productSkn,jdbcType=INTEGER}, | ||
65 | + </if> | ||
66 | + <if test="attributeId != null" > | ||
67 | + #{attributeId,jdbcType=INTEGER}, | ||
68 | + </if> | ||
69 | + <if test="attributeValueId != null" > | ||
70 | + #{attributeValueId,jdbcType=VARCHAR}, | ||
71 | + </if> | ||
72 | + <if test="displayPosition != null" > | ||
73 | + #{displayPosition,jdbcType=INTEGER}, | ||
74 | + </if> | ||
75 | + </trim> | ||
76 | + </insert> | ||
77 | + <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductAttributePropertyValues" > | ||
78 | + update product_attribute_property_values | ||
79 | + <set > | ||
80 | + <if test="productSkn != null" > | ||
81 | + product_skn = #{productSkn,jdbcType=INTEGER}, | ||
82 | + </if> | ||
83 | + <if test="attributeId != null" > | ||
84 | + attribute_id = #{attributeId,jdbcType=INTEGER}, | ||
85 | + </if> | ||
86 | + <if test="attributeValueId != null" > | ||
87 | + attribute_value_id = #{attributeValueId,jdbcType=VARCHAR}, | ||
88 | + </if> | ||
89 | + <if test="displayPosition != null" > | ||
90 | + display_position = #{displayPosition,jdbcType=INTEGER}, | ||
91 | + </if> | ||
92 | + </set> | ||
93 | + where id = #{id,jdbcType=INTEGER} | ||
94 | + </update> | ||
95 | + <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.ProductAttributePropertyValues" > | ||
96 | + update product_attribute_property_values | ||
97 | + set product_skn = #{productSkn,jdbcType=INTEGER}, | ||
98 | + attribute_id = #{attributeId,jdbcType=INTEGER}, | ||
99 | + attribute_value_id = #{attributeValueId,jdbcType=VARCHAR}, | ||
100 | + display_position = #{displayPosition,jdbcType=INTEGER} | ||
101 | + where id = #{id,jdbcType=INTEGER} | ||
102 | + </update> | ||
103 | +</mapper> |
index/src/main/java/com/yoho/search/consumer/index/increment/ProductAttributeMqListener.java
0 → 100644
1 | +package com.yoho.search.consumer.index.increment; | ||
2 | + | ||
3 | +import java.util.Map; | ||
4 | + | ||
5 | +import org.apache.commons.lang3.StringUtils; | ||
6 | +import org.slf4j.Logger; | ||
7 | +import org.slf4j.LoggerFactory; | ||
8 | +import org.springframework.amqp.core.Message; | ||
9 | +import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; | ||
10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
11 | +import org.springframework.stereotype.Component; | ||
12 | + | ||
13 | +import com.alibaba.fastjson.JSONObject; | ||
14 | +import com.rabbitmq.client.Channel; | ||
15 | +import com.yoho.error.event.SearchEvent; | ||
16 | +import com.yoho.search.base.utils.ConvertUtils; | ||
17 | +import com.yoho.search.base.utils.EventReportEnum; | ||
18 | +import com.yoho.search.base.utils.ISearchConstants; | ||
19 | +import com.yoho.search.consumer.service.base.ProductAttributeService; | ||
20 | +import com.yoho.search.core.es.utils.IgnoreSomeException; | ||
21 | +import com.yoho.search.dal.model.ProductAttribute; | ||
22 | + | ||
23 | +@Component | ||
24 | +public class ProductAttributeMqListener extends AbstractMqListener implements ChannelAwareMessageListener{ | ||
25 | + | ||
26 | + private static final Logger logger = LoggerFactory.getLogger(ProductAttributePropertyValuesMqListener.class); | ||
27 | + | ||
28 | + @Autowired | ||
29 | + private ProductAttributeService productAttributeService; | ||
30 | + | ||
31 | + @Override | ||
32 | + public void onMessage(Message message, Channel channel) throws Exception { | ||
33 | + try { | ||
34 | + String messageStr = new String(message.getBody(), "UTF-8"); | ||
35 | + logger.info("[model=ProductAttributeMqListener] [message={}]", messageStr); | ||
36 | + // 如果在重建索引等待 | ||
37 | + this.waitingRebuildingIndex(); | ||
38 | + JSONObject json = JSONObject.parseObject(messageStr); | ||
39 | + String tableName = ISearchConstants.TABLE_NAME_TBL_PRODUCT_ATTRIBUTE; | ||
40 | + String action = json.getString("action"); | ||
41 | + if (ISearchConstants.ACTION_DELETE.equals(action)) { | ||
42 | + deleteData(json.getString("data"), tableName); | ||
43 | + } else if (ISearchConstants.ACTION_UPDATE.equals(action)) { | ||
44 | + updateData(json.getObject("data", Map.class), tableName); | ||
45 | + } else { | ||
46 | + updateData(json.getObject("data", Map.class), tableName); | ||
47 | + } | ||
48 | + } catch (Exception e) { | ||
49 | + publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTATTRIBUTEMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTATTRIBUTEMQLISTENER_ONMESSAGE.getFunctionName(), | ||
50 | + EventReportEnum.PRODUCTATTRIBUTEMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null)); | ||
51 | + Thread.sleep(1000); | ||
52 | + throw e; | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + @SuppressWarnings({ "rawtypes", "unchecked" }) | ||
57 | + public void updateData(final Map data, final String tableName) throws Exception { | ||
58 | + long begin = System.currentTimeMillis(); | ||
59 | + ProductAttribute productAttribute = new ProductAttribute(); | ||
60 | + productAttribute = (ProductAttribute) ConvertUtils.toJavaBean(productAttribute, data); | ||
61 | + if (productAttribute == null || productAttribute.getAttributeId() == null) { | ||
62 | + return; | ||
63 | + } | ||
64 | + // 更新数据库 | ||
65 | + productAttributeService.saveOrUpdateProductAttribute(productAttribute); | ||
66 | + logger.info("[func=updateData][step=success][tableName={}][attributeId={}][cost={}ms]", tableName, productAttribute.getAttributeId(), (System.currentTimeMillis() - begin)); | ||
67 | + } | ||
68 | + | ||
69 | + public void deleteData(final String id, final String tableName) throws Exception { | ||
70 | + if (StringUtils.isBlank(id)) { | ||
71 | + return; | ||
72 | + } | ||
73 | + long begin = System.currentTimeMillis(); | ||
74 | + // 删除数据 | ||
75 | + productAttributeService.deleteProductAttributeById(Integer.valueOf(id)); | ||
76 | + logger.info("[func=deleteData][step=success][tableName={}][attributeId={}][cost={}ms]", tableName, id, (System.currentTimeMillis() - begin)); | ||
77 | + } | ||
78 | + | ||
79 | +} |
1 | +package com.yoho.search.consumer.index.increment; | ||
2 | + | ||
3 | +import java.util.ArrayList; | ||
4 | +import java.util.HashMap; | ||
5 | +import java.util.Map; | ||
6 | + | ||
7 | +import org.apache.commons.lang3.StringUtils; | ||
8 | +import org.slf4j.Logger; | ||
9 | +import org.slf4j.LoggerFactory; | ||
10 | +import org.springframework.amqp.core.Message; | ||
11 | +import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; | ||
12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
13 | +import org.springframework.stereotype.Component; | ||
14 | + | ||
15 | +import com.alibaba.fastjson.JSONObject; | ||
16 | +import com.rabbitmq.client.Channel; | ||
17 | +import com.yoho.error.event.SearchEvent; | ||
18 | +import com.yoho.search.base.utils.ConvertUtils; | ||
19 | +import com.yoho.search.base.utils.EventReportEnum; | ||
20 | +import com.yoho.search.base.utils.ISearchConstants; | ||
21 | +import com.yoho.search.consumer.index.common.IYohoIndexService; | ||
22 | +import com.yoho.search.consumer.service.base.ProductAttributeService; | ||
23 | +import com.yoho.search.consumer.service.base.ProductService; | ||
24 | +import com.yoho.search.core.es.utils.IgnoreSomeException; | ||
25 | +import com.yoho.search.dal.model.Product; | ||
26 | +import com.yoho.search.dal.model.ProductAttributePropertyValues; | ||
27 | + | ||
28 | +@Component | ||
29 | +public class ProductAttributePropertyValuesMqListener extends AbstractMqListener implements ChannelAwareMessageListener{ | ||
30 | + | ||
31 | + private static final Logger logger = LoggerFactory.getLogger(ProductAttributePropertyValuesMqListener.class); | ||
32 | + | ||
33 | + @Autowired | ||
34 | + private ProductAttributeService productAttributeService; | ||
35 | + @Autowired | ||
36 | + private ProductService productService; | ||
37 | + @Autowired | ||
38 | + private IYohoIndexService indexService; | ||
39 | + | ||
40 | + @Override | ||
41 | + public void onMessage(Message message, Channel channel) throws Exception { | ||
42 | + try { | ||
43 | + String messageStr = new String(message.getBody(), "UTF-8"); | ||
44 | + logger.info("[model=ProductAttributePropertyValuesMqListener] [message={}]", messageStr); | ||
45 | + // 如果在重建索引等待 | ||
46 | + this.waitingRebuildingIndex(); | ||
47 | + JSONObject json = JSONObject.parseObject(messageStr); | ||
48 | + String indexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX; | ||
49 | + String action = json.getString("action"); | ||
50 | + if (ISearchConstants.ACTION_DELETE.equals(action)) { | ||
51 | + deleteData(json.getString("data"), indexName); | ||
52 | + } else if (ISearchConstants.ACTION_UPDATE.equals(action)) { | ||
53 | + updateData(json.getObject("data", Map.class), indexName); | ||
54 | + } else { | ||
55 | + updateData(json.getObject("data", Map.class), indexName); | ||
56 | + } | ||
57 | + } catch (Exception e) { | ||
58 | + publisher.publishEvent(new SearchEvent(EventReportEnum.PRODUCTATTRIBUTEPROPERTYVALUESMQLISTENER_ONMESSAGE.getEventName(), EventReportEnum.PRODUCTATTRIBUTEPROPERTYVALUESMQLISTENER_ONMESSAGE.getFunctionName(), | ||
59 | + EventReportEnum.PRODUCTATTRIBUTEPROPERTYVALUESMQLISTENER_ONMESSAGE.getMoudleName(), "exception", IgnoreSomeException.filterSomeException(e), null)); | ||
60 | + Thread.sleep(1000); | ||
61 | + throw e; | ||
62 | + } | ||
63 | + } | ||
64 | + | ||
65 | + @SuppressWarnings({ "rawtypes", "unchecked" }) | ||
66 | + public void updateData(final Map data, final String indexName) throws Exception { | ||
67 | + long begin = System.currentTimeMillis(); | ||
68 | + ProductAttributePropertyValues productAttributePropertyValues = new ProductAttributePropertyValues(); | ||
69 | + productAttributePropertyValues = (ProductAttributePropertyValues) ConvertUtils.toJavaBean(productAttributePropertyValues, data); | ||
70 | + if (productAttributePropertyValues == null || productAttributePropertyValues.getProductSkn() == null) { | ||
71 | + return; | ||
72 | + } | ||
73 | + // 更新数据库 | ||
74 | + productAttributeService.saveOrUpdate(productAttributePropertyValues); | ||
75 | + // 获取product数据 | ||
76 | + Product product = productService.getBySkn(productAttributePropertyValues.getProductSkn()); | ||
77 | + if (product == null) { | ||
78 | + logger.info("[func=updateData][indexName={}] can not find this productId(skn= {}) in table product", indexName, productAttributePropertyValues.getProductSkn()); | ||
79 | + return; | ||
80 | + } | ||
81 | + // 更新es数据 | ||
82 | + Map<String, Object> esData = new HashMap<String, Object>(); | ||
83 | + String attributeNames = getAttributeNames(productAttributePropertyValues.getProductSkn()); | ||
84 | + esData.put("attributeNames", attributeNames); | ||
85 | + indexService.updateIndexData(indexName, product.getId().toString(), esData); | ||
86 | + logger.info("[func=updateData][step=success][indexName={}][skn={}][cost={}ms]", indexName, productAttributePropertyValues.getProductSkn(), (System.currentTimeMillis() - begin)); | ||
87 | + } | ||
88 | + | ||
89 | + public void deleteData(final String id, final String indexName) throws Exception { | ||
90 | + if (StringUtils.isBlank(id)) { | ||
91 | + return; | ||
92 | + } | ||
93 | + long begin = System.currentTimeMillis(); | ||
94 | + ProductAttributePropertyValues productAttributePropertyValues = productAttributeService.selectById(Integer.valueOf(id)); | ||
95 | + // 删除数据 | ||
96 | + productAttributeService.deleteById(Integer.valueOf(id)); | ||
97 | + // 获取product数据 | ||
98 | + Product product = productService.getBySkn(productAttributePropertyValues.getProductSkn()); | ||
99 | + if (product == null) { | ||
100 | + logger.info("[func=deleteData][indexName={}] can not find this productId({}) in table product", indexName, id); | ||
101 | + return; | ||
102 | + } | ||
103 | + // 更新ES数据 | ||
104 | + Map<String, Object> data = new HashMap<String, Object>(); | ||
105 | + String attributeNames = getAttributeNames(productAttributePropertyValues.getProductSkn()); | ||
106 | + data.put("attributeNames", attributeNames); | ||
107 | + indexService.updateIndexData(indexName, product.getId().toString(), data); | ||
108 | + logger.info("[func=deleteData][step=success][indexName={}][productId={}][cost={}ms]", indexName, product.getId(), (System.currentTimeMillis() - begin)); | ||
109 | + } | ||
110 | + | ||
111 | + public String getAttributeNames(Integer skn){ | ||
112 | + ArrayList<Integer> skns = new ArrayList<Integer>(); | ||
113 | + skns.add(skn); | ||
114 | + Map<Integer, String> attributeMap = productAttributeService.selectBySkns(skns); | ||
115 | + if(attributeMap.get(skn)!=null){ | ||
116 | + return attributeMap.get(skn); | ||
117 | + } | ||
118 | + return ""; | ||
119 | + } | ||
120 | +} |
@@ -936,6 +936,10 @@ | @@ -936,6 +936,10 @@ | ||
936 | "type": "string", | 936 | "type": "string", |
937 | "analyzer": "comma_spliter" | 937 | "analyzer": "comma_spliter" |
938 | }, | 938 | }, |
939 | + "attributeNames": { | ||
940 | + "type": "string", | ||
941 | + "analyzer": "comma_spliter" | ||
942 | + }, | ||
939 | "sknDefaultImg": { | 943 | "sknDefaultImg": { |
940 | "type": "string", | 944 | "type": "string", |
941 | "index": "not_analyzed" | 945 | "index": "not_analyzed" |
1 | +package com.yoho.search.consumer.service.base; | ||
2 | + | ||
3 | +import java.util.HashMap; | ||
4 | +import java.util.HashSet; | ||
5 | +import java.util.List; | ||
6 | +import java.util.Map; | ||
7 | +import java.util.Set; | ||
8 | +import java.util.stream.Collectors; | ||
9 | + | ||
10 | +import org.apache.commons.lang.StringUtils; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | +import org.springframework.stereotype.Service; | ||
13 | + | ||
14 | +import com.alibaba.fastjson.JSONArray; | ||
15 | +import com.alibaba.fastjson.JSONObject; | ||
16 | +import com.yoho.search.dal.ProductAttributeMapper; | ||
17 | +import com.yoho.search.dal.ProductAttributePropertyValuesMapper; | ||
18 | +import com.yoho.search.dal.model.ProductAttribute; | ||
19 | +import com.yoho.search.dal.model.ProductAttributePropertyValues; | ||
20 | + | ||
21 | +/** | ||
22 | + * 从product_attribute_property_values和product_attribute获取skn的AttributeNames | ||
23 | + * @author gemingdan | ||
24 | + * | ||
25 | + */ | ||
26 | +@Service | ||
27 | +public class ProductAttributeService { | ||
28 | + | ||
29 | + @Autowired | ||
30 | + private ProductAttributeMapper productAttributeMapper; | ||
31 | + | ||
32 | + @Autowired | ||
33 | + private ProductAttributePropertyValuesMapper productAttributePropertyValuesMapper; | ||
34 | + | ||
35 | + public Map<Integer,String> selectBySkns(List<Integer> skns){ | ||
36 | + Map<Integer,String> result= new HashMap<Integer,String>(); | ||
37 | + List<ProductAttributePropertyValues> attributeList =productAttributePropertyValuesMapper.selectBySkns(skns); | ||
38 | + if(attributeList==null){ | ||
39 | + return result; | ||
40 | + } | ||
41 | + Set<Integer> attributeIds=new HashSet<Integer>(); | ||
42 | + attributeList.forEach(a->{ | ||
43 | + attributeIds.add(a.getAttributeId()); | ||
44 | + }); | ||
45 | + if(attributeIds.size()==0){ | ||
46 | + return result; | ||
47 | + } | ||
48 | + List<ProductAttribute> valueList=productAttributeMapper.selectByAttributeIds(attributeIds); | ||
49 | + if(valueList==null||valueList.size()==0){ | ||
50 | + return result; | ||
51 | + } | ||
52 | + Map<Integer, ProductAttribute> ProductAttributeMap = valueList.stream().parallel().collect(Collectors.toMap(ProductAttribute::getAttributeId, (p) -> p)); | ||
53 | + Map<Integer,Set<String>> resultSet= new HashMap<Integer,Set<String>>(); | ||
54 | + attributeList.forEach(a->{ | ||
55 | + if(ProductAttributeMap.get(a.getAttributeId())==null||a.getAttributeValueId()==null){ | ||
56 | + return; | ||
57 | + } | ||
58 | + ProductAttribute pa= ProductAttributeMap.get(a.getAttributeId()); | ||
59 | + String[] attributeValueIds = a.getAttributeValueId().split(","); | ||
60 | + if(pa.getAttributeValues()==null||pa.getAttributeValues().indexOf("[")<0){ | ||
61 | + return; | ||
62 | + } | ||
63 | + JSONArray values = JSONArray.parseArray(pa.getAttributeValues()); | ||
64 | + Set<String> attributeNameSet=new HashSet<String>(); | ||
65 | + values.forEach(v->{ | ||
66 | + JSONObject vobj=(JSONObject)v; | ||
67 | + for(int i=0;i<attributeValueIds.length;i++){ | ||
68 | + Integer id=(Integer)vobj.get("id"); | ||
69 | + if(id!=null&&attributeValueIds[i].endsWith(id.toString())){ | ||
70 | + attributeNameSet.add((String)vobj.get("name")); | ||
71 | + } | ||
72 | + } | ||
73 | + }); | ||
74 | + if(attributeNameSet.size()==0){ | ||
75 | + return; | ||
76 | + } | ||
77 | + if(resultSet.get(a.getProductSkn())!=null){ | ||
78 | + attributeNameSet.addAll(resultSet.get(a.getProductSkn())); | ||
79 | + } | ||
80 | + resultSet.put(a.getProductSkn(),attributeNameSet); | ||
81 | + }); | ||
82 | + resultSet.forEach((skn,set)->{ | ||
83 | + result.put(skn,StringUtils.join(set.toArray(), ",") ); | ||
84 | + }); | ||
85 | + return result; | ||
86 | + } | ||
87 | + | ||
88 | + public void saveOrUpdate(ProductAttributePropertyValues productAttributePropertyValues) { | ||
89 | + if(productAttributePropertyValues==null||productAttributePropertyValues.getId()==null){ | ||
90 | + return; | ||
91 | + } | ||
92 | + if(productAttributePropertyValuesMapper.selectByPrimaryKey(productAttributePropertyValues.getId())==null){ | ||
93 | + //插入 | ||
94 | + productAttributePropertyValuesMapper.insert(productAttributePropertyValues); | ||
95 | + }else{ | ||
96 | + //更新 | ||
97 | + productAttributePropertyValuesMapper.updateByPrimaryKey(productAttributePropertyValues); | ||
98 | + } | ||
99 | + } | ||
100 | + | ||
101 | + public void deleteById(Integer id) { | ||
102 | + productAttributePropertyValuesMapper.deleteByPrimaryKey(id); | ||
103 | + } | ||
104 | + | ||
105 | + public ProductAttributePropertyValues selectById(Integer id) { | ||
106 | + return productAttributePropertyValuesMapper.selectByPrimaryKey(id); | ||
107 | + } | ||
108 | + | ||
109 | + public void saveOrUpdateProductAttribute(ProductAttribute productAttribute) { | ||
110 | + if(productAttribute==null||productAttribute.getAttributeId()==null){ | ||
111 | + return; | ||
112 | + } | ||
113 | + if(productAttributeMapper.selectByPrimaryKey(productAttribute.getAttributeId())==null){ | ||
114 | + //插入 | ||
115 | + productAttributeMapper.insert(productAttribute); | ||
116 | + }else{ | ||
117 | + //更新 | ||
118 | + productAttributeMapper.updateByPrimaryKey(productAttribute); | ||
119 | + } | ||
120 | + | ||
121 | + } | ||
122 | + | ||
123 | + public void deleteProductAttributeById(Integer id) { | ||
124 | + productAttributeMapper.deleteByPrimaryKey(id); | ||
125 | + } | ||
126 | + | ||
127 | + | ||
128 | +} |
@@ -194,6 +194,7 @@ public class ProductIndexService { | @@ -194,6 +194,7 @@ public class ProductIndexService { | ||
194 | map.put("phrase", productIndexBO.getPhrase()); | 194 | map.put("phrase", productIndexBO.getPhrase()); |
195 | map.put("isPhraseExist", productIndexBO.getIsPhraseExist()); | 195 | map.put("isPhraseExist", productIndexBO.getIsPhraseExist()); |
196 | map.put("pattern", productIndexBO.getPattern()); | 196 | map.put("pattern", productIndexBO.getPattern()); |
197 | + map.put("attributeNames", productIndexBO.getAttributeNames()); | ||
197 | return map; | 198 | return map; |
198 | } | 199 | } |
199 | 200 |
@@ -103,6 +103,9 @@ public class ProductIndexBO extends ProductIBO implements Serializable { | @@ -103,6 +103,9 @@ public class ProductIndexBO extends ProductIBO implements Serializable { | ||
103 | 103 | ||
104 | // from `erp_product`.`product_ext` | 104 | // from `erp_product`.`product_ext` |
105 | private String sknDefaultImg; | 105 | private String sknDefaultImg; |
106 | + | ||
107 | + //from erp_product.product_attribute yh_shops.product_attribute_property_values | ||
108 | + private String attributeNames; | ||
106 | 109 | ||
107 | // get | 110 | // get |
108 | public BigDecimal getSpecialPrice() { | 111 | public BigDecimal getSpecialPrice() { |
@@ -482,4 +485,12 @@ public class ProductIndexBO extends ProductIBO implements Serializable { | @@ -482,4 +485,12 @@ public class ProductIndexBO extends ProductIBO implements Serializable { | ||
482 | this.sknDefaultImg = sknDefaultImg; | 485 | this.sknDefaultImg = sknDefaultImg; |
483 | } | 486 | } |
484 | 487 | ||
488 | + public String getAttributeNames() { | ||
489 | + return attributeNames; | ||
490 | + } | ||
491 | + | ||
492 | + public void setAttributeNames(String attributeNames) { | ||
493 | + this.attributeNames = attributeNames; | ||
494 | + } | ||
495 | + | ||
485 | } | 496 | } |
1 | +package com.yoho.search.consumer.service.logic.productIndex.viewBuilder; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | +import java.util.Map; | ||
5 | + | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | + | ||
9 | +import com.yoho.search.consumer.service.base.ProductAttributeService; | ||
10 | +import com.yoho.search.consumer.service.bo.ProductIndexBO; | ||
11 | + | ||
12 | +/** | ||
13 | + * attributeNames | ||
14 | + * from erp_product.product_attribute yh_shops.product_attribute_property_values | ||
15 | + * @author gemingdan | ||
16 | + * | ||
17 | + */ | ||
18 | +@Component | ||
19 | +public class ProductAttributeNamesBuilder implements ViewBuilder { | ||
20 | + | ||
21 | + @Autowired | ||
22 | + private ProductAttributeService productAttributeService; | ||
23 | + | ||
24 | + @Override | ||
25 | + public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids,List<Integer> skns) { | ||
26 | + Map<Integer, String> attributeNamesMap = productAttributeService.selectBySkns(skns); | ||
27 | + for(ProductIndexBO b:productIndexBOs){ | ||
28 | + if(b.getProductSkn()!=null&&attributeNamesMap.get(b.getProductSkn())!=null){ | ||
29 | + b.setAttributeNames(attributeNamesMap.get(b.getProductSkn())); | ||
30 | + } | ||
31 | + if(b.getAttributeNames()==null){ | ||
32 | + b.setAttributeNames(""); | ||
33 | + } | ||
34 | + } | ||
35 | + } | ||
36 | + | ||
37 | +} |
@@ -77,6 +77,8 @@ | @@ -77,6 +77,8 @@ | ||
77 | <rabbit:queue durable="true" exclusive="false" name="data_update_channel_tblproductskc" /> | 77 | <rabbit:queue durable="true" exclusive="false" name="data_update_channel_tblproductskc" /> |
78 | <rabbit:queue durable="true" exclusive="false" name="data_update_channel_tblproductsku" /> | 78 | <rabbit:queue durable="true" exclusive="false" name="data_update_channel_tblproductsku" /> |
79 | <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productext" /> | 79 | <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productext" /> |
80 | + <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productattributepropertyvalues" /> | ||
81 | + <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productattribute" /> | ||
80 | 82 | ||
81 | <rabbit:template exchange="${search.mq.exchange}" id="amqpTemplate" | 83 | <rabbit:template exchange="${search.mq.exchange}" id="amqpTemplate" |
82 | connection-factory="connectionFactory" message-converter="jsonMessageConverter" /> | 84 | connection-factory="connectionFactory" message-converter="jsonMessageConverter" /> |
@@ -156,6 +158,8 @@ | @@ -156,6 +158,8 @@ | ||
156 | <rabbit:listener queue-names="data_update_channel_tblproductskc" ref="tblProductSkcMqListener" /> | 158 | <rabbit:listener queue-names="data_update_channel_tblproductskc" ref="tblProductSkcMqListener" /> |
157 | <rabbit:listener queue-names="data_update_channel_tblproductsku" ref="tblProductSkuMqListener" /> | 159 | <rabbit:listener queue-names="data_update_channel_tblproductsku" ref="tblProductSkuMqListener" /> |
158 | <rabbit:listener queue-names="data_update_channel_productext" ref="productExtMqListener" /> | 160 | <rabbit:listener queue-names="data_update_channel_productext" ref="productExtMqListener" /> |
161 | + <rabbit:listener queue-names="data_update_channel_productattributepropertyvalues" ref="productAttributePropertyValuesMqListener" /> | ||
162 | + <rabbit:listener queue-names="data_update_channel_productattribute" ref="productAttributeMqListener" /> | ||
159 | 163 | ||
160 | </rabbit:listener-container> | 164 | </rabbit:listener-container> |
161 | </beans> | 165 | </beans> |
-
Please register or login to post a comment