Commit 45137b4494c153e1d5a68cce912bd88b48fb659b
Merge remote-tracking branch 'origin/master'
Showing
16 changed files
with
291 additions
and
50 deletions
shop/src/main/java/com/canrd/shop/common/excel/listenter/ImportRelatedCategoryListenter.java
1 | 1 | package com.canrd.shop.common.excel.listenter; |
2 | 2 | |
3 | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | +import cn.hutool.core.collection.CollUtil; | |
4 | 5 | import com.alibaba.excel.context.AnalysisContext; |
5 | 6 | import com.alibaba.excel.event.AnalysisEventListener; |
6 | 7 | import com.canrd.shop.module.dto.EbCategorysRelation; |
... | ... | @@ -10,6 +11,7 @@ import com.canrd.shop.service.IEbCategorysRelationService; |
10 | 11 | import com.canrd.shop.service.ProductCategoryService; |
11 | 12 | |
12 | 13 | |
14 | +import java.util.List; | |
13 | 15 | import java.util.Optional; |
14 | 16 | |
15 | 17 | /** |
... | ... | @@ -30,20 +32,20 @@ public class ImportRelatedCategoryListenter extends AnalysisEventListener<Import |
30 | 32 | |
31 | 33 | @Override |
32 | 34 | public void invoke(ImportRelatedCategoryVo importRelatedCategoryVo, AnalysisContext analysisContext) { |
33 | - Optional<ProductCategoryDO> categoryOptional = categoryService.lambdaQuery() | |
35 | + List<ProductCategoryDO> ProductCategoryDOs = categoryService.lambdaQuery() | |
34 | 36 | .eq(ProductCategoryDO::getName, importRelatedCategoryVo.getCategoryName()) |
35 | 37 | .select(ProductCategoryDO::getId) |
36 | - .oneOpt(); | |
37 | - Optional<ProductCategoryDO> relatedCategoryOptional = categoryService.lambdaQuery() | |
38 | + .list(); | |
39 | + List<ProductCategoryDO> relatedProductCategoryDOs = categoryService.lambdaQuery() | |
38 | 40 | .eq(ProductCategoryDO::getName, importRelatedCategoryVo.getRelatedCategoryName()) |
39 | 41 | .select(ProductCategoryDO::getId) |
40 | - .oneOpt(); | |
41 | - if (!categoryOptional.isPresent()||!relatedCategoryOptional.isPresent()){ | |
42 | + .list(); | |
43 | + if (CollUtil.isEmpty(ProductCategoryDOs) ||CollUtil.isEmpty(relatedProductCategoryDOs)){ | |
42 | 44 | return; |
43 | 45 | } |
44 | 46 | EbCategorysRelation bean = BeanUtil.toBean(importRelatedCategoryVo, EbCategorysRelation.class); |
45 | - bean.setCategoryId(categoryOptional.get().getId()); | |
46 | - bean.setRelatedCategoryId(relatedCategoryOptional.get().getId()); | |
47 | + bean.setCategoryId(ProductCategoryDOs.get(0).getId()); | |
48 | + bean.setRelatedCategoryId(relatedProductCategoryDOs.get(0).getId()); | |
47 | 49 | ebCategorysRelationService.save(bean); |
48 | 50 | } |
49 | 51 | ... | ... |
shop/src/main/java/com/canrd/shop/mapper/ProductMapper.java
... | ... | @@ -10,7 +10,6 @@ import com.canrd.shop.module.dto.ProductDO; |
10 | 10 | import com.canrd.shop.module.vo.ProductQueryVO; |
11 | 11 | import org.apache.ibatis.annotations.Mapper; |
12 | 12 | import org.apache.ibatis.annotations.Param; |
13 | -import org.apache.ibatis.annotations.Select; | |
14 | 13 | |
15 | 14 | import java.util.List; |
16 | 15 | |
... | ... | @@ -24,8 +23,8 @@ import java.util.List; |
24 | 23 | public interface ProductMapper extends BaseMapper<ProductDO> { |
25 | 24 | |
26 | 25 | |
27 | - IPage<ProductDO> selectAll(Page<ProductQueryVO> productQueryVOPage, @Param(Constants.WRAPPER) Wrapper<ProductQueryVO> wrapper); | |
26 | + IPage<ProductDO> queryAll(Page<ProductQueryVO> productQueryVOPage, @Param(Constants.WRAPPER) Wrapper<ProductQueryVO> wrapper); | |
28 | 27 | |
29 | - List<ProductDO> selectList(@Param(Constants.WRAPPER) QueryWrapper<ProductQueryVO> queryWrapper); | |
28 | + List<ProductDO> queryList(@Param(Constants.WRAPPER) QueryWrapper<ProductQueryVO> queryWrapper); | |
30 | 29 | } |
31 | 30 | ... | ... |
shop/src/main/java/com/canrd/shop/mapper/ProductcategoryrelationMapper.java
0 → 100644
1 | +package com.canrd.shop.mapper; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
4 | +import com.canrd.shop.module.dto.Productcategoryrelation; | |
5 | + | |
6 | +/** | |
7 | + * <p> | |
8 | + * Mapper 接口 | |
9 | + * </p> | |
10 | + * | |
11 | + * @author author | |
12 | + * @since 2024-11-14 | |
13 | + */ | |
14 | +public interface ProductcategoryrelationMapper extends BaseMapper<Productcategoryrelation> { | |
15 | + | |
16 | +} | ... | ... |
shop/src/main/java/com/canrd/shop/module/dto/ProductDO.java
... | ... | @@ -8,6 +8,7 @@ import lombok.experimental.SuperBuilder; |
8 | 8 | import java.io.Serializable; |
9 | 9 | import java.math.BigDecimal; |
10 | 10 | import java.util.Date; |
11 | +import java.util.List; | |
11 | 12 | |
12 | 13 | /** |
13 | 14 | * (Product)实体类 |
... | ... | @@ -137,5 +138,7 @@ public class ProductDO implements Serializable { |
137 | 138 | private Integer similar; |
138 | 139 | @TableField(exist = false) |
139 | 140 | private Integer ttsTotalSimilar=0; |
141 | + @TableField(exist = false) | |
142 | + private List<String> relatedProductIds; | |
140 | 143 | |
141 | 144 | } | ... | ... |
shop/src/main/java/com/canrd/shop/module/dto/Productcategoryrelation.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 com.baomidou.mybatisplus.annotation.IdType; | |
6 | +import java.time.LocalDateTime; | |
7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
8 | +import java.io.Serializable; | |
9 | +import lombok.Data; | |
10 | +import lombok.EqualsAndHashCode; | |
11 | +import lombok.experimental.Accessors; | |
12 | + | |
13 | +/** | |
14 | + * <p> | |
15 | + * | |
16 | + * </p> | |
17 | + * | |
18 | + * @author author | |
19 | + * @since 2024-11-14 | |
20 | + */ | |
21 | +@Data | |
22 | +@EqualsAndHashCode(callSuper = false) | |
23 | +@Accessors(chain = true) | |
24 | +@TableName("productcategoryrelation") | |
25 | +public class Productcategoryrelation implements Serializable { | |
26 | + | |
27 | + private static final long serialVersionUID = 1L; | |
28 | + | |
29 | + @TableField(value = "productId") | |
30 | + private String productId; | |
31 | + @TableField(value = "categoryId") | |
32 | + private String categoryId; | |
33 | + @TableField(value = "modifyDate") | |
34 | + private LocalDateTime modifyDate; | |
35 | + | |
36 | + | |
37 | +} | ... | ... |
shop/src/main/java/com/canrd/shop/service/IProductcategoryrelationService.java
0 → 100644
1 | +package com.canrd.shop.service; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.extension.service.IService; | |
4 | +import com.canrd.shop.module.dto.Productcategoryrelation; | |
5 | + | |
6 | +/** | |
7 | + * <p> | |
8 | + * 服务类 | |
9 | + * </p> | |
10 | + * | |
11 | + * @author author | |
12 | + * @since 2024-11-14 | |
13 | + */ | |
14 | +public interface IProductcategoryrelationService extends IService<Productcategoryrelation> { | |
15 | + | |
16 | +} | ... | ... |
shop/src/main/java/com/canrd/shop/service/impl/ProductServiceImpl.java
... | ... | @@ -17,11 +17,7 @@ import com.canrd.shop.common.utils.PageUtils; |
17 | 17 | import com.canrd.shop.common.utils.StringUtils; |
18 | 18 | import com.canrd.shop.converter.ProductConverter; |
19 | 19 | import com.canrd.shop.mapper.ProductMapper; |
20 | -import com.canrd.shop.module.dto.BrandDO; | |
21 | -import com.canrd.shop.module.dto.ProductAttributeDO; | |
22 | -import com.canrd.shop.module.dto.ProductAttributeMapStoreDO; | |
23 | -import com.canrd.shop.module.dto.ProductDO; | |
24 | -import com.canrd.shop.module.dto.TicketTypeDO; | |
20 | +import com.canrd.shop.module.dto.*; | |
25 | 21 | import com.canrd.shop.module.vo.ProductAttributeVO; |
26 | 22 | import com.canrd.shop.module.vo.ProductQueryVO; |
27 | 23 | import com.canrd.shop.module.vo.ProductVO; |
... | ... | @@ -63,6 +59,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im |
63 | 59 | |
64 | 60 | @Autowired |
65 | 61 | private ProductAttributeService productAttributeService; |
62 | + @Autowired | |
63 | + private IProductcategoryrelationService productCategoryRelationService; | |
66 | 64 | |
67 | 65 | @Autowired |
68 | 66 | private ProductAttributeMapStoreService productAttributeMapStoreService; |
... | ... | @@ -76,6 +74,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im |
76 | 74 | @Autowired |
77 | 75 | private ISwitchControlService switchControlService; |
78 | 76 | |
77 | + @Autowired | |
78 | + private IEbCategorysRelationService ebCategorysRelationService; | |
79 | + | |
79 | 80 | /** |
80 | 81 | * 通过ID查询单条数据 |
81 | 82 | * <p> |
... | ... | @@ -152,14 +153,16 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im |
152 | 153 | queryWapper.eq("pf.id",productQueryVO.getProductFunctionId()); |
153 | 154 | } |
154 | 155 | if(StringUtils.isNotBlank(productQueryVO.getKeyword())){ |
155 | - List<TicketTypeDO> tickeyTypeDOList = ticketTypeService.lambdaQuery().like(TicketTypeDO::getRank, productQueryVO.getKeyword()).list(); | |
156 | + List<TicketTypeDO> tickeyTypeDOList = ticketTypeService.lambdaQuery() | |
157 | + .like(TicketTypeDO::getRank, productQueryVO.getKeyword()) | |
158 | + .list(); | |
156 | 159 | Set<String> productIds = tickeyTypeDOList.stream().map(TicketTypeDO::getProductId).collect(Collectors.toSet()); |
157 | 160 | queryWapper.and(subQueryWapper -> { |
158 | 161 | subQueryWapper.like("p.name", productQueryVO.getKeyword()).or().in("p.id", productIds); |
159 | 162 | }); |
160 | 163 | } |
161 | 164 | Page page = new Page<>(productQueryVO.getPageNo(), productQueryVO.getPageSize()); |
162 | - IPage<ProductDO> iPage = productMapper.selectAll(page,queryWapper); | |
165 | + IPage<ProductDO> iPage = productMapper.queryAll(page,queryWapper); | |
163 | 166 | suppleProducts(iPage.getRecords()); |
164 | 167 | productQueryVO.setTotal(Long.valueOf(iPage.getTotal()).intValue()); |
165 | 168 | return ServerResult.success().setData(PageUtils.getPageReturn(iPage.getRecords(), productQueryVO)); |
... | ... | @@ -187,6 +190,24 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im |
187 | 190 | } |
188 | 191 | } |
189 | 192 | } |
193 | + | |
194 | + List<Productcategoryrelation> productcategoryrelations = productCategoryRelationService.lambdaQuery() | |
195 | + .in(Productcategoryrelation::getProductId, productIds) | |
196 | + .list(); | |
197 | + List<String> categoryIds = productcategoryrelations.stream().map(Productcategoryrelation::getCategoryId).collect(Collectors.toList()); | |
198 | + Map<String,List<String>> productId2cateIds = productcategoryrelations.stream() | |
199 | + .collect(Collectors.groupingBy(Productcategoryrelation::getProductId, | |
200 | + Collectors.mapping(Productcategoryrelation::getCategoryId, Collectors.toList()))); | |
201 | + List<EbCategorysRelation> cateRelations = ebCategorysRelationService.lambdaQuery() | |
202 | + .in(EbCategorysRelation::getCategoryId, categoryIds) | |
203 | + .list(); | |
204 | + Map<String,List<EbCategorysRelation>> cateId2relCates = cateRelations.stream() | |
205 | + .collect(Collectors.groupingBy(EbCategorysRelation::getCategoryId, | |
206 | + Collectors.mapping(Function.identity(), Collectors.toList()))); | |
207 | + Map<String,List<EbCategorysRelation>> prodId2relCateIds = productId2cateIds.entrySet().stream() | |
208 | + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream() | |
209 | + .flatMap(cateId -> Optional.ofNullable(cateId2relCates.get(cateId)).orElse(Collections.emptyList()).stream()) | |
210 | + .collect(Collectors.toList()))); | |
190 | 211 | records.forEach(product -> { |
191 | 212 | if (productPriceShow){ |
192 | 213 | if (Objects.nonNull(pId2ttMinPriceMap.get(product.getId()))){ |
... | ... | @@ -197,6 +218,26 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im |
197 | 218 | List<Map> maps = JSON.parseArray(product.getProductimageliststore(), Map.class); |
198 | 219 | Map map = maps.get(0); |
199 | 220 | product.setImageFileKey(map.get("fileKey").toString()); |
221 | + | |
222 | + | |
223 | + List<EbCategorysRelation> ebCategorysRelations = prodId2relCateIds.get(product.getId()); | |
224 | + if (CollUtil.isNotEmpty(ebCategorysRelations)){ | |
225 | + Map<String,Integer> relatedCateId2Relevance = ebCategorysRelations.stream() | |
226 | + .collect(Collectors.toMap(EbCategorysRelation::getRelatedCategoryId, EbCategorysRelation::getRelevance,(a, b) -> a)); | |
227 | + TreeMap<String, Integer> cateId2Relevance = new TreeMap<>(relatedCateId2Relevance); | |
228 | + StringJoiner orderByJoiner = new StringJoiner(" when "," order by case pcid when "," else 0 end limit 10 "); | |
229 | + cateId2Relevance.forEach((k,v)->orderByJoiner.add("'"+k+"'"+" then "+v)); | |
230 | + QueryWrapper<ProductDO> objectQueryWrapper = new QueryWrapper<ProductDO>() | |
231 | + .in("pc.id", cateId2Relevance.keySet()) | |
232 | + .select("id") | |
233 | + .last(orderByJoiner.toString()); | |
234 | + List<ProductDO> relatedProducts = this | |
235 | + .list(objectQueryWrapper); | |
236 | + List<String> relatedProductIds = relatedProducts.stream() | |
237 | + .map(ProductDO::getId) | |
238 | + .collect(Collectors.toList()); | |
239 | + product.setRelatedProductIds(relatedProductIds); | |
240 | + } | |
200 | 241 | }); |
201 | 242 | } |
202 | 243 | |
... | ... | @@ -232,7 +273,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im |
232 | 273 | subQueryWapper.like("p.name", productQueryVO.getKeyword()).or().in(CollUtil.isNotEmpty(finalProductIds),"p.id", finalProductIds); |
233 | 274 | }); |
234 | 275 | } |
235 | - List<ProductDO> productDOS = this.baseMapper.selectList(queryWapper); | |
276 | + List<ProductDO> productDOS = this.baseMapper.queryList(queryWapper); | |
236 | 277 | List<ProductDO> accurateProducts = Lists.newArrayList(); |
237 | 278 | Set<String> accurateProductIdSet = Sets.newHashSet(); |
238 | 279 | //区分大小写 |
... | ... | @@ -390,7 +431,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im |
390 | 431 | queryWapper.like("p.name", productQueryVO.getKeyword()); |
391 | 432 | } |
392 | 433 | Page page = new Page<>(productQueryVO.getPageNo(), productQueryVO.getPageSize()); |
393 | - IPage<ProductDO> iPage = productMapper.selectAll(page,queryWapper); | |
434 | + IPage<ProductDO> iPage = productMapper.queryAll(page,queryWapper); | |
394 | 435 | productQueryVO.setTotal(Long.valueOf(iPage.getTotal()).intValue()); |
395 | 436 | return ServerResult.success().setData(PageUtils.getPageReturn(iPage.getRecords(), productQueryVO)); |
396 | 437 | } | ... | ... |
shop/src/main/java/com/canrd/shop/service/impl/ProductcategoryrelationServiceImpl.java
0 → 100644
1 | +package com.canrd.shop.service.impl; | |
2 | + | |
3 | + | |
4 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
5 | +import com.canrd.shop.mapper.ProductcategoryrelationMapper; | |
6 | +import com.canrd.shop.module.dto.Productcategoryrelation; | |
7 | +import com.canrd.shop.service.IProductcategoryrelationService; | |
8 | +import org.springframework.stereotype.Service; | |
9 | + | |
10 | +/** | |
11 | + * <p> | |
12 | + * 服务实现类 | |
13 | + * </p> | |
14 | + * | |
15 | + * @author author | |
16 | + * @since 2024-11-14 | |
17 | + */ | |
18 | +@Service | |
19 | +public class ProductcategoryrelationServiceImpl extends ServiceImpl<ProductcategoryrelationMapper, Productcategoryrelation> implements IProductcategoryrelationService { | |
20 | + | |
21 | +} | ... | ... |
shop/src/main/resources/application-test.yml
1 | 1 | mybatis-plus: |
2 | 2 | configuration: |
3 | + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |
3 | 4 | cache-enabled: false |
4 | 5 | call-setters-on-nulls: true |
5 | 6 | jdbc-type-for-null: 'null' |
6 | 7 | map-underscore-to-camel-case: true |
7 | - log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl | |
8 | 8 | global-config: |
9 | 9 | db-config: |
10 | 10 | capital-mode: false | ... | ... |
shop/src/main/resources/log4j2-dev.xml
... | ... | @@ -3,13 +3,12 @@ |
3 | 3 | <!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出 --> |
4 | 4 | <!--monitorInterval:Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数 --> |
5 | 5 | <configuration status="debug" monitorInterval="30"> |
6 | - <!--<contextName>log4j2</contextName>--> | |
7 | 6 | <properties> |
8 | 7 | <!--${sys:catalina.home}表示linux中环境变量中的tomcat根目录 用户主目录--> |
9 | 8 | <!--原来用logback时候在统一配置中心也配置一个logging.path=/opt/tomcat-log/${spring.application.name} LOG_PATH是内置变量--> |
10 | 9 | <!--${sys:user.home} 用户主目录--> |
11 | - <!-- <Property name="log_path">${sys:user.home}/logs</Property>--> | |
12 | -<!-- <Property name="log_path" value="./logs/" />--> | |
10 | + <!-- <Property name="log_path">${sys:user.home}/logs</Property>--> | |
11 | + <!-- <Property name="log_path" value="./logs/" />--> | |
13 | 12 | <property name="console_log_pattern">%d|%t|%traceId|%-5level|%F:%L|%M|%m%n</property> |
14 | 13 | <!-- 保留日志天数 D H M S 分别对应天 小时 分钟 秒 --> |
15 | 14 | <property name="KEEP_LOG_DAY">60D</property> |
... | ... | @@ -20,34 +19,22 @@ |
20 | 19 | <appenders> |
21 | 20 | <console name="Console" target="SYSTEM_OUT"> |
22 | 21 | <!--输出日志的格式 --> |
23 | - <PatternLayout charset="UTF-8" pattern="${console_log_pattern}"/> | |
24 | - <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" /> | |
22 | + <PatternLayout charset="UTF-8" pattern="${console_log_pattern}"/> | |
23 | + <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY" /> | |
25 | 24 | </console> |
26 | - <!--这个输出控制台的配置 --> | |
27 | - <!--<console name="Console" target="SYSTEM_OUT" follow="false">--> | |
28 | - <!--<!–输出日志的格式 –>--> | |
29 | - <!--<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n" />--> | |
30 | - <!--</console>--> | |
31 | - | |
32 | 25 | <!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档 --> |
33 | 26 | <RollingFile name="RollingFileInfo" fileName="${sys:logging.path}/logs/overtime.log" filePattern="${sys:logging.path}/logs/$${date:yyyy-MM-dd}/info-%d{yyyy-MM-dd}-%i.log"> |
34 | 27 | <!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) --> |
35 | 28 | <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY" /> |
36 | - <!--<Filters>--> | |
37 | - <!--<ThresholdFilter level="INFO"/>--> | |
38 | - <!--<ThresholdFilter level="WARN" onMatch="DENY"--> | |
39 | - <!--onMismatch="NEUTRAL"/>--> | |
40 | - <!--</Filters>--> | |
41 | - <PatternLayout charset="UTF-8" pattern="${console_log_pattern}"/> | |
29 | + <PatternLayout charset="UTF-8" pattern="${console_log_pattern}"/> | |
42 | 30 | <Policies> |
43 | 31 | <!-- 归档每天的文件 --> |
44 | - <!--<TimeBasedTriggeringPolicy interval="1" modulate="true"/>--> | |
45 | 32 | <TimeBasedTriggeringPolicy /> |
46 | 33 | <!-- 限制单个文件大小 --> |
47 | 34 | <SizeBasedTriggeringPolicy size="${EVERY_FILE_SIZE}"/> |
48 | 35 | </Policies> |
49 | 36 | <!-- 限制每天文件个数 --> <!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件,这里设置了100 --> |
50 | - <DefaultRolloverStrategy max="256"> | |
37 | + <DefaultRolloverStrategy max="256"> | |
51 | 38 | <Delete basePath="${sys:logging.path}/logs/" maxDepth="3"> |
52 | 39 | <IfFileName glob="*/*info*.log"/> |
53 | 40 | <IfLastModified age="${KEEP_LOG_DAY}"/> |
... | ... | @@ -58,19 +45,15 @@ |
58 | 45 | <!--然后定义logger,只有定义了logger并引入的appender,appender才会生效 --> |
59 | 46 | <loggers> |
60 | 47 | <!--过滤掉spring和mybatis的一些无用的DEBUG信息 --> |
61 | - <logger name="org.springframework" level="debug" > | |
62 | - <ThresholdFilter level="debug"/> | |
48 | + <logger name="org.springframework" level="debug" additivity="false"> | |
63 | 49 | <appender-ref ref="RollingFileInfo" /> |
64 | 50 | </logger> |
65 | - <logger name="org.mybatis" level="DEBUG" > | |
66 | - <ThresholdFilter level="debug"/> | |
51 | + <logger name="org.mybatis" level="debug" additivity="false"> | |
67 | 52 | <appender-ref ref="RollingFileInfo" /> |
68 | 53 | </logger> |
69 | - <logger name="com.canrd.shop" level="DEBUG" > | |
70 | - <ThresholdFilter level="debug"/> | |
54 | + <logger name="com.canrd.shop" level="debug" additivity="false"> | |
71 | 55 | <appender-ref ref="RollingFileInfo" /> |
72 | 56 | </logger> |
73 | - <!--<root level="all">--> | |
74 | 57 | <root level="debug"> |
75 | 58 | <appender-ref ref="Console" /> |
76 | 59 | </root> | ... | ... |
shop/src/main/resources/mapper/ProductMapper.xml
... | ... | @@ -6,8 +6,8 @@ |
6 | 6 | <result column="name" property="name"/> |
7 | 7 | </resultMap> |
8 | 8 | |
9 | - <select id="selectAll" resultMap="BaseResultMap"> | |
10 | - select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath | |
9 | + <select id="queryAll" resultMap="BaseResultMap"> | |
10 | + select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath,pc.id as pcid | |
11 | 11 | from product p |
12 | 12 | left join productcategoryrelation pcr on p.id=pcr.productId |
13 | 13 | left join productcategory pc on pc.id=pcr.categoryId |
... | ... | @@ -16,8 +16,8 @@ |
16 | 16 | ${ew.customSqlSegment} |
17 | 17 | </select> |
18 | 18 | |
19 | - <select id="selectList" resultMap="BaseResultMap"> | |
20 | - select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath | |
19 | + <select id="queryList" resultMap="BaseResultMap"> | |
20 | + select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath,p.productCategory_id,pc.id as pcid | |
21 | 21 | from product p |
22 | 22 | left join productcategoryrelation pcr on p.id=pcr.productId |
23 | 23 | left join productcategory pc on pc.id=pcr.categoryId |
... | ... | @@ -26,4 +26,20 @@ |
26 | 26 | left join tickettype tt on p.id=tt.productId |
27 | 27 | ${ew.customSqlSegment} |
28 | 28 | </select> |
29 | + | |
30 | + <select id="selectAll" resultMap="BaseResultMap"> | |
31 | + select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath,pc.id as pcid | |
32 | + from product p | |
33 | + left join productcategoryrelation pcr on p.id=pcr.productId | |
34 | + left join productcategory pc on pc.id=pcr.categoryId | |
35 | + ${ew.customSqlSegment} | |
36 | + </select> | |
37 | + | |
38 | + <select id="selectList" resultMap="BaseResultMap"> | |
39 | + select distinct p.id,p.name,p.productImageListStore,p.htmlFilePath,p.productCategory_id,pc.id as pcid | |
40 | + from product p | |
41 | + left join productcategoryrelation pcr on p.id=pcr.productId | |
42 | + left join productcategory pc on pc.id=pcr.categoryId | |
43 | + ${ew.customSqlSegment} | |
44 | + </select> | |
29 | 45 | </mapper> |
30 | 46 | \ No newline at end of file | ... | ... |
src/main/java/com/order/erp/domain/model/Productcategoryrelation.java
0 → 100644
1 | +package com.order.erp.domain.model; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.annotation.TableName; | |
4 | +import com.baomidou.mybatisplus.annotation.IdType; | |
5 | +import java.time.LocalDateTime; | |
6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
7 | +import java.io.Serializable; | |
8 | +import io.swagger.annotations.ApiModel; | |
9 | +import io.swagger.annotations.ApiModelProperty; | |
10 | +import lombok.Data; | |
11 | +import lombok.EqualsAndHashCode; | |
12 | +import lombok.experimental.Accessors; | |
13 | + | |
14 | +/** | |
15 | + * <p> | |
16 | + * | |
17 | + * </p> | |
18 | + * | |
19 | + * @author author | |
20 | + * @since 2024-11-14 | |
21 | + */ | |
22 | +@Data | |
23 | +@EqualsAndHashCode(callSuper = false) | |
24 | +@Accessors(chain = true) | |
25 | +@TableName("productcategoryrelation") | |
26 | +@ApiModel(value="Productcategoryrelation对象", description="") | |
27 | +public class Productcategoryrelation implements Serializable { | |
28 | + | |
29 | + private static final long serialVersionUID = 1L; | |
30 | + | |
31 | + private String productId; | |
32 | + | |
33 | + private String categoryId; | |
34 | + | |
35 | + private LocalDateTime modifyDate; | |
36 | + | |
37 | + | |
38 | +} | ... | ... |
src/main/java/com/order/erp/mapper/ProductcategoryrelationMapper.java
0 → 100644
1 | +package com.order.erp.mapper; | |
2 | + | |
3 | +import com.order.erp.domain.model.Productcategoryrelation; | |
4 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
5 | + | |
6 | +/** | |
7 | + * <p> | |
8 | + * Mapper 接口 | |
9 | + * </p> | |
10 | + * | |
11 | + * @author author | |
12 | + * @since 2024-11-14 | |
13 | + */ | |
14 | +public interface ProductcategoryrelationMapper extends BaseMapper<Productcategoryrelation> { | |
15 | + | |
16 | +} | ... | ... |
src/main/java/com/order/erp/service/IProductcategoryrelationService.java
0 → 100644
1 | +package com.order.erp.service; | |
2 | + | |
3 | +import com.order.erp.domain.model.Productcategoryrelation; | |
4 | +import com.baomidou.mybatisplus.extension.service.IService; | |
5 | + | |
6 | +/** | |
7 | + * <p> | |
8 | + * 服务类 | |
9 | + * </p> | |
10 | + * | |
11 | + * @author author | |
12 | + * @since 2024-11-14 | |
13 | + */ | |
14 | +public interface IProductcategoryrelationService extends IService<Productcategoryrelation> { | |
15 | + | |
16 | +} | ... | ... |
src/main/java/com/order/erp/service/impl/ProductcategoryrelationServiceImpl.java
0 → 100644
1 | +package com.order.erp.service.impl; | |
2 | + | |
3 | +import com.order.erp.domain.model.Productcategoryrelation; | |
4 | +import com.order.erp.mapper.ProductcategoryrelationMapper; | |
5 | +import com.order.erp.service.IProductcategoryrelationService; | |
6 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
7 | +import org.springframework.stereotype.Service; | |
8 | + | |
9 | +/** | |
10 | + * <p> | |
11 | + * 服务实现类 | |
12 | + * </p> | |
13 | + * | |
14 | + * @author author | |
15 | + * @since 2024-11-14 | |
16 | + */ | |
17 | +@Service | |
18 | +public class ProductcategoryrelationServiceImpl extends ServiceImpl<ProductcategoryrelationMapper, Productcategoryrelation> implements IProductcategoryrelationService { | |
19 | + | |
20 | +} | ... | ... |
src/main/resources/mapper/ProductcategoryrelationMapper.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.order.erp.mapper.ProductcategoryrelationMapper"> | |
4 | + | |
5 | + <!-- 通用查询映射结果 --> | |
6 | + <resultMap id="BaseResultMap" type="com.order.erp.domain.model.Productcategoryrelation"> | |
7 | + <result column="productId" property="productId" /> | |
8 | + <result column="categoryId" property="categoryId" /> | |
9 | + <result column="modifyDate" property="modifyDate" /> | |
10 | + </resultMap> | |
11 | + | |
12 | + <!-- 通用查询结果列 --> | |
13 | + <sql id="Base_Column_List"> | |
14 | + productId, categoryId, modifyDate | |
15 | + </sql> | |
16 | + | |
17 | +</mapper> | ... | ... |