Commit 752e49560dec7b972b4025d16b9987f4e2744cfb

Authored by 曾国涛
2 parents 27724e37 956a2f00

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	shop/src/main/java/com/canrd/shop/service/impl/ProductServiceImpl.java
shop/src/main/java/com/canrd/shop/mapper/ProductFunctionMapper.java
@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 import com.canrd.shop.module.dto.ProductCategoryDO; 4 import com.canrd.shop.module.dto.ProductCategoryDO;
5 import com.canrd.shop.module.dto.ProductFunctionDO; 5 import com.canrd.shop.module.dto.ProductFunctionDO;
6 import org.apache.ibatis.annotations.Mapper; 6 import org.apache.ibatis.annotations.Mapper;
  7 +import org.apache.ibatis.annotations.Param;
  8 +
  9 +import java.util.List;
7 10
8 /** 11 /**
9 * @author hongtao.zhao 12 * @author hongtao.zhao
@@ -11,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper; @@ -11,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
11 */ 14 */
12 @Mapper 15 @Mapper
13 public interface ProductFunctionMapper extends BaseMapper<ProductFunctionDO> { 16 public interface ProductFunctionMapper extends BaseMapper<ProductFunctionDO> {
  17 + List<ProductFunctionDO> getFirstFunction(@Param("id") String productId);
14 } 18 }
shop/src/main/java/com/canrd/shop/module/dto/FunctionDO.java 0 → 100644
  1 +package com.canrd.shop.module.dto;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.TableField;
  4 +import com.baomidou.mybatisplus.annotation.TableName;
  5 +import lombok.*;
  6 +import lombok.experimental.SuperBuilder;
  7 +
  8 +@TableName("productfunctionrelation")
  9 +@Data
  10 +@AllArgsConstructor
  11 +@ToString
  12 +@NoArgsConstructor
  13 +@EqualsAndHashCode(callSuper = false)
  14 +@SuperBuilder
  15 +public class FunctionDO {
  16 + @TableField(value = "productId")
  17 + private String productId;
  18 + @TableField(value = "functionId")
  19 + private String functionId;
  20 +}
  21 +
shop/src/main/java/com/canrd/shop/module/dto/ProductFunctionDO.java
@@ -24,6 +24,4 @@ public class ProductFunctionDO { @@ -24,6 +24,4 @@ public class ProductFunctionDO {
24 private String id; 24 private String id;
25 25
26 private String name; 26 private String name;
27 -  
28 -  
29 } 27 }
shop/src/main/java/com/canrd/shop/module/vo/ProductCrumbsVO.java 0 → 100644
  1 +package com.canrd.shop.module.vo;
  2 +
  3 +import lombok.*;
  4 +import lombok.experimental.SuperBuilder;
  5 +
  6 +@Data
  7 +@AllArgsConstructor
  8 +@ToString
  9 +@NoArgsConstructor
  10 +@EqualsAndHashCode(callSuper = false)
  11 +@SuperBuilder
  12 +public class ProductCrumbsVO {
  13 + String category1;
  14 + String category2;
  15 + String function;
  16 +}
