From a7dd2177cd63602e5c1db4eea7ff20d8f4c98302 Mon Sep 17 00:00:00 2001 From: mcutegs2 Date: Mon, 15 Jun 2020 19:25:27 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"1.=20DB=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=20=EA=B4=80=EB=A0=A8=20Dao,=20Vo=20=EC=9E=90=EB=B0=94?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=EC=83=9D=EC=84=B1""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9bc7963d4c05243f14b224f4952644719cb43d4b. --- hospital/src/main/java/DB/BasicDao.java | 28 +++++ hospital/src/main/java/DB/BoardDao.java | 115 ++++++++++++++++++ hospital/src/main/java/DB/BoardVo.java | 69 +++++++++++ hospital/src/main/java/DB/MemberDao.java | 78 ++++++++++++ hospital/src/main/java/DB/MemberVo.java | 75 ++++++++++++ .../main/java/command/BoardViewCommand.java | 20 +++ .../src/main/java/controller/Fcontroller.java | 2 + hospital/src/main/webapp/boardView.jsp | 50 ++++++++ hospital/src/main/webapp/index.jsp | 2 +- hospital/src/main/webapp/patientJoin.jsp | 26 +--- 10 files changed, 440 insertions(+), 25 deletions(-) create mode 100644 hospital/src/main/java/DB/BasicDao.java create mode 100644 hospital/src/main/java/DB/BoardDao.java create mode 100644 hospital/src/main/java/DB/BoardVo.java create mode 100644 hospital/src/main/java/DB/MemberDao.java create mode 100644 hospital/src/main/java/DB/MemberVo.java create mode 100644 hospital/src/main/java/command/BoardViewCommand.java create mode 100644 hospital/src/main/webapp/boardView.jsp diff --git a/hospital/src/main/java/DB/BasicDao.java b/hospital/src/main/java/DB/BasicDao.java new file mode 100644 index 0000000..f808b23 --- /dev/null +++ b/hospital/src/main/java/DB/BasicDao.java @@ -0,0 +1,28 @@ +package DB; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class BasicDao { + private String driver = "com.mysql.jdbc.Driver"; + private String url = "jdbc:mysql://@110.35.119.108:3307:hospital_DB"; + private String user = "mes"; + private String password = "Mestkdrhdghldmlth1!"; + protected Connection conn; + protected PreparedStatement psmt; + protected ResultSet rs; + + public BasicDao() { + try { + Class.forName(this.driver); + this.conn = DriverManager.getConnection(this.url, this.user, this.password); + + } catch (SQLException | ClassNotFoundException var2) { + var2.printStackTrace(); + } + + } +} diff --git a/hospital/src/main/java/DB/BoardDao.java b/hospital/src/main/java/DB/BoardDao.java new file mode 100644 index 0000000..3c91978 --- /dev/null +++ b/hospital/src/main/java/DB/BoardDao.java @@ -0,0 +1,115 @@ +package DB; + +import java.sql.SQLException; +import java.util.ArrayList; + +public class BoardDao extends BasicDao { + private final String SELECT_ALL = "SELECT * FROM user_tbl"; + + public BoardDao() { + } + + public ArrayList select() { + ArrayList list = new ArrayList(); + + try { + this.psmt = this.conn.prepareStatement("SELECT * FROM user_tbl"); + this.rs = this.psmt.executeQuery(); + + while(this.rs.next()) { + BoardVo vo = new BoardVo(); + vo.u_ID(this.rs.getInt("u_ID")); + vo.setWriter(this.rs.getString("writer")); + vo.setwDate(this.rs.getDate("wDate")); + vo.setTitle(this.rs.getString("title")); + vo.setContent(this.rs.getString("content")); + vo.setHit(this.rs.getInt("hit")); + list.add(vo); + } + } catch (SQLException var3) { + var3.printStackTrace(); + } + + return list; + } + + public BoardVo select(BoardVo vo) { + try { + int boardId = vo.getBoardId(); + this.psmt = this.conn.prepareStatement("SELECT * FROM BOARD WHERE boardId = ?"); + this.psmt.setInt(1, boardId); + this.rs = this.psmt.executeQuery(); + if (this.rs.next()) { + vo.setWriter(this.rs.getString("writer")); + vo.setwDate(this.rs.getDate("wDate")); + vo.setTitle(this.rs.getString("title")); + vo.setContent(this.rs.getString("content")); + vo.setHit(this.rs.getInt("hit")); + this.hitCountUp(this.rs.getInt("boardId")); + } + } catch (SQLException var3) { + var3.printStackTrace(); + } + + return vo; + } + + public int insert(BoardVo vo) { + int n = 0; + + try { + this.psmt = this.conn.prepareStatement("insert into board values(b_num.nextval,?,?,?,?,0)"); + this.psmt.setString(1, vo.getWriter()); + this.psmt.setDate(2, vo.getwDate()); + this.psmt.setString(3, vo.getTitle()); + this.psmt.setString(4, vo.getContent()); + n = this.psmt.executeUpdate(); + } catch (SQLException var4) { + var4.printStackTrace(); + } + + return n; + } + + public int update(BoardVo vo) { + int n = 0; + + try { + this.psmt = this.conn.prepareStatement("update board set content = ? where boardId = ?"); + this.psmt.setInt(1, vo.getBoardId()); + this.psmt.setString(2, vo.getContent()); + n = this.psmt.executeUpdate(); + } catch (SQLException var4) { + var4.printStackTrace(); + } + + return n; + } + + public int delete(BoardVo vo) { + int n = 0; + + try { + this.psmt = this.conn.prepareStatement("delete from board where boardId = ?"); + this.psmt.setInt(1, vo.getBoardId()); + n = this.psmt.executeUpdate(); + } catch (SQLException var4) { + var4.printStackTrace(); + } + + return n; + } + + public void hitCountUp(int id) { + String var2 = "UPDATE board set hit = hit+1 where boardId = ?"; + + try { + this.psmt = this.conn.prepareStatement("UPDATE board set hit = hit+1 where boardId = ?"); + this.psmt.setInt(1, id); + this.psmt.executeUpdate(); + } catch (SQLException var4) { + var4.printStackTrace(); + } + + } +} diff --git a/hospital/src/main/java/DB/BoardVo.java b/hospital/src/main/java/DB/BoardVo.java new file mode 100644 index 0000000..aeb3be9 --- /dev/null +++ b/hospital/src/main/java/DB/BoardVo.java @@ -0,0 +1,69 @@ +package DB; + +import java.sql.Date; + +public class BoardVo { + int boardId; + String writer; + String u_ID; + Date wDate; + String title; + String content; + int hit; + + public BoardVo() { + } + + public String getWriter() { + return this.writer; + } + + public void setWriter(String writer) { + this.writer = writer; + } + + public int getBoardId() { + return this.boardId; + } + + public void setBoardId(int boardId) { + this.boardId = boardId; + } + + public Date getwDate() { + return this.wDate; + } + + public void setwDate(Date wDate) { + this.wDate = wDate; + } + + public String getTitle() { + return this.title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return this.content; + } + + public void setContent(String content) { + this.content = content; + } + + public int getHit() { + return this.hit; + } + + public void setHit(int hit) { + this.hit = hit; + } + + public void u_ID(String u_ID) { + // TODO Auto-generated method stub + + } +} diff --git a/hospital/src/main/java/DB/MemberDao.java b/hospital/src/main/java/DB/MemberDao.java new file mode 100644 index 0000000..e4c3425 --- /dev/null +++ b/hospital/src/main/java/DB/MemberDao.java @@ -0,0 +1,78 @@ + +package DB; + +import java.sql.SQLException; +import java.util.ArrayList; + +public class MemberDao extends BasicDao { + private final String MEMBER_LIST = "SELECT * FROM member"; + private final String MEMBER_CHECK = "SELECT * FROM member WHERE id = ? and pw = ?"; + private final String MEMBER_INSERT = "INSERT into member values(?,?,?,?,?,?,?)"; + + public MemberDao() { + } + + public ArrayList select() { + ArrayList list = new ArrayList(); + + try { + this.psmt = this.conn.prepareStatement("SELECT * FROM member"); + this.rs = this.psmt.executeQuery(); + + while(this.rs.next()) { + MemberVo member = new MemberVo(); + member.setId(this.rs.getString("ID")); + member.setName(this.rs.getString("NAME")); + member.setAddr(this.rs.getString("ADDR")); + member.setTel(this.rs.getString("TEL")); + member.setGender(this.rs.getString("GENDER")); + member.setHobby(this.rs.getString("HOBBY")); + list.add(member); + } + } catch (SQLException var3) { + var3.printStackTrace(); + } + + return list; + } + + public MemberVo selectMember(MemberVo member) { + MemberVo vo = null; + + try { + this.psmt = this.conn.prepareStatement("SELECT * FROM member WHERE id = ? and pw = ?"); + this.psmt.setString(1, member.getId()); + this.psmt.setString(2, member.getPw()); + this.rs = this.psmt.executeQuery(); + if (this.rs.next()) { + String id = this.rs.getString("id"); + String pw = this.rs.getString("pw"); + vo = new MemberVo(id, pw); + } + } catch (SQLException var5) { + var5.printStackTrace(); + } + + return vo; + } + + public int memberInsert(MemberVo member) { + int n = 0; + + try { + this.psmt = this.conn.prepareStatement("INSERT into member values(?,?,?,?,?,?,?)"); + this.psmt.setString(1, member.getId()); + this.psmt.setString(2, member.getName()); + this.psmt.setString(3, member.getPw()); + this.psmt.setString(4, member.getAddr()); + this.psmt.setString(5, member.getTel()); + this.psmt.setString(6, member.getGender()); + this.psmt.setString(7, member.getHobby()); + n = this.psmt.executeUpdate(); + } catch (SQLException var4) { + var4.printStackTrace(); + } + + return n; + } +} diff --git a/hospital/src/main/java/DB/MemberVo.java b/hospital/src/main/java/DB/MemberVo.java new file mode 100644 index 0000000..a696c8f --- /dev/null +++ b/hospital/src/main/java/DB/MemberVo.java @@ -0,0 +1,75 @@ +package DB; + +public class MemberVo { + public String id; + public String name; + public String pw; + public String addr; + public String tel; + public String gender; + public String hobby; + + public MemberVo() { + } + + public MemberVo(String id, String pw) { + this.id = id; + this.pw = pw; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddr() { + return this.addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } + + public String getTel() { + return this.tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + public String getGender() { + return this.gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public String getHobby() { + return this.hobby; + } + + public void setHobby(String hobby) { + this.hobby = hobby; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPw() { + return this.pw; + } + + public void setPw(String pw) { + this.pw = pw; + } + } \ No newline at end of file diff --git a/hospital/src/main/java/command/BoardViewCommand.java b/hospital/src/main/java/command/BoardViewCommand.java new file mode 100644 index 0000000..3dd86eb --- /dev/null +++ b/hospital/src/main/java/command/BoardViewCommand.java @@ -0,0 +1,20 @@ +package command; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import DB.BoardDao; +import DB.BoardVo; + +public class BoardViewCommand implements Command { + public BoardViewCommand() { + } + + public String exec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + return "boardView.jsp"; + } +} diff --git a/hospital/src/main/java/controller/Fcontroller.java b/hospital/src/main/java/controller/Fcontroller.java index 345f069..f225cb4 100644 --- a/hospital/src/main/java/controller/Fcontroller.java +++ b/hospital/src/main/java/controller/Fcontroller.java @@ -11,6 +11,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import command.BoardViewCommand; import command.Command; import command.HomeCommand; import command.UserJoinCommand; @@ -36,6 +37,7 @@ public class Fcontroller extends HttpServlet { list.put("/patientlogin.do", new patientLoginCommand()); // 환자 로그인 처리 list.put ("/UserJoin.do", new UserJoinCommand()); // 임직원 회원가입 페이지 list.put ("/patientJoin.do", new patientJoinCommand()); // 환자 회원가입 페이지 + list.put("/boardView.do", new BoardViewCommand()); // 데이터 보기 test 페이지 //이 부분에 계속적으로 매핑을 추가하면 됨 } diff --git a/hospital/src/main/webapp/boardView.jsp b/hospital/src/main/webapp/boardView.jsp new file mode 100644 index 0000000..89dd079 --- /dev/null +++ b/hospital/src/main/webapp/boardView.jsp @@ -0,0 +1,50 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + + + + +
+
+
+ + + + + + + + + + + + + + + +
작성자${board.writer}작성일자${board.wDate}
제목${board.title}
내용${board.content}
+
+
+
+ + \ No newline at end of file diff --git a/hospital/src/main/webapp/index.jsp b/hospital/src/main/webapp/index.jsp index 59f6e7b..ead8ab9 100644 --- a/hospital/src/main/webapp/index.jsp +++ b/hospital/src/main/webapp/index.jsp @@ -5,7 +5,7 @@ 병원 관리 시스템 - + diff --git a/hospital/src/main/webapp/patientJoin.jsp b/hospital/src/main/webapp/patientJoin.jsp index 44022d9..385532e 100644 --- a/hospital/src/main/webapp/patientJoin.jsp +++ b/hospital/src/main/webapp/patientJoin.jsp @@ -56,7 +56,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -95,28 +95,6 @@ - - - - -
회원명환자성명
회원ID   생년월일
병과나이
성별
직책 -
-     - -
-
-     - -
-
-     - -
-
-     - -
-