Browse Source

--处理流程接口加入文件上传参数类型接收处理

develop
mengff 11 months ago
parent
commit
e5bbe7a53e
  1. 13
      zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java
  2. 12
      zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java

13
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));
}

12
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;

Loading…
Cancel
Save