|
@@ -1,9 +1,11 @@
|
|
|
package com.style24.front.biz.service;
|
|
package com.style24.front.biz.service;
|
|
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -14,6 +16,8 @@ import com.style24.persistence.domain.Counsel;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
+import com.gagaframework.web.util.GagaDateUtil;
|
|
|
|
|
+import com.gagaframework.web.util.GagaFileUtil;
|
|
|
import com.gagaframework.web.util.GagaStringUtil;
|
|
import com.gagaframework.web.util.GagaStringUtil;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -28,6 +32,9 @@ public class TsfCounselService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private TsfCounselDao counselDao;
|
|
private TsfCounselDao counselDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private Environment env;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 1:1문의 생성
|
|
* 1:1문의 생성
|
|
@@ -42,20 +49,51 @@ public class TsfCounselService {
|
|
|
counsel.setCustNo(TsfSession.getInfo().getCustNo());
|
|
counsel.setCustNo(TsfSession.getInfo().getCustNo());
|
|
|
counsel.setCellPhnno(TsfSession.getInfo().getCellPhnno());
|
|
counsel.setCellPhnno(TsfSession.getInfo().getCellPhnno());
|
|
|
counsel.setEmail(TsfSession.getInfo().getEmail());
|
|
counsel.setEmail(TsfSession.getInfo().getEmail());
|
|
|
-
|
|
|
|
|
- if (StringUtils.isNotBlank(counsel.getFile1SysFileNm())) {
|
|
|
|
|
- counsel.setOrgFileNm1(counsel.getFile1OrgFileNm());
|
|
|
|
|
- counsel.setSysFileNm1(counsel.getFile1SysFileNm());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (StringUtils.isNotBlank(counsel.getFile2SysFileNm())) {
|
|
|
|
|
- counsel.setOrgFileNm2(counsel.getFile2OrgFileNm());
|
|
|
|
|
- counsel.setSysFileNm2(counsel.getFile2SysFileNm());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
counsel.setRegNo(TsfSession.getInfo().getCustNo());
|
|
counsel.setRegNo(TsfSession.getInfo().getCustNo());
|
|
|
counsel.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
counsel.setUpdNo(TsfSession.getInfo().getCustNo());
|
|
|
counselDao.createOneToOneQna(counsel);
|
|
counselDao.createOneToOneQna(counsel);
|
|
|
|
|
+
|
|
|
|
|
+ if(counsel.getOrgFileNmArr() != null) {
|
|
|
|
|
+ int ind = 1;
|
|
|
|
|
+ String[] orgItem = counsel.getOrgFileNmArr();
|
|
|
|
|
+ String[] sysItem = counsel.getSysFileNmArr();
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < orgItem.length; i++) {
|
|
|
|
|
+ String imgInd = String.valueOf(ind);
|
|
|
|
|
+ if (ind < 10) {
|
|
|
|
|
+ imgInd = "0" + imgInd;
|
|
|
|
|
+ }
|
|
|
|
|
+ String planUploadPath = env.getProperty("upload.default.target.path");
|
|
|
|
|
+ String yearMonth = GagaDateUtil.getToday().substring(0, 6);
|
|
|
|
|
+ planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, "/counsel");
|
|
|
|
|
+ File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, sysItem[i]));
|
|
|
|
|
+ planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
|
|
|
|
|
+ String newFilename = "COUNSEL_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + org.springframework.util.StringUtils.getFilenameExtension(sysItem[i]);
|
|
|
|
|
+ File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(planUploadPath, newFilename)));
|
|
|
|
|
+ // Rename a file
|
|
|
|
|
+ File path = new File(planUploadPath);
|
|
|
|
|
+ if (!path.exists()) {
|
|
|
|
|
+ path.mkdir();
|
|
|
|
|
+ }
|
|
|
|
|
+ newFile.renameTo(uniqueFile);
|
|
|
|
|
+
|
|
|
|
|
+ if (i == 0) {
|
|
|
|
|
+ counsel.setOrgFileNm1(orgItem[i]);
|
|
|
|
|
+ counsel.setSysFileNm1("/counsel/" + yearMonth + "/" + newFilename);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ counsel.setOrgFileNm2(orgItem[i]);
|
|
|
|
|
+ counsel.setSysFileNm2("/counsel/" + yearMonth + "/" + newFilename);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ind++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ counselDao.updateOneToOneQna(counsel);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|