diff --git a/VamPa/src/main/java/com/vam/controller/ReplyController.java b/VamPa/src/main/java/com/vam/controller/ReplyController.java new file mode 100644 index 0000000..4f1db39 --- /dev/null +++ b/VamPa/src/main/java/com/vam/controller/ReplyController.java @@ -0,0 +1,24 @@ +package com.vam.controller; + +import org.springframework.beans.factory.annotation.Autowired; +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.ReplyDTO; +import com.vam.service.ReplyService; + +@RestController +@RequestMapping("/reply") +public class ReplyController { + + @Autowired + private ReplyService replyService; + + /* 댓글 등록 */ + @PostMapping("/enroll") + public void enrollReplyPOST(ReplyDTO dto) { + replyService.enrollReply(dto); + } + +} diff --git a/VamPa/src/main/java/com/vam/mapper/ReplyMapper.java b/VamPa/src/main/java/com/vam/mapper/ReplyMapper.java new file mode 100644 index 0000000..3d2b92d --- /dev/null +++ b/VamPa/src/main/java/com/vam/mapper/ReplyMapper.java @@ -0,0 +1,10 @@ +package com.vam.mapper; + +import com.vam.model.ReplyDTO; + +public interface ReplyMapper { + + /* 댓글 등록 */ + public int enrollReply(ReplyDTO dto); + +} diff --git a/VamPa/src/main/java/com/vam/model/ReplyDTO.java b/VamPa/src/main/java/com/vam/model/ReplyDTO.java new file mode 100644 index 0000000..d842ef5 --- /dev/null +++ b/VamPa/src/main/java/com/vam/model/ReplyDTO.java @@ -0,0 +1,75 @@ +package com.vam.model; + +import java.util.Date; + +public class ReplyDTO { + + private int replyId; + + private int bookId; + + private String memberId; + + private Date regDate; + + private String content; + + private double rating; + + public int getReplyId() { + return replyId; + } + + public void setReplyId(int replyId) { + this.replyId = replyId; + } + + public int getBookId() { + return bookId; + } + + public void setBookId(int bookId) { + this.bookId = bookId; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public Date getRegDate() { + return regDate; + } + + public void setRegDate(Date regDate) { + this.regDate = regDate; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public double getRating() { + return rating; + } + + public void setRating(double rating) { + this.rating = rating; + } + + @Override + public String toString() { + return "ReplyDTO [replyId=" + replyId + ", bookId=" + bookId + ", memberId=" + memberId + ", regDate=" + regDate + + ", content=" + content + ", rating=" + rating + "]"; + } + + + +} diff --git a/VamPa/src/main/java/com/vam/service/ReplyService.java b/VamPa/src/main/java/com/vam/service/ReplyService.java new file mode 100644 index 0000000..b77503e --- /dev/null +++ b/VamPa/src/main/java/com/vam/service/ReplyService.java @@ -0,0 +1,10 @@ +package com.vam.service; + +import com.vam.model.ReplyDTO; + +public interface ReplyService { + + /* 댓글 등록 */ + public int enrollReply(ReplyDTO dto); + +} diff --git a/VamPa/src/main/java/com/vam/service/ReplyServiceImpl.java b/VamPa/src/main/java/com/vam/service/ReplyServiceImpl.java new file mode 100644 index 0000000..457b1e8 --- /dev/null +++ b/VamPa/src/main/java/com/vam/service/ReplyServiceImpl.java @@ -0,0 +1,24 @@ +package com.vam.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.vam.mapper.ReplyMapper; +import com.vam.model.ReplyDTO; + +@Service +public class ReplyServiceImpl implements ReplyService{ + + @Autowired + private ReplyMapper replyMapper; + + /* 댓글등록 */ + @Override + public int enrollReply(ReplyDTO dto) { + + int result = replyMapper.enrollReply(dto); + + return result; + } + +} diff --git a/VamPa/src/main/resources/com/vam/mapper/ReplyMapper.xml b/VamPa/src/main/resources/com/vam/mapper/ReplyMapper.xml new file mode 100644 index 0000000..44ba271 --- /dev/null +++ b/VamPa/src/main/resources/com/vam/mapper/ReplyMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating}) + + + + \ No newline at end of file diff --git a/VamPa/src/test/java/com/vam/mapper/ReplyMapperTests.java b/VamPa/src/test/java/com/vam/mapper/ReplyMapperTests.java new file mode 100644 index 0000000..224b3ad --- /dev/null +++ b/VamPa/src/test/java/com/vam/mapper/ReplyMapperTests.java @@ -0,0 +1,39 @@ +package com.vam.mapper; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.vam.model.ReplyDTO; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml") +public class ReplyMapperTests { + + @Autowired + private ReplyMapper mapper; + + + @Test + public void replyEnrollTest() { + + String id = "admin"; + int bookId = 95; + double rating = 3.5; + String content = "댓글 테스트"; + + ReplyDTO dto = new ReplyDTO(); + dto.setBookId(bookId); + dto.setMemberId(id); + dto.setRating(rating); + dto.setContent(content); + + mapper.enrollReply(dto); + + + } + + +} diff --git a/VamPa/target/classes/com/vam/mapper/ReplyMapper.xml b/VamPa/target/classes/com/vam/mapper/ReplyMapper.xml new file mode 100644 index 0000000..44ba271 --- /dev/null +++ b/VamPa/target/classes/com/vam/mapper/ReplyMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating}) + + + + \ No newline at end of file diff --git a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index 761c208..67f42c0 100644 --- a/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Wed Dec 29 02:56:42 KST 2021 +#Mon Jan 03 13:38:26 KST 2022 m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa m2e.projectName=VamPa groupId=com.vam diff --git a/VamPa_MySQL/src/main/java/com/vam/controller/ReplyController.java b/VamPa_MySQL/src/main/java/com/vam/controller/ReplyController.java new file mode 100644 index 0000000..679e197 --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/controller/ReplyController.java @@ -0,0 +1,24 @@ +package com.vam.controller; + +import org.springframework.beans.factory.annotation.Autowired; +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.ReplyDTO; +import com.vam.service.ReplyService; + +@RestController +@RequestMapping("/reply") +public class ReplyController { + + @Autowired + private ReplyService replyService; + + /* 댓글 등록 */ + @PostMapping("/enroll") + public void enrollReplyPOST(ReplyDTO dto) { + replyService.enrollReply(dto); + } + +} diff --git a/VamPa_MySQL/src/main/java/com/vam/mapper/ReplyMapper.java b/VamPa_MySQL/src/main/java/com/vam/mapper/ReplyMapper.java new file mode 100644 index 0000000..6349785 --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/mapper/ReplyMapper.java @@ -0,0 +1,10 @@ +package com.vam.mapper; + +import com.vam.model.ReplyDTO; + +public interface ReplyMapper { + + /* 댓글 등록 */ + public int enrollReply(ReplyDTO dto); + +} diff --git a/VamPa_MySQL/src/main/java/com/vam/model/ReplyDTO.java b/VamPa_MySQL/src/main/java/com/vam/model/ReplyDTO.java new file mode 100644 index 0000000..a1f47ab --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/model/ReplyDTO.java @@ -0,0 +1,73 @@ +package com.vam.model; + +import java.util.Date; + +public class ReplyDTO { + + private int replyId; + + private int bookId; + + private String memberId; + + private Date regDate; + + private String content; + + private double rating; + + public int getReplyId() { + return replyId; + } + + public void setReplyId(int replyId) { + this.replyId = replyId; + } + + public int getBookId() { + return bookId; + } + + public void setBookId(int bookId) { + this.bookId = bookId; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public Date getRegDate() { + return regDate; + } + + public void setRegDate(Date regDate) { + this.regDate = regDate; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public double getRating() { + return rating; + } + + public void setRating(double rating) { + this.rating = rating; + } + + @Override + public String toString() { + return "ReplyDTO [replyId=" + replyId + ", bookId=" + bookId + ", memberId=" + memberId + ", regDate=" + regDate + + ", content=" + content + ", rating=" + rating + "]"; + } + +} diff --git a/VamPa_MySQL/src/main/java/com/vam/service/ReplyService.java b/VamPa_MySQL/src/main/java/com/vam/service/ReplyService.java new file mode 100644 index 0000000..70a9988 --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/service/ReplyService.java @@ -0,0 +1,10 @@ +package com.vam.service; + +import com.vam.model.ReplyDTO; + +public interface ReplyService { + + /* 댓글 등록 */ + public int enrollReply(ReplyDTO dto); + +} diff --git a/VamPa_MySQL/src/main/java/com/vam/service/ReplyServiceImpl.java b/VamPa_MySQL/src/main/java/com/vam/service/ReplyServiceImpl.java new file mode 100644 index 0000000..2985986 --- /dev/null +++ b/VamPa_MySQL/src/main/java/com/vam/service/ReplyServiceImpl.java @@ -0,0 +1,24 @@ +package com.vam.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.vam.mapper.ReplyMapper; +import com.vam.model.ReplyDTO; + +@Service +public class ReplyServiceImpl implements ReplyService{ + + @Autowired + private ReplyMapper replyMapper; + + /* 댓글등록 */ + @Override + public int enrollReply(ReplyDTO dto) { + + int result = replyMapper.enrollReply(dto); + + return result; + } + +} diff --git a/VamPa_MySQL/src/main/resources/com/vam/mapper/ReplyMapper.xml b/VamPa_MySQL/src/main/resources/com/vam/mapper/ReplyMapper.xml new file mode 100644 index 0000000..44ba271 --- /dev/null +++ b/VamPa_MySQL/src/main/resources/com/vam/mapper/ReplyMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating}) + + + + \ No newline at end of file diff --git a/VamPa_MySQL/target/classes/com/vam/mapper/ReplyMapper.xml b/VamPa_MySQL/target/classes/com/vam/mapper/ReplyMapper.xml new file mode 100644 index 0000000..44ba271 --- /dev/null +++ b/VamPa_MySQL/target/classes/com/vam/mapper/ReplyMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating}) + + + + \ No newline at end of file diff --git a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties index 9a348e3..132e0cc 100644 --- a/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties +++ b/VamPa_MySQL/target/m2e-wtp/web-resources/META-INF/maven/com.vam/controller/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Wed Dec 29 02:56:42 KST 2021 +#Mon Jan 03 13:38:26 KST 2022 m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project2\\VamPa_MySQL m2e.projectName=VamPa_MySQL groupId=com.vam