yujian
2020-05-09 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserComplaintServiceImpl.java
@@ -9,7 +9,7 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.mybatis.user.UserComplaintMapper;
@@ -17,6 +17,7 @@
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.exception.user.UserComplaintException;
import com.yeshi.fanli.service.inter.user.UserComplaintService;
import com.yeshi.fanli.util.FilePathEnum;
import net.sf.json.JSONArray;
@@ -27,7 +28,7 @@
   private UserComplaintMapper userComplaintMapper;
   
   @Override
   public void addUserComplaint(List<CommonsMultipartFile> fileList, Long uid, String content)
   public void addUserComplaint(List<MultipartFile> fileList, Long uid, String content)
         throws UserComplaintException, IOException, Exception {
      
      if (content == null || content.trim().length() == 0) {
@@ -45,13 +46,13 @@
         
         JSONArray array = new JSONArray();
         // 文件上传
         for (CommonsMultipartFile file: fileList) {
         for (MultipartFile file: fileList) {
            
            InputStream inputStream = file.getInputStream();
            String contentType = file.getContentType();
            String type = contentType.substring(contentType.indexOf("/") + 1);
            // 上传文件相对位置
            String fileUrl="/img/UserComplaint/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
            String fileUrl= FilePathEnum.userComplaint.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
            
            String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
            array.add(uploadFilePath);