Quellcode durchsuchen

新手教程/机构数据导入导出part1

Aslee vor 3 Jahren
Ursprung
Commit
166e16c6e1
31 geänderte Dateien mit 1580 neuen und 25 gelöschten Zeilen
  1. 65 3
      pom.xml
  2. 34 0
      src/main/java/com/caimei/controller/AuthApi.java
  3. 4 0
      src/main/java/com/caimei/controller/AuthClubApi.java
  4. 41 0
      src/main/java/com/caimei/controller/FileApi.java
  5. 2 2
      src/main/java/com/caimei/controller/UploadApi.java
  6. 4 1
      src/main/java/com/caimei/mapper/AuthMapper.java
  7. 4 0
      src/main/java/com/caimei/mapper/AuthProductMapper.java
  8. 10 0
      src/main/java/com/caimei/mapper/FileMapper.java
  9. 2 0
      src/main/java/com/caimei/mapper/ShopMapper.java
  10. 25 0
      src/main/java/com/caimei/model/po/AuthImportPo.java
  11. 13 0
      src/main/java/com/caimei/model/po/CmBrandAuthPo.java
  12. 52 0
      src/main/java/com/caimei/model/po/CourseFilePo.java
  13. 35 0
      src/main/java/com/caimei/model/vo/CourseFileListVo.java
  14. 3 0
      src/main/java/com/caimei/model/vo/ProductFormVo.java
  15. 20 0
      src/main/java/com/caimei/service/AuthService.java
  16. 31 0
      src/main/java/com/caimei/service/FileService.java
  17. 7 0
      src/main/java/com/caimei/service/ShopService.java
  18. 1 1
      src/main/java/com/caimei/service/impl/AuthProductServiceImpl.java
  19. 617 4
      src/main/java/com/caimei/service/impl/AuthServiceImpl.java
  20. 66 0
      src/main/java/com/caimei/service/impl/FileServiceImpl.java
  21. 1 1
      src/main/java/com/caimei/service/impl/ImageServiceImpl.java
  22. 5 0
      src/main/java/com/caimei/service/impl/ShopServiceImpl.java
  23. 23 11
      src/main/java/com/caimei/service/impl/UploadServiceImpl.java
  24. 154 0
      src/main/java/com/caimei/utils/Encodes.java
  25. 41 0
      src/main/java/com/caimei/utils/ExcelNumberFormatter.java
  26. 262 0
      src/main/java/com/caimei/utils/ExcelOperateUtil.java
  27. 1 1
      src/main/java/com/caimei/utils/OSSUtils.java
  28. 13 1
      src/main/resources/mapper/AuthMapper.xml
  29. 10 0
      src/main/resources/mapper/AuthProductMapper.xml
  30. 28 0
      src/main/resources/mapper/FileMapper.xml
  31. 6 0
      src/main/resources/mapper/ShopMapper.xml

+ 65 - 3
pom.xml

@@ -248,11 +248,73 @@
             <artifactId>spring-amqp</artifactId>
             <version>1.7.5.RELEASE</version>
         </dependency>
+
+        <!-- poi依赖  -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>3.17</version>
+        </dependency>
+        <!--2007 docx文件读取,需要导入poi-ooxml-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>3.17</version>
+        </dependency>
+        <!--2003 doc文件的读取,需要导入poi-scratchpad-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-scratchpad</artifactId>
+            <version>3.8</version>
+        </dependency>
         <dependency>
-            <groupId>com.rabbitmq</groupId>
-            <artifactId>amqp-client</artifactId>
-            <version>5.12.0</version>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>ooxml-schemas</artifactId>
+            <version>1.0</version>
+            <exclusions>
+                <!--解决含嵌入文件ppt转换报错 ArrayStoreException-->
+                <exclusion>
+                    <artifactId>xmlbeans</artifactId>
+                    <groupId>org.apache.xmlbeans</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
+
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itext-asian</artifactId>
+            <version>5.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.pdfbox</groupId>
+            <artifactId>pdfbox</artifactId>
+            <version>2.0.16</version>
+        </dependency>
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itextpdf</artifactId>
+            <version>5.5.13</version>
+        </dependency>
+
+        <!-- jxls begin -->
+        <dependency>
+            <groupId>net.sf.jxls</groupId>
+            <artifactId>jxls-core</artifactId>
+            <version>1.0.6</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.jxls</groupId>
+            <artifactId>jxls-reader</artifactId>
+            <version>1.0.6</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.4</version>
+            <classifier>jdk15</classifier>
+        </dependency>
+
+        <!-- jxls end -->
     </dependencies>
 
     <profiles>

+ 34 - 0
src/main/java/com/caimei/controller/AuthApi.java

@@ -13,7 +13,9 @@ import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
 
@@ -105,4 +107,36 @@ public class AuthApi {
         Integer auditBy = paramsMap.getInteger("auditBy");
         return authService.auditAuth(authId, auditStatus, invalidReason, auditBy);
     }
+
+
+    @ApiOperation("excel导入")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
+            @ApiImplicitParam(name = "createBy", required = true, value = "创建人用户id"),
+            @ApiImplicitParam(name = "file", required = true, value = "代理声明文件"),
+    })
+    @PostMapping("/import/excel")
+    public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
+        if (null == authUserId) {
+            return ResponseJson.error("参数异常,请输入供应商id");
+        }
+        if (null == createBy) {
+            return ResponseJson.error("参数异常,请输入创建人id");
+        }
+        if (null == file) {
+            return ResponseJson.error("参数异常,请选择文件");
+        }
+        return authService.importDataByExcel(file, authUserId, createBy);
+    }
+
+
+    @ApiOperation("excel导出")
+    @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
+    @GetMapping("/export/excel")
+    public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
+        if (null == authUserId) {
+            return ResponseJson.error("参数异常,请输入供应商id");
+        }
+        return authService.exportDataByExcel(authUserId, response);
+    }
 }

+ 4 - 0
src/main/java/com/caimei/controller/AuthClubApi.java

@@ -14,8 +14,12 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**

+ 41 - 0
src/main/java/com/caimei/controller/FileApi.java

@@ -2,6 +2,7 @@ package com.caimei.controller;
 
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.CourseFileListVo;
 import com.caimei.model.vo.FileListVo;
 import com.caimei.service.FileService;
 import com.github.pagehelper.PageInfo;
@@ -90,4 +91,44 @@ public class FileApi {
         Integer auditBy = paramsMap.getInteger("auditBy");
         return fileService.auditFile(fileId, auditStatus, invalidReason, auditBy);
     }
+
+
+    @ApiOperation("添加/编辑教程文件")
+    @ApiImplicitParam(name = "params", required = false, value = "fileId:文件id;fileTitle:文件标题;fileName:文件名称;ossName:oss名称;fileType:文件类型:1视频,2文档;fileModule:文件模块:1品牌授权-授权列表,2机构管理-机构列表")
+    @PostMapping("/course/save")
+    public ResponseJson saveCourseFile(@RequestBody String params) {
+        JSONObject paramsMap = JSONObject.parseObject(params);
+        Integer fileId = paramsMap.getInteger("fileId");
+        String fileTitle = paramsMap.getString("fileTitle");
+        String fileName = paramsMap.getString("fileName");
+        String ossName = paramsMap.getString("ossName");
+        Integer fileType = paramsMap.getInteger("fileType");
+        Integer fileModule = paramsMap.getInteger("fileModule");
+        return fileService.saveCourseFile(fileId, fileTitle, fileName, ossName, fileType, fileModule);
+    }
+
+    @ApiOperation("教程文件列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileType", required = false, value = "文件类型:1视频,2文档"),
+            @ApiImplicitParam(name = "fileTitle", required = false, value = "文件标题"),
+            @ApiImplicitParam(name = "fileModule", required = false, value = "文件模块:1品牌授权-授权列表,2机构管理-机构列表"),
+            @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
+            @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
+    })
+    @GetMapping("/course/list")
+    public ResponseJson<PageInfo<CourseFileListVo>> getCourseFileList(Integer fileType, Integer fileModule, String fileTitle,
+                                                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                                      @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        return fileService.getCourseFileList(fileType, fileModule, fileTitle, pageNum, pageSize);
+    }
+
+
+
+    @ApiOperation("删除文件")
+    @ApiImplicitParam(name = "params", value = "fileId:文件id", required = true)
+    @PostMapping("/course/delete")
+    public ResponseJson deleteCourseFile(@RequestBody Map<String,Integer> params) {
+        Integer fileId = params.get("fileId");
+        return fileService.deleteCourseFile(fileId);
+    }
 }

+ 2 - 2
src/main/java/com/caimei/controller/UploadApi.java

