diff --git a/bonus-base/src/main/resources/mybatis/mybatis-config.xml b/bonus-base/src/main/resources/mybatis/mybatis-config.xml index ac47c03..4cc1e8d 100644 --- a/bonus-base/src/main/resources/mybatis/mybatis-config.xml +++ b/bonus-base/src/main/resources/mybatis/mybatis-config.xml @@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Config 3.0//EN" - + diff --git a/bonus-business/src/main/java/com/bonus/business/controller/MaterialController.java b/bonus-business/src/main/java/com/bonus/business/controller/MaterialController.java new file mode 100644 index 0000000..d5712b9 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/controller/MaterialController.java @@ -0,0 +1,144 @@ +package com.bonus.business.controller; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; + +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.business.domain.WebFileDto; +import com.bonus.business.service.ITbPromotionMaterialService; +import com.bonus.common.utils.FastJsonHelper; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; +import com.bonus.common.annotation.Log; +import com.bonus.common.core.controller.BaseController; +import com.bonus.common.core.domain.AjaxResult; +import com.bonus.common.enums.BusinessType; +import com.bonus.common.utils.poi.ExcelUtil; +import com.bonus.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 宣传物料信息Controller + * + * @author ruoyi + * @date 2025-09-10 + */ +@RestController +@RequestMapping("/system/material") +public class MaterialController extends BaseController { + @Resource + private ITbPromotionMaterialService service; + + /** + * 查询宣传物料信息列表 + */ +// @PreAuthorize("@ss.hasPermi('system:material:list')") + @GetMapping("/list") + public TableDataInfo list(TbPromotionMaterial tbPromotionMaterial) { + try { + startPage(); + List list = service.selectTbPromotionMaterialList(tbPromotionMaterial); + return getDataTable(list); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return getDataTable(new ArrayList<>()); + } + } + + + /** + * 获取宣传物料信息详细信息 + */ +// @PreAuthorize("@ss.hasPermi('system:material:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + try { + return success(service.selectTbPromotionMaterialById(id)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return error("系统异常,请联系管理员"); + } + } + + /** + * 新增宣传物料信息 + */ +// @PreAuthorize("@ss.hasPermi('system:material:add')") + @Log(title = "新增宣传物料信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestParam(value = "files") MultipartFile[] files,@RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) { + try { + List listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class); + // 验证对应关系 + if (listFile.size() != files.length || files.length != 2) { + return error("文件信息与文件数量不匹配或文件缺失"); + } + //先将数据对应关系处理 + for (int i = 0; i < listFile.size(); i++) { + listFile.get(i).setFile(files[i]); + } + TbPromotionMaterial tbPromotionMaterial = FastJsonHelper.jsonStrToBean(params, TbPromotionMaterial.class); + + return toAjax(service.insertTbPromotionMaterial(tbPromotionMaterial,listFile)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return error("系统异常,请联系管理员"); + } + } + + /** + * 修改宣传物料信息 + */ +// @PreAuthorize("@ss.hasPermi('system:material:edit')") + @Log(title = "修改宣传物料信息", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + public AjaxResult edit(@RequestParam(value = "files") MultipartFile[] files,@RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) { + try { + List listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class); + // 验证对应关系 + if (listFile.size() != files.length || files.length != 2) { + return error("文件信息与文件数量不匹配或文件缺失"); + } + //先将数据对应关系处理 + for (int i = 0; i < listFile.size(); i++) { + listFile.get(i).setFile(files[i]); + } + TbPromotionMaterial tbPromotionMaterial = FastJsonHelper.jsonStrToBean(params, TbPromotionMaterial.class); + + return toAjax(service.updateTbPromotionMaterial(tbPromotionMaterial,listFile)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return error("系统异常,请联系管理员"); + } + } + + /** + * 删除宣传物料信息 + */ +// @PreAuthorize("@ss.hasPermi('system:material:remove')") + @Log(title = "宣传物料信息", businessType = BusinessType.DELETE) + @PostMapping("/{id}") + public AjaxResult remove(@PathVariable Long id) { + try { + return toAjax(service.deleteTbPromotionMaterialById(id)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return error("系统异常,请联系管理员"); + } + } + + /** + * 导出宣传物料信息列表 + */ +// @PreAuthorize("@ss.hasPermi('system:material:export')") + @Log(title = "导出宣传物料信息列表", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, TbPromotionMaterial tbPromotionMaterial) { + List list = service.selectTbPromotionMaterialList(tbPromotionMaterial); + ExcelUtil util = new ExcelUtil(TbPromotionMaterial.class); + util.exportExcel(response, list, "宣传物料信息数据"); + } + +} diff --git a/bonus-business/src/main/java/com/bonus/business/controller/MaterialScreenController.java b/bonus-business/src/main/java/com/bonus/business/controller/MaterialScreenController.java new file mode 100644 index 0000000..68f02e8 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/controller/MaterialScreenController.java @@ -0,0 +1,33 @@ +package com.bonus.business.controller; + +import com.bonus.business.domain.TbProduct; +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.business.service.MaterialScreenService; +import com.bonus.business.service.ProductScreenService; +import com.bonus.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 产品大屏 + */ +@RestController +@RequestMapping("/screen/material/") +public class MaterialScreenController { + + @Autowired + private MaterialScreenService service; + /** + * 展示中心查询 + * @param o + * @return + */ + + @PostMapping("/getMaterialList") + public AjaxResult getMaterialList(TbPromotionMaterial o ){ + return service.getMaterialList(o) ; + } + +} diff --git a/bonus-business/src/main/java/com/bonus/business/controller/SelectController.java b/bonus-business/src/main/java/com/bonus/business/controller/SelectController.java new file mode 100644 index 0000000..f2242d7 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/controller/SelectController.java @@ -0,0 +1,40 @@ +package com.bonus.business.controller; + +import com.bonus.business.domain.MapBeanPo; +import com.bonus.business.service.SelectService; +import com.bonus.common.core.controller.BaseController; +import com.bonus.common.core.domain.AjaxResult; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @Description: 公用下拉框控制器 + * @Author: fly + * @Date: 2025/9/10 + */ +@RestController +@RequestMapping("/select") +public class SelectController extends BaseController { + + @Resource + private SelectService service; + + /** + * 查询产品列表 + * @param po + * @return + */ + @PostMapping("/selectProduct") + public AjaxResult selectProduct(MapBeanPo po){ + try{ + return service.selectProduct(po); + }catch (Exception e){ + logger.error(e.toString(),e); + } + return AjaxResult.error("查询产品下拉框失败"); + } + +} diff --git a/bonus-business/src/main/java/com/bonus/business/domain/MapBeanPo.java b/bonus-business/src/main/java/com/bonus/business/domain/MapBeanPo.java new file mode 100644 index 0000000..b974105 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/domain/MapBeanPo.java @@ -0,0 +1,25 @@ +package com.bonus.business.domain; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Data +public class MapBeanPo { + + private Integer id; + + private String name; + + private Integer subComId; + + private Integer proId; + + private Integer subId; + + public MapBeanPo(Integer id, String name) { + this.id = id; + this.name = name; + } + +} diff --git a/bonus-business/src/main/java/com/bonus/business/domain/MapBeanVo.java b/bonus-business/src/main/java/com/bonus/business/domain/MapBeanVo.java new file mode 100644 index 0000000..1ad47f2 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/domain/MapBeanVo.java @@ -0,0 +1,25 @@ +package com.bonus.business.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MapBeanVo { + + private String key; + + private String value; + + private Integer id; + + private String name; + + public MapBeanVo(String key, String value){ + this.value = value; + this.key = key; + } + +} diff --git a/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterial.java b/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterial.java index 557604a..0f262c3 100644 --- a/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterial.java +++ b/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterial.java @@ -1,16 +1,23 @@ package com.bonus.business.domain; import com.bonus.common.core.domain.BaseEntity; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.bonus.common.annotation.Excel; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + /** * 宣传物料信息对象 tb_promotion_material * * @author ruoyi * @date 2025-09-10 */ +@Data public class TbPromotionMaterial extends BaseEntity { private static final long serialVersionUID = 1L; @@ -50,139 +57,56 @@ public class TbPromotionMaterial extends BaseEntity @Excel(name = "修改人") private Long updateUser; - /** 删除状态 */ - private String delFlag; - /** 产品名称(通过,拼接) */ @Excel(name = "产品名称(通过,拼接)") private String productName; - public void setId(Long id) - { + private String productId; + + /** 删除状态 */ + private String delFlag; + + /** 文件类型 0 视频 1文档 */ + private String fileType; + + /** 文件地址 */ + private String filePath; + + /** 文件 */ + private List files; + + + // 构造函数 + public TbPromotionMaterial() {} + + public TbPromotionMaterial(Long id, String productName, String productId) { this.id = id; - } - - public Long getId() - { - return id; - } - - public void setName(String name) - { - this.name = name; - } - - public String getName() - { - return name; - } - - public void setTypeId(Long typeId) - { - this.typeId = typeId; - } - - public Long getTypeId() - { - return typeId; - } - - public void setTypeName(String typeName) - { - this.typeName = typeName; - } - - public String getTypeName() - { - return typeName; - } - - public void setImage(String image) - { - this.image = image; - } - - public String getImage() - { - return image; - } - - public void setVersion(String version) - { - this.version = version; - } - - public String getVersion() - { - return version; - } - - public void setDescription(String description) - { - this.description = description; - } - - public String getDescription() - { - return description; - } - - public void setCreateUser(Long createUser) - { - this.createUser = createUser; - } - - public Long getCreateUser() - { - return createUser; - } - - public void setUpdateUser(Long updateUser) - { - this.updateUser = updateUser; - } - - public Long getUpdateUser() - { - return updateUser; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getDelFlag() - { - return delFlag; - } - - public void setProductName(String productName) - { this.productName = productName; + this.productId = productId; } - public String getProductName() - { - return productName; + /** + * 将单个 TbPromotionMaterial 拆分为多个对象 + */ + public List split(TbPromotionMaterial source) { + if (source == null || source.getProductName() == null || source.getProductId() == null) { + return Collections.emptyList(); + } + String[] names = source.getProductName().split(","); + String[] ids = source.getProductId().split(","); + // 检查长度是否一致 + if (names.length != ids.length) { + throw new IllegalArgumentException("productName 和 productId 的数量不匹配"); + } + return IntStream.range(0, names.length) + .mapToObj(i -> { + TbPromotionMaterial item = new TbPromotionMaterial(); + item.setId(source.getId()); + item.setProductName(names[i].trim()); // 去除空格 + item.setProductId(ids[i].trim()); + return item; + }) + .collect(Collectors.toList()); } - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("name", getName()) - .append("typeId", getTypeId()) - .append("typeName", getTypeName()) - .append("image", getImage()) - .append("version", getVersion()) - .append("description", getDescription()) - .append("createUser", getCreateUser()) - .append("createTime", getCreateTime()) - .append("updateUser", getUpdateUser()) - .append("updateTime", getUpdateTime()) - .append("delFlag", getDelFlag()) - .append("productName", getProductName()) - .toString(); - } } diff --git a/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterialFiles.java b/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterialFiles.java index 1578498..5b16069 100644 --- a/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterialFiles.java +++ b/bonus-business/src/main/java/com/bonus/business/domain/TbPromotionMaterialFiles.java @@ -1,6 +1,8 @@ package com.bonus.business.domain; import com.bonus.common.core.domain.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.bonus.common.annotation.Excel; @@ -11,6 +13,8 @@ import com.bonus.common.annotation.Excel; * @author ruoyi * @date 2025-09-10 */ +@EqualsAndHashCode(callSuper = true) +@Data public class TbPromotionMaterialFiles extends BaseEntity { private static final long serialVersionUID = 1L; @@ -35,152 +39,26 @@ public class TbPromotionMaterialFiles extends BaseEntity private String fileType; /** 文件前缀 */ - @Excel(name = "文件前缀") - private String folderPath; + @Excel(name = "桶名称") + private String bucketName; /** 原文件名称 */ @Excel(name = "原文件名称") private String originalName; - /** 文件大小 */ - @Excel(name = "文件大小") - private String fileSize; - /** 文件名称 */ @Excel(name = "文件名称") private String fileName; /** 访问路径=前缀+文件名 */ - @Excel(name = "访问路径=前缀+文件名") + @Excel(name = "访问路径") private String filePath; + /** 文件大小 */ + @Excel(name = "文件大小") + private String fileSize; + /** 删除状态 */ private String delFlag; - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - - public void setMaterialId(Long materialId) - { - this.materialId = materialId; - } - - public Long getMaterialId() - { - return materialId; - } - - public void setTypeId(Long typeId) - { - this.typeId = typeId; - } - - public Long getTypeId() - { - return typeId; - } - - public void setTypeName(String typeName) - { - this.typeName = typeName; - } - - public String getTypeName() - { - return typeName; - } - - public void setFileType(String fileType) - { - this.fileType = fileType; - } - - public String getFileType() - { - return fileType; - } - - public void setFolderPath(String folderPath) - { - this.folderPath = folderPath; - } - - public String getFolderPath() - { - return folderPath; - } - - public void setOriginalName(String originalName) - { - this.originalName = originalName; - } - - public String getOriginalName() - { - return originalName; - } - - public void setFileSize(String fileSize) - { - this.fileSize = fileSize; - } - - public String getFileSize() - { - return fileSize; - } - - public void setFileName(String fileName) - { - this.fileName = fileName; - } - - public String getFileName() - { - return fileName; - } - - public void setFilePath(String filePath) - { - this.filePath = filePath; - } - - public String getFilePath() - { - return filePath; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getDelFlag() - { - return delFlag; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("materialId", getMaterialId()) - .append("typeId", getTypeId()) - .append("typeName", getTypeName()) - .append("fileType", getFileType()) - .append("folderPath", getFolderPath()) - .append("originalName", getOriginalName()) - .append("fileSize", getFileSize()) - .append("fileName", getFileName()) - .append("filePath", getFilePath()) - .append("delFlag", getDelFlag()) - .toString(); - } } diff --git a/bonus-business/src/main/java/com/bonus/business/domain/WebFileDto.java b/bonus-business/src/main/java/com/bonus/business/domain/WebFileDto.java new file mode 100644 index 0000000..1e0c393 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/domain/WebFileDto.java @@ -0,0 +1,27 @@ +package com.bonus.business.domain; + +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +/** + * @author: fly + * @date: 2025/08/14 + */ +@Data +public class WebFileDto { + + /** + * 文件类型名称 + */ + private String name; + /** + * 文件类型下级编号 + */ + private String type; + + + private MultipartFile file; + + private String base64File; + +} diff --git a/bonus-business/src/main/java/com/bonus/business/mapper/MaterialScreenMapper.java b/bonus-business/src/main/java/com/bonus/business/mapper/MaterialScreenMapper.java new file mode 100644 index 0000000..628a892 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/mapper/MaterialScreenMapper.java @@ -0,0 +1,14 @@ +package com.bonus.business.mapper; + +import com.bonus.business.domain.TbProduct; +import com.bonus.business.domain.TbPromotionMaterial; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface MaterialScreenMapper { + + List getMaterialList(TbPromotionMaterial product); + +} diff --git a/bonus-business/src/main/java/com/bonus/business/mapper/SelectMapper.java b/bonus-business/src/main/java/com/bonus/business/mapper/SelectMapper.java new file mode 100644 index 0000000..53f6ec1 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/mapper/SelectMapper.java @@ -0,0 +1,21 @@ +package com.bonus.business.mapper; + + +import com.bonus.business.domain.MapBeanPo; +import com.bonus.business.domain.MapBeanVo; +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.common.core.domain.AjaxResult; + +import java.util.List; + +/** + * 宣传物料信息Mapper接口 + * + * @author ruoyi + * @date 2025-09-10 + */ +public interface SelectMapper { + + List selectProduct(MapBeanPo po); + +} diff --git a/bonus-business/src/main/java/com/bonus/business/mapper/TbPromotionMaterialMapper.java b/bonus-business/src/main/java/com/bonus/business/mapper/TbPromotionMaterialMapper.java new file mode 100644 index 0000000..f0dd2e2 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/mapper/TbPromotionMaterialMapper.java @@ -0,0 +1,93 @@ +package com.bonus.business.mapper; + + +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.business.domain.TbPromotionMaterialFiles; + +import java.util.List; + +/** + * 宣传物料信息Mapper接口 + * + * @author ruoyi + * @date 2025-09-10 + */ +public interface TbPromotionMaterialMapper { + /** + * 查询宣传物料信息 + * + * @param id 宣传物料信息主键 + * @return 宣传物料信息 + */ + public TbPromotionMaterial selectTbPromotionMaterialById(Long id); + + /** + * 查询宣传物料信息列表 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 宣传物料信息集合 + */ + public List selectTbPromotionMaterialList(TbPromotionMaterial tbPromotionMaterial); + + /** + * 新增宣传物料信息 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 结果 + */ + public int insertTbPromotionMaterial(TbPromotionMaterial tbPromotionMaterial); + + /** + * 修改宣传物料信息 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 结果 + */ + public int updateTbPromotionMaterial(TbPromotionMaterial tbPromotionMaterial); + + /** + * 删除宣传物料信息 + * + * @param id 宣传物料信息主键 + * @return 结果 + */ + public int deleteTbPromotionMaterialById(Long id); + + /** + * 批量新增文件 + * + * @param materialFile 宣传物料信息 + * @return 结果 + */ + int insertMaterialFile(TbPromotionMaterialFiles materialFile); + + /** + * 根据id查询文件 + * @param o 数据id + * @return 文件列表 + */ + List getFileMaterialId(TbPromotionMaterial o); + + /** + * 批量新增物料与产品的关联 + * + * @param split 宣传物料信息 + * @return 影响行数 + */ + int insertMaterialProductRelevance(List split); + + /** + * 删除物料与产品的关联 + * + * @param id 宣传物料信息id + * @return 影响行数 + */ + int deleteMaterialProductRelevance(Long id); + + /** + * 修改物料封面 + * + * @param bean 宣传物料信息 + */ + void updateCover(TbPromotionMaterial bean); +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/ITbPromotionMaterialService.java b/bonus-business/src/main/java/com/bonus/business/service/ITbPromotionMaterialService.java new file mode 100644 index 0000000..63eb550 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/ITbPromotionMaterialService.java @@ -0,0 +1,56 @@ +package com.bonus.business.service; + +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.business.domain.WebFileDto; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * 宣传物料信息Service接口 + * + * @author ruoyi + * @date 2025-09-10 + */ +public interface ITbPromotionMaterialService +{ + /** + * 查询宣传物料信息 + * + * @param id 宣传物料信息主键 + * @return 宣传物料信息 + */ + public TbPromotionMaterial selectTbPromotionMaterialById(Long id); + + /** + * 查询宣传物料信息列表 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 宣传物料信息集合 + */ + public List selectTbPromotionMaterialList(TbPromotionMaterial tbPromotionMaterial); + + /** + * 新增宣传物料信息 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 结果 + */ + public int insertTbPromotionMaterial(TbPromotionMaterial tbPromotionMaterial, List listFiles); + + /** + * 修改宣传物料信息 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 结果 + */ + public int updateTbPromotionMaterial(TbPromotionMaterial tbPromotionMaterial,List listFiles); + + /** + * 删除宣传物料信息信息 + * + * @param id 宣传物料信息主键 + * @return 结果 + */ + public int deleteTbPromotionMaterialById(Long id); +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/MaterialScreenService.java b/bonus-business/src/main/java/com/bonus/business/service/MaterialScreenService.java new file mode 100644 index 0000000..e8b7e7b --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/MaterialScreenService.java @@ -0,0 +1,15 @@ +package com.bonus.business.service; + +import com.bonus.business.domain.TbProduct; +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.common.core.domain.AjaxResult; + +public interface MaterialScreenService { + /** + * 查询展示中心 + * @param o + * @return + */ + AjaxResult getMaterialList(TbPromotionMaterial o); + +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/SelectService.java b/bonus-business/src/main/java/com/bonus/business/service/SelectService.java new file mode 100644 index 0000000..d83fac7 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/SelectService.java @@ -0,0 +1,19 @@ +package com.bonus.business.service; + +import com.bonus.business.domain.MapBeanPo; +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.common.core.domain.AjaxResult; + +import java.util.List; + +/** + * 宣传物料信息Service接口 + * + * @author ruoyi + * @date 2025-09-10 + */ +public interface SelectService +{ + + AjaxResult selectProduct(MapBeanPo po); +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/MaterialScreenServiceImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/MaterialScreenServiceImpl.java new file mode 100644 index 0000000..c454395 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/MaterialScreenServiceImpl.java @@ -0,0 +1,52 @@ +package com.bonus.business.service.impl; + +import com.bonus.business.domain.ProductCaseImage; +import com.bonus.business.domain.TbProduct; +import com.bonus.business.domain.TbProductCase; +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.business.mapper.MaterialScreenMapper; +import com.bonus.business.mapper.ProductMapper; +import com.bonus.business.mapper.ProductScreenMapper; +import com.bonus.business.service.MaterialScreenService; +import com.bonus.business.service.ProductScreenService; +import com.bonus.common.config.MinioConfig; +import com.bonus.common.core.domain.AjaxResult; +import com.bonus.common.utils.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Service +public class MaterialScreenServiceImpl implements MaterialScreenService { + + @Autowired + private MaterialScreenMapper mapper; + + @Resource + private MinioConfig minioConfig; + + + @Override + public AjaxResult getMaterialList(TbPromotionMaterial o) { + try{ + List list = mapper.getMaterialList(o); + if(StringUtils.isNotEmpty(list)){ + list.forEach(vo->{ + vo.setImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName()+vo.getImage()); + vo.setFilePath(minioConfig.getUrl()+"/"+minioConfig.getBucketName()+vo.getFilePath()); + }); + } + return AjaxResult.success(list); + }catch (Exception e){ + log.error(e.toString()); + } + return AjaxResult.success(new ArrayList()); + } + + +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/SelectServiceImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/SelectServiceImpl.java new file mode 100644 index 0000000..2cd70df --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/SelectServiceImpl.java @@ -0,0 +1,34 @@ +package com.bonus.business.service.impl; + +import com.bonus.business.domain.MapBeanPo; +import com.bonus.business.domain.MapBeanVo; +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.business.mapper.SelectMapper; +import com.bonus.business.mapper.TbPromotionMaterialMapper; +import com.bonus.business.service.ITbPromotionMaterialService; +import com.bonus.business.service.SelectService; +import com.bonus.common.core.domain.AjaxResult; +import com.bonus.common.utils.DateUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 宣传物料信息Service业务层处理 + * + * @author ruoyi + * @date 2025-09-10 + */ +@Service +public class SelectServiceImpl implements SelectService +{ + @Resource + private SelectMapper mapper; + + @Override + public AjaxResult selectProduct(MapBeanPo po) { + List list =mapper.selectProduct(po); + return AjaxResult.success(list); + } +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/TbPromotionMaterialServiceImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/TbPromotionMaterialServiceImpl.java new file mode 100644 index 0000000..bcb4e77 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/TbPromotionMaterialServiceImpl.java @@ -0,0 +1,203 @@ +package com.bonus.business.service.impl; + +import java.util.List; +import java.util.Objects; + +import com.bonus.business.domain.ProductCaseImage; +import com.bonus.business.domain.TbPromotionMaterial; +import com.bonus.business.domain.TbPromotionMaterialFiles; +import com.bonus.business.domain.WebFileDto; +import com.bonus.business.mapper.TbPromotionMaterialMapper; +import com.bonus.business.service.ITbPromotionMaterialService; +import com.bonus.common.config.MinioConfig; +import com.bonus.common.core.domain.AjaxResult; +import com.bonus.common.utils.DateUtils; +import com.bonus.common.utils.SecurityUtils; +import com.bonus.common.utils.StringUtils; +import com.bonus.common.utils.file.FileTypeUtils; +import com.bonus.file.config.SysFile; +import com.bonus.file.service.FileUploadService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * 宣传物料信息Service业务层处理 + * + * @author ruoyi + * @date 2025-09-10 + */ +@Service +public class TbPromotionMaterialServiceImpl implements ITbPromotionMaterialService +{ + @Resource + private TbPromotionMaterialMapper mapper; + + @Autowired + private MinioConfig minioConfig; + + @Resource + private FileUploadService fileUploadService; + + public String day= DateUtils.getCurrentYear(); + + public String month=DateUtils.getCurrentMonth(); + + public String year=DateUtils.getCurrentYear(); + + /** + * 查询宣传物料信息列表 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 宣传物料信息 + */ + @Override + public List selectTbPromotionMaterialList(TbPromotionMaterial tbPromotionMaterial) + { + List tbPromotionMaterials = mapper.selectTbPromotionMaterialList(tbPromotionMaterial); + for (TbPromotionMaterial bean : tbPromotionMaterials) { + //查询附件 + bean.setTypeId(2L); + List files = mapper.getFileMaterialId(bean); + //拼接个访问前缀 + for (TbPromotionMaterialFiles o: files) { + o.setFilePath(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + o.getFilePath()); + } + bean.setFiles(files); + } + return tbPromotionMaterials; + } + + /** + * 查询宣传物料信息 + * + * @param id 宣传物料信息主键 + * @return 宣传物料信息 + */ + @Override + public TbPromotionMaterial selectTbPromotionMaterialById(Long id) + { + TbPromotionMaterial bean = mapper.selectTbPromotionMaterialById(id); + //查询所有文件 + List files = mapper.getFileMaterialId(bean); + //拼接个访问前缀 + for (TbPromotionMaterialFiles o: files) { + o.setFilePath(minioConfig.getUrl()+"/"+minioConfig.getBucketName() + o.getFilePath()); + } + bean.setFiles(files); + return bean; + } + + /** + * 新增宣传物料信息 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 结果 + */ + @Override + public int insertTbPromotionMaterial(TbPromotionMaterial tbPromotionMaterial, List listFiles) + { + tbPromotionMaterial.setCreateUser(SecurityUtils.getUserId()); + tbPromotionMaterial.setCreateTime(DateUtils.getNowDate()); + int i = mapper.insertTbPromotionMaterial(tbPromotionMaterial); + if (i > 0) { + //删除以前的关联关系 + int x = mapper.deleteMaterialProductRelevance(tbPromotionMaterial.getId()); + //将产品与物料关系存到另一张表 + List split = tbPromotionMaterial.split(tbPromotionMaterial); + int n = mapper.insertMaterialProductRelevance(split); + //将物料文件上传 + int m = uploadFile(listFiles, "tb_promotion_material_files", tbPromotionMaterial.getId()); + } + return i; + } + + /** + * 修改宣传物料信息 + * + * @param tbPromotionMaterial 宣传物料信息 + * @return 结果 + */ + @Override + public int updateTbPromotionMaterial(TbPromotionMaterial tbPromotionMaterial,List listFiles) + { + tbPromotionMaterial.setUpdateUser(SecurityUtils.getUserId()); + tbPromotionMaterial.setUpdateTime(DateUtils.getNowDate()); + int i = mapper.updateTbPromotionMaterial(tbPromotionMaterial); + if (i > 0) { + //将产品与物料关系存到另一张表 + List split = tbPromotionMaterial.split(tbPromotionMaterial); + int n = mapper.insertMaterialProductRelevance(split); + //将物料文件上传 + int m = uploadFile(listFiles, "tb_promotion_material_files", tbPromotionMaterial.getId()); + } + return i; + } + + /** + * 删除宣传物料信息信息 + * + * @param id 宣传物料信息主键 + * @return 结果 + */ + @Override + public int deleteTbPromotionMaterialById(Long id) + { + //删除以前的关联关系 + int x = mapper.deleteMaterialProductRelevance(id); + return mapper.deleteTbPromotionMaterialById(id); + } + + /** + * 上传附件 + * @param + * @return + */ + public int uploadFile(List listFiles, String tableId, Long sourceId){ + int i = 0; + for (WebFileDto fileData: listFiles) { + MultipartFile file = fileData.getFile(); + boolean videoFile = FileTypeUtils.isVideoFile(file); + String uuid = StringUtils.randomUUID(); + String originFileName = file.getOriginalFilename(); + String suffix=StringUtils.substringAfterLast(originFileName, "."); + //产品 封面 + String filePath = "/material" + "/" + + year + "/" + month + "/" + day + "/" + uuid + "." + suffix; + SysFile sysFile = fileUploadService.uploadLargeFile(file, filePath); + TbPromotionMaterialFiles materialFile=new TbPromotionMaterialFiles(); + materialFile.setMaterialId(sourceId); + materialFile.setTypeId(Long.valueOf(fileData.getType())); + materialFile.setTypeName(Objects.equals(fileData.getType(), "1") ?"封面":"附件"); + materialFile.setFileType(videoFile?"0":"1"); + materialFile.setBucketName(minioConfig.getBucketName()); + materialFile.setOriginalName(originFileName); + materialFile.setFileName(uuid+"." + suffix); + materialFile.setFilePath(filePath); + // 获取文件大小(字节) + long sizeInBytes = file.getSize(); + // 转换为可读格式(如KB/MB) + String humanReadableSize = convertToHumanReadable(sizeInBytes); + materialFile.setFileSize(humanReadableSize); + i += mapper.insertMaterialFile(materialFile); + //如果是封面存入主表 + if (Objects.equals(fileData.getType(), "1")) { + TbPromotionMaterial bean = new TbPromotionMaterial(); + bean.setId(sourceId); + bean.setImage(filePath); + mapper.updateCover(bean); + } + } + return i==listFiles.size()?1:0; + } + + // 辅助方法:字节转可读格式 + private String convertToHumanReadable(long bytes) { + if (bytes < 1024) return bytes + " B"; + else if (bytes < 1024 * 1024) return String.format("%.2f KB", bytes / 1024.0); + else return String.format("%.2f MB", bytes / (1024 * 1024.0)); + } + +} diff --git a/bonus-business/src/main/resources/mapper/business/MaterialScreenMapper.xml b/bonus-business/src/main/resources/mapper/business/MaterialScreenMapper.xml new file mode 100644 index 0000000..baf854b --- /dev/null +++ b/bonus-business/src/main/resources/mapper/business/MaterialScreenMapper.xml @@ -0,0 +1,32 @@ + + + + + + \ No newline at end of file diff --git a/bonus-business/src/main/resources/mapper/business/SelectMapper.xml b/bonus-business/src/main/resources/mapper/business/SelectMapper.xml new file mode 100644 index 0000000..314f06a --- /dev/null +++ b/bonus-business/src/main/resources/mapper/business/SelectMapper.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/bonus-business/src/main/resources/mapper/business/TbPromotionMaterialMapper.xml b/bonus-business/src/main/resources/mapper/business/TbPromotionMaterialMapper.xml new file mode 100644 index 0000000..014e2f8 --- /dev/null +++ b/bonus-business/src/main/resources/mapper/business/TbPromotionMaterialMapper.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + select id, name, type_id, type_name, image, version, description, create_user, create_time, update_user, update_time, del_flag, product_name from tb_promotion_material + + + + + + + + insert into tb_promotion_material + + id, + name, + type_id, + type_name, + image, + version, + description, + create_user, + create_time, + update_user, + update_time, + del_flag, + product_name, + + + #{id}, + #{name}, + #{typeId}, + #{typeName}, + #{image}, + #{version}, + #{description}, + #{createUser}, + #{createTime}, + #{updateUser}, + #{updateTime}, + #{delFlag}, + #{productName}, + + + + + update tb_promotion_material + + name = #{name}, + type_id = #{typeId}, + type_name = #{typeName}, + image = #{image}, + version = #{version}, + description = #{description}, + create_user = #{createUser}, + create_time = #{createTime}, + update_user = #{updateUser}, + update_time = #{updateTime}, + del_flag = #{delFlag}, + product_name = #{productName}, + + where id = #{id} + + + + update tb_promotion_material set del_flag = 1 where id = #{id} + + + + insert into tb_promotion_material_files + (material_id, type_id, type_name, file_type, bucket_name, original_name, file_size, file_name, file_path) + values (#{materialId}, #{typeId}, #{typeName}, #{fileType}, #{bucketName}, #{originalName}, #{fileSize}, #{fileName}, #{filePath}) + + + + + + insert into tb_promotion_material_product + (material_id, product_id,product_name) + values + + (#{item.id}, #{item.productId}, #{item.productName}) + + + + + delete from tb_promotion_material_product where material_id = #{id} + + + + update tb_promotion_material set image = #{image} where id = #{id} + + \ No newline at end of file diff --git a/bonus-common/src/main/java/com/bonus/common/utils/DateUtils.java b/bonus-common/src/main/java/com/bonus/common/utils/DateUtils.java index 1c83573..978a596 100644 --- a/bonus-common/src/main/java/com/bonus/common/utils/DateUtils.java +++ b/bonus-common/src/main/java/com/bonus/common/utils/DateUtils.java @@ -139,10 +139,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { * * @param endDate 结束日期 * @param startDate 开始日期 - * @param separator 自定义拼接符 * @return 时间差字符串 */ - public static String timeDistance(Date endDate, Date startDate, String separator) { + public static String timeDistance(Date endDate, Date startDate,String separator) { long duration = endDate.getTime() - startDate.getTime(); long days = TimeUnit.MILLISECONDS.toDays(duration); long hours = TimeUnit.MILLISECONDS.toHours(duration) % 24; diff --git a/bonus-common/src/main/java/com/bonus/common/utils/FastJsonHelper.java b/bonus-common/src/main/java/com/bonus/common/utils/FastJsonHelper.java new file mode 100644 index 0000000..2a41009 --- /dev/null +++ b/bonus-common/src/main/java/com/bonus/common/utils/FastJsonHelper.java @@ -0,0 +1,186 @@ +package com.bonus.common.utils; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; + +import java.util.List; + +/** + * @author fly + * @version 1 + * json与jsonArray所有自定义bean嵌套的相关操作 + * 将fast json 简单的封装和添加注释而成 + * + * com.alibaba + * fastjson + * 1.2.47 + * + *修改时间:2021-09-30 + */ + public class FastJsonHelper { + + /** + * JSONArray : 相当于 List + * JSONObject: 相当于 Map + * public static final Object parse(String text); // 把JSON文本parse为JSONObject或者JSONArray + * public static final JSONObject parseObject(String text); // 把JSON文本parse成JSONObject + * public static final T parseObject(String text, Class clazz); // 把JSON文本parse为JavaBean + * public static final JSONArray parseArray(String text); // 把JSON文本parse成JSONArray + * public static final List< > parseArray(String text, Class clazz); //把JSON文本parse成JavaBean集合 + * public static final String toJSONString(Object object); // 将JavaBean序列化为JSON文本 || JSONObject转成JSON文本 + * public static final String toJSONString(Object object, boolean prettyFormat); // 将JavaBean序列化为带格式的JSON文本 + * public static final Object toJSON(Object javaObject); //将JavaBean转换为JSONObject或者JSONArray。 + */ + + + + /** + * 将任意bean转换成json字符串 + * fast json + * @param bean + * @param + * @return + */ + public static String beanToJsonStr(T bean) { + String jsonStr = JSON.toJSONString(bean); + return jsonStr; + } + + /** + * 把一个json字符串转换成bean对象 + * fast json + * @param str + * @param + * @return + */ + public static T jsonStrToBean(String str, Class clazz) { + T bean = JSON.parseObject(str, clazz); + return bean; + } + + /** + * 把一个jsonObj转换成bean对象 + * fast json + * @param jsonObj + * @param + * @return + */ + public static T jsonObjToBean(JSONObject jsonObj, Class clazz) { + String s = jsonObj.toJSONString(); + T bean = JSON.parseObject(s, clazz); + return bean; + } + + /** + * 把一个bean对象转换成jsonObj + * fast json + * @param bean + * @param + * @return + */ + public static JSONObject beanToJsonObj(T bean) { + Object o = JSON.toJSON(bean); + return (JSONObject) o; + } + + /** + * 把一个jsonStr转换成jsonObj + * fast json + * @param str + * @return + */ + public static JSONObject jsonStrToJsonObj(String str) { + Object o = JSON.parseObject(str); + return (JSONObject) o; + } + + /** + * 把一个jsonObj转换成jsonStr + * fast json + * @param jsonObj + * @return + */ + public static String jsonObjToJsonStr(JSONObject jsonObj) { + String s = jsonObj.toJSONString(); + return s; + } + + + /** + * 把一个beanList对象转换成jsonArrStr + * fast json + * @param beanList + * @param + * @return + */ + public static String beanListToJsonArrStr(List beanList) { + JSONArray o = (JSONArray)JSON.toJSON(beanList); + String s = JSON.toJSONString(o); + return s; + } + + /** + * 把一个jsonArrStr转换成beanList对象 + * fast json + * @param jsonArrStr + * @param + * @return + */ + public static List jsonArrStrToBeanList(String jsonArrStr, Class clazz) { + List ts = JSON.parseArray(jsonArrStr, clazz); + return ts; + } + + + /** + * 把一个JsonArr转换成JsonArrStr + * fast json + * @param jsonArr + * @return + */ + public static String jsonArrToJsonArrStr(JSONArray jsonArr) { + String s = JSON.toJSONString(jsonArr); + return s; + } + + + /** + * 把一个JsonArrStr文本转换成JsonArr + * fast json + * @param jsonArrStr + * @return + */ + public static JSONArray jsonArrStrToJsonArr(String jsonArrStr) { + Object o = JSON.parse(jsonArrStr); + return (JSONArray) o; + } + + + /** + * 把一个JsonArr转换成beanList + * fast json + * @param jsonArr + * @return + */ + public static List jsonArrToBeanList(JSONArray jsonArr, Class clazz) { + String s = JSON.toJSONString(jsonArr); + List ts = JSON.parseArray(s, clazz); + return ts; + } + + + /** + * 把一个beanList文本转换成JsonArr + * fast json + * @param beanList + * @return + */ + public static JSONArray beanListToJsonArr(List beanList) { + Object o = JSON.toJSON(beanList); + return (JSONArray) o; + } + + + } + diff --git a/bonus-common/src/main/java/com/bonus/common/utils/file/FileTypeUtils.java b/bonus-common/src/main/java/com/bonus/common/utils/file/FileTypeUtils.java index 11ebbc3..ded162b 100644 --- a/bonus-common/src/main/java/com/bonus/common/utils/file/FileTypeUtils.java +++ b/bonus-common/src/main/java/com/bonus/common/utils/file/FileTypeUtils.java @@ -1,7 +1,11 @@ package com.bonus.common.utils.file; import java.io.File; +import java.io.IOException; +import java.util.Arrays; + import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; /** * 文件类型工具类 @@ -10,6 +14,35 @@ import org.apache.commons.lang3.StringUtils; */ public class FileTypeUtils { + + // 常见视频文件的文件头(十六进制) + private static final String[] VIDEO_HEADER_PREFIXES = { + "000001BA", // MPEG + "000001B3", // MPEG + "66747970", // MP4 + "464C56", // FLV + "494433", // MP3 (音频,可排除) + "89504E47", // PNG (图片) + "47494638", // GIF + "25504446", // PDF + "FFD8FFE0", // JPEG + "52494646", // WebP / AVI (RIFF 容器) + "4D5A" // EXE (危险文件) + }; + + // 真正的视频 MIME 类型 + private static final String[] VIDEO_CONTENT_TYPES = { + "video/mp4", + "video/avi", + "video/x-msvideo", + "video/mpeg", + "video/quicktime", + "video/x-flv", + "video/webm", + "video/3gpp", + "video/ogg" + }; + /** * 获取文件类型 *

