Parcourir la source

Merge branch 'sowon' into develop

sowon4187 il y a 5 ans
Parent
commit
26a038e454

+ 110 - 11
src/main/java/com/style24/admin/biz/service/TsaPlanService.java

@@ -1,11 +1,12 @@
 package com.style24.admin.biz.service;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 
-import org.apache.commons.lang3.StringUtils;
+import org.springframework.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
@@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gagaframework.web.parameter.GagaMap;
+import com.gagaframework.web.util.GagaDateUtil;
 import com.gagaframework.web.util.GagaFileUtil;
 import com.gagaframework.web.util.GagaStringUtil;
 import com.style24.admin.biz.dao.TsaPlanDao;
@@ -64,8 +66,49 @@ public class TsaPlanService {
 	@Transactional("shopTxnManager")
 	public void createPlanInfo(Plan param) {
 		Plan plan = new Plan();
+		int ind = 1;
 		param.setRegNo(TsaSession.getInfo().getUserNo());
 		param.setUpdNo(TsaSession.getInfo().getUserNo());
+		if(param.getMainPimg() != null && !"".equals(param.getMainPimg())){
+			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, "/planning");
+			File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, param.getMainPimg()));
+			planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
+			String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(param.getMainPimg());
+			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);
+			param.setMainPimg("/planning/" + yearMonth + "/" + newFilename);
+		}
+		if(param.getMainMimg() != null && !"".equals(param.getMainMimg())){
+			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, "/planning");
+			File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, param.getMainMimg()));
+			planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
+			String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(param.getMainMimg());
+			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);
+			param.setMainMimg("/planning/" + yearMonth + "/" + newFilename);
+		}
 		planDao.createPlanInfo(param);
 		
 		String[] brand = param.getMultiBrand();
@@ -365,7 +408,47 @@ public class TsaPlanService {
 			plan.setRegNo(TsaSession.getInfo().getUserNo());
 			planDao.createPlanCustGrade(plan);
 		}
-		
+		int ind = 1;
+		if(param.getMainPimg() != null && !"".equals(param.getMainPimg())){
+			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, "/planning");
+			File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, param.getMainPimg()));
+			planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
+			String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(param.getMainPimg());
+			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);
+			param.setMainPimg("/planning/" + yearMonth + "/" + newFilename);
+		}
+		if(param.getMainMimg() != null && !"".equals(param.getMainMimg())){
+			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, "/planning");
+			File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, param.getMainMimg()));
+			planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
+			String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(param.getMainMimg());
+			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);
+			param.setMainMimg("/planning/" + yearMonth + "/" + newFilename);
+		}
 		// 최종업데이트 
 		planDao.updatePlanInfo(param);
 
