diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java b/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java index f332ebfc..142c5a39 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java @@ -1,8 +1,13 @@ package com.zc.business.controller; +import java.io.IOException; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.exception.file.InvalidExtensionException; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.file.MimeTypeUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; @@ -85,8 +90,12 @@ public class DcEventProcessController extends BaseController @PreAuthorize("@ss.hasPermi('system:process:add')") @Log(title = "事件处理流程", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody DcEventProcess dcEventProcess) - { + public AjaxResult add(@RequestBody DcEventProcess dcEventProcess) throws IOException, InvalidExtensionException { + //如果有文件传入 + if(!dcEventProcess.getFile().isEmpty()){ + String address =FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + dcEventProcess.setContext(address); + } return toAjax(dcEventProcessService.insertDcEventProcess(dcEventProcess)); } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java b/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java index 751b51d9..02514610 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotBlank; @@ -73,6 +74,17 @@ public class DcEventProcess @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private String processName; + public MultipartFile getFile() { + return file; + } + + public void setFile(MultipartFile file) { + this.file = file; + } + + @ApiModelProperty("上传文件") + private MultipartFile file; + public void setId(Long id) { this.id = id;