|
@@ -1,11 +1,18 @@
|
|
|
package com.style24.core.biz.service;
|
|
package com.style24.core.biz.service;
|
|
|
|
|
|
|
|
|
|
+import com.gagaframework.web.util.GagaDateUtil;
|
|
|
|
|
+import com.gagaframework.web.util.GagaFileUtil;
|
|
|
import com.style24.core.biz.dao.TscPopupDao;
|
|
import com.style24.core.biz.dao.TscPopupDao;
|
|
|
import com.style24.persistence.domain.Popup;
|
|
import com.style24.persistence.domain.Popup;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
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.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -20,6 +27,9 @@ public class TscPopupService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private TscPopupDao popupDao;
|
|
private TscPopupDao popupDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private Environment env;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 팝업 리스트 카운트
|
|
* 팝업 리스트 카운트
|
|
|
* @return
|
|
* @return
|
|
@@ -39,4 +49,41 @@ public class TscPopupService {
|
|
|
public Collection<Popup> getPopupList(Popup popup){
|
|
public Collection<Popup> getPopupList(Popup popup){
|
|
|
return popupDao.getPopupList(popup);
|
|
return popupDao.getPopupList(popup);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 팝업관리 저장
|
|
|
|
|
+ * @return
|
|
|
|
|
+ * @author bin2107
|
|
|
|
|
+ * @since 2021. 3. 3
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional("shopTxnManager")
|
|
|
|
|
+ public void savePopup(Popup popup) {
|
|
|
|
|
+ String popupImgNm = "";
|
|
|
|
|
+ String displayUploadPath = env.getProperty("upload.default.target.path");
|
|
|
|
|
+
|
|
|
|
|
+ if(!StringUtils.isEmpty(popup.getNewImgFileNm1())){
|
|
|
|
|
+ String newFilename = "POPUP_" + GagaDateUtil.getTodayDateTime() + "." + StringUtils.getFilenameExtension(popup.getNewImgFileNm1());
|
|
|
|
|
+
|
|
|
|
|
+ // 기존이미지 삭제
|
|
|
|
|
+ try{
|
|
|
|
|
+ GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(displayUploadPath, popup.getOrgFileNm()));
|
|
|
|
|
+ }catch (IOException e){
|
|
|
|
|
+ // nothing
|
|
|
|
|
+ log.info("[savePopup POPUP 기존 이미지 삭제중 error]");
|
|
|
|
|
+ //e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(displayUploadPath, newFilename)));
|
|
|
|
|
+ File file = new File(GagaFileUtil.getConcatenationPath(displayUploadPath, popup.getNewImgFileNm1()));
|
|
|
|
|
+
|
|
|
|
|
+ // Rename a file
|
|
|
|
|
+ file.renameTo(uniqueFile);
|
|
|
|
|
+
|
|
|
|
|
+ popup.setOrgFileNm(newFilename);
|
|
|
|
|
+ popup.setSysFileNm(newFilename);
|
|
|
|
|
+ }
|
|
|
|
|
+ popupDao.savePopup(popup);
|
|
|
|
|
+ popupDao.deletePopupFront(popup);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|