@@ -63,10 +63,10 @@ public class UploadApi {
             saveFile = imageDomain + "/" + saveFile;
             map.put("data", saveFile);
             map.put("msg", "上传成功");
-            logger.info(">>>>>>>>>>>>>>>>图片上传成功:" + saveFile);
+            logger.info("【图片上传】>>>>>>>>>>>>>>>>图片上传成功:" + saveFile);
         } else {
             map.put("msg", "上传失败");
-            logger.info(">>>>>>>>>>>>>>>>图片上传失败:");
+            logger.info("【图片上传】>>>>>>>>>>>>>>>>图片上传失败:");
         }
         return map;
     }

+ 4 - 1
src/main/java/com/caimei/mapper/AuthMapper.java

@@ -2,7 +2,6 @@ package com.caimei.mapper;
 
 import com.caimei.model.po.CmBrandAuthPo;
 import com.caimei.model.vo.AuthVo;
-import com.caimei.model.vo.ClubVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -35,4 +34,8 @@ public interface AuthMapper {
     Integer getClubStatus(Integer authId);
 
     CmBrandAuthPo getAuthById(Integer authId);
+
+    Integer getAuthIdByAuthParty(@Param("authParty") String authParty, @Param("authUserId") Integer authUserId);
+
+    List<CmBrandAuthPo> getAuthPartyList(Integer authUserId);
 }

+ 4 - 0
src/main/java/com/caimei/mapper/AuthProductMapper.java

@@ -51,4 +51,8 @@ public interface AuthProductMapper {
     void updateProductAuditStatus(@Param("productId") Integer productId, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);
 
     List<WxProductListVo> getWxProductList(@Param("authId") Integer authId, @Param("productName") String productName);
+
+    Integer getBrandIdByBrandName(String brand);
+
+    List<ProductFormVo> getAuthProductList(Integer authId);
 }

+ 10 - 0
src/main/java/com/caimei/mapper/FileMapper.java

@@ -1,6 +1,8 @@
 package com.caimei.mapper;
 
+import com.caimei.model.po.CourseFilePo;
 import com.caimei.model.po.FilePo;
+import com.caimei.model.vo.CourseFileListVo;
 import com.caimei.model.vo.FileListVo;
 import com.caimei.model.vo.WxFileListVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -33,4 +35,12 @@ public interface FileMapper {
     void updateFileSelective(FilePo file);
 
     List<WxFileListVo> getWxFileList(@Param("authUserId") Integer authUserId, @Param("fileTitle") String fileTitle);
+
+    void updateCourseFile(CourseFilePo courseFile);
+
+    void insertCourseFile(CourseFilePo courseFile);
+
+    List<CourseFileListVo> getCourseFileList(@Param("fileType") Integer fileType, @Param("fileModule") Integer fileModule, @Param("fileTitle") String fileTitle);
+
+    void deleteCourseFileByFileId(Integer fileId);
 }

+ 2 - 0
src/main/java/com/caimei/mapper/ShopMapper.java

@@ -81,4 +81,6 @@ public interface ShopMapper {
     String getAppId(Integer authUserId);
 
     String getShopNameByAppId(String appId);
+
+    List<String> getShopBrands(Integer authUserId);
 }

+ 25 - 0
src/main/java/com/caimei/model/po/AuthImportPo.java

@@ -0,0 +1,25 @@
+package com.caimei.model.po;
+
+import com.caimei.model.dto.ProductSaveDto;
+import lombok.Data;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+
+import java.util.List;
+
+/**
+ * 授权信息导入po
+ * @author Aslee
+ */
+@Data
+public class AuthImportPo {
+
+    /**
+     * 授权机构
+     */
+    private String authParty;
+
+    /**
+     * 授权机构对应的商品列表
+     */
+    private List<ProductSaveDto> productList;
+}

+ 13 - 0
src/main/java/com/caimei/model/po/CmBrandAuthPo.java

@@ -2,6 +2,9 @@ package com.caimei.model.po;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
+
+import com.caimei.model.vo.ProductFormVo;
 import lombok.Data;
 
 /**
@@ -42,4 +45,14 @@ public class CmBrandAuthPo {
      */
     private Integer createBy;
 
+    /**
+     * 商品列表
+     */
+    private List<ProductFormVo> productList;
+
+    /**
+     * 商品参数数量最大值
+     */
+    private Integer maxParamNum;
+
 }

+ 52 - 0
src/main/java/com/caimei/model/po/CourseFilePo.java

@@ -0,0 +1,52 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * cm_brand_file
+ * @author  Aslee
+ */
+@Data
+public class CourseFilePo {
+    /**
+     * 文件id
+     */
+    private Integer id;
+
+    /**
+     * 供应商用户id
+     */
+    private Integer authUserId;
+
+    /**
+     * 文件标题
+     */
+    private String title;
+
+    /**
+     * 文件名称
+     */
+    private String name;
+
+    /**
+     * oss名称
+     */
+    private String ossName;
+
+    /**
+     * 文件类型:1视频,2文档
+     */
+    private Integer fileType;
+
+    /**
+     * 文件模块:1品牌授权-授权列表,2机构管理-机构列表
+     */
+    private Integer fileModule;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+}

+ 35 - 0
src/main/java/com/caimei/model/vo/CourseFileListVo.java

@@ -0,0 +1,35 @@
+package com.caimei.model.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * cm_brand_file
+ * @author Aslee
+ * @date 2021/7/8
+ */
+@Data
+public class CourseFileListVo {
+    @ApiModelProperty("文件id")
+    private Integer fileId;
+
+    @ApiModelProperty("文件标题")
+    private String fileTitle;
+
+    @ApiModelProperty("文件名称")
+    private String fileName;
+
+    @ApiModelProperty("文件模块:1品牌授权-授权列表,2机构管理-机构列表")
+    private Integer fileModule;
+
+    @ApiModelProperty("文件链接")
+    private String fileUrl;
+
+    @ApiModelProperty("oss名称")
+    private String ossName;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+}

+ 3 - 0
src/main/java/com/caimei/model/vo/ProductFormVo.java

@@ -23,6 +23,9 @@ public class ProductFormVo {
     @ApiModelProperty("品牌id")
     private Integer brandId;
 
+    @ApiModelProperty("品牌名称")
+    private String brandName;
+
     @ApiModelProperty("商品名称")
     private String productName;
 

+ 20 - 0
src/main/java/com/caimei/service/AuthService.java

@@ -3,6 +3,9 @@ package com.caimei.service;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.vo.AuthVo;
 import com.github.pagehelper.PageInfo;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
 
 /**
  * Description
@@ -64,4 +67,21 @@ public interface AuthService {
      * @return ResponseJson
      */
     ResponseJson auditAuth(Integer authId, Integer auditStatus, String invalidReason, Integer auditBy);
+
+    /**
+     * 导入excel中的授权机构和商品数据
+     * @param file          excel表格
+     * @param authUserId    供应商用户id
+     * @param createBy
+     * @return
+     */
+    ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy);
+
+    /**
+     * 导出授权机构和商品数据
+     * @param authUserId    供应商用户id
+     * @param response
+     * @return
+     */
+    ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response);
 }

+ 31 - 0
src/main/java/com/caimei/service/FileService.java

@@ -1,6 +1,7 @@
 package com.caimei.service;
 
 import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.CourseFileListVo;
 import com.caimei.model.vo.FileListVo;
 import com.caimei.model.vo.WxFileListVo;
 import com.github.pagehelper.PageInfo;
@@ -76,4 +77,34 @@ public interface FileService {
      * @return
      */
     ResponseJson<PageInfo<WxFileListVo>> getWxFileList(Integer authUserId, String fileTitle, Integer pageNum, Integer pageSize);
+
+    /**
+     * 保存教程文件
+     * @param fileId        文件id
+     * @param fileTitle     文件标题
+     * @param fileName      文件名称
+     * @param ossName       oss名称
+     * @param fileType      文件类型:1视频,2文档
+     * @param fileModule    文件模块:1品牌授权-授权列表,2机构管理-机构列表
+     * @return
+     */
+    ResponseJson saveCourseFile(Integer fileId, String fileTitle, String fileName, String ossName, Integer fileType, Integer fileModule);
+
+    /**
+     * 教程文件列表
+     * @param fileType      文件类型:1视频,2文档
+     * @param fileModule    文件模块:1品牌授权-授权列表,2机构管理-机构列表
+     * @param fileTitle     文件标题
+     * @param pageNum       页码
+     * @param pageSize      每页数量
+     * @return
+     */
+    ResponseJson<PageInfo<CourseFileListVo>> getCourseFileList(Integer fileType, Integer fileModule, String fileTitle, Integer pageNum, Integer pageSize);
+
+    /**
+     * 删除教程文件
+     * @param fileId    文件id
+     * @return
+     */
+    ResponseJson deleteCourseFile(Integer fileId);
 }

