파이널 프로젝트 - 1. 주제 정하기
https://velog.io/@jeong11/finalproject-subject
파이널 프로젝트 - 2. 예약사이트 기능 파악 및 기능 구현
https://velog.io/@jeong11/finalproject-기능구현
파이널 프로젝트 - 3. 예약사이트 DB
https://velog.io/@jeong11/finalproject-dbsql
지난 포스팅 dto, mapper 설정
https://velog.io/@jeong11/finalproject-dto-mapper
dao 인터페이스 파일과 dao를 상속하는 daoImpl 파일 두 가지를 만들어주었다
PostDAO.java - 인터페이스
package dao;
import java.util.List;
import dto.Post;
public interface PostDAO {
int insertPost(Post post);
int updatePost(Post post);
int deletePost(String id);
Post selectPost(String id);
List<Post> selectPostList(String userId);
}
PostDAOImpl.java
package dao;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import dto.Post;
import mapper.PostMapper;
@Repository
public class PostDAOImpl implements PostDAO {
@Autowired
private SqlSession sqlSession;
@Override
public int insertPost(Post post) {
return sqlSession.getMapper(PostMapper.class).insertPost(post);
}
@Override
public int updatePost(Post post) {
return sqlSession.getMapper(PostMapper.class).updatePost(post);
}
@Override
public int deletePost(String id) {
return sqlSession.getMapper(PostMapper.class).deletePost(id);
}
@Override
public Post selectPost(String id) {
return sqlSession.getMapper(PostMapper.class).selectPost(id);
}
@Override
public List<Post> selectPostList(String userId) {
return sqlSession.getMapper(PostMapper.class).selectPostList(userId);
}
}
ReplyDAO.java - 인터페이스
package dao;
import java.util.List;
import dto.Reply;
public interface ReplyDAO {
int insertReply(Reply reply);
int updateReply(Reply reply);
int deleteReply(String id);
Reply selectReply(String id);
List<Reply> selectPostReplyList(String postId);
List<Reply> selectUserReplyList(String userId);
}
ReplyDAOImpl.java
package dao;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import dto.Reply;
import mapper.ReplyMapper;
@Repository
public class ReplyDAOImpl implements ReplyDAO {
@Autowired
private SqlSession sqlSession;
@Override
public int insertReply(Reply reply) {
return sqlSession.getMapper(ReplyMapper.class).insertReply(reply);
}
@Override
public int updateReply(Reply reply) {
return sqlSession.getMapper(ReplyMapper.class).updateReply(reply);
}
@Override
public int deleteReply(String id) {
return sqlSession.getMapper(ReplyMapper.class).deleteReply(id);
}
@Override
public Reply selectReply(String id) {
return sqlSession.getMapper(ReplyMapper.class).selectReply(id);
}
@Override
public List<Reply> selectPostReplyList(String postId) {
return sqlSession.getMapper(ReplyMapper.class).selectPostReplyList(postId);
}
@Override
public List<Reply> selectUserReplyList(String userId) {
return sqlSession.getMapper(ReplyMapper.class).selectUserReplyList(userId);
}
}
DolbomDAO.java
package dao;
import java.util.List;
import dto.Dolbom;
public interface DolbomDAO {
int insertDolbom(Dolbom dolbom);
int updateDolbom(Dolbom dolbom);
Dolbom selectDolbom(String id);
List<Dolbom> selectDolbomList(String reservationId);
List<Dolbom> selectSitterDolbomList(String sitterId);
}
DolbomDAOImpl.java
package dao;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import dto.Dolbom;
import mapper.DolbomMapper;
@Repository
public class DolbomDAOImpl implements DolbomDAO {
@Autowired
private SqlSession sqlSession;
@Override
public int insertDolbom(Dolbom dolbom) {
return sqlSession.getMapper(DolbomMapper.class).insertDolbom(dolbom);
}
@Override
public int updateDolbom(Dolbom dolbom) {
return sqlSession.getMapper(DolbomMapper.class).updateDolbom(dolbom);
}
@Override
public Dolbom selectDolbom(String id) {
return sqlSession.getMapper(DolbomMapper.class).selectDolbom(id);
}
@Override
public List<Dolbom> selectDolbomList(String reservationId) {
return sqlSession.getMapper(DolbomMapper.class).selectDolbomList(reservationId);
}
@Override
public List<Dolbom> selectSitterDolbomList(String sitterId) {
return sqlSession.getMapper(DolbomMapper.class).selectSitterDolbomList(sitterId);
}
}
@Service, @Transactional, @Override 까먹지 말고 잘 확인하면서 써주기!
PostService.java - 인터페이스
package service;
import java.util.List;
import dto.Post;
public interface PostService {
void addPost(Post post) throws Exception;
void modifyPost(Post post) throws Exception;
void removePost(String id) throws Exception;
Post getPost(String id) throws Exception;
List<Post> getPostList(String userId) throws Exception;
}
PostServiceImpl.java
package service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import dao.PostDAO;
import dto.Post;
@Service
public class PostServiceImpl implements PostService {
@Autowired
private PostDAO postDAO;
@Transactional
@Override
public void addPost(Post post) throws Exception {
postDAO.insertPost(post);
}
@Transactional
@Override
public void modifyPost(Post post) throws Exception {
postDAO.updatePost(post);
}
@Transactional
@Override
public void removePost(String id) throws Exception {
postDAO.deletePost(id);
};
@Override
public Post getPost(String id) throws Exception {
return postDAO.selectPost(id);
}
@Override
public List<Post> getPostList(String userId) throws Exception {
return postDAO.selectPostList(userId);
}
}
ReplyService.java - 인터페이스
package service;
import java.util.List;
import dto.Reply;
public interface ReplyService {
void addReply(Reply reply) throws Exception;
void modifyReply(Reply reply) throws Exception;
void removeReply(String id) throws Exception;
Reply getReply(String id) throws Exception;
List<Reply> selectPostReplyList(String postId) throws Exception;
List<Reply> selectUserReplyList(String userId) throws Exception;
}
ReplyServiceImpl.java
package service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import dao.ReplyDAO;
import dto.Reply;
@Repository
public class ReplyServiceImpl implements ReplyService {
@Autowired
private ReplyDAO replyDAO;
@Transactional
@Override
public void addReply(Reply reply) throws Exception {
replyDAO.insertReply(reply);
}
@Transactional
@Override
public void modifyReply(Reply reply) throws Exception {
replyDAO.updateReply(reply);
}
@Transactional
@Override
public void removeReply(String id) throws Exception {
replyDAO.deleteReply(id);
}
@Override
public Reply getReply(String id) throws Exception {
return replyDAO.selectReply(id);
}
@Override
public List<Reply> selectPostReplyList(String postId) throws Exception {
return replyDAO.selectPostReplyList(postId);
}
@Override
public List<Reply> selectUserReplyList(String userId) throws Exception {
return replyDAO.selectUserReplyList(userId);
}
}
DolbomService.java - 인터페이스
package service;
import java.util.List;
import dto.Dolbom;
public interface DolbomService {
void addInsertDolbom(Dolbom dolbom) throws Exception;
void modifyDolbom(Dolbom dolbom) throws Exception;
Dolbom getselectDolbom(String id) throws Exception;
List<Dolbom> getselectDolbomList(String reservationId) throws Exception;
List<Dolbom> getselectSitterDolbomList(String sitterId) throws Exception;
}
DolbomServiceImpl.java
package service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import dao.DolbomDAO;
import dto.Dolbom;
@Service
public class DolbomServiceImpl implements DolbomService {
@Autowired
private DolbomDAO dolbomDAO;
@Transactional
@Override
public void addInsertDolbom(Dolbom dolbom) throws Exception {
dolbomDAO.insertDolbom(dolbom);
}
@Transactional
@Override
public void modifyDolbom(Dolbom dolbom) throws Exception {
dolbomDAO.updateDolbom(dolbom);
}
@Override
public Dolbom getselectDolbom(String id) throws Exception {
return dolbomDAO.selectDolbom(id);
}
@Override
public List<Dolbom> getselectDolbomList(String reservationId) throws Exception {
return dolbomDAO.selectDolbomList(reservationId);
}
@Override
public List<Dolbom> getselectSitterDolbomList(String sitterId) throws Exception {
return dolbomDAO.selectSitterDolbomList(sitterId);
}
}