shop/src/main/java/com/canrd/shop/module/vo/ProductVO.java
@@ -52,6 +52,8 @@ public class ProductVO implements Serializable { @@ -52,6 +52,8 @@ public class ProductVO implements Serializable {
52 52
53 private String metakeywords; 53 private String metakeywords;
54 54
  55 + private ProductCrumbsVO productCrumbsVO;
  56 +
55 private String name; 57 private String name;
56 58
57 private String englishname; 59 private String englishname;
shop/src/main/java/com/canrd/shop/service/ProductFunctionService.java
1 package com.canrd.shop.service; 1 package com.canrd.shop.service;
2 2
3 import com.baomidou.mybatisplus.extension.service.IService; 3 import com.baomidou.mybatisplus.extension.service.IService;
4 -import com.canrd.shop.module.dto.ProductCategoryDO;  
5 import com.canrd.shop.module.dto.ProductFunctionDO; 4 import com.canrd.shop.module.dto.ProductFunctionDO;
  5 +import org.apache.ibatis.annotations.Param;
  6 +
  7 +import java.util.List;
6 8
7 /** 9 /**
8 * @author hongtao.zhao 10 * @author hongtao.zhao
9 * @since 2023-06-10 11 * @since 2023-06-10
10 */ 12 */
11 public interface ProductFunctionService extends IService<ProductFunctionDO> { 13 public interface ProductFunctionService extends IService<ProductFunctionDO> {
  14 + List<ProductFunctionDO> getFirstFunction(String id);
12 } 15 }
shop/src/main/java/com/canrd/shop/service/impl/ProductFunctionServiceImpl.java
1 package com.canrd.shop.service.impl; 1 package com.canrd.shop.service.impl;
2 2
3 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 3 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 -import com.canrd.shop.mapper.ProductCategoryMapper;  
5 import com.canrd.shop.mapper.ProductFunctionMapper; 4 import com.canrd.shop.mapper.ProductFunctionMapper;
6 -import com.canrd.shop.module.dto.ProductCategoryDO;  
7 import com.canrd.shop.module.dto.ProductFunctionDO; 5 import com.canrd.shop.module.dto.ProductFunctionDO;
8 -import com.canrd.shop.service.ProductCategoryService;  
9 import com.canrd.shop.service.ProductFunctionService; 6 import com.canrd.shop.service.ProductFunctionService;
  7 +import org.apache.ibatis.annotations.Param;
10 import org.springframework.stereotype.Service; 8 import org.springframework.stereotype.Service;
11 9
  10 +import java.util.List;
  11 +
12 /** 12 /**
13 * @author hongtao.zhao 13 * @author hongtao.zhao
14 * @since 2023-06-10 14 * @since 2023-06-10
15 */ 15 */
16 @Service 16 @Service
17 public class ProductFunctionServiceImpl extends ServiceImpl<ProductFunctionMapper, ProductFunctionDO> implements ProductFunctionService { 17 public class ProductFunctionServiceImpl extends ServiceImpl<ProductFunctionMapper, ProductFunctionDO> implements ProductFunctionService {
  18 + @Override
  19 + public List<ProductFunctionDO> getFirstFunction(@Param("id")String productId) {
  20 + return this.baseMapper.getFirstFunction(productId);
  21 + }
18 } 22 }
shop/src/main/java/com/canrd/shop/service/impl/ProductServiceImpl.java
@@ -6,7 +6,6 @@ import com.alibaba.fastjson2.JSON; @@ -6,7 +6,6 @@ import com.alibaba.fastjson2.JSON;
6 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 6 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 7 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
8 import com.baomidou.mybatisplus.core.metadata.IPage; 8 import com.baomidou.mybatisplus.core.metadata.IPage;
9 -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;  
10 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 9 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
11 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 10 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12 import com.canrd.shop.common.constant.PriceConstants; 11 import com.canrd.shop.common.constant.PriceConstants;
@@ -18,15 +17,14 @@ import com.canrd.shop.common.utils.StringUtils; @@ -18,15 +17,14 @@ import com.canrd.shop.common.utils.StringUtils;
18 import com.canrd.shop.converter.ProductConverter; 17 import com.canrd.shop.converter.ProductConverter;
19 import com.canrd.shop.mapper.ProductMapper; 18 import com.canrd.shop.mapper.ProductMapper;
20 import com.canrd.shop.module.dto.*; 19 import com.canrd.shop.module.dto.*;
21 -import com.canrd.shop.module.vo.ProductAttributeVO;  
22 -import com.canrd.shop.module.vo.ProductQueryVO;  
23 -import com.canrd.shop.module.vo.ProductVO;  
24 -import com.canrd.shop.module.vo.TickeyTypeVO; 20 +import com.canrd.shop.module.vo.*;
25 import com.canrd.shop.service.*; 21 import com.canrd.shop.service.*;
26 import com.google.common.collect.Lists; 22 import com.google.common.collect.Lists;
27 import com.google.common.collect.Sets; 23 import com.google.common.collect.Sets;
28 import lombok.extern.slf4j.Slf4j; 24 import lombok.extern.slf4j.Slf4j;
  25 +import org.apache.commons.collections4.CollectionUtils;
29 import org.apache.commons.lang3.BooleanUtils; 26 import org.apache.commons.lang3.BooleanUtils;
  27 +import org.apache.ibatis.annotations.Param;
30 import org.springframework.beans.factory.annotation.Autowired; 28 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Service; 29 import org.springframework.stereotype.Service;
32 30
@@ -78,6 +76,12 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -78,6 +76,12 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
78 private IEbCategorysRelationService ebCategorysRelationService; 76 private IEbCategorysRelationService ebCategorysRelationService;
79 77
80 @Autowired 78 @Autowired
  79 + private ProductCategoryService categoryService;
  80 +
  81 + @Autowired
  82 + private ProductFunctionService functionService;
  83 +
  84 + @Autowired
81 private IJournalCategoryRelationService journalCategoryService; 85 private IJournalCategoryRelationService journalCategoryService;
82 @Autowired 86 @Autowired
83 private IJournalService journalService; 87 private IJournalService journalService;
@@ -139,6 +143,50 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -139,6 +143,50 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
139 .list(); 143 .list();
140 List<String> categoryIds = productcategoryrelations.stream().map(Productcategoryrelation::getCategoryId).collect(Collectors.toList()); 144 List<String> categoryIds = productcategoryrelations.stream().map(Productcategoryrelation::getCategoryId).collect(Collectors.toList());
141 145
  146 + if (CollectionUtils.isNotEmpty(categoryIds)) {
  147 + // 查询第一级分类
  148 + List<ProductCategoryDO> productCategories = categoryService.lambdaQuery()
  149 + .in(ProductCategoryDO::getId, categoryIds)
  150 + .eq(ProductCategoryDO::getParentId, "33ba6943c8bf4ca082614f299865341c")
  151 + .list();
  152 + ProductCategoryDO firstCategory = null;
  153 + if (productCategories.isEmpty()) {
  154 + firstCategory = findParentCategory(categoryIds, "33ba6943c8bf4ca082614f299865341c");
  155 + } else {
  156 + firstCategory = productCategories.get(0);
  157 + }
  158 +
  159 + if (firstCategory != null) {
  160 + // 查询第二级分类
  161 + List<ProductCategoryDO> productCategories2 = categoryService.lambdaQuery()
  162 + .in(ProductCategoryDO::getId, categoryIds)
  163 + .eq(ProductCategoryDO::getParentId, firstCategory.getId())
  164 + .list();
  165 + ProductCategoryDO secondCategory = productCategories2.stream()
  166 + .filter(category -> !"Not specified".equals(category.getName()))
  167 + .findFirst()
  168 + .orElse(productCategories2.isEmpty() ? null : productCategories2.get(0)); // 如果找不到,使用列表第一个元素或 null
  169 +
  170 + // 获取功能信息
  171 + List<ProductFunctionDO> functions = functionService.getFirstFunction(productVO.getId());
  172 + ProductFunctionDO selectedFunction = null;
  173 + if (CollectionUtils.isNotEmpty(functions)){
  174 + selectedFunction = functions.stream()
  175 + .filter(function -> !"Not specified".equals(function.getName()))
  176 + .findFirst()
  177 + .orElse(functions.get(0)); // 如果找不到,使用列表第一个元素
  178 + }
  179 +
  180 + // 构建面包屑信息
  181 + ProductCrumbsVO productCrumbsVO = ProductCrumbsVO.builder()
  182 + .category1(firstCategory.getName())
  183 + .category2(secondCategory != null ? secondCategory.getName() : null)
  184 + .function(selectedFunction != null ? selectedFunction.getName() : null)
  185 + .build();
  186 + productVO.setProductCrumbsVO(productCrumbsVO);
  187 + }
  188 + }
  189 +
142 List<EbCategorysRelation> cateRelations = ebCategorysRelationService.lambdaQuery() 190 List<EbCategorysRelation> cateRelations = ebCategorysRelationService.lambdaQuery()
143 .in(EbCategorysRelation::getCategoryId, categoryIds) 191 .in(EbCategorysRelation::getCategoryId, categoryIds)
144 .list(); 192 .list();
@@ -148,20 +196,22 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -148,20 +196,22 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
148 TreeMap<String, Integer> cateId2Relevance = new TreeMap<>(relatedCateId2Relevance); 196 TreeMap<String, Integer> cateId2Relevance = new TreeMap<>(relatedCateId2Relevance);
149 StringJoiner orderByJoiner = new StringJoiner(" when "," order by case pc.id when "," else 0 end "); 197 StringJoiner orderByJoiner = new StringJoiner(" when "," order by case pc.id when "," else 0 end ");
150 cateId2Relevance.forEach((k,v)->orderByJoiner.add("'"+k+"'"+" then "+v)); 198 cateId2Relevance.forEach((k,v)->orderByJoiner.add("'"+k+"'"+" then "+v));
151 - QueryWrapper<ProductDO> objectQueryWrapper = new QueryWrapper<ProductDO>()  
152 - .eq("ismarketable",true)  
153 - .in("pc.id", cateId2Relevance.keySet())  
154 - .select("distinct p.id","pc.id")  
155 - .last(orderByJoiner.toString());  
156 -  
157 - List<ProductDO> relatedProducts = this  
158 - .list(objectQueryWrapper);  
159 - List<String> relatedProductIds = relatedProducts.stream()  
160 - .map(ProductDO::getId)  
161 - .distinct()  
162 - .limit(10)  
163 - .collect(Collectors.toList());  
164 - productVO.setRelatedProductIds(relatedProductIds); 199 + if(CollUtil.isNotEmpty(cateId2Relevance)) {
  200 + QueryWrapper<ProductDO> objectQueryWrapper = new QueryWrapper<ProductDO>()
  201 + .eq("ismarketable",true)
  202 + .in("pc.id", cateId2Relevance.keySet())
  203 + .select("distinct p.id","pc.id")
  204 + .last(orderByJoiner.toString());
  205 +
  206 + List<ProductDO> relatedProducts = this
  207 + .list(objectQueryWrapper);
  208 + List<String> relatedProductIds = relatedProducts.stream()
  209 + .map(ProductDO::getId)
  210 + .distinct()
  211 + .limit(10)
  212 + .collect(Collectors.toList());
  213 + productVO.setRelatedProductIds(relatedProductIds);
  214 + }
165 215
166 List<JournalCategoryRelation> journalCategoryRelations = journalCategoryService.lambdaQuery() 216 List<JournalCategoryRelation> journalCategoryRelations = journalCategoryService.lambdaQuery()
167 .in(JournalCategoryRelation::getCategoryId, categoryIds) 217 .in(JournalCategoryRelation::getCategoryId, categoryIds)
@@ -171,12 +221,43 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -171,12 +221,43 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
171 .in(Journal::getId, journalIds) 221 .in(Journal::getId, journalIds)
172 .page(new Page<>(1,10)).getRecords(); 222 .page(new Page<>(1,10)).getRecords();
173 productVO.setJournals(journals); 223 productVO.setJournals(journals);
  224 +
174 productVO.setPriceShow(productPriceShow); 225 productVO.setPriceShow(productPriceShow);
175 226
176 227
177 return ServerResult.success(productVO); 228 return ServerResult.success(productVO);
178 } 229 }
179 230
  231 + //查找一级分类
  232 + private ProductCategoryDO findParentCategory(List<String> categoryIds, String targetParentId) {
  233 + for (String categoryId : categoryIds) {
  234 + // 查询当前 categoryId 的数据
  235 + ProductCategoryDO currentCategory = categoryService.lambdaQuery()
  236 + .eq(ProductCategoryDO::getId, categoryId)
  237 + .one();
  238 + if (currentCategory != null) {
  239 + // 如果当前分类的 parentId 等于目标 parentId,返回当前分类
  240 + if (targetParentId.equals(currentCategory.getParentId())) {
  241 + return currentCategory;
  242 + }
  243 + // 否则递归查找 parentId 的分类
  244 + ProductCategoryDO parentCategory = categoryService.lambdaQuery()
  245 + .eq(ProductCategoryDO::getId, currentCategory.getParentId())
  246 + .one();
  247 + if (parentCategory != null) {
  248 + ProductCategoryDO foundCategory = findParentCategory(
  249 + Collections.singletonList(parentCategory.getId()),
  250 + targetParentId
  251 + );
  252 + if (foundCategory != null) {
  253 + return foundCategory;
  254 + }
  255 + }
  256 + }
  257 + }
  258 + return null; // 如果未找到符合条件的分类,返回 null
  259 + }
  260 +
