Commit 05c6d77d authored by lixiaolei's avatar lixiaolei

submit

parent 625569df
......@@ -116,7 +116,6 @@ public class BusinessInfoController extends BaseController
@PostMapping("/edit")
public AjaxResult edit(@RequestBody BusinessInfo businessInfo)
{
if(!CheckUtils.isPhone(businessInfo.getConstructionPhone()) || !CheckUtils.isPhone(businessInfo.getSupervisorPhone())) throw new BaseException("500","请输入正确的手机号码");
return toAjax(businessInfoService.updateBusinessInfo(businessInfo));
}
......
......@@ -150,6 +150,18 @@
<artifactId>dsk-acc-open-sdk-java</artifactId>
<version>${dsk-openapi-sdk.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
</project>
......@@ -7,10 +7,14 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -252,10 +256,6 @@ public class FileUtils
return fileList;
}
public static void main(String[] args) {
System.out.println(getAllFileNames("D:/dsk-operate-sys/uploadPath/10").size());
}
/**
* 获取文件夹中的所有文件,不包括文件夹
*
......@@ -290,6 +290,48 @@ public class FileUtils
return fileList;
}
/**
* 下载文件
*
* @param url 要下载的文件链接
* @param targetFolder 目标文件
* @throws IOException
*/
public static void downloadFolder(String url, String targetFolder) throws IOException {
URL downloadUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
connection.setRequestMethod("GET");
connection.connect();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("下载文件夹失败: " + connection.getResponseMessage());
}
try (ZipInputStream zipInputStream = new ZipInputStream(connection.getInputStream())) {
ZipEntry entry;
while ((entry = zipInputStream.getNextEntry()) != null) {
String entryName = entry.getName();
if (StringUtils.isBlank(entryName)) {
continue;
}
File entryFile = new File(targetFolder, entryName);
if (entry.isDirectory()) {
entryFile.mkdirs();
} else {
File parent = entryFile.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
try (FileOutputStream outputStream = new FileOutputStream(entryFile)) {
IOUtils.copy(zipInputStream, outputStream);
}
}
}
}
}
/**
* 文件名称验证
......
......@@ -19,6 +19,7 @@ import com.dsk.common.exception.base.BaseException;
import com.dsk.common.utils.CheckUtils;
import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.common.utils.StringUtils;
import com.dsk.common.utils.file.FileUtils;
import com.dsk.system.domain.BusinessExcelDto;
import com.dsk.system.domain.BusinessAddDto;
......@@ -192,6 +193,10 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
@Override
@Transactional
public int updateBusinessInfo(BusinessInfo businessInfo) {
if (StringUtils.isNotEmpty(businessInfo.getConstructionPhone()) && StringUtils.isNotEmpty(businessInfo.getSupervisorPhone())) {
if (!CheckUtils.isPhone(businessInfo.getConstructionPhone()) || !CheckUtils.isPhone(businessInfo.getSupervisorPhone()))
throw new BaseException("500", "请输入正确的手机号码");
}
businessInfo.setUpdateTime(DateUtils.getNowDate());
return businessInfoMapper.updateBusinessInfo(businessInfo);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment