[Spring][쇼핑몰 프로젝트][29] 상품 이미지 수정 - 6(배치 프로그램 적용 3)
https://kimvampa.tistory.com/240
This commit is contained in:
84
VamPa/src/test/java/com/vam/task/TaskTest.java
Normal file
84
VamPa/src/test/java/com/vam/task/TaskTest.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.vam.task;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.vam.mapper.AdminMapper;
|
||||
import com.vam.model.AttachImageVO;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
||||
public class TaskTest {
|
||||
|
||||
@Autowired
|
||||
private AdminMapper mapper;
|
||||
|
||||
private String getFolderYesterDay() {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
cal.add(Calendar.DATE, -1);
|
||||
|
||||
String str = sdf.format(cal.getTime());
|
||||
|
||||
return str.replace("-", File.separator);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void taskTests() {
|
||||
|
||||
List<AttachImageVO> fileList = mapper.checkFileList();
|
||||
|
||||
System.out.println("fileList : ");
|
||||
fileList.forEach( list -> System.out.println(list));
|
||||
System.out.println("========================================");
|
||||
|
||||
List<Path> checkFilePath = new ArrayList<Path>();
|
||||
|
||||
fileList.forEach(vo -> {
|
||||
Path path = Paths.get("C:\\upload", vo.getUploadPath(), vo.getUuid() + "_" + vo.getFileName());
|
||||
checkFilePath.add(path);
|
||||
});
|
||||
|
||||
System.out.println("checkFilePath : ");
|
||||
checkFilePath.forEach(list -> System.out.println(list));
|
||||
System.out.println("========================================");
|
||||
|
||||
fileList.forEach(vo -> {
|
||||
Path path = Paths.get("C:\\upload", vo.getUploadPath(), "s_" + vo.getUuid() + "_" + vo.getFileName());
|
||||
checkFilePath.add(path);
|
||||
});
|
||||
|
||||
System.out.println("checkFilePath(썸네일 이미지 정보 추가 후) : ");
|
||||
checkFilePath.forEach(list -> System.out.println(list));
|
||||
System.out.println("========================================");
|
||||
|
||||
File targetDir = Paths.get("C:\\upload", getFolderYesterDay()).toFile();
|
||||
File[] targetFile = targetDir.listFiles();
|
||||
|
||||
System.out.println("targetFile : ");
|
||||
for(File file : targetFile) {
|
||||
System.out.println(file);
|
||||
}
|
||||
System.out.println("========================================");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user