jiangping
2025-04-17 9b00b80c926b3d1b38b7ef9b682ee097345dde3f
server/src/main/java/com/doumee/api/common/PublicCloudController.java
@@ -11,15 +11,13 @@
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.FtpUtil;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.service.common.EmailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
@@ -44,10 +42,27 @@
public class PublicCloudController extends BaseController {
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private EmailService emailService;
    public static FtpUtil ftp  = null;
    @ApiOperation(value = "测试邮件发送")
    @RequestMapping(method= RequestMethod.POST,value="/testEmail")
    @ResponseBody
    public void test(  @RequestParam(required = false) String id, @RequestParam(required = false) String email) throws Exception {
//        sendEmailWithImages(String toEmail, String title, Map<String,String> contentForm, List<String> imgList)
        Map<String,String> content = new HashMap<>();
        content.put("标题","这是标题");
        content.put("简介","这是简介");
        List<String> list = new ArrayList<>();
        list.add("https://dmtest.ahapp.net/file/workorder/20250410/1.jpg");
        list.add("https://dmtest.ahapp.net/file/workorder/20250410/2.png");
        list.add("https://dmtest.ahapp.net/file/workorder/20250410/4.png");
        emailService.sendEmailWithImages(StringUtils.defaultString(email,"jp@doumee.com"),"来自蹄蹄的邮件"+DateUtil.getPlusTime2(new Date()),content,list);
    }
    @ApiOperation(value = "批量上传文件到FTP")
    @RequestMapping(method= RequestMethod.POST,value="/uploadBatch")
    @ResponseBody
@@ -151,7 +166,11 @@
//        folder = systemDictDataBiz.queryByCode(Constants.FTP,folder).getCode();
        Date d1 = new Date();
        log.error("总得上传文件成功=============开始========="+DateUtil.getPlusTime2(d1));
        folder =StringUtils.defaultString(folder).replace("/", "");
        SystemDictData folderData =  systemDictDataBiz.queryByCode(Constants.FTP,folder);
        if(Objects.isNull(folderData)||StringUtils.isBlank(folderData.getCode())){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"目标文件夹错误");
        }
        folder =folderData.getCode().replace("/", "");
        String prefixPath = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode();
        InputStream is = null;
        response.setCharacterEncoding("UTF-8");
@@ -173,6 +192,7 @@
                Iterator<String> it = multipartRequest.getFileNames();
                while (it.hasNext()) {
                    MultipartFile file = multipartRequest.getFile(it.next());
                    System.out.println(file.getSize());
                    String originname = file.getOriginalFilename();
                    is = file.getInputStream();
                    String endType = ".jpg";