Procházet zdrojové kódy

댓글 이벤트 중간커밋

sowon4187 před 5 roky
rodič
revize
034b1f9c51

+ 30 - 0
src/main/java/com/style24/front/biz/dao/TsfPlanningDao.java

@@ -352,4 +352,34 @@ public interface TsfPlanningDao {
 	 */
 	Collection<Plan> getReplyList(Plan plan);
 	
+	/**
+	 * 기획전/이벤트 댓글 저장
+	 *
+	 * @param Plan
+	 * @return 
+	 * @author sowon
+	 * @date 2021. 4. 13
+	 */
+	void saveEntryReply(Plan plan);
+	
+	/**
+	 * 기획전/이벤트 댓글 카운트
+	 *
+	 * @param Plan
+	 * @return int
+	 * @author sowon
+	 * @date 2021. 4. 13
+	 */
+	int getEntryReplyCount(Plan plan);
+	
+	/**
+	 * 기획전/이벤트 댓글 삭제
+	 *
+	 * @param Plan
+	 * @return 
+	 * @author sowon
+	 * @date 2021. 4. 13
+	 */
+	void deleteEntryReply(Plan plan);
+	
 }

+ 37 - 0
src/main/java/com/style24/front/biz/service/TsfPlanningService.java

@@ -522,4 +522,41 @@ public class TsfPlanningService {
 		return planningDao.getReplyList(plan);
 	}
 
+
+	/**
+	 * 기획전/이벤트 댓글 저장
+	 *
+	 * @param Plan
+	 * @return 
+	 * @author sowon
+	 * @date 2021. 4. 13
+	 */
+	public void saveEntryReply(Plan plan) {
+		plan.setCustNo(TsfSession.getInfo().getCustNo());
+		planningDao.saveEntryReply(plan);
+	}
+	
+	/**
+	 * 기획전/이벤트 댓글 카운트
+	 *
+	 * @param Plan
+	 * @return int
+	 * @author sowon
+	 * @date 2021. 4. 13
+	 */
+	public int getEntryReplyCount(Plan plan) {
+		return planningDao.getEntryReplyCount(plan);
+	}
+	
+	/**
+	 * 기획전/이벤트 댓글 삭제
+	 *
+	 * @param Plan
+	 * @return 
+	 * @author sowon
+	 * @date 2021. 4. 13
+	 */
+	public void deleteEntryReply(Plan plan) {
+		planningDao.deleteEntryReply(plan);
+	}
 }

+ 34 - 7
src/main/java/com/style24/front/biz/web/TsfPlanningController.java