@@ -73,4 +106,72 @@ public class FileTypeUtils } return strFileExtendName; } + + /** + * 判断 MultipartFile 是否为视频文件(Java 8 兼容版) + */ + public static boolean isVideoFile(MultipartFile file) { + if (file == null || file.isEmpty()) { + return false; + } + String contentType = file.getContentType(); + if (contentType == null) { + return false; + } + // 先用 MIME 类型快速判断(备用方案) + boolean isVideoByMimeType = Arrays.stream(VIDEO_CONTENT_TYPES) + .anyMatch(contentType::startsWith); + try { + byte[] headerBytes = new byte[12]; + int read = file.getInputStream().read(headerBytes); + if (read < 4) { + return false; + } + String headerHex = bytesToHex(headerBytes, Math.min(read, 8)).toUpperCase(); + boolean isVideo = false; // 用一个变量保存结果 + switch (headerHex) { + case "66747970": // MP4 + case "000001BA": // MPEG + case "000001B3": // MPEG + case "464C56": // FLV + isVideo = true; + break; + case "52494646": // RIFF (AVI, WebM) + // 进一步判断子类型:AVI 或 WebM + if (read >= 12) { + String subType = bytesToHex(Arrays.copyOfRange(headerBytes, 8, 12)).toUpperCase(); + isVideo = "41564920".equals(subType) || "5745424D".equals(subType); // "AVI " 或 "WEBM" + } + break; + + default: + // 文件头不匹配,降级使用 MIME 类型判断 + isVideo = isVideoByMimeType; + break; + } + return isVideo; + } catch (IOException e) { + // 读取出错,降级使用 MIME 类型判断 + return isVideoByMimeType; + } + } + + /** + * 将字节数组转为十六进制字符串 + */ + private static String bytesToHex(byte[] bytes, int len) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < len; i++) { + sb.append(String.format("%02X", bytes[i] & 0xFF)); + } + return sb.toString(); + } + + /** + * 获取字节数组的十六进制表示(完整) + */ + private static String bytesToHex(byte[] bytes) { + return bytesToHex(bytes, bytes.length); + } + } \ No newline at end of file diff --git a/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java b/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java index a6f4576..1843dd8 100644 --- a/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java +++ b/bonus-file/src/main/java/com/bonus/file/service/FileUploadService.java @@ -41,14 +41,30 @@ public class FileUploadService { * @param filePath */ public void delFile(String filePath) { - try{ - boolean isCz=minioUtil.isObjectExist(minioConfig.getBucketName(),filePath); - if(isCz){ - minioUtil.removeFile(minioConfig.getBucketName(),filePath); + try { + boolean isCz = minioUtil.isObjectExist(minioConfig.getBucketName(), filePath); + if (isCz) { + minioUtil.removeFile(minioConfig.getBucketName(), filePath); } + } catch (Exception e) { + log.error(e.toString(), e); + } + } + + /** + * 上传文件 + * @param file + * @return + */ + public SysFile uploadLargeFile(MultipartFile file,String path) { + try{ + return minioUtil.uploadFile(file, path); }catch (Exception e){ log.error(e.toString(),e); } - + return null; } + + + }