From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserComplaintServiceImpl.java | 158 ++++++++++++++++++++++++++-------------------------- 1 files changed, 79 insertions(+), 79 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserComplaintServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserComplaintServiceImpl.java index 0a85287..44a129b 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserComplaintServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserComplaintServiceImpl.java @@ -1,79 +1,79 @@ -package com.yeshi.fanli.service.impl.user; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import org.yeshi.utils.tencentcloud.COSManager; - -import com.yeshi.fanli.dao.mybatis.user.UserComplaintMapper; -import com.yeshi.fanli.entity.bus.user.UserComplaint; -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; - -@Service -public class UserComplaintServiceImpl implements UserComplaintService { - - @Resource - private UserComplaintMapper userComplaintMapper; - - @Override - public void addUserComplaint(List<MultipartFile> fileList, Long uid, String content) - throws UserComplaintException, IOException, Exception { - - if (content == null || content.trim().length() == 0) { - throw new UserComplaintException(1, "鍚愭Ы鍐呭涓嶈兘涓虹┖"); - } - - // 鍥剧墖鏈�澶氫簲寮犮�佸彲浠ヤ负绌� - if (fileList != null && fileList.size() > 5 ) { - throw new UserComplaintException(1, "鍥剧墖鏈�澶氬彲涓婁紶浜斿紶"); - } - - // 鍥剧墖鍒楄〃 - String pictureList = null; - if (fileList != null && fileList.size() > 0) { - - JSONArray array = new JSONArray(); - // 鏂囦欢涓婁紶 - for (MultipartFile file: fileList) { - - InputStream inputStream = file.getInputStream(); - String contentType = file.getContentType(); - String type = contentType.substring(contentType.indexOf("/") + 1); - // 涓婁紶鏂囦欢鐩稿浣嶇疆 - String fileUrl= FilePathEnum.userComplaint.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type; - - String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl(); - array.add(uploadFilePath); - } - - pictureList = array.toString(); - } - - UserInfo userInfo = null; - if (uid != null) { - userInfo = new UserInfo(); - userInfo.setId(uid); - } - - UserComplaint userComplaint = new UserComplaint(); - userComplaint.setContent(content); - userComplaint.setPictureList(pictureList); - userComplaint.setUserInfo(userInfo); - userComplaint.setCreateTime(new Date()); - userComplaintMapper.insertSelective(userComplaint); - } - - -} +package com.yeshi.fanli.service.impl.user; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import org.yeshi.utils.tencentcloud.COSManager; + +import com.yeshi.fanli.dao.mybatis.user.UserComplaintMapper; +import com.yeshi.fanli.entity.bus.user.UserComplaint; +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; + +@Service +public class UserComplaintServiceImpl implements UserComplaintService { + + @Resource + private UserComplaintMapper userComplaintMapper; + + @Override + public void addUserComplaint(List<MultipartFile> fileList, Long uid, String content) + throws UserComplaintException, IOException, Exception { + + if (content == null || content.trim().length() == 0) { + throw new UserComplaintException(1, "鍚愭Ы鍐呭涓嶈兘涓虹┖"); + } + + // 鍥剧墖鏈�澶氫簲寮犮�佸彲浠ヤ负绌� + if (fileList != null && fileList.size() > 5 ) { + throw new UserComplaintException(1, "鍥剧墖鏈�澶氬彲涓婁紶浜斿紶"); + } + + // 鍥剧墖鍒楄〃 + String pictureList = null; + if (fileList != null && fileList.size() > 0) { + + JSONArray array = new JSONArray(); + // 鏂囦欢涓婁紶 + for (MultipartFile file: fileList) { + + InputStream inputStream = file.getInputStream(); + String contentType = file.getContentType(); + String type = contentType.substring(contentType.indexOf("/") + 1); + // 涓婁紶鏂囦欢鐩稿浣嶇疆 + String fileUrl= FilePathEnum.userComplaint.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type; + + String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl(); + array.add(uploadFilePath); + } + + pictureList = array.toString(); + } + + UserInfo userInfo = null; + if (uid != null) { + userInfo = new UserInfo(); + userInfo.setId(uid); + } + + UserComplaint userComplaint = new UserComplaint(); + userComplaint.setContent(content); + userComplaint.setPictureList(pictureList); + userComplaint.setUserInfo(userInfo); + userComplaint.setCreateTime(new Date()); + userComplaintMapper.insertSelective(userComplaint); + } + + +} -- Gitblit v1.8.0