180 /** 261 /**
181 * 分页查询 262 * 分页查询
182 * 263 *
@@ -235,7 +316,7 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -235,7 +316,7 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
235 } 316 }
236 } 317 }
237 318
238 - List<Productcategoryrelation> productcategoryrelations = productCategoryRelationService.lambdaQuery() 319 + /*List<Productcategoryrelation> productcategoryrelations = productCategoryRelationService.lambdaQuery()
239 .in(Productcategoryrelation::getProductId, productIds) 320 .in(Productcategoryrelation::getProductId, productIds)
240 .list(); 321 .list();
241 List<String> categoryIds = productcategoryrelations.stream().map(Productcategoryrelation::getCategoryId).collect(Collectors.toList()); 322 List<String> categoryIds = productcategoryrelations.stream().map(Productcategoryrelation::getCategoryId).collect(Collectors.toList());
@@ -251,7 +332,7 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -251,7 +332,7 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
251 Map<String,List<EbCategorysRelation>> prodId2relCateIds = productId2cateIds.entrySet().stream() 332 Map<String,List<EbCategorysRelation>> prodId2relCateIds = productId2cateIds.entrySet().stream()
252 .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream() 333 .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream()
253 .flatMap(cateId -> Optional.ofNullable(cateId2relCates.get(cateId)).orElse(Collections.emptyList()).stream()) 334 .flatMap(cateId -> Optional.ofNullable(cateId2relCates.get(cateId)).orElse(Collections.emptyList()).stream())
254 - .collect(Collectors.toList()))); 335 + .collect(Collectors.toList())));*/
255 records.forEach(product -> { 336 records.forEach(product -> {
256 if (productPriceShow){ 337 if (productPriceShow){
257 if (Objects.nonNull(pId2ttMinPriceMap.get(product.getId()))){ 338 if (Objects.nonNull(pId2ttMinPriceMap.get(product.getId()))){
@@ -264,8 +345,8 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -264,8 +345,8 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
264 product.setImageFileKey(map.get("fileKey").toString()); 345 product.setImageFileKey(map.get("fileKey").toString());
265 346
266 347
267 - List<EbCategorysRelation> ebCategorysRelations = prodId2relCateIds.get(product.getId());  
268 - if (CollUtil.isNotEmpty(ebCategorysRelations)){ 348 + /*List<EbCategorysRelation> ebCategorysRelations = prodId2relCateIds.get(product.getId());*/
  349 + /*if (CollUtil.isNotEmpty(ebCategorysRelations)){
269 Map<String,Integer> relatedCateId2Relevance = ebCategorysRelations.stream() 350 Map<String,Integer> relatedCateId2Relevance = ebCategorysRelations.stream()
270 .collect(Collectors.toMap(EbCategorysRelation::getRelatedCategoryId, EbCategorysRelation::getRelevance,(a, b) -> a)); 351 .collect(Collectors.toMap(EbCategorysRelation::getRelatedCategoryId, EbCategorysRelation::getRelevance,(a, b) -> a));
271 TreeMap<String, Integer> cateId2Relevance = new TreeMap<>(relatedCateId2Relevance); 352 TreeMap<String, Integer> cateId2Relevance = new TreeMap<>(relatedCateId2Relevance);
@@ -283,7 +364,7 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im @@ -283,7 +364,7 @@ public class ProductServiceImpl extends ServiceImpl&lt;ProductMapper, ProductDO&gt; im
283 .limit(10) 364 .limit(10)
284 .collect(Collectors.toList()); 365 .collect(Collectors.toList());
285 product.setRelatedProductIds(relatedProductIds); 366 product.setRelatedProductIds(relatedProductIds);
286 - } 367 + }*/
287 }); 368 });
288 } 369 }
289 370
shop/src/main/resources/application-local.yml
@@ -59,11 +59,11 @@ spring: @@ -59,11 +59,11 @@ spring:
59 testOnReturn: true 59 testOnReturn: true
60 password: 123456 60 password: 123456
61 time-between-eviction-runs-millis: 1000 61 time-between-eviction-runs-millis: 1000
62 - url: jdbc:mysql://127.0.0.1:3306/canrd_overseas?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true&useAffectedRows=true&autoReconnectForPools=true 62 + url: jdbc:mysql://192.168.31.242:13306/canrd_overseas?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&useSSL=false&autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true&useAffectedRows=true&autoReconnectForPools=true
63 username: root 63 username: root
64 64
65 65
66 -logging:  
67 - config: classpath:log4j2-dev.xml 66 +#logging:
  67 +# config: classpath:log4jj2-dev.xml
68 openai: 68 openai:
69 token: Bearer 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 69 token: Bearer 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
70 \ No newline at end of file 70 \ No newline at end of file
shop/src/main/resources/application.yml
@@ -3,7 +3,7 @@ server: @@ -3,7 +3,7 @@ server:
3 3
4 spring: 4 spring:
5 profiles: 5 profiles:
6 - active: test 6 + active: prod
7 mvc: 7 mvc:
8 throw-exception-if-no-handler-found: true 8 throw-exception-if-no-handler-found: true
9 resources: 9 resources:
shop/src/main/resources/mapper/ProductFunctionMapper.xml 0 → 100644
  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.canrd.shop.mapper.ProductFunctionMapper">
  4 +
  5 +<!-- <select id="getFirstFunction" resultType="com.canrd.shop.module.dto.ProductFunctionDO"-->
  6 +<!-- parameterType="java.lang.String">-->
  7 + <select id="getFirstFunction" resultType="com.canrd.shop.module.dto.ProductFunctionDO"
  8 + parameterType="java.lang.String">
  9 + SELECT pf.*
  10 + FROM productfunction pf
  11 + WHERE pf.id IN (
  12 + SELECT pfr.functionId
  13 + FROM productfunctionrelation pfr
  14 + WHERE pfr.productId = #{id}
  15 + );
  16 + </select>
  17 +</mapper>
0 \ No newline at end of file 18 \ No newline at end of file
shop/src/main/resources/mapper/ProductMapper.xml
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 </resultMap> 7 </resultMap>
8 8
9 <select id="queryAll" resultMap="BaseResultMap"> 9 <select id="queryAll" resultMap="BaseResultMap">
10 - select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath,pc.id as pcid 10 + select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath
11 from product p 11 from product p
12 left join productcategoryrelation pcr on p.id=pcr.productId 12 left join productcategoryrelation pcr on p.id=pcr.productId
13 left join productcategory pc on pc.id=pcr.categoryId 13 left join productcategory pc on pc.id=pcr.categoryId
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 </select> 17 </select>
18 18
19 <select id="queryList" resultMap="BaseResultMap"> 19 <select id="queryList" resultMap="BaseResultMap">
20 - select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath,p.productCategory_id,pc.id as pcid 20 + select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath,p.productCategory_id
21 from product p 21 from product p
22 left join productcategoryrelation pcr on p.id=pcr.productId 22 left join productcategoryrelation pcr on p.id=pcr.productId
23 left join productcategory pc on pc.id=pcr.categoryId 23 left join productcategory pc on pc.id=pcr.categoryId