@@ -241,22 +241,49 @@ public class TsfPlanningController extends TsfBaseController {
 	 */
 	@PostMapping("/reply/list")
 	@ResponseBody
-	public GagaMap getReplyList(Plan plan) {
+	public GagaMap getReplyList(@RequestBody Plan plan) {
 		GagaMap result = new GagaMap();
-		plan.setPlanSq(plan.getPlanSq());
-		
-		result.set("replyList",planningService.getReplyList(plan));
 		if (TsfSession.isLogin()) {
 			result.set("custNo",TsfSession.getInfo().getCustNo());
 		}
 		TscPageRequest pageable = new TscPageRequest((plan.getPageNo() > 0 ? plan.getPageNo() - 1 : 0), plan.getPageSize(), plan.getPageUnit());
-		//pageable.setTotalCount(reviewService.getCompleteReviewCount(review));
-		pageable.setTotalCount(10);
+		pageable.setTotalCount(planningService.getEntryReplyCount(plan));
 		plan.setPageable(pageable);
 		log.info("pageable: {}", pageable);
 		log.info("totalCount {}", pageable.getTotalCount());
-		
 		result.set("paging", plan);
+		result.set("replyList",planningService.getReplyList(plan));
+		result.set("replyCount",planningService.getEntryReplyCount(plan));
+		return result;
+	}
+	
+	/**
+	 * 기획전/이벤트 댓글 저장
+	 *
+	 * @return
+	 * @author sowon	
+	 * @since 2021. 04. 13
+	 */
+	@PostMapping("/reply/save")
+	@ResponseBody
+	public GagaMap saveEntryReply(@RequestBody Plan plan) {
+		GagaMap result = new GagaMap();
+		planningService.saveEntryReply(plan);
+		return result;
+	}
+	
+	/**
+	 * 기획전/이벤트 댓글 삭제
+	 *
+	 * @return
+	 * @author sowon	
+	 * @since 2021. 04. 13
+	 */
+	@PostMapping("/reply/delete")
+	@ResponseBody
+	public GagaMap deleteEntryReply(@RequestBody Plan plan) {
+		GagaMap result = new GagaMap();
+		planningService.deleteEntryReply(plan);
 		return result;
 	}
 

+ 2 - 2
src/main/java/com/style24/persistence/domain/Plan.java

@@ -267,14 +267,14 @@ public class Plan extends TscBaseDomain {
 	private String entryVal6;			//참여값6
 	private String entryVal7;			//참여값7
 	private String entryVal8;			//참여값8
-	
+	private Integer planEntrySq;		//참여일련번호
 	
 	
 	
 	// Pagination
 	private TscPageRequest pageable;
 	private int pageNo = 1;
-	private int pageSize = 50;
+	private int pageSize = 10;
 	private int pageUnit = 10;
 
 	private String condition; // 키워드 종류

+ 59 - 1
src/main/java/com/style24/persistence/mybatis/shop/TsfPlanning.xml

@@ -1204,6 +1204,7 @@
 	<!-- 댓글 리스트  (수정필)-->
 	<select id="getReplyList" resultType="Plan" parameterType="Plan">
 		/* TsfPlanning.getReplyList */	
+		<include refid="selectForPagingHeader"/>
 		SELECT Z.*
 		      ,(SELECT CUST_ID FROM TB_CUSTOMER WHERE CUST_NO = Z.ENTRY_CUST_NO) AS CUST_ID
 		FROM 
@@ -1224,10 +1225,67 @@
 			     , PE.REG_DT
 			     , PE.UPD_NO
 			     , PE.UPD_DT
+			     , RANK() OVER(ORDER BY REG_DT DESC) AS NUMB
 			FROM TB_PLAN_ENTRY PE
 			WHERE 1=1
 		    AND PE.PLAN_SQ = #{planSq}
-		    ORDER BY REG_NO DESC
+		    ORDER BY REG_DT DESC
 		)Z
+		<include refid="selectForPagingFooter"/>
 	</select>
+	
+	<insert id="saveEntryReply" parameterType="Plan">
+		/* TsfPlanning.saveEntryReply */	
+		INSERT INTO TB_PLAN_ENTRY
+		(
+		  PLAN_SQ
+		, ENTRY_CUST_NO
+		, ENTRY_DT
+		, ENTRY_VAL1
+		, ENTRY_VAL2
+		, ENTRY_VAL3
+		, ENTRY_VAL4
+		, ENTRY_VAL5
+		, ENTRY_VAL6
+		, ENTRY_VAL7
+		, ENTRY_VAL8
+		, REG_NO
+		, REG_DT
+		, UPD_NO
+		, UPD_DT
+		)
+		VALUES(
+		  #{planSq}
+		, #{custNo}
+		, CURRENT_TIMESTAMP
+		, #{entryVal1}
+		, #{entryVal2}
+		, #{entryVal3}
+		, #{entryVal4}
+		, #{entryVal5}
+		, #{entryVal6}
+		, #{entryVal7}
+		, #{entryVal8}
+		, #{custNo}
+		, CURRENT_TIMESTAMP
+		, #{custNo}
+		, CURRENT_TIMESTAMP
+		)	
+	</insert>
+	
+	<select id="getEntryReplyCount" resultType="int" parameterType="Plan">
+		/* TsfPlanning.getEntryReplyCount */		
+		SELECT COUNT(*) AS COUNT
+		FROM TB_PLAN_ENTRY
+		WHERE PLAN_SQ = #{planSq}
+	</select>
+	
+	
+	<delete id="deleteEntryReply" parameterType="Plan">
+		/* TsfPlanning.deleteEntryReply */
+		DELETE 
+		FROM TB_PLAN_ENTRY
+		WHERE PLAN_ENTRY_SQ = #{planEntrySq}		
+	</delete>
+	
 </mapper>

+ 30 - 15
src/main/webapp/WEB-INF/views/web/planning/PlanningDetailFormWeb.html

@@ -49,7 +49,7 @@
 												th:attr="onclick=|sendSns('facebook', '${stylelUrl+'/planning/detail/form?planSq='+planInfo.planSq}', '${planInfo.planNm}', '', '');|">
 												<span>페이스북</span>
 											</button>
-											<button type="button" class="tw"
+											<button type="button" class="tw" 
 												th:attr="onclick=|sendSns('twitter', '${stylelUrl+'/planning/detail/form?planSq='+planInfo.planSq}', '${planInfo.planNm+ '#style24몰'}', '', '');|">
 												<span>트위터</span>
 											</button>
@@ -287,6 +287,7 @@ let goods2 = [[${goods2Info}]];
 let goods4 = [[${goods4Info}]];
 let template =[[${templateOrd}]];
 let replyList = [[${replyList}]];
+let replyCount = [[${replyCount}]];
 let _mall = [[${@environment.getProperty('domain.front')}]];
 let goodsView =[[${@environment.getProperty('upload.goods.view')}]]
 let imgUrl=[[${@environment.getProperty('upload.image.view')}]];
@@ -753,9 +754,6 @@ var fnTextConfirm = function() {
 var ajaxReplyList = function () {
 	gagaPaging.init('searchForm', fnSearchCallback, 'paging', 10);
 	gagaPaging.load(1);
-	 /* $.getJSON('/planning/reply/list?planSq='+plan.planSq, function(result, status) { */
-		
-	/*  }); */
 }
 
 var fnSearchCallback = function (result) {
@@ -763,7 +761,7 @@ var fnSearchCallback = function (result) {
 	 if (result!=null) {
 		 var html = '';
 		 html += '<div class="cmt_list_tit">';
-		 html += '	<strong>댓글</strong><span class="cnt">('+result.replyList.length.addComma()+')</span>';
+		 html += '	<strong>댓글</strong><span class="cnt">('+result.replyCount.addComma()+')</span>';
 		 html += '</div>';
 		 if (result.replyList.length>0) {
 			 html += '<ul class="cmt_list">';
@@ -775,15 +773,12 @@ var fnSearchCallback = function (result) {
 				 html += '		</div>';
 				 html += '		<div class="cmt_cont">';
 				 html += '			<div class="img_wrap clear">';
-				 html += '				<span class="pics"><img class="picsThumbs" src="/images/pc/thumb/ev_list_img01.jpg" alt="썸네일"></span>';
-				 html += '				<span class="pics"><img class="picsThumbs" src="/images/pc/thumb/ev_list_img02.jpg" alt="썸네일"></span>';
-				 html += '				<span class="pics"><img class="picsThumbs" src="/images/pc/thumb/ev_list_img03.jpg" alt="썸네일"></span>';
-				 html += '				<span class="pics"><img class="picsThumbs" src="/images/pc/thumb/ev_list_img04.jpg" alt="썸네일"></span>';
+				// html += '				<span class="pics"><img class="picsThumbs" src="/images/pc/thumb/ev_list_img01.jpg" alt="썸네일"></span>';
 				 html += '			</div>';
 				 html += '			<p>'+item.entryVal1+'</p>';
 				 if (item.entryCustNo == result.custNo) {
-					 html += '			<button class="btn btn_default btn_del"><span>삭제</span></button>';
-				}
+					 html += '			<button class="btn btn_default btn_del" value="'+item.planEntrySq+'" onclick="fnDelReply(this.value)"><span>삭제</span></button>';
+				 }
 				 html += '		</div>';
 				 html += '	</li>';
 			 });
@@ -805,6 +800,23 @@ var fnSearchCallback = function (result) {
 	gagaPaging.createPagination(result.paging.pageable);
 }
 
+// 댓글 삭제
+var fnDelReply = function(obj) {
+	
+	data = {planEntrySq : obj};
+	var jsonData = JSON.stringify(data);
+
+	mcxDialog.confirm("댓글을 삭제 하시겠습니까?", {
+		cancelBtnText : "취소",
+		sureBtnText : "확인",
+		sureBtnClick : function() {
+
+		gagajf.ajaxJsonSubmit('/planning/reply/delete', jsonData,function() {
+			ajaxReplyList();	
+			});
+		}
+	})
+}
 $('#fileAdd').on('change', function() { fnChooseFile(this); });
 
 var fnChooseFile = function(obj,fileNo) {
@@ -866,7 +878,8 @@ var fnReplySave = function() {
 		return;
 	}
 	
-	data = {content : content};
+	data = {entryVal1 : content,
+			planSq : plan.planSq};
 	var jsonData = JSON.stringify(data);
 
 	mcxDialog.confirm("댓글을 등록 하시겠습니까?", {
@@ -875,9 +888,11 @@ var fnReplySave = function() {
 		sureBtnClick : function() {
 
 		gagajf.ajaxJsonSubmit('/planning/reply/save', jsonData,function() {
-						
-		});
-	}
+			ajaxReplyList();	
+			$('#replyText').val('');
+			});
+		}
+	})
 }