24
VamPa/src/main/java/com/vam/controller/ReplyController.java
Normal file
24
VamPa/src/main/java/com/vam/controller/ReplyController.java
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
10
VamPa/src/main/java/com/vam/mapper/ReplyMapper.java
Normal file
10
VamPa/src/main/java/com/vam/mapper/ReplyMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
import com.vam.model.ReplyDTO;
|
||||
|
||||
public interface ReplyMapper {
|
||||
|
||||
/* 댓글 등록 */
|
||||
public int enrollReply(ReplyDTO dto);
|
||||
|
||||
}
|
||||
75
VamPa/src/main/java/com/vam/model/ReplyDTO.java
Normal file
75
VamPa/src/main/java/com/vam/model/ReplyDTO.java
Normal file
@@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
10
VamPa/src/main/java/com/vam/service/ReplyService.java
Normal file
10
VamPa/src/main/java/com/vam/service/ReplyService.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.service;
|
||||
|
||||
import com.vam.model.ReplyDTO;
|
||||
|
||||
public interface ReplyService {
|
||||
|
||||
/* 댓글 등록 */
|
||||
public int enrollReply(ReplyDTO dto);
|
||||
|
||||
}
|
||||
24
VamPa/src/main/java/com/vam/service/ReplyServiceImpl.java
Normal file
24
VamPa/src/main/java/com/vam/service/ReplyServiceImpl.java
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
14
VamPa/src/main/resources/com/vam/mapper/ReplyMapper.xml
Normal file
14
VamPa/src/main/resources/com/vam/mapper/ReplyMapper.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.ReplyMapper">
|
||||
|
||||
<!-- 댓글등록 -->
|
||||
<insert id="enrollReply">
|
||||
|
||||
insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
39
VamPa/src/test/java/com/vam/mapper/ReplyMapperTests.java
Normal file
39
VamPa/src/test/java/com/vam/mapper/ReplyMapperTests.java
Normal file
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
14
VamPa/target/classes/com/vam/mapper/ReplyMapper.xml
Normal file
14
VamPa/target/classes/com/vam/mapper/ReplyMapper.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.ReplyMapper">
|
||||
|
||||
<!-- 댓글등록 -->
|
||||
<insert id="enrollReply">
|
||||
|
||||
insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
10
VamPa_MySQL/src/main/java/com/vam/mapper/ReplyMapper.java
Normal file
10
VamPa_MySQL/src/main/java/com/vam/mapper/ReplyMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
import com.vam.model.ReplyDTO;
|
||||
|
||||
public interface ReplyMapper {
|
||||
|
||||
/* 댓글 등록 */
|
||||
public int enrollReply(ReplyDTO dto);
|
||||
|
||||
}
|
||||
73
VamPa_MySQL/src/main/java/com/vam/model/ReplyDTO.java
Normal file
73
VamPa_MySQL/src/main/java/com/vam/model/ReplyDTO.java
Normal file
@@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
10
VamPa_MySQL/src/main/java/com/vam/service/ReplyService.java
Normal file
10
VamPa_MySQL/src/main/java/com/vam/service/ReplyService.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.service;
|
||||
|
||||
import com.vam.model.ReplyDTO;
|
||||
|
||||
public interface ReplyService {
|
||||
|
||||
/* 댓글 등록 */
|
||||
public int enrollReply(ReplyDTO dto);
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.ReplyMapper">
|
||||
|
||||
<!-- 댓글등록 -->
|
||||
<insert id="enrollReply">
|
||||
|
||||
insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
14
VamPa_MySQL/target/classes/com/vam/mapper/ReplyMapper.xml
Normal file
14
VamPa_MySQL/target/classes/com/vam/mapper/ReplyMapper.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.ReplyMapper">
|
||||
|
||||
<!-- 댓글등록 -->
|
||||
<insert id="enrollReply">
|
||||
|
||||
insert into vam_reply(bookId, memberId, content, rating) values(#{bookId}, #{memberId}, #{content}, #{rating})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user