+ 7 - 0
src/main/java/com/caimei/service/ShopService.java

@@ -135,4 +135,11 @@ public interface ShopService {
      * @return
      */
     ResponseJson handleFeedback(Integer feedbackId, String handleResult);
+
+    /**
+     * 根据供应商id查询供应商下所有品牌
+     * @param authUserId    供应商id
+     * @return
+     */
+    List<String> getShopBrands(Integer authUserId);
 }

+ 1 - 1
src/main/java/com/caimei/service/impl/AuthProductServiceImpl.java

@@ -217,7 +217,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         if (StringUtils.isNotEmpty(img)) {
             MultipartFile imgFile = Base64Util.base64ToMultipart(img);
             if (null != imgFile) {
-                imagePath = imageDomain + "/" + uploadService.saveFile(imgFile);
+                imagePath = uploadService.saveFile(imgFile);
             }
             log.info(">>>>>>>>>>>>>>>>水印图片上传成功:" + imagePath);
         } else {

+ 617 - 4
src/main/java/com/caimei/service/impl/AuthServiceImpl.java

@@ -1,22 +1,41 @@
 package com.caimei.service.impl;
 
+import com.caimei.config.FastDfsClient;
 import com.caimei.mapper.AuthMapper;
+import com.caimei.mapper.AuthProductMapper;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.dto.ProductSaveDto;
+import com.caimei.model.po.AuthImportPo;
 import com.caimei.model.po.CmBrandAuthPo;
+import com.caimei.model.po.ProductParamPo;
 import com.caimei.model.vo.AuthVo;
+import com.caimei.model.vo.ProductFormVo;
 import com.caimei.service.AuthProductService;
 import com.caimei.service.AuthService;
+import com.caimei.service.ShopService;
+import com.caimei.utils.ExcelOperateUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-import java.util.ListIterator;
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Description
@@ -31,6 +50,9 @@ public class AuthServiceImpl implements AuthService {
     @Resource
     private AuthMapper authMapper;
 
+    @Resource
+    private AuthProductMapper authProductMapper;
+
     private AuthProductService authProductService;
 
     @Autowired
@@ -38,6 +60,22 @@ public class AuthServiceImpl implements AuthService {
         this.authProductService = authProductService;
     }
 
+    private ShopService shopService;
+
+    @Autowired
+    public void setShopService(ShopService shopService) {
+        this.shopService = shopService;
+    }
+
+    @Value("${spring.profiles.active}")
+    private String active;
+
+    @Autowired
+    private FastDfsClient client;
+
+    @Value("${caimei.imageDomain}")
+    private String imageDomain;
+
     @Override
     public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty, Integer status, Integer auditStatus, Integer lowerAuditStatus, Integer pageNum, Integer pageSize) {
         if (null == authUserId) {
@@ -109,6 +147,10 @@ public class AuthServiceImpl implements AuthService {
         if (StringUtils.isBlank(authParty)) {
             return ResponseJson.error("参数异常,请输入授权机构名称");
         }
+        Integer authIdByAuthParty = authMapper.getAuthIdByAuthParty(authParty, authUserId);
+        if (null != authIdByAuthParty && !authIdByAuthParty.equals(authId)) {
+            return ResponseJson.error("参数异常,该授权机构已存在,请重新输入", null);
+        }
         if (null == createBy) {
             return ResponseJson.error("参数异常,请输入创建人id");
         }
@@ -135,7 +177,7 @@ public class AuthServiceImpl implements AuthService {
             } else {
                 authMapper.updateAuthByAuthId(auth);
             }
-        return ResponseJson.success("保存品牌授权成功");
+        return ResponseJson.success("保存品牌授权成功", auth);
     }
 
     @Override
@@ -165,4 +207,575 @@ public class AuthServiceImpl implements AuthService {
         authMapper.updateAuthAuditStatus(authId, status, auditStatus, invalidReason, auditBy, auditTime);
         return ResponseJson.success("审核品牌授权成功");
     }
+
+
+    @Override
+    public ResponseJson importDataByExcel(MultipartFile file, Integer authUserId, Integer createBy) {
+        String originalFilename = file.getOriginalFilename();
+        String randomStr = UUID.randomUUID().toString();
+        assert originalFilename != null;
+        int index = originalFilename.lastIndexOf(".");
+        String extName = originalFilename.substring(index);
+        String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/";
+        if ("dev".equals(active)) {
+            filePath = "D:\\WorkSpace\\file\\tempImport\\";
+        }
+        filePath += randomStr + extName;
+        try {
+            File tempFile = new File(filePath);
+            if (!tempFile.exists()) {
+                tempFile.mkdirs();
+            }
+            file.transferTo(tempFile);
+            return saveExcelData(filePath, authUserId, createBy);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        log.info(">>>>>>>>>>>>>>>>文件临时路径:" + filePath);
+        return null;
+    }
+
+    @Override
+    public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
+        try {
+            // 导出表格名
+            String fileName = new String("机构商品数据.xlsx".getBytes("UTF-8"),"iso-8859-1");
+            // 机构数据
+            List<CmBrandAuthPo> authPartyList = authMapper.getAuthPartyList(authUserId);
+            authPartyList.forEach(authParty->{
+                // 商品参数数量最大值
+                final Integer[] maxParamNum = {0};
+                Integer authId = authParty.getId();
+                List<ProductFormVo> productList = authProductMapper.getAuthProductList(authId);
+                productList.forEach(product->{
+                    // 参数列表
+                    List<ProductParamPo> paramList = authProductMapper.getParamsByProductId(product.getProductId());
+                    product.setParamList(paramList);
+                    if (paramList.size() > maxParamNum[0]) {
+                        maxParamNum[0] = paramList.size();
+                    }
+                });
+                authParty.setMaxParamNum(maxParamNum[0]);
+                authParty.setProductList(productList);
+            });
+            OutputStream outputStream = response.getOutputStream();
+            response.reset();
+            response.setHeader("Content-disposition",
+                    "attachment; filename="+fileName);
+            response.setContentType("application/msexcel");
+            return exportData(authPartyList, outputStream);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResponseJson.error("导出失败");
+        }
+    }
+
+    private ResponseJson saveExcelData(String filePath, Integer authUserId, Integer createBy) {
+        //判断是否为excel类型文件
+        if (!filePath.endsWith(".xls") && !filePath.endsWith(".xlsx")) {
+            System.out.println("文件不是excel类型");
+        }
+        // 获取供应商品牌
+        List<String> shopBrands = shopService.getShopBrands(authUserId);
+
+        // 授权列表
+        List<AuthImportPo> authImportList = new ArrayList<>();
+
+        try {
+            FileInputStream fis = new FileInputStream(filePath);
+            // 得到表格数据
+            XSSFWorkbook workbook = new XSSFWorkbook(fis);
+            // 获取工作表数量
+            int sheetsNum = workbook.getNumberOfSheets();
+
+            //得到第一个工作表(机构表)
+            XSSFSheet authPartySheet = workbook.getSheetAt(0);
+            //获得表头
+            Row rowHead = authPartySheet.getRow(0);
+            //判断表头是否正确
+            if (1 != rowHead.getLastCellNum() || !"授权机构".equals(rowHead.getCell(0).getStringCellValue())) {
+                return ResponseJson.error("授权机构表格式错误");
+            }
+            // 获得数据的总行数
+            int authPartyRowNum = authPartySheet.getLastRowNum();
+            // 商品sn码列表
+            List<String> snCodeList = new ArrayList<>();
+
+            //获得所有数据
+            for (int i = 1; i <= authPartyRowNum; i++) {
+                //获得第i行对象
+                Row row = authPartySheet.getRow(i);
+                //获得获得第i行第0列的机构名称
+                Cell cell = row.getCell(0);
+                // 机构名称
+                String authParty = cell.getStringCellValue();
+                if (StringUtils.isNotEmpty(authParty)) {
+                    /*
+                     * 授权数据
+                     */
+                    AuthImportPo authImportPo = new AuthImportPo();
+                    // 商品列表
+                    List<ProductSaveDto> productList = new ArrayList<>();
+
+                    // 得到机构对应的商品工作表
+                    XSSFSheet productSheet = i <= sheetsNum ? workbook.getSheetAt(i) : null;
+                    String sheetName = null != productSheet ? productSheet.getSheetName() : null;
+                    if (null == productSheet || !authParty.equals(sheetName)) {
+                        // 遍历所有工作表,找到表名与授权机构名称相同的商品工作表
+                        for (int j = 1; i < sheetsNum; i++) {
+                            productSheet = workbook.getSheetAt(j);
+                            sheetName = productSheet.getSheetName();
+                            if (!authParty.equals(sheetName)) {
+                                // 没有该机构对应的商品表
+                                productSheet = null;
+                            }
+                        }
+                    }
+                    if (null != productSheet) {
+                        //获得表头
+                        Row productRowHead = productSheet.getRow(0);
+                        //判断表头是否正确
+                        short cellTotalNum = productRowHead.getLastCellNum();
+                        if (cellTotalNum < 13) {
+                            return ResponseJson.error(authParty + "机构商品表格式错误");
+                        }
+                        // 校验商品数据是否符合规范
+                        int productRowNum = productSheet.getLastRowNum();
+                        for (int k = 1; k <= productRowNum; k++) {
+                            XSSFRow productRow = productSheet.getRow(k);
+                            if (null != productRow && productRow.getCell(0) != null) {
+                                String errorReason = "";
+                                // 校验商品名称
+                                String productName = productRow.getCell(0).getStringCellValue();
+                                if (StringUtils.isEmpty(productName)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品名称不能为空";
+                                }
+                                // 校验商品sn码
+                                String snCode = productRow.getCell(1).getStringCellValue();
+                                if (StringUtils.isEmpty(snCode)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品名称不能为空";
+                                } else {
+                                    Integer productIdBySnCode = authProductMapper.getProductIdBySnCode(snCode);
+                                    if (null != productIdBySnCode || snCodeList.contains(snCode)) {
+                                        errorReason = authParty + "机构商品表第" + (k + 1) + "行商品sn码已存在,请重新输入";
+                                    } else {
+                                        snCodeList.add(snCode);
+                                    }
+                                }
+                                // 校验品牌名称
+                                String brand = productRow.getCell(2).getStringCellValue();
+                                Integer brandId = null;
+                                if (StringUtils.isEmpty(brand)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品品牌不能为空";
+                                } else {
+                                    if (!shopBrands.contains(brand)) {
+                                        errorReason = authParty + "机构商品表第" + (k + 1) + "行商品品牌不存在";
+                                    } else {
+                                        brandId = authProductMapper.getBrandIdByBrandName(brand);
+                                    }
+                                }
+                                Map<String, XSSFPictureData> pictures = ExcelOperateUtil.getPictures(productSheet);
+                                Map<String, String> imageMap = ExcelOperateUtil.printImg(pictures);
+                                // 校验商品图片
+                                String productImage = imageMap.get(k + "-3");
+                                if (StringUtils.isEmpty(productImage)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行商品图片不能为空";
+                                }
+                                // 校验授权牌照
+                                String certificateImage = imageMap.get(k + "-4");
+                                if (StringUtils.isEmpty(certificateImage)) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行授权牌照不能为空";
+                                }
+                                List<ProductParamPo> paramList = new ArrayList<>();
+                                // 校验参数列表
+                                for (int a = 5; a + 1 < cellTotalNum; a += 2) {
+                                    XSSFCell paramNameCell = productRow.getCell(a);
+                                    XSSFCell paramContentCell = productRow.getCell(a + 1);
+                                    boolean validName = null != paramNameCell;
+                                    boolean validContent = null != paramContentCell;
+                                    if (validName && validContent) {
+                                        String paramName = paramNameCell.getStringCellValue();
+                                        String paramContent = paramContentCell.getStringCellValue();
+                                        validName = StringUtils.isNotEmpty(paramName);
+                                        validContent = StringUtils.isNotEmpty(paramContent);
+                                        if (validName && validContent) {
+                                            ProductParamPo productParamPo = new ProductParamPo();
+                                            productParamPo.setParamName(paramName);
+                                            productParamPo.setParamContent(paramContent);
+                                            paramList.add(productParamPo);
+                                        } else if ((validName || validContent)) {
+                                            errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数据异常";
+                                        }
+                                    } else if (validName || validContent) {
+                                        errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数据异常";
+                                    }
+                                }
+                                if (paramList.size() < 4) {
+                                    errorReason = authParty + "机构商品表第" + (k + 1) + "行参数数量不足";
+                                }
+                                if (StringUtils.isNotEmpty(errorReason)) {
+                                    // 删除临时图片文件
+                                    for (String image : imageMap.values()) {
+                                        if (StringUtils.isNotEmpty(image)) {
+                                            File tempFile = new File(image);
+                                            tempFile.delete();
+                                        }
+                                    }
+                                    return ResponseJson.error(errorReason);
+                                }
+                                /*
+                                    组装商品数据
+                                 */
+                                ProductSaveDto product = new ProductSaveDto();
+                                // 品牌id
+                                product.setBrandId(brandId);
+                                // 商品名称
+                                product.setProductName(productName);
+                                // sn码
+                                product.setSnCode(snCode);
+                                // 商品图片
+                                product.setProductImage(productImage);
+                                // 授权牌照
+                                product.setCertificateImage(certificateImage);
+                                // 参数列表
+                                product.setParamList(paramList);
+                                // 创建人
+                                product.setCreateBy(createBy);
+                                productList.add(product);
+                                // 删除临时图片文件
+                                for (String image : imageMap.values()) {
+                                    if (StringUtils.isNotEmpty(image)) {
+                                        File tempFile = new File(image);
+                                        tempFile.delete();
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    // 授权机构
+                    authImportPo.setAuthParty(authParty);
+                    // 商品列表
+                    authImportPo.setProductList(productList);
+                    // 添加数据
+                    authImportList.add(authImportPo);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResponseJson.error("导入失败,请检查表格数据");
+        } finally {
+            // 删除临时数据
+            File tempFile = new File(filePath);
+            tempFile.delete();
+        }
+        // 保存授权数据
+        authImportList.forEach(authImportPo -> {
+            String authParty = authImportPo.getAuthParty();
+            List<ProductSaveDto> productList = authImportPo.getProductList();
+            Integer authId = authMapper.getAuthIdByAuthParty(authParty, authUserId);
+            // 保存授权机构
+            if (null == authId) {
+                ResponseJson responseJson = saveAuth(null, authUserId, authParty, createBy);
+                CmBrandAuthPo authPo = (CmBrandAuthPo) responseJson.getData();
+                authId = authPo.getId();
+            }
+            Integer finalAuthId = authId;
+            // 保存商品列表
+            productList.forEach(productDto -> {
+                try {
+                    productDto.setAuthId(finalAuthId);
+                    // 上传商品图片和授权牌照
+                    String productImage = productDto.getProductImage();
+                    String certificateImage = productDto.getCertificateImage();
+                    productDto.setProductImage(uploadImage(productImage));
+                    productDto.setCertificateImage(uploadImage(certificateImage));
+                    authProductService.saveProduct(productDto);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            });
+        });
+        return ResponseJson.success("导入成功");
+    }
+
+    private ResponseJson exportData(List<CmBrandAuthPo> authPartyList, OutputStream outputStream) {
+        try {
+            HSSFWorkbook workbook = new HSSFWorkbook();
+            // 创建机构工作表
+            HSSFSheet authPartySheet = workbook.createSheet("授权机构");
+            // sheet样式定义
+            HSSFCellStyle topCellStyle = this.getTopCellStyle(workbook);
+            HSSFCellStyle customCellStyle = this.getCustomCellStyle(workbook);
+            // 创建列头行
+            HSSFRow topRow = authPartySheet.createRow(0);
+            HSSFCell topRowCell = topRow.createCell(0);
+            topRowCell.setCellType(CellType.valueOf("STRING"));
+            HSSFRichTextString text = new HSSFRichTextString("授权机构");
+            topRowCell.setCellValue(text);
+            topRowCell.setCellStyle(topCellStyle);
+            // 行索引
+            AtomicInteger authPartyRowNum = new AtomicInteger(1);
+            // 每个机构创建一行数据
+            authPartyList.forEach(authParty -> {
+                HSSFRow authPartyRow = authPartySheet.createRow(authPartyRowNum.get());
+                HSSFCell authPartyCell = authPartyRow.createCell(0);
+                authPartyCell.setCellType(CellType.valueOf("STRING"));
+                HSSFRichTextString authPartyName = new HSSFRichTextString(authParty.getAuthParty());
+                authPartyCell.setCellValue(authPartyName);
+                authPartyCell.setCellStyle(customCellStyle);
+                authPartyRowNum.getAndIncrement();
+            });
+            // 让列宽随着导出的列长自动适应
+            int columnWidth = authPartySheet.getColumnWidth(0) / 256;
+            for (int rowNum = 0; rowNum < authPartySheet.getLastRowNum(); rowNum++) {
+                HSSFRow currentRow;
+                // 当前行未被使用过
+                if (authPartySheet.getRow(rowNum) == null) {
+                    currentRow = authPartySheet.createRow(rowNum);
+                } else {
+                    currentRow = authPartySheet.getRow(rowNum);
+                }
+                if (currentRow.getCell(0) != null) {
+                    HSSFCell currentCell = currentRow.getCell(0);
+                    if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
+                        int length = currentCell.getStringCellValue()
+                                .getBytes().length;
+                        if (columnWidth < length) {
+                            columnWidth = length;
+                        }
+                    }
+                }
+            }
+            authPartySheet.setColumnWidth(0, (columnWidth + 4) * 256);
+
+            // 创建每个机构对应的商品表
+            authPartyList.forEach(authParty -> {
+                // 授权机构名称作为表名
+                String productSheetName = authParty.getAuthParty();
+                // 商品列表
+                List<ProductFormVo> productList = authParty.getProductList();
+                // 创建商品工作表
+                HSSFSheet productSheet = workbook.createSheet(productSheetName);
+                // 创建列头行
+                HSSFRow productTopRow = productSheet.createRow(0);
+                // 添加列头单元格(5个固定列+参数列表)
+                String[] rowName = {"商品名称", "商品SN码", "所属品牌", "商品图片(尺寸:128px×88px)",
+                        "授权牌(尺寸:128px×88px)", "参数名称1", "参数值1", "参数名称2", "参数值2", "参数名称3",
+                        "参数值3", "参数名称4", "参数值4", "参数名称5", "参数值5", "参数名称6", "参数值6", "参数名称7",
+                        "参数值7", "参数名称8", "参数值8", "参数名称9", "参数值9", "参数名称10", "参数值10", "参数名称11",
+                        "参数值11", "参数名称12", "参数值12"};
+                for (int i = 0; i < 5 + authParty.getMaxParamNum(); i++) {
+                    HSSFCell productTopRowCell = productTopRow.createCell(i);
+                    productTopRowCell.setCellType(CellType.valueOf("STRING"));
+                    HSSFRichTextString columnText = new HSSFRichTextString(rowName[i]);
+                    productTopRowCell.setCellValue(columnText);
+                    productTopRowCell.setCellStyle(topCellStyle);
+                }
+                // 添加商品数据到单元格中
+                // 行索引
+                AtomicInteger productRowNum = new AtomicInteger(1);
+                productList.forEach(product -> {
+                    // 创建商品行
+                    HSSFRow productRow = productSheet.createRow(productRowNum.get());
+                    // 设置行高度
+                    productRow.setHeight((short) 2200);
+                    // 参数列表
+                    List<ProductParamPo> paramList = product.getParamList();
+                    // 组装商品数据
+                    List<String> productData = new ArrayList<>();
+                    productData.add(product.getProductName());
+                    productData.add(product.getSnCode());
+                    productData.add(product.getBrandName());
+                    productData.add(product.getProductImage());
+                    productData.add(product.getCertificateImage());
+                    paramList.forEach(param -> {
+                        productData.add(param.getParamName());
+                        productData.add(param.getParamContent());
+                    });
+                    for (int j = 0; j < 5 + paramList.size(); j++) {
+                        HSSFCell productCell = productRow.createCell(j);
+                        if (j == 3 || j == 4) {
+//                            productSheet.addMergedRegion(new CellRangeAddress(j + 1,j + 1,j + 1,j + 1)) ;
+                            // 头像
+                            InputStream imageStream = getImageStream(productData.get(j));
+                            if (null != imageStream){
+                                try {
+                                    BufferedImage bufferedImage = ImageIO.read(imageStream);
+                                    ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+                                    ImageIO.write(bufferedImage, "jpg", byteArrayOut);
+                                    byte[] data = byteArrayOut.toByteArray();
+                                    HSSFPatriarch drawingPatriarch = productSheet.createDrawingPatriarch();
+                                    // 设置图片位置
+                                    HSSFClientAnchor anchor = new HSSFClientAnchor(30, 30, 700, 200, (short)j,productRowNum.get(),(short)j,productRowNum.get());
+                                    drawingPatriarch.createPicture(anchor, workbook.addPicture(data, HSSFWorkbook.PICTURE_TYPE_JPEG));
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            } else {
+                                productCell.setCellType(CellType.valueOf("STRING"));
+                                productCell.setCellValue("");
+                            }
+                        } else {
+                            productCell.setCellType(CellType.valueOf("STRING"));
+                            HSSFRichTextString productCellValue = new HSSFRichTextString(productData.get(j));
+                            productCell.setCellValue(productCellValue);
+                            productCell.setCellStyle(customCellStyle);
+                        }
+                    }
+                    productRowNum.getAndIncrement();
+                });
+
+                // 让列宽随着导出的列长自动适应
+                for (int colNum = 0; (colNum < 5 + authParty.getMaxParamNum()); colNum++) {
+                    if (colNum == 3 || colNum == 4) {
+                        productSheet.setColumnWidth(colNum, 8200);
+                    } else {
+                        int productColumnWidth = productSheet.getColumnWidth(colNum) / 256;
+                        for (int rowNum = 0; rowNum < productSheet.getLastRowNum(); rowNum++) {
+                            HSSFRow currentRow;
+                            // 当前行未被使用过
+                            if (productSheet.getRow(rowNum) == null) {
+                                currentRow = productSheet.createRow(rowNum);
+                            } else {
+                                currentRow = productSheet.getRow(rowNum);
+                            }
+                            if (currentRow.getCell(colNum) != null) {
+                                HSSFCell currentCell = currentRow.getCell(colNum);
+                                if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
+                                    int length = currentCell.getStringCellValue()
+                                            .getBytes().length;
+                                    if (productColumnWidth < length) {
+                                        productColumnWidth = length;
+                                    }
+                                }
+                            }
+                        }
+                        productSheet.setColumnWidth(colNum, (productColumnWidth + 4) * 256);
+                    }
+                }
+
+            });
+            outputStream.flush();
+            workbook.write(outputStream);
+            outputStream.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResponseJson.error("导出失败");
+        }
+        return ResponseJson.success("导出成功");
+    }
+
+    private String uploadImage(String filePath) throws FileNotFoundException {
+        // 临时图片
+        File tempFile = new File(filePath);
+        log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + filePath);
+        String imageUrl = imageDomain + "/" + client.uploadFile(filePath);
+        // 删除临时图片
+        boolean delete = tempFile.delete();
+        log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
+        return imageUrl;
+    }
+
+
+    /**
+     * 列头单元格样式
+     */
+    private HSSFCellStyle getTopCellStyle(HSSFWorkbook workbook) {
+
+        // 设置字体
+        HSSFFont font = workbook.createFont();
+        // 设置字体大小
+        font.setFontHeightInPoints((short) 11);
+        // 字体加粗
+        font.setBold(true);
+        // 设置字体名字
+        font.setFontName("Courier New");
+        // 设置样式;
+        HSSFCellStyle style = workbook.createCellStyle();
+        // 设置底边框;
+        style.setBorderBottom(BorderStyle.THIN);
+        // 设置底边框颜色;
+        style.setBottomBorderColor(IndexedColors.BLACK.index);
+        // 设置左边框;
+        style.setBorderLeft(BorderStyle.THIN);
+        // 设置左边框颜色;
+        style.setLeftBorderColor(IndexedColors.BLACK.index);
+        // 设置右边框;
+        style.setBorderRight(BorderStyle.THIN);
+        // 设置右边框颜色;
+        style.setRightBorderColor(IndexedColors.BLACK.index);
+        // 设置顶边框;
+        style.setBorderTop(BorderStyle.THIN);
+        // 设置顶边框颜色;
+        style.setTopBorderColor(IndexedColors.BLACK.index);
+        // 在样式用应用设置的字体;
+        style.setFont(font);
+        // 设置自动换行;
+        style.setWrapText(false);
+        // 设置水平对齐的样式为居中对齐;
+        style.setAlignment(HorizontalAlignment.CENTER);
+        // 设置垂直对齐的样式为居中对齐;
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+
+        return style;
+    }
+
+    /**
+     * 列数据信息单元格样式
+     */
+    private HSSFCellStyle getCustomCellStyle(HSSFWorkbook workbook) {
+        // 设置字体
+        HSSFFont font = workbook.createFont();
+        // 设置字体大小
+        // font.setFontHeightInPoints((short)10);
+        // 字体加粗
+        // font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+        // 设置字体名字
+        font.setFontName("Courier New");
+        // 设置样式;
+        HSSFCellStyle style = workbook.createCellStyle();
+        // 设置底边框;
+        style.setBorderBottom(BorderStyle.THIN);
+        // 设置底边框颜色;
+        style.setBottomBorderColor(IndexedColors.BLACK.index);
+        // 设置左边框;
+        style.setBorderLeft(BorderStyle.THIN);
+        // 设置左边框颜色;
+        style.setLeftBorderColor(IndexedColors.BLACK.index);
+        // 设置右边框;
+        style.setBorderRight(BorderStyle.THIN);
+        // 设置右边框颜色;
+        style.setRightBorderColor(IndexedColors.BLACK.index);
+        // 设置顶边框;
+        style.setBorderTop(BorderStyle.THIN);
+        // 设置顶边框颜色;
+        style.setTopBorderColor(IndexedColors.BLACK.index);
+        // 在样式用应用设置的字体;
+        style.setFont(font);
+        // 设置自动换行;
+        style.setWrapText(false);
+        // 设置水平对齐的样式为居中对齐;
+        style.setAlignment(HorizontalAlignment.CENTER);
+        // 设置垂直对齐的样式为居中对齐;
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        return style;
+    }
+
+
+    public InputStream getImageStream(String url) {
+        try {
+            HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
+            connection.setReadTimeout(5000);
+            connection.setConnectTimeout(5000);
+            connection.setRequestMethod("GET");
+            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+                InputStream inputStream = connection.getInputStream();
+                return inputStream;
+            }
+        } catch (IOException e) {
+            System.out.println("获取网络图片出现异常,图片路径为:" + url);
+            e.printStackTrace();
+        }
+        return null;
+    }
 }

+ 66 - 0
src/main/java/com/caimei/service/impl/FileServiceImpl.java

@@ -2,10 +2,13 @@ package com.caimei.service.impl;
 
 import com.caimei.mapper.FileMapper;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.CourseFilePo;
 import com.caimei.model.po.FilePo;
+import com.caimei.model.vo.CourseFileListVo;
 import com.caimei.model.vo.FileListVo;
 import com.caimei.model.vo.WxFileListVo;
 import com.caimei.service.FileService;
+import com.caimei.utils.OSSUtils;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -165,4 +168,67 @@ public class FileServiceImpl implements FileService {
         PageInfo<WxFileListVo> pageData = new PageInfo<>(fileList);
         return ResponseJson.success(pageData);
     }
+
+    @Override
+    public ResponseJson saveCourseFile(Integer fileId, String fileTitle, String fileName, String ossName, Integer fileType, Integer fileModule) {
+        if (StringUtils.isEmpty(fileTitle)) {
+            return ResponseJson.error("参数异常,请输入文件标题");
+        }
+        if (StringUtils.isEmpty(fileName)) {
+            return ResponseJson.error("参数异常,请输入文件名称");
+        }
+        if (StringUtils.isEmpty(ossName)) {
+            return ResponseJson.error("参数异常,请上传文件");
+        }
+        if (null == fileType) {
+            return ResponseJson.error("参数异常,请选择文件类型");
+        }
+        if (null == fileModule) {
+            return ResponseJson.error("参数异常,请选择所属模块");
+        }
+        /*
+            组装文件数据
+        */
+        CourseFilePo courseFile = new CourseFilePo();
+        courseFile.setTitle(fileTitle);
+        courseFile.setOssName(ossName);
+        courseFile.setName(fileName);
+        courseFile.setFileType(fileType);
+        courseFile.setFileModule(fileModule);
+        if (null != fileId) {
+            /*
+                更新文件
+             */
+            courseFile.setId(fileId);
+            fileMapper.updateCourseFile(courseFile);
+        } else {
+            /*
+                新增文件
+             */
+            fileMapper.insertCourseFile(courseFile);
+        }
+        return ResponseJson.success("保存成功");
+    }
+
+    @Override
+    public ResponseJson<PageInfo<CourseFileListVo>> getCourseFileList(Integer fileType, Integer fileModule, String fileTitle, Integer pageNum, Integer pageSize) {
+        if (null == fileType) {
+            return ResponseJson.error("参数异常,请输入文件类型", null);
+        }
+        PageHelper.startPage(pageNum, pageSize);
+        List<CourseFileListVo> fileList = fileMapper.getCourseFileList(fileType, fileModule, fileTitle);
+        fileList.forEach(file-> file.setFileUrl(OSSUtils.getOssUrl(file.getOssName())));
+        PageInfo<CourseFileListVo> pageData = new PageInfo<>(fileList);
+        return ResponseJson.success(pageData);
+    }
+
+    @Override
+    public ResponseJson deleteCourseFile(Integer fileId) {
+        if (null == fileId) {
+            return ResponseJson.error("参数异常,请输入文件id");
+        }
+        // 删除文件
+        fileMapper.deleteCourseFileByFileId(fileId);
+        return ResponseJson.success("删除文件成功");
+    }
 }

+ 1 - 1
src/main/java/com/caimei/service/impl/ImageServiceImpl.java

@@ -80,7 +80,7 @@ public class ImageServiceImpl implements ImageService {
         image.setStatus(2);
         image.setAuditStatus(2);
         String imageZipUrl = uploadService.saveImageZip(imageArr);
-        System.out.println(">>>>>>>>>>>>>>>>"+imageZipUrl);
+        System.out.println("【图片上传】>>>>>>>>>>>>>>>>图片压缩包上传成功:"+imageZipUrl);
         image.setZipUrl(imageZipUrl);
         if (null == imageId) {
             image.setAuthUserId(authUserId);

+ 5 - 0
src/main/java/com/caimei/service/impl/ShopServiceImpl.java

@@ -399,4 +399,9 @@ public class ShopServiceImpl implements ShopService {
         shopMapper.handleFeedback(feedbackId, handleResult);
         return ResponseJson.success("处理成功");
     }
+
+    @Override
+    public List<String> getShopBrands(Integer authUserId) {
+        return shopMapper.getShopBrands(authUserId);
+    }
 }

+ 23 - 11
src/main/java/com/caimei/service/impl/UploadServiceImpl.java

@@ -40,29 +40,37 @@ public class UploadServiceImpl implements UploadService {
     @Override
     public String saveFile(MultipartFile file) throws IOException {
         String originalFilename = file.getOriginalFilename();
-        String randomUUID = UUID.randomUUID().toString();
+        String randomStr = UUID.randomUUID().toString();
+        assert originalFilename != null;
         int index = originalFilename.lastIndexOf(".");
-        String exet = originalFilename.substring(index);
-        String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempImage/";
+        String extName = originalFilename.substring(index);
+        String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/";
         if ("dev".equals(active)){
-            filePath = "D:\\uploadImage\\";
+            filePath = "D:\\WorkSpace\\file\\tempIomprt";
         }
-        filePath += "\\" + randomUUID + exet;
-        file.transferTo(new File(filePath));
-        log.info(">>>>>>>>>>>>>>>>图片上传路径:" + filePath);
-        return client.uploadFile(filePath);
+        filePath += "\\" + randomStr + extName;
+        // 临时图片
+        File tempFile = new File(filePath);
+        file.transferTo(tempFile);
+        log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + filePath);
+        String imageUrl = imageDomain + "/" + client.uploadFile(filePath);
+        // 删除临时图片
+        boolean delete = tempFile.delete();
+        log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
+        return imageUrl;
     }
 
 
     @Override
     public String saveImageZip(JSONArray imageArr) throws Exception {
-        String randomUUID = UUID.randomUUID().toString();
+        String randomStr = UUID.randomUUID().toString();
         String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempImage/";
         if ("dev".equals(active)){
             filePath = "D:\\uploadZip\\";
         }
-        filePath += randomUUID + ".zip";
+        filePath += randomStr + ".zip";
         File zipFile = new File(filePath);
+        log.info("【图片上传】>>>>>>>>>>>>>>>>图片压缩包临时路径:" + filePath);
         ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
         BufferedOutputStream bo = new BufferedOutputStream(out);
         for (Object s : imageArr) {
@@ -84,7 +92,11 @@ public class UploadServiceImpl implements UploadService {
         }
         bo.close();
         out.close();
-        return imageDomain + "/" + client.uploadFile(filePath);
+        String imageUrl = imageDomain + "/" + client.uploadFile(filePath);
+        // 删除临时图片
+        boolean delete = zipFile.delete();
+        log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片压缩包:" + delete);
+        return imageUrl;
     }
 
 

+ 154 - 0
src/main/java/com/caimei/utils/Encodes.java

@@ -0,0 +1,154 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ */
+package com.caimei.utils;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+/**
+ * 封装各种格式的编码解码工具类.
+ * 1.Commons-Codec的 hex/base64 编码
+ * 2.自制的base62 编码
+ * 3.Commons-Lang的xml/html escape
+ * 4.JDK提供的URLEncoder
+ * @author calvin
+ * @version 2013-01-15
+ */
+public class Encodes {
+
+	private static final String DEFAULT_URL_ENCODING = "UTF-8";
+	private static final char[] BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
+
+	/**
+	 * Hex编码.
+	 */
+	public static String encodeHex(byte[] input) {
+		return new String(Hex.encodeHex(input));
+	}
+
+	/**
+	 * Hex解码.
+	 */
+	public static byte[] decodeHex(String input) {
+		try {
+			return Hex.decodeHex(input.toCharArray());
+		} catch (DecoderException e) {
+		    e.printStackTrace();
+            return null;
+		}
+	}
+
+	/**
+	 * Base64编码.
+	 */
+	public static String encodeBase64(byte[] input) {
+		return new String(Base64.encodeBase64(input));
+	}
+	
+	/**
+	 * Base64编码.
+	 */
+	public static String encodeBase64(String input) {
+		try {
+			return new String(Base64.encodeBase64(input.getBytes(DEFAULT_URL_ENCODING)));
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+
+//	/**
+//	 * Base64编码, URL安全(将Base64中的URL非法字符'+'和'/'转为'-'和'_', 见RFC3548).
+//	 */
+//	public static String encodeUrlSafeBase64(byte[] input) {
+//		return Base64.encodeBase64URLSafe(input);
+//	}
+
+	/**
+	 * Base64解码.
+	 */
+	public static byte[] decodeBase64(String input) {
+		return Base64.decodeBase64(input.getBytes());
+	}
+	
+	/**
+	 * Base64解码.
+	 */
+	public static String decodeBase64String(String input) {
+		try {
+			return new String(Base64.decodeBase64(input.getBytes()), DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+
+	/**
+	 * Base62编码。
+	 */
+	public static String encodeBase62(byte[] input) {
+		char[] chars = new char[input.length];
+		for (int i = 0; i < input.length; i++) {
+			chars[i] = BASE62[((input[i] & 0xFF) % BASE62.length)];
+		}
+		return new String(chars);
+	}
+
+	/**
+	 * Html 转码.
+	 */
+	public static String escapeHtml(String html) {
+		return StringEscapeUtils.escapeHtml4(html);
+	}
+
+	/**
+	 * Html 解码.
+	 */
+	public static String unescapeHtml(String htmlEscaped) {
+		return StringEscapeUtils.unescapeHtml4(htmlEscaped);
+	}
+
+	/**
+	 * Xml 转码.
+	 */
+	public static String escapeXml(String xml) {
+		return StringEscapeUtils.escapeXml10(xml);
+	}
+
+	/**
+	 * Xml 解码.
+	 */
+	public static String unescapeXml(String xmlEscaped) {
+		return StringEscapeUtils.unescapeXml(xmlEscaped);
+	}
+
+	/**
+	 * URL 编码, Encode默认为UTF-8. 
+	 */
+	public static String urlEncode(String part) {
+		try {
+			return URLEncoder.encode(part, DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+            return "error";
+		}
+	}
+
+	/**
+	 * URL 解码, Encode默认为UTF-8. 
+	 */
+	public static String urlDecode(String part) {
+
+		try {
+			return URLDecoder.decode(part, DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+            return "error";
+		}
+	}
+}

+ 41 - 0
src/main/java/com/caimei/utils/ExcelNumberFormatter.java

@@ -0,0 +1,41 @@
+package com.caimei.utils;
+
+import com.caimei.module.pay.util.MathUtil;
+import org.apache.commons.lang.StringUtils;
+
+public class ExcelNumberFormatter {
+	
+	public String format(String bigDecimal){
+		if(bigDecimal == null){
+			return StringUtils.EMPTY;
+		}else{
+			return MathUtil.round(bigDecimal,2).toString();
+		}
+	}
+
+	public Double formatStr(String bigDecimal){
+		if(bigDecimal == null){
+			return 0.00;
+		}else{
+			return MathUtil.round(bigDecimal,2).doubleValue();
+		}
+	}
+
+	public String formatDouble(Double number){
+		if(number == null){
+			return StringUtils.EMPTY;
+		}else{
+			return MathUtil.round(number.toString(),2).toString();
+		}
+	}
+
+	public String addStr(Object str1, Object str2) {
+		if (str1 == null || str2 == null) return "";
+		return str1.toString() + str2.toString();
+	}
+
+	public String addStrings(Object str1, Object str2, Object str3, Object str4) {
+		if (str1 == null || str2 == null || str3 == null || str4 == null) return "";
+		return str1.toString() + str2.toString() + str3.toString() + str4.toString();
+	}
+}

+ 262 - 0
src/main/java/com/caimei/utils/ExcelOperateUtil.java

@@ -0,0 +1,262 @@
+package com.caimei.utils;
+
+import net.sf.jxls.exception.ParsePropertyException;
+import net.sf.jxls.transformer.XLSTransformer;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.*;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.util.*;
+
+@Component
+public class ExcelOperateUtil {
+    private static String active;
+
+    @Value("${spring.profiles.active}")
+    public void setActive(String active) {
+        ExcelOperateUtil.active = active;
+    }
+
+    public static Map<String, XSSFPictureData> getPictures(XSSFSheet sheet) throws IOException {
+        Map<String, XSSFPictureData> map = new HashMap<String, XSSFPictureData>();
+        List<XSSFShape> list = sheet.getDrawingPatriarch().getShapes();
+        for (XSSFShape shape : list) {
+            if (shape instanceof XSSFPicture) {
+                XSSFPicture picture = (XSSFPicture) shape;
+                XSSFClientAnchor cAnchor = (XSSFClientAnchor) picture.getAnchor();
+                XSSFPictureData pdata = picture.getPictureData();
+                String key = cAnchor.getRow1() + "-" + cAnchor.getCol1(); // 行号-列号
+                map.put(key, pdata);
+            }
+        }
+        return map;
+    }
+
+    public static Map<String,String> printImg(Map<String, XSSFPictureData> maplist) throws IOException {
+        Object[] key = maplist.keySet().toArray();
+        String imgSaveDir = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/";
+        if ("dev".equals(active)){
+            imgSaveDir = "D:\\WorkSpace\\file\\tempImport\\";
+        }
+        File file = new File(imgSaveDir);
+        //目录不存在则创建
+        if(!file.exists()) {
+            file.mkdirs();
+        }
+        Map<String,String> temMap = new HashMap<>();
+        for (int i = 0; i < maplist.size(); i++) {
+            // 获取图片流
+            XSSFPictureData pic = maplist.get(key[i]);
+            // 获取图片索引
+            //String picName = key[i].toString();
+            String jpgFileName = "img_" + UUID.randomUUID().toString().replaceAll("-","")+".jpg";
+            temMap.put(key[i].toString(), imgSaveDir + jpgFileName);
+            byte[] data = pic.getData();
+            //图片保存路径
+            FileOutputStream out = new FileOutputStream(imgSaveDir+jpgFileName);
+            out.write(data);
+            out.close();
+        }
+        return temMap;
+    }
+
+
+    /*public void downloadExcel(String templateFileName, String fileName, HttpServletResponse response) {
+        //得到模板文件路径
+        String srcFilePath = FileUtils.class.getClassLoader().getResource(templateFileName).getPath();
+        InputStream is = null;
+        OutputStream out = null;
+        //设置响应
+        response.setContentType("application/octet-stream; charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment; filename=" + Encodes.urlEncode(fileName));
+        try {
+            is = new BufferedInputStream(new FileInputStream(srcFilePath));
+            out = response.getOutputStream();
+            int i = 0;
+            byte[] buffer = new byte[1024];
+            while ((i = is.read(buffer)) != -1) {
+                out.write(buffer, 0, i);
+                out.flush();
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public void createExcel(String templateFileName, List<?> list, String fileName, HttpServletResponse response) {
+        //创建XLSTransformer对象
+        XLSTransformer transformer = new XLSTransformer();
+        //得到模板文件路径
+        String srcFilePath = FileUtils.class.getClassLoader().getResource(templateFileName).getPath();
+        Map<String, Object> beanParams = new HashMap<String, Object>();
+        beanParams.put("list", list);
+        ExcelDateFormatter simpleDateFormat = new ExcelDateFormatter();
+        ExcelNumberFormatter excelNumberFormatter = new ExcelNumberFormatter();
+        ExcelUserTypeFormatter excelUserTypeFormatter = new ExcelUserTypeFormatter();
+        beanParams.put("dateFormat", simpleDateFormat);
+        beanParams.put("excelNumberFormatter", excelNumberFormatter);
+        beanParams.put("excelUserTypeFormatter", excelUserTypeFormatter);
+        InputStream is = null;
+        OutputStream out = null;
+        //设置响应
+        response.setContentType("application/octet-stream; charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment; filename=" + Encodes.urlEncode(fileName));
+        try {
+            is = new BufferedInputStream(new FileInputStream(srcFilePath));
+            *//*这里调用了transformer.transformXLS(in, beans)方法得到一个Workbook,这方法会把模板
+             *(至于模板怎么写,详细看官方文档)先读入到输入流再处理,再把Workbook的内容写入到输出流发送出去.*//*
+            Workbook workbook = transformer.transformXLS(is, beanParams);
+            out = response.getOutputStream();
+            //将内容写入输出流并把缓存的内容全部发出去  an OLE2 stream, nor an OOXML stream----》模板文件有问题
+            workbook.write(out);
+            out.flush();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (ParsePropertyException e) {
+            e.printStackTrace();
+        } catch (InvalidFormatException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                }
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+    }*/
+
+    /**
+     * @param templateFileName 模板名
+     * @param fileName         导出报表的名称
+     * @param listSheetNames   形成Excel文件的时候Sheet的Name
+     * @param objects          我们传入的对应每个Sheet的一个Java对象
+     * @param response
+     */
+    public static void createMultipleSheetsExcel(String templateFileName, String fileName, List<String> listSheetNames, List<List> objects, HttpServletResponse response) {
+        //调用引擎生成excel报表
+        XLSTransformer transformer = new XLSTransformer();
+
+        //得到模板文件路径
+        String srcFilePath = templateFileName;
+        InputStream is = null;
+        OutputStream out = null;
+
+        //设置响应
+        response.setContentType("application/octet-stream; charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment; filename=" + Encodes.urlEncode(fileName));
+
+        try {
+            is = new BufferedInputStream(new FileInputStream(srcFilePath));
+		  /*
+	       * transformMultipleSheetsList(InputStream is, List objects, List newSheetNames, String beanName, Map beanParams, int startSheetNum)
+	       *1)is:即Template文件的一个输入流
+	        2)objects:即我们传入的对应每个Sheet的一个Java对象,这里传入的List的元素为一个Map对象
+	        3)newSheetNames:即形成Excel文件的时候Sheet的Name
+	        4)beanName:这个参数在jxls对我们传入的List进行解析的时候使用,而且,该参数还对应Template文件中的Tag,例如,beanName为map,那么在Template文件中取值的公式应该定义成${map.get("property1")};如果beanName为payslip,公式应该定义成${payslip.get("property1")}
+	        5)beanParams:这个参数在使用的时候我的代码没有使用到,这个参数是在如果传入的objects还与其他的对象关联的时候使用的,该参数是一个HashMap类型的参数,如果不使用的话,直接传入new HashMap()即可
+	        6)startSheetNo:传入0即可,即SheetNo从0开始
+	       */
+            HashMap hashMap = new HashMap();
+            hashMap.put("excelNumberFormatter", new ExcelNumberFormatter());
+            Workbook workbook = transformer.transformMultipleSheetsList(is, objects, listSheetNames, "list", hashMap, 0);
+            out = response.getOutputStream();
+            //将内容写入输出流并把缓存的内容全部发出去
+            workbook.write(out);
+            out.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                }
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+    }
+
+    /*public void createExcel(String srcFilePath, Map<String, Object> beanParams, String fileName, HttpServletResponse response) {
+        //创建XLSTransformer对象
+        XLSTransformer transformer = new XLSTransformer();
+        ExcelDateFormatter simpleDateFormat = new ExcelDateFormatter();
+        ExcelNumberFormatter excelNumberFormatter = new ExcelNumberFormatter();
+        ExcelUserTypeFormatter excelUserTypeFormatter = new ExcelUserTypeFormatter();
+        beanParams.put("dateFormat", simpleDateFormat);
+        beanParams.put("excelNumberFormatter", excelNumberFormatter);
+        beanParams.put("excelUserTypeFormatter", excelUserTypeFormatter);
+        InputStream is = null;
+        OutputStream out = null;
+        //设置响应
+        response.setContentType("application/octet-stream; charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment; filename=" + Encodes.urlEncode(fileName));
+        try {
+            is = new BufferedInputStream(new FileInputStream(srcFilePath));
+            *//*这里调用了transformer.transformXLS(in, beans)方法得到一个Workbook,这方法会把模板
+             *(至于模板怎么写,详细看官方文档)先读入到输入流再处理,再把Workbook的内容写入到输出流发送出去.*//*
+            Workbook workbook = transformer.transformXLS(is, beanParams);
+            out = response.getOutputStream();
+            //将内容写入输出流并把缓存的内容全部发出去  an OLE2 stream, nor an OOXML stream----》模板文件有问题
+            workbook.write(out);
+            out.flush();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (ParsePropertyException e) {
+            e.printStackTrace();
+        } catch (InvalidFormatException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                }
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+    }*/
+}

+ 1 - 1
src/main/java/com/caimei/utils/OSSUtils.java

@@ -178,7 +178,7 @@ public class OSSUtils {
         OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
         // 设置URL过期时间为1个小时
         Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
-        String url = ossClient.generatePresignedUrl(privateBucket, fileName, expiration).toString();
+        String url = ossClient.generatePresignedUrl(privateBucket, active + "/authFile/" + fileName, expiration).toString();
         // 关闭OSSClient。
         ossClient.shutdown();
         return url;

+ 13 - 1
src/main/resources/mapper/AuthMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.AuthMapper">
-    <insert id="insertAuth" >
+    <insert id="insertAuth" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmBrandAuthPo">
         insert into cm_brand_auth (authUserId, authParty, status, createTime, createBy, auditStatus)
         values (#{authUserId}, #{authParty}, #{status}, #{createTime}, #{createBy}, #{auditStatus})
     </insert>
@@ -71,4 +71,16 @@
         from cm_brand_auth
         where id = #{authId}
     </select>
+    <select id="getAuthIdByAuthParty" resultType="java.lang.Integer">
+        select id
+        from cm_brand_auth
+        where authParty = #{authParty}
+          and authUserId = #{authUserId}
+    </select>
+    <select id="getAuthPartyList" resultType="com.caimei.model.po.CmBrandAuthPo">
+        select id, authParty
+        from cm_brand_auth
+        where authUserId = #{authUserId}
+        order by createTime desc
+    </select>
 </mapper>

+ 10 - 0
src/main/resources/mapper/AuthProductMapper.xml

@@ -147,4 +147,14 @@
         </if>
         order by createTime desc
     </select>
+    <select id="getBrandIdByBrandName" resultType="java.lang.Integer">
+        select id from cm_brand where name = #{brand}
+    </select>
+    <select id="getAuthProductList" resultType="com.caimei.model.vo.ProductFormVo">
+        select p.id as productId,p.name as productName,snCode,cb.name as brandName,image as productImage,certificateImage
+        from cm_brand_auth_product p
+        left join cm_brand cb on p.brandId = cb.id
+        where authId = #{authId}
+        order by createTime desc
+    </select>
 </mapper>

+ 28 - 0
src/main/resources/mapper/FileMapper.xml

@@ -6,6 +6,10 @@
         values (#{authUserId}, #{title}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
                 #{createTime})
     </insert>
+    <insert id="insertCourseFile">
+        insert into cm_brand_course_file (title, name, ossName, type, module, createTime)
+        values (#{title}, #{name}, #{ossName}, #{type}, #{module}, NOW());
+    </insert>
     <update id="updateFileByFileId">
         update cm_brand_file
         set title       = #{title},
@@ -51,9 +55,21 @@
         </set>
         where id = #{id}
     </update>
+    <update id="updateCourseFile">
+        update cm_brand_course_file
+        set title   = #{title},
+            name    = #{name},
+            ossName = #{ossName},
+            type    = #{type},
+            module  = #{module}
+        where id = #{id}
+    </update>
     <delete id="deleteFileByFileId">
         delete from cm_brand_file where id = #{fileId}
     </delete>
+    <delete id="deleteCourseFileByFileId">
+        delete from cm_brand_course_file where id = #{fileId}
+    </delete>
     <select id="getFileList" resultType="com.caimei.model.vo.FileListVo">
         select a.id as fileId,a.title as fileTitle,a.name as fileName,a.previewUrl as filePreviewUrl,
         a.downloadUrl as fileDownloadUrl, a.auditStatus,a.invalidReason,a.status,a.createTime,
@@ -90,4 +106,16 @@
         </if>
         order by a.createTime desc
     </select>
+    <select id="getCourseFileList" resultType="com.caimei.model.vo.CourseFileListVo">
+        select title as fileTitle, name as fileName, ossName, module as fileModule, createTime
+        from cm_brand_course_file
+        where type = #{fileType}
+        <if test="fileTitle != null and fileTitle != ''">
+            and title = #{fileTitle}
+        </if>
+        <if test="fileModule != null">
+            and module = #{fileModule}
+        </if>
+        order by createTime desc
+    </select>
 </mapper>

+ 6 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -283,5 +283,11 @@
     <select id="getShopNameByAppId" resultType="java.lang.String">
         select name from cm_brand_auth_user where appId = #{appId} and status = 1
     </select>
+    <select id="getShopBrands" resultType="java.lang.String">
+        select b.name
+        from cm_brand_auth_shop_info i
+                 left join cm_brand b on i.brandId = b.id
+        where i.authUserId = #{authUserId}
+    </select>
 
 </mapper>