From b950c186fa1c5670f899f48f1fde483899db1622 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Tue, 26 Mar 2024 13:37:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BF=AE=E6=94=B9):=20=E5=AF=BC=E5=85=A5E?= =?UTF-8?q?xcel=E4=B8=8D=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: bunny <1319900154@qq.com> --- .../main/java/com/atguigu/config/WebMvcConfiguration.java | 2 +- .../com/atguigu/spzx/manger/excel/CategoryExcelListener.java | 3 ++- .../spzx/manger/service/impl/CategoryServiceImpl.java | 4 ++-- spzx-manager/src/main/resources/mapper/CategoryMapper.xml | 5 ++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java b/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java index 1177f64..bf9ea7e 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java @@ -38,7 +38,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport { protected void addInterceptors(InterceptorRegistry registry) { log.info("WebMvcConfiguration===>开始注册自定义拦截器..."); // 需要拦截的 - registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/admin") + registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/admin/**") .excludePathPatterns(interceptorsProperties.getNoAuthUrls()); } } \ No newline at end of file diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/excel/CategoryExcelListener.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/excel/CategoryExcelListener.java index 7eedc59..92c8ff6 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/excel/CategoryExcelListener.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/excel/CategoryExcelListener.java @@ -19,7 +19,8 @@ public class CategoryExcelListener extends AnalysisEventListener { private static final int BATCH_COUNT = 100; // 缓存的数据 private final List cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); - private CategoryMapper categoryMapper; + // 获取mapper对象 + private final CategoryMapper categoryMapper; @Override public void invoke(T t, AnalysisContext analysisContext) { diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryServiceImpl.java index 9d83e1e..8bf1a86 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryServiceImpl.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryServiceImpl.java @@ -2,7 +2,7 @@ package com.atguigu.spzx.manger.service.impl; import com.alibaba.excel.EasyExcel; import com.atguigu.exception.BunnyException; -import com.atguigu.spzx.manger.excel.ExcelListener; +import com.atguigu.spzx.manger.excel.CategoryExcelListener; import com.atguigu.spzx.manger.mapper.CategoryMapper; import com.atguigu.spzx.manger.service.CategoryService; import com.atguigu.spzx.model.entity.product.Category; @@ -88,7 +88,7 @@ public class CategoryServiceImpl implements CategoryService { @Override public void importData(MultipartFile file) { // 创建监听器对象,传递mapper对象 - ExcelListener listener = new ExcelListener<>(); + CategoryExcelListener listener = new CategoryExcelListener<>(categoryMapper); // 调用read方法读取excel数据 try { EasyExcel.read(file.getInputStream(), CategoryExcelVo.class, listener).sheet().doRead(); diff --git a/spzx-manager/src/main/resources/mapper/CategoryMapper.xml b/spzx-manager/src/main/resources/mapper/CategoryMapper.xml index f20139e..1296a5e 100644 --- a/spzx-manager/src/main/resources/mapper/CategoryMapper.xml +++ b/spzx-manager/src/main/resources/mapper/CategoryMapper.xml @@ -13,9 +13,8 @@ insert into category (id, name, image_url, parent_id, status, order_num, create_time, update_time, is_deleted) values - (#{item.id}, #{item.name}, #{item.image_url}, #{item.parent_id}, #{item.status}, #{item.order_num}, - #{item.create_time}, #{item.update_time}, - #{item.is_deleted}) + ( #{item.id}, #{item.name}, #{item.imageUrl}, #{item.parentId}, #{item.status}, #{item.orderNum}, now(), + now(), 0)