@@ -730,11 +813,11 @@ public class TsaPlanService {
 			planGoods.setPlanSq(param.getPlanSq());
 
 			String planDtlSq = String.valueOf(planGoods.getPlanDtlSq());
-			if (StringUtils.isBlank(planDtlSq)) {
+			if (org.apache.commons.lang3.StringUtils.isBlank(planDtlSq)) {
 				throw new IllegalStateException("상품코드 : " + planGoods.getGoodsCd() + " 기획전 코너 번호가 없습니다.");
 			}
 
-			if (StringUtils.isBlank(planGoods.getGoodsCd())) {
+			if (org.apache.commons.lang3.StringUtils.isBlank(planGoods.getGoodsCd())) {
 				throw new IllegalStateException("비어 있는 상품코드가 존재합니다.");
 			}
 
@@ -806,7 +889,7 @@ public class TsaPlanService {
 		// 리뷰 등록
 		Plan rePlan = new Plan();
 		//리뷰 등록 - tb_plan_contents
-		if(param.getReTitle() != "" || !StringUtils.isAllEmpty(param.getMultiPlanReview())) {
+		if(param.getReTitle() != "" || !org.apache.commons.lang3.StringUtils.isAllEmpty(param.getMultiPlanReview())) {
 			rePlan.setRegNo(regNo);
 			rePlan.setUpdNo(regNo);
 			rePlan.setTmplType("G082_10");
@@ -867,7 +950,7 @@ public class TsaPlanService {
 		
 		//이미지등록
 		Plan filePlan = new Plan();
-		if(!StringUtils.isAllEmpty(param.getMultiPlanFile()) || param.getFileDispOrd() >=0) {
+		if(!org.apache.commons.lang3.StringUtils.isAllEmpty(param.getMultiPlanFile()) || param.getFileDispOrd() >=0) {
 			filePlan.setRegNo(regNo);
 			filePlan.setUpdNo(regNo);
 			filePlan.setTmplType("G082_30");
@@ -883,10 +966,26 @@ public class TsaPlanService {
 			
 			//파일아이템 등록
 			String[] fileItemVal = param.getMultiPlanFile();
-			
-			// 기획전 브랜드 insert
+			int ind = 1;
 			for (int j = 0; j < fileItemVal.length; j++) {
-				filePlan.setItemVal(fileItemVal[j]);
+				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, "/planning");
+				File newFile = new File(GagaFileUtil.getConcatenationPath(planUploadPath, fileItemVal[j]));
+				planUploadPath = GagaFileUtil.getConcatenationPath(planUploadPath, yearMonth);
+				String newFilename = "PLANNING_" + GagaDateUtil.getTodayDateTime() + "_" + imgInd + "." + StringUtils.getFilenameExtension(fileItemVal[j]);
+				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);
+				filePlan.setItemVal("/planning/" + yearMonth + "/" + newFilename);
 				planDao.createPlanContentsItem(filePlan);
 			}
 		}
@@ -896,7 +995,7 @@ public class TsaPlanService {
 
 			
 			// 웹용 상단PC 등록
-			if (StringUtils.isNotBlank(param.getFsrcPcTop())) {
+			if (org.apache.commons.lang3.StringUtils.isNotBlank(param.getFsrcPcTop())) {
 				
 				createPlanFsrcPcTop(param);
 			}
@@ -906,7 +1005,7 @@ public class TsaPlanService {
 			
 			
 			// 웹용 상단PC 등록
-			if (StringUtils.isNotBlank(param.getFsrcPcBtm())) {
+			if (org.apache.commons.lang3.StringUtils.isNotBlank(param.getFsrcPcBtm())) {
 				createPlanFsrcPcBtm(param);
 			}
 

+ 3 - 3
src/main/webapp/WEB-INF/views/marketing/PlanDetailPopupForm.html

@@ -158,7 +158,7 @@
 						<th>PC 메인 이미지<i id="pMimgStar"></i><br/>[삭제여부<label class="chkBox"><input type="checkbox" name="orgMainPimgDelYn" value="Y"/></label>]</th>
 						<td>
 							<div th:if=*{mainPimg} id="mainPimgView" style="float:left;">
-								<img id="PreMainPimgUrl" th:src="${@environment.getProperty('upload.image.view') + '/planning/'} + *{mainPimg}" style="max-width:720px;"/>
+								<img id="PreMainPimgUrl" th:src="${@environment.getProperty('upload.image.view')} + *{mainPimg}" style="max-width:720px;"/>
 							</div>
 						</td>
 						<td colspan="4">
@@ -174,7 +174,7 @@
 						<th>모바일 메인 이미지<i id="mMimgStar"></i><br/>[삭제여부<label class="chkBox"><input type="checkbox" name="orgMainMimgDelYn" value="Y"/></label>]</th>
 						<td>
 							<div th:if=*{mainMimg} id="imgFileView" style="float:left;">
-								<img id="PreMainMimgUrl" th:src="${@environment.getProperty('upload.image.view') + '/planning/'} + *{mainMimg}" style="max-width:720px;"/>
+								<img id="PreMainMimgUrl" th:src="${@environment.getProperty('upload.image.view')} + *{mainMimg}" style="max-width:720px;"/>
 							</div>
 						</td>
 						<td colspan="4">
@@ -223,7 +223,7 @@
 						<th>댓글이미지<br/>[삭제여부<label class="chkBox"><input type="checkbox" name="orgReplyImgDelYn" value="Y"/></label>]</th>
 						<td>
 							<div th:if=*{replyImg} id="replyImgView" style="float:left;">
-								<img id="replyImgUrl" th:src="${@environment.getProperty('upload.image.view') + '/planning/'} + *{replyImg}" style="max-width:720px;"/>
+								<img id="replyImgUrl" th:src="${@environment.getProperty('upload.image.view')} + *{replyImg}" style="max-width:720px;"/>
 							</div>
 						</td>
 						<td colspan="5">