Browse Source

移动端图片上传接口 init

dev
liuchuang 6 years ago
parent
commit
809eb8fe8d
  1. 6
      esua-epdc/epdc-module/epdc-api/epdc-api-client/pom.xml
  2. 14
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiIssueController.java
  3. 23
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/OssFeignClient.java
  4. 23
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/OssFeignClientFallback.java
  5. 11
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/IssueService.java
  6. 11
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/IssueServiceImpl.java

6
esua-epdc/epdc-module/epdc-api/epdc-api-client/pom.xml

@ -45,17 +45,17 @@
</dependency>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-events-client</artifactId>
<artifactId>epdc-services-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-services-client</artifactId>
<artifactId>epdc-user-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-user-client</artifactId>
<artifactId>epdc-oss-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>

14
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiIssueController.java

@ -3,12 +3,14 @@ package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.common.token.dto.TokenDto;
import com.elink.esua.epdc.commons.tools.annotation.LoginUser;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.UploadDTO;
import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO;
import com.elink.esua.epdc.dto.issue.form.IssueFormDTO;
import com.elink.esua.epdc.dto.issue.result.IssueResultDTO;
import com.elink.esua.epdc.service.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -48,4 +50,16 @@ public class ApiIssueController {
return issueService.listIssues(userDetail, formDto);
}
/**
* 文件上传
* @Params: [file]
* @Return: com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UploadDTO>
* @Author: liuchuang
* @Date: 2019/9/8 18:34
*/
@PostMapping("upload")
public Result<UploadDTO> upload(@RequestParam("file") MultipartFile file) {
return issueService.upload(file);
}
}

23
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/OssFeignClient.java

@ -0,0 +1,23 @@
package com.elink.esua.epdc.feign;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.UploadDTO;
import com.elink.esua.epdc.feign.fallback.OssFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
/**
* 文件对象模块
* @Author LC
* @Date 2019/9/8 18:24
*/
@FeignClient(name = ServiceConstant.EPDC_OSS_SERVER, fallback = OssFeignClientFallback.class)
public interface OssFeignClient {
@PostMapping(value = "oss/file/upload", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result<UploadDTO> upload(@RequestPart("file") MultipartFile file);
}

23
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/OssFeignClientFallback.java

@ -0,0 +1,23 @@
package com.elink.esua.epdc.feign.fallback;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.UploadDTO;
import com.elink.esua.epdc.feign.OssFeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
/**
* 文件对象模块
* @Author LC
* @Date 2019/9/8 18:25
*/
@Component
public class OssFeignClientFallback implements OssFeignClient {
@Override
public Result<UploadDTO> upload(MultipartFile file) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_OSS_SERVER, "upload", file.getOriginalFilename());
}
}

11
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/IssueService.java

@ -2,9 +2,11 @@ package com.elink.esua.epdc.service;
import com.elink.esua.epdc.common.token.dto.TokenDto;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.UploadDTO;
import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO;
import com.elink.esua.epdc.dto.issue.form.IssueFormDTO;
import com.elink.esua.epdc.dto.issue.result.IssueResultDTO;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -32,4 +34,13 @@ public interface IssueService {
* @Date: 2019/9/7 11:26
*/
Result<List<IssueResultDTO>> listIssues(TokenDto userDetail, IssueFormDTO formDto);
/**
* 文件上传
* @Params: [file]
* @Return: com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UploadDTO>
* @Author: liuchuang
* @Date: 2019/9/8 18:34
*/
Result<UploadDTO> upload(MultipartFile file);
}

11
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/IssueServiceImpl.java

@ -3,14 +3,17 @@ package com.elink.esua.epdc.service.impl;
import com.elink.esua.epdc.common.token.dto.TokenDto;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.CompleteDeptDTO;
import com.elink.esua.epdc.dto.UploadDTO;
import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO;
import com.elink.esua.epdc.dto.issue.form.IssueFormDTO;
import com.elink.esua.epdc.dto.issue.result.IssueResultDTO;
import com.elink.esua.epdc.feign.IssueFeignClient;
import com.elink.esua.epdc.feign.OssFeignClient;
import com.elink.esua.epdc.feign.SysDeptFeignClient;
import com.elink.esua.epdc.service.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -28,6 +31,9 @@ public class IssueServiceImpl implements IssueService {
@Autowired
private SysDeptFeignClient sysDeptFeignClient;
@Autowired
private OssFeignClient ossFeignClient;
@Override
public Result saveEvent(TokenDto userDetail, EpdcEventSubmitFormDTO formDto) {
// 获取该网格所有上级机构
@ -55,4 +61,9 @@ public class IssueServiceImpl implements IssueService {
formDto.setDeptId(userDetail.getGridId());
return issueFeignClient.listIssues(formDto);
}
@Override
public Result<UploadDTO> upload(MultipartFile file) {
return ossFeignClient.upload(file);
}
}

Loading…
Cancel
Save