board2service
package org.lhr.service;
import java.util.ArrayList;
import org.lhr.DTO.BoardDTO;
import org.lhr.DTO.Criteria;
import org.springframework.web.bind.annotation.RequestParam;
public interface Board2Service {
// 추상메서드들
// 게시판 글쓰기
public void write2(BoardDTO bdto);
// 게시판 리스트
public ArrayList<BoardDTO> list2(Criteria cri);
// 게시판 상세페이지
public BoardDTO detail2(@RequestParam("bno") int bno);
// 게시판 글수정
public void update2(BoardDTO bdto);
// 게시판 글삭제
public void delete2(BoardDTO bdto);
// 페이징 처리하기 위한 전체 건수
public int getTotal();
}
board2imple
package org.lhr.service;
import java.util.ArrayList;
import org.lhr.DTO.BoardDTO;
import org.lhr.DTO.Criteria;
import org.lhr.mapper.Board2Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
@Service
public class Board2ServiceImpl implements Board2Service{
@Autowired
Board2Mapper b2mp;
public void write2(BoardDTO bdto) {
b2mp.write2(bdto);
}
public ArrayList<BoardDTO> list2(Criteria cri) {
return b2mp.list2(cri);
}
public BoardDTO detail2(@RequestParam("bno") int bno) {
return b2mp.detail2(bno);
}
public void update2(BoardDTO bdto) {
b2mp.update2(bdto);
}
public void delete2(BoardDTO bdto) {
b2mp.delete2(bdto);
}
public int getTotal() {
return b2mp.getTotal();
}
}
boardservice
package org.lhr.service;
import java.util.List;
import org.lhr.DTO.BoardDTO;
import org.lhr.DTO.Criteria;
import org.springframework.web.bind.annotation.RequestParam;
public interface BoardService {
//추상메서드이기때문에 {}가없음 그냥 ;로 끝내면됨 class에서 구현할것이기 때문에
public void boardWrite(BoardDTO bdto);
public BoardDTO detail(@RequestParam("bno") int bno);
//글쓰기(insert)
public void boardInsert(BoardDTO bdto) ;
//제목을 클릭-> 상세페이지(select) - 한건
//select된결과를 어떤 필통에 담을지 return type으로
//추상메소드기 때문에 return이 없음
//번호를 입력해서 해당하는 게시물만 셀렉트 해올것이기 떄문에 매개변수가 필요함 select 절에 where 조건절이 들어가니까
public BoardDTO boardDetail(BoardDTO bdto) ;
//게시판 전체 리스트 페이지(select) - 여러건
public List<BoardDTO> boardList(Criteria cri);
public int getTotal();
//수정(update)
//성공했는지 실패햇는지 알러트창이 뜨게하고싶거나하면 return값이 필요함 -> void 값이 아니고 return값을 줘야함
//그게 아니면 그냥 void주면됨
public void boardUpdate(BoardDTO bdto);
//삭제(delete)
public void boardDelete(BoardDTO bdto);
}
boardimple
package org.lhr.service;
import java.util.List;
import org.lhr.DTO.BoardDTO;
import org.lhr.DTO.Criteria;
import org.lhr.mapper.BoardAttachMapper;
import org.lhr.mapper.BoardMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
@Service
public class BoardServiceImplement implements BoardService{
//메소드를 만들라고 BoardServiceImplement에 빨간및줄이 그어짐
//여기서 dao를 연결시켜주는 역할
@Autowired
//패키지가 다른데에서 클래스를 불러올때 선언해줌
private BoardMapper boardMapper;
@Autowired
BoardAttachMapper battachMapper;
@Transactional
public void boardWrite(BoardDTO bdto) {
//tbl_board 테이블에 insert
boardMapper.boardWrite(bdto);
//tbl_attach 테이블에 insert
bdto.getAttachList().forEach(attach->{
attach.setNo(bdto.getBno());
battachMapper.insert(attach);
});
}
public int getTotal() {
return boardMapper.getTotal();
}
//글쓰기 (insert)구현부
public void boardInsert(BoardDTO bdto) {
//insert 할 수 있도록 BoardMapper(DAO)랑 연결
boardMapper.boardInsert(bdto);
}
//제목을 클릭 -> 상세페이지 (select) - 1건 구현부
public BoardDTO boardDetail(BoardDTO bdto) {
return null ;
}
//게시판 전체 리스트 페이지 (select) - 여러건 구현부
public List<BoardDTO> boardList(Criteria cri) {
return boardMapper.getList(cri);
//결과를 이쪽으로 보내야하니까 리턴 자체가 저렇게됨
}
//수정(update) 구현부
public void boardUpdate(BoardDTO bdto2) {
boardMapper.boardUpdate(bdto2);
}
//삭제(delete) 구현부
public void boardDelete(BoardDTO bdtoD) {
boardMapper.boardDelete(bdtoD);
}
//servlet-context에 service를 추가해줘야함
public BoardDTO detail(@RequestParam("bno") int bno) {
return boardMapper.detail(bno);
}
}
lbmservice
package org.lhr.service;
import java.util.ArrayList;
import org.lhr.DTO.LBMboardDTO;
import org.lhr.DTO.LBMmemberDTO;
import org.springframework.web.bind.annotation.RequestParam;
public interface LBMService {
public void memberinsert(LBMmemberDTO lbmm);
public void boardwrite(LBMboardDTO lbmb);
public void boardmodify(LBMboardDTO lbmb);
public void boarddelete(LBMboardDTO lbmb);
public ArrayList<LBMboardDTO> boardlist();
public LBMboardDTO boarddetail(@RequestParam("bno") int bno);
}
lbmimple
package org.lhr.service;
import java.util.ArrayList;
import org.lhr.DTO.LBMboardDTO;
import org.lhr.DTO.LBMmemberDTO;
import org.lhr.mapper.LBMMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
@Service
public class LBMServiceImpl implements LBMService{
@Autowired
LBMMapper lbmmp;
public void memberinsert(LBMmemberDTO lbmm) {
lbmmp.addmember(lbmm);
}
public void boardwrite(LBMboardDTO lbmb) {
lbmmp.write(lbmb);
}
public void boardmodify(LBMboardDTO lbmb) {
lbmmp.modify(lbmb);
}
public void boarddelete(LBMboardDTO lbmb) {
lbmmp.delete(lbmb);
}
public ArrayList<LBMboardDTO> boardlist() {
return lbmmp.boardlist();
}
public LBMboardDTO boarddetail(@RequestParam("bno") int bno) {
System.out.println("service="+lbmmp.boarddetail(bno));
return lbmmp.boarddetail(bno);
}
}
memberservice
package org.lhr.service;
import java.util.ArrayList;
import org.lhr.DTO.Criteria;
import org.lhr.DTO.MemberDTO;
public interface MemberService {
//회원정보수정
public void memberupdate(MemberDTO mdto);
//회원가입
public void memberinsert(MemberDTO mdto);
//회원 탈퇴
public void memberdelete(MemberDTO mdto);
//회원 리스트
public ArrayList<MemberDTO> memberlist(Criteria cri);
//회원정보
public MemberDTO memberdetail(MemberDTO mdto);
//페이징 처리하기 위한 전체 건수
public int getTotal();
}
memberimple
package org.lhr.service;
import java.util.ArrayList;
import org.lhr.DTO.Criteria;
import org.lhr.DTO.MemberDTO;
import org.lhr.mapper.MemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class MemberServiceImpl implements MemberService {
@Autowired
MemberMapper mbmp;
public void memberupdate(MemberDTO mdto){
mbmp.memberupdate(mdto);
};
public void memberinsert(MemberDTO mdto){
mbmp.memberinsert(mdto);
};
public void memberdelete(MemberDTO mdto){
mbmp.memberdelete(mdto);
};
public ArrayList<MemberDTO> memberlist(Criteria cri){
return mbmp.memberlist(cri);
};
public MemberDTO memberdetail(MemberDTO mdto){
return mbmp.memberdetail(mdto);
};
public int getTotal() {
return mbmp.getTotal();
}
}
'Programming > 게시판 만들기' 카테고리의 다른 글
[게시판 만들기] js (0) | 2021.02.14 |
---|---|
[게시판 만들기] mapper.xml (0) | 2021.02.14 |
[게시판 만들기] MAPPER (0) | 2021.02.14 |
[게시판 만들기] DTO (0) | 2021.02.14 |
[게시판 만들기] board controller / member controller (0) | 2021.02.14 |