@@ -1,11 +1,15 @@
|
||||
package com.vam.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.ReplyDTO;
|
||||
import com.vam.model.ReplyPageDTO;
|
||||
import com.vam.service.ReplyService;
|
||||
|
||||
@RestController
|
||||
@@ -29,4 +33,10 @@ public class ReplyController {
|
||||
return replyService.checkReply(dto);
|
||||
}
|
||||
|
||||
/* 댓글 페이징 */
|
||||
@GetMapping(value="/list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public ReplyPageDTO replyListPOST(Criteria cri) {
|
||||
return replyService.replyList(cri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.ReplyDTO;
|
||||
|
||||
public interface ReplyMapper {
|
||||
@@ -10,4 +13,10 @@ public interface ReplyMapper {
|
||||
/* 댓글 존재 체크 */
|
||||
public Integer checkReply(ReplyDTO dto);
|
||||
|
||||
/* 댓글 페이징 */
|
||||
public List<ReplyDTO> getReplyList(Criteria cri);
|
||||
|
||||
/* 댓글 총 갯수(페이징) */
|
||||
public int getReplyTotal(int bookId);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public class Criteria {
|
||||
/* 카테고리 코드 */
|
||||
private String cateCode;
|
||||
|
||||
/* 상품 번호(댓글 기능에서 사용) */
|
||||
private int bookId;
|
||||
|
||||
/* Criteria 생성자 */
|
||||
public Criteria(int pageNum, int amount) {
|
||||
this.pageNum = pageNum;
|
||||
@@ -85,13 +88,23 @@ public class Criteria {
|
||||
public void setCateCode(String cateCode) {
|
||||
this.cateCode = cateCode;
|
||||
}
|
||||
|
||||
public int getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(int bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Criteria [pageNum=" + pageNum + ", amount=" + amount + ", type=" + type + ", keyword=" + keyword
|
||||
+ ", authorArr=" + Arrays.toString(authorArr) + ", cateCode=" + cateCode + "]";
|
||||
+ ", authorArr=" + Arrays.toString(authorArr) + ", cateCode=" + cateCode + ", bookId=" + bookId + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
32
VamPa/src/main/java/com/vam/model/ReplyPageDTO.java
Normal file
32
VamPa/src/main/java/com/vam/model/ReplyPageDTO.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReplyPageDTO {
|
||||
|
||||
List<ReplyDTO> list;
|
||||
|
||||
PageDTO pageInfo;
|
||||
|
||||
public List<ReplyDTO> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<ReplyDTO> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public PageDTO getPageInfo() {
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public void setPageInfo(PageDTO pageInfo) {
|
||||
this.pageInfo = pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplyPageDTO [list=" + list + ", pageInfo=" + pageInfo + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.vam.service;
|
||||
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.ReplyDTO;
|
||||
import com.vam.model.ReplyPageDTO;
|
||||
|
||||
public interface ReplyService {
|
||||
|
||||
@@ -10,4 +12,7 @@ public interface ReplyService {
|
||||
/* 댓글 존재 체크 */
|
||||
public String checkReply(ReplyDTO dto);
|
||||
|
||||
/* 댓글 페이징 */
|
||||
public ReplyPageDTO replyList(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.vam.mapper.ReplyMapper;
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.PageDTO;
|
||||
import com.vam.model.ReplyDTO;
|
||||
import com.vam.model.ReplyPageDTO;
|
||||
|
||||
@Service
|
||||
public class ReplyServiceImpl implements ReplyService{
|
||||
@@ -36,5 +39,15 @@ public class ReplyServiceImpl implements ReplyService{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplyPageDTO replyList(Criteria cri) {
|
||||
ReplyPageDTO dto = new ReplyPageDTO();
|
||||
|
||||
dto.setList(replyMapper.getReplyList(cri));
|
||||
dto.setPageInfo(new PageDTO(cri, replyMapper.getReplyTotal(cri.getBookId())));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,5 +17,29 @@
|
||||
where memberId = #{memberId} and bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 댓글 페이징 -->
|
||||
<select id="getReplyList" resultType="com.vam.model.ReplyDTO">
|
||||
|
||||
<![CDATA[
|
||||
select * from(
|
||||
select rownum as rn, replyId, bookId, memberId, content, rating, regDate
|
||||
from vam_reply
|
||||
where rownum <= #{pageNum} * #{amount} and bookId = #{bookId}
|
||||
order by regDate desc
|
||||
)
|
||||
where rn > (#{pageNum} -1) * #{amount}
|
||||
]]>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getReplyTotal" resultType="int">
|
||||
|
||||
select count(*)
|
||||
from vam_reply
|
||||
where bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -17,5 +17,29 @@
|
||||
where memberId = #{memberId} and bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 댓글 페이징 -->
|
||||
<select id="getReplyList" resultType="com.vam.model.ReplyDTO">
|
||||
|
||||
<![CDATA[
|
||||
select * from(
|
||||
select rownum as rn, replyId, bookId, memberId, content, rating, regDate
|
||||
from vam_reply
|
||||
where rownum <= #{pageNum} * #{amount} and bookId = #{bookId}
|
||||
order by regDate desc
|
||||
)
|
||||
where rn > (#{pageNum} -1) * #{amount}
|
||||
]]>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getReplyTotal" resultType="int">
|
||||
|
||||
select count(*)
|
||||
from vam_reply
|
||||
where bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.vam.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.ReplyDTO;
|
||||
import com.vam.model.ReplyPageDTO;
|
||||
import com.vam.service.ReplyService;
|
||||
|
||||
@RestController
|
||||
@@ -29,4 +33,10 @@ public class ReplyController {
|
||||
return replyService.checkReply(dto);
|
||||
}
|
||||
|
||||
/* 댓글 페이징 */
|
||||
@GetMapping(value="/list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public ReplyPageDTO replyListPOST(Criteria cri) {
|
||||
return replyService.replyList(cri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.ReplyDTO;
|
||||
|
||||
public interface ReplyMapper {
|
||||
@@ -10,4 +13,10 @@ public interface ReplyMapper {
|
||||
/* 댓글 존재 체크 */
|
||||
public Integer checkReply(ReplyDTO dto);
|
||||
|
||||
/* 댓글 페이징 */
|
||||
public List<ReplyDTO> getReplyList(Criteria cri);
|
||||
|
||||
/* 댓글 총 갯수(페이징) */
|
||||
public int getReplyTotal(int bookId);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ public class Criteria {
|
||||
/* 카테고리 코드 */
|
||||
private String cateCode;
|
||||
|
||||
/* 상품 번호(댓글 기능에서 사용) */
|
||||
private int bookId;
|
||||
|
||||
/* Criteria 생성자 */
|
||||
public Criteria(int pageNum, int amount) {
|
||||
this.pageNum = pageNum;
|
||||
@@ -101,11 +104,22 @@ public class Criteria {
|
||||
this.cateCode = cateCode;
|
||||
}
|
||||
|
||||
public int getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(int bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Criteria [pageNum=" + pageNum + ", amount=" + amount + ", type=" + type + ", keyword=" + keyword
|
||||
+ ", authorArr=" + Arrays.toString(authorArr) + ", cateCode=" + cateCode + "]";
|
||||
return "Criteria [pageNum=" + pageNum + ", amount=" + amount + ", skip=" + skip + ", type=" + type
|
||||
+ ", keyword=" + keyword + ", authorArr=" + Arrays.toString(authorArr) + ", cateCode=" + cateCode
|
||||
+ ", bookId=" + bookId + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
32
VamPa_MySQL/src/main/java/com/vam/model/ReplyPageDTO.java
Normal file
32
VamPa_MySQL/src/main/java/com/vam/model/ReplyPageDTO.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReplyPageDTO {
|
||||
|
||||
List<ReplyDTO> list;
|
||||
|
||||
PageDTO pageInfo;
|
||||
|
||||
public List<ReplyDTO> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<ReplyDTO> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public PageDTO getPageInfo() {
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public void setPageInfo(PageDTO pageInfo) {
|
||||
this.pageInfo = pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplyPageDTO [list=" + list + ", pageInfo=" + pageInfo + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.vam.service;
|
||||
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.ReplyDTO;
|
||||
import com.vam.model.ReplyPageDTO;
|
||||
|
||||
public interface ReplyService {
|
||||
|
||||
@@ -9,5 +11,8 @@ public interface ReplyService {
|
||||
|
||||
/* 댓글 존재 체크 */
|
||||
public String checkReply(ReplyDTO dto);
|
||||
|
||||
/* 댓글 페이징 */
|
||||
public ReplyPageDTO replyList(Criteria cri);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.vam.mapper.ReplyMapper;
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.PageDTO;
|
||||
import com.vam.model.ReplyDTO;
|
||||
import com.vam.model.ReplyPageDTO;
|
||||
|
||||
@Service
|
||||
public class ReplyServiceImpl implements ReplyService{
|
||||
@@ -33,6 +36,16 @@ public class ReplyServiceImpl implements ReplyService{
|
||||
return "1";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplyPageDTO replyList(Criteria cri) {
|
||||
ReplyPageDTO dto = new ReplyPageDTO();
|
||||
|
||||
dto.setList(replyMapper.getReplyList(cri));
|
||||
dto.setPageInfo(new PageDTO(cri, replyMapper.getReplyTotal(cri.getBookId())));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,5 +17,24 @@
|
||||
where memberId = #{memberId} and bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 댓글 페이징 -->
|
||||
<select id="getReplyList" resultType="com.vam.model.ReplyDTO">
|
||||
|
||||
select replyId, bookId, memberId, content, rating, regDate
|
||||
from vam_reply
|
||||
where bookId = #{bookId}
|
||||
order by regDate desc
|
||||
limit #{skip}, #{amount}
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getReplyTotal" resultType="int">
|
||||
|
||||
select count(*)
|
||||
from vam_reply
|
||||
where bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -17,5 +17,24 @@
|
||||
where memberId = #{memberId} and bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 댓글 페이징 -->
|
||||
<select id="getReplyList" resultType="com.vam.model.ReplyDTO">
|
||||
|
||||
select replyId, bookId, memberId, content, rating, regDate
|
||||
from vam_reply
|
||||
where bookId = #{bookId}
|
||||
order by regDate desc
|
||||
limit #{skip}, #{amount}
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getReplyTotal" resultType="int">
|
||||
|
||||
select count(*)
|
||||
from vam_reply
|
||||
where bookId = #{bookId}
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user