ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [게시판] Model
    프로젝트 2022. 7. 21. 12:45

    BoardVO

    package com.ptsd.model;
    
    import lombok.AllArgsConstructor;
    import lombok.Getter;
    import lombok.NoArgsConstructor;
    import lombok.NonNull;
    import lombok.RequiredArgsConstructor;
    import lombok.Setter;
    
    @AllArgsConstructor
    @NoArgsConstructor
    @RequiredArgsConstructor
    @Getter
    @Setter
    
    public class BoardVO {
    	
    	@NonNull
    	private String TAXI_NUM;
    	@NonNull
    	private String TAXI_COMMENT_TITLE;
    	@NonNull
    	private String TAXI_COMMENT_WRITER;
    	// @NonNull
    	// private String taxi_comment_fileName;
    	@NonNull
    	private String TAXI_COMMENT_COMMENT;
    	private String TAXI_COMMENT_DATE;
    	private int TAXI_COMMENT_SEQ;
    	private int BOARDLIST_NUM;
    	@NonNull
    	private float RATING;
    	
    }

     

    BoardDAO

    package com.ptsd.model;
    
    import java.util.ArrayList;
    
    import javax.servlet.annotation.WebServlet;
    
    import org.apache.ibatis.session.SqlSession;
    import org.apache.ibatis.session.SqlSessionFactory;
    
    import com.ptsd.database.SqlSessionManager;
    
    public class BoardDAO {
    
    	private SqlSessionFactory sqlSessionFactory = SqlSessionManager.getSqlSession();
    	private SqlSession sqlSession = null;
    	
    	
    	// 게시글 업로드
    	public int upload(BoardVO vo) {
    		int row = 0;
    		try {
    			sqlSession = sqlSessionFactory.openSession(true);
    			row = sqlSession.insert("com.ptsd.model.BoardDAO.boardinsert",vo);
    			System.out.println("1");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}finally {
    			sqlSession.close();
    		}
    		
    		return row;
    	}
    	
    	// 게시글 목록 조회
    	public ArrayList<BoardVO> showBoard() {
    		//int startNum = (page-1)*10+1;
    		//int endNum = page*10;
    		// DB에 있는 레코드의 모든 정보를 가져오는 기능에 그 레코드에 가상의 번호를 붙여서 총 몇 개의 레코드가 존재하는지를 계산하는 기능을 추가해야합니다.
    		ArrayList<BoardVO> list = new ArrayList<BoardVO>();
    		try {
    			sqlSession = sqlSessionFactory.openSession(true);
    			list = (ArrayList)sqlSession.selectList("com.ptsd.model.BoardDAO.boardselect");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}finally {
    			sqlSession.close();
    		}
    		
    		return list;
    	}
    	
    	// 게시글 세부내용
    	public BoardVO showDetail(int BOARDLIST_NUM) {
    		BoardVO vo = null;
    		try {
    			sqlSession = sqlSessionFactory.openSession(true);
    			vo = sqlSession.selectOne("com.ptsd.model.BoardDAO.boarddetail", BOARDLIST_NUM);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}finally {
    			sqlSession.close();
    		}
    		
    		return vo;
    		
    	}
    	
    	// 게시글 삭제
    	public int ListDelete(int TAXI_COMMENT_SEQ) {
    		int row = 0;
    		try {
    			sqlSession = sqlSessionFactory.openSession(true);
    			row = sqlSession.delete("com.ptsd.model.BoardDAO.boarddelete", TAXI_COMMENT_SEQ);
    			System.out.println(row);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}finally {
    			sqlSession.close();
    		}
    		
    		return row;
    	}
    
    	public int getCount(String kwd) {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    	
    }

    '프로젝트' 카테고리의 다른 글

    [ jsp ] index.jsp  (0) 2022.07.21
    [ jsp ] board.jsp  (0) 2022.07.21
    [게시판] DataBase  (0) 2022.07.21
    [게시판] Controller  (0) 2022.07.21
    [로그인/로그아웃] Controller  (0) 2022.07.21

    댓글

Designed by Tistory.