Index: nextboard/.classpath
===================================================================
--- nextboard/.classpath (revision 3)
+++ nextboard/.classpath (revision 3)
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
Index: nextboard/.project
===================================================================
--- nextboard/.project (revision 3)
+++ nextboard/.project (revision 3)
@@ -0,0 +1,36 @@
+
+
+ nextboard
+
+
+
+
+
+ org.eclipse.wst.jsdt.core.javascriptValidator
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.wst.common.project.facet.core.nature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.wst.jsdt.core.jsNature
+
+
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/MemoDao.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/MemoDao.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/MemoDao.java (revision 3)
@@ -0,0 +1,66 @@
+/**
+ * Memo 관련 인터페이스
+ */
+package org.springframework.samples.kyuriboard.dao;
+
+import java.util.List;
+
+import org.springframework.samples.kyuriboard.domain.Memo;
+import org.springframework.dao.DataAccessException;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public interface MemoDao {
+
+
+ /**
+ * 주어진 메모ID로 메모를 반환한다.
+ * @param memoId 메모ID
+ * @return Memo 메모 객체
+ * @throws DataAccessException
+ */
+ Memo getMemoByMemoId(int memoId) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시판ID로 메모 리스트를 반환한다.
+ * @param boardId 게시판ID
+ * @return java.util.List
+ * @throws DataAccessException
+ */
+ List getMemoListByBoardId(int boardId) throws DataAccessException;
+
+
+ /**
+ * 메모를 입력한다.
+ * @param memo 메모 객체
+ * @throws DataAccessException
+ */
+ void insertMemo(Memo memo) throws DataAccessException;
+
+
+ /**
+ * 메모를 수정한다
+ * @param memo 메모 객체
+ * @throws DataAccessException
+ */
+ void updateMemo(Memo memo) throws DataAccessException;
+
+
+ /**
+ * 메모를 삭제한다
+ * @param memoId 삭제할 메모 ID
+ * @throws DataAccessException
+ */
+ void deleteMemo(int memoId) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물ID에 해당하는 메모들을 삭제한다
+ * @param boardId 삭제할 게시물 ID
+ * @throws DataAccessException
+ */
+ void deleteMemoByBoardId(int boardId) throws DataAccessException;
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/UserDao.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/UserDao.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/UserDao.java (revision 3)
@@ -0,0 +1,62 @@
+/**
+ * 사용자 관련 인터페이스
+ */
+package org.springframework.samples.kyuriboard.dao;
+
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.samples.kyuriboard.domain.User;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ * User 도메인 클래스에 대한 처리
+ */
+public interface UserDao {
+
+
+ /**
+ * 주어진 사용자ID로 사용자를 반환한다.
+ * @param userId 사용자ID
+ * @return User 사용자
+ * @throws DataAccessException
+ */
+ User getUserByUserId(String userId) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자ID와 비밀번호로 사용자를 반환한다.
+ * @param userId 사용자ID
+ * @param passwd 사용자 비밀번호
+ * @return User 사용자
+ * @throws DataAccessException
+ */
+ User getUserByUserIdAndPasswd(String userId, String passwd) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자를 입력한다.
+ * @param user 사용자
+ * @throws DataAccessException
+ */
+ void insertUser(User user) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자를 수정한다.
+ * @param user 사용자
+ * @throws DataAccessException
+ */
+ void updateUser(User user) throws DataAccessException;
+
+
+ /**
+ * 사용자 리스트를 반환한다.
+ * @return java.util.List 사용자 리스트
+ * @throws DataAccessException
+ */
+ List getUserList() throws DataAccessException;
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/BoardDao.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/BoardDao.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/BoardDao.java (revision 3)
@@ -0,0 +1,87 @@
+/**
+ * Board 객체 관련 Interface
+ */
+package org.springframework.samples.kyuriboard.dao;
+
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.samples.kyuriboard.domain.Board;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public interface BoardDao {
+
+
+ /**
+ * 주어진 게시물ID로 게시물 객체를 반환한다.
+ * @param boardId 게시물ID
+ * @return Board 게시물 객체
+ * @throws DataAccessException
+ */
+ Board getBoardByBoardId(int boardId) throws DataAccessException;
+
+
+ /**
+ * 게시물의 총 리스트를 반환한다.
+ * @return java.util.List 게시물 총 리스트
+ * @throws DataAccessException
+ */
+ List getBoardList() throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자ID에 해당하는 게시물 리스트를 반환한다.
+ * @param userId 사용자ID
+ * @return java.util.List 게시물 리스트
+ * @throws DataAccessException
+ */
+ List getBoardListByUserId(String userId) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자명에 해당하는 게시물 리스트를 반환한다.
+ * @param userName 사용자명
+ * @return java.util.List 게시물 리스트
+ * @throws DataAccessException
+ */
+ List getBoardListByUserName(String userName) throws DataAccessException;
+
+
+ /**
+ * 주어진 제목에 해당하는 게시물 리스트를 반환한다.
+ * @param title 게시물 제목
+ * @return java.util.List 게시물 리스트
+ * @throws DataAccessException
+ */
+ List getBoardListByTitle(String title) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물을 입력한다.
+ * @param board 입력할 게시물 객체
+ * @throws DataAccessException
+ */
+ void insertBoard(Board board) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물을 수정한다.
+ * @param board 수정할 게시물
+ * @throws DataAccessException
+ */
+ void updateBoard(Board board) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물을 삭제한다
+ * @param boardId 삭제할 게시물 ID
+ * @throws DataAccessException
+ */
+ void deleteBoard(int boardId) throws DataAccessException;
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapMemoDao.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapMemoDao.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapMemoDao.java (revision 3)
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.dao.ibatis;
+
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
+import org.springframework.samples.kyuriboard.dao.MemoDao;
+import org.springframework.samples.kyuriboard.domain.Memo;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class SqlMapMemoDao extends SqlMapClientDaoSupport implements MemoDao {
+
+ private SqlMapSequenceDao sequenceDao;
+
+ public void setSequenceDao(SqlMapSequenceDao sequenceDao) {
+ this.sequenceDao = sequenceDao;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.MemoDao#deleteMemo(int)
+ */
+ public void deleteMemo(int memoId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ Object parameterObject = new Integer(memoId);
+ getSqlMapClientTemplate().delete("deleteMemo", parameterObject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.MemoDao#getMemoByMemoId(int)
+ */
+ public Memo getMemoByMemoId(int memoId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ Object parameterObject = new Integer(memoId);
+ return (Memo) getSqlMapClientTemplate().queryForObject("getMemoByMemoId", parameterObject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.MemoDao#getMemoListByBoardId(int)
+ */
+ public List getMemoListByBoardId(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ Object parameterObject = new Integer(boardId);
+ return getSqlMapClientTemplate().queryForList("getMemoListByBoardId", parameterObject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.MemoDao#insertMemo(org.springframework.samples.kyuriboard.domain.Memo)
+ */
+ public void insertMemo(Memo memo) throws DataAccessException {
+ // TODO Auto-generated method stub
+ memo.setMemoId(this.sequenceDao.getNextId("memoid"));
+ getSqlMapClientTemplate().insert("insertMemo", memo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.MemoDao#updateMemo(org.springframework.samples.kyuriboard.domain.Memo)
+ */
+ public void updateMemo(Memo memo) throws DataAccessException {
+ // TODO Auto-generated method stub
+ getSqlMapClientTemplate().update("updateMemo", memo);
+ }
+
+ public void deleteMemoByBoardId(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ Object parameterObject = new Integer(boardId);
+ getSqlMapClientTemplate().update("deleteMemoByBoardId", parameterObject);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapUserDao.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapUserDao.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapUserDao.java (revision 3)
@@ -0,0 +1,63 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.dao.ibatis;
+
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
+import org.springframework.samples.kyuriboard.dao.UserDao;
+import org.springframework.samples.kyuriboard.domain.User;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class SqlMapUserDao extends SqlMapClientDaoSupport implements UserDao {
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.UserDao#getUserByUserId(java.lang.String)
+ */
+ public User getUserByUserId(String userId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return (User) getSqlMapClientTemplate().queryForObject("getUserByUserId", userId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.UserDao#getUserByUserIdAndPasswd(java.lang.String, java.lang.String)
+ */
+ public User getUserByUserIdAndPasswd(String userId, String passwd)
+ throws DataAccessException {
+ // TODO Auto-generated method stub
+ User user = new User();
+ user.setUserId(userId);
+ user.setPasswd(passwd);
+ return (User) getSqlMapClientTemplate().queryForObject("getUserByUserIdAndPasswd", user);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.UserDao#getUserList()
+ */
+ public List getUserList() throws DataAccessException {
+ // TODO Auto-generated method stub
+ return getSqlMapClientTemplate().queryForList("getUserList", null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.UserDao#insertUser(org.springframework.samples.kyuriboard.domain.User)
+ */
+ public void insertUser(User user) throws DataAccessException {
+ // TODO Auto-generated method stub
+ getSqlMapClientTemplate().insert("insertUser", user);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.UserDao#updateUser(org.springframework.samples.kyuriboard.domain.User)
+ */
+ public void updateUser(User user) throws DataAccessException {
+ // TODO Auto-generated method stub
+ getSqlMapClientTemplate().update("updateUser", user);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Board.xml
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Board.xml (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Board.xml (revision 3)
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT boardid, title, visited, recom, userip, htmlyn, insertdate, content, userid
+ FROM board
+ WHERE boardid = #value#
+
+
+
+ SELECT boardid, title, visited, recom, userip, htmlyn, insertdate, content, userid
+ FROM board
+ ORDER BY boardid DESC
+
+
+
+ SELECT boardid, title, visited, recom, userip, htmlyn, insertdate, content, userid
+ FROM board
+ WHERE userid = #value#
+ ORDER BY boardid DESC
+
+
+
+ SELECT boardid, title, visited, recom, userip, htmlyn, insertdate, content, userid
+ FROM board
+ WHERE userid LIKE '%$value$%'
+ ORDER BY boardid DESC
+
+
+
+ SELECT boardid, title, visited, recom, userip, htmlyn, insertdate, content, userid
+ FROM board
+ WHERE title LIKE '%$value$%'
+ ORDER BY boardid DESC
+
+
+
+ INSERT INTO board
+ (boardid, title, visited, recom, userip, htmlyn, insertdate, content, userid)
+ VALUES (#boardId#, #title#, #visited#, #recom#, #userIp#, #htmlyn#, sysdate(), #content#, #userId#)
+
+
+
+ UPDATE board
+ SET title = #title#,
+ visited = #visited#,
+ recom = #recom#,
+ userip = #userIp#,
+ htmlyn = #htmlyn#,
+ insertdate = #insertDate#,
+ content = #content#,
+ userid = #userId#
+ WHERE boardid = #boardId#
+
+
+
+ DELETE FROM board
+ WHERE boardid = #value#
+
+
+
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Sequence.xml
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Sequence.xml (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Sequence.xml (revision 3)
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+ SELECT name, nextid
+ FROM sequence
+ WHERE name = #name#
+
+
+
+ UPDATE sequence
+ SET nextid = #nextId#
+ WHERE name = #name#
+
+
+
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Memo.xml
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Memo.xml (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/Memo.xml (revision 3)
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT memoid, boardid, content, insertdate, userid
+ FROM memo
+ WHERE memoid = #value#
+
+
+
+ SELECT memoid, boardid, content, insertdate, userid
+ FROM memo
+ WHERE boardid = #value#
+ ORDER BY memoid DESC
+
+
+
+ INSERT INTO memo
+ (memoid, boardid, content, insertdate, userid)
+ VALUES (#memoId#, #boardId#, #content#, sysdate(), #userId#)
+
+
+
+ UPDATE memo
+ SET boardid = #boardId#,
+ content = #content#,
+ insertdate = #insertDate#,
+ userid = #userId#
+ WHERE memoid = #memoId#
+
+
+
+ DELETE FROM memo
+ WHERE memoid = #value#
+
+
+
+ DELETE FROM memo
+ WHERE boardid = #value#
+
+
+
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/User.xml
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/User.xml (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/maps/User.xml (revision 3)
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT userid, username, passwd, email, insertdate
+ FROM user
+ WHERE userid = #value#
+
+
+
+ SELECT userid, username, passwd, email, insertdate
+ FROM user
+ WHERE userid = #userId#
+ AND passwd = #passwd#
+
+
+
+ SELECT userid, username, passwd, email, insertdate
+ FROM user
+
+
+
+ INSERT INTO user
+ (userid, username, passwd, email, insertdate)
+ VALUES (#userId#, #userName#, #passwd#, #email#, sysdate())
+
+
+
+ UPDATE user
+ SET username = #userName#
+ , passwd = #passwd#
+ , email = #email#
+ WHERE userid = #userId#
+
+
+
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/Sequence.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/Sequence.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/Sequence.java (revision 3)
@@ -0,0 +1,76 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.dao.ibatis;
+
+import java.io.Serializable;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class Sequence implements Serializable {
+
+ /**
+ * 직렬화 ID
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 씨퀀스 이름(PK)
+ */
+ private String name;
+
+ /**
+ * 씨퀀스 번호
+ */
+ private int nextId;
+
+ /**
+ * Default 생성자
+ *
+ */
+ public Sequence() {
+ }
+
+ /**
+ * 인자 생성자
+ * @param name 씨퀀스 이름
+ * @param nextId 씨퀀스 ID
+ */
+ public Sequence(String name, int nextId) {
+ this.name = name;
+ this.nextId = nextId;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the nextId
+ */
+ public int getNextId() {
+ return nextId;
+ }
+
+ /**
+ * @param nextId the nextId to set
+ */
+ public void setNextId(int nextId) {
+ this.nextId = nextId;
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapBoardDao.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapBoardDao.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapBoardDao.java (revision 3)
@@ -0,0 +1,95 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.dao.ibatis;
+
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
+import org.springframework.samples.kyuriboard.dao.BoardDao;
+import org.springframework.samples.kyuriboard.domain.Board;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class SqlMapBoardDao extends SqlMapClientDaoSupport implements BoardDao {
+
+ private SqlMapSequenceDao sequenceDao;
+
+ public void setSequenceDao(SqlMapSequenceDao sequenceDao) {
+ this.sequenceDao = sequenceDao;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#deleteBoard(int)
+ */
+ public void deleteBoard(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ Object parameterObject = new Integer(boardId);
+ getSqlMapClientTemplate().delete("deleteBoard", parameterObject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardByBoardId(int)
+ */
+ public Board getBoardByBoardId(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ Object parameterObject = new Integer(boardId);
+ return (Board) getSqlMapClientTemplate().queryForObject("getBoardByBoardId", parameterObject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardList()
+ */
+ public List getBoardList() throws DataAccessException {
+ // TODO Auto-generated method stub
+ return getSqlMapClientTemplate().queryForList("getBoardList");
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardListByTitle(java.lang.String)
+ */
+ public List getBoardListByTitle(String title) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return getSqlMapClientTemplate().queryForList("getBoardListByTitle", title);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardListByUserId(java.lang.String)
+ */
+ public List getBoardListByUserId(String userId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return getSqlMapClientTemplate().queryForList("getBoardListByUserId", userId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#getBoardListByUserName(java.lang.String)
+ */
+ public List getBoardListByUserName(String userName)
+ throws DataAccessException {
+ // TODO Auto-generated method stub
+ return getSqlMapClientTemplate().queryForList("getBoardListByUserName", userName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#insertBoard(org.springframework.samples.kyuriboard.domain.Board)
+ */
+ public void insertBoard(Board board) throws DataAccessException {
+ // TODO Auto-generated method stub
+ board.setBoardId(this.sequenceDao.getNextId("boardid"));
+ getSqlMapClientTemplate().insert("insertBoard", board);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.dao.BoardDao#updateBoard(org.springframework.samples.kyuriboard.domain.Board)
+ */
+ public void updateBoard(Board board) throws DataAccessException {
+ // TODO Auto-generated method stub
+ getSqlMapClientTemplate().update("updateBoard", board);
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapSequenceDao.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapSequenceDao.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/dao/ibatis/SqlMapSequenceDao.java (revision 3)
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.dao.ibatis;
+
+import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
+import org.springframework.dao.DataAccessException;
+import org.springframework.dao.DataRetrievalFailureException;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class SqlMapSequenceDao extends SqlMapClientDaoSupport {
+
+ /**
+ * 씨퀀스의 다음 ID를 얻어오고, 해당 시퀀스의 번호를 1 증가 시킨다.
+ * @param name 해당 시퀀스 명
+ * @return 시퀀스의 증가된 값
+ * @throws DataAccessException 해당 시퀀스 Row를 찾을 수 없슴.
+ */
+ public int getNextId(String name) throws DataAccessException {
+ Sequence sequence = new Sequence(name, -1);
+ sequence = (Sequence) getSqlMapClientTemplate().queryForObject("getSequence", sequence);
+ if (sequence == null) {
+ throw new DataRetrievalFailureException("Could not get next value of sequence [" + name + "] : sequence does not exist");
+ }
+ Object parameterObject = new Sequence(name, sequence.getNextId() + 1);
+ getSqlMapClientTemplate().update("updateSequence", parameterObject, 1);
+ return sequence.getNextId();
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/domain/Board.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/domain/Board.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/domain/Board.java (revision 3)
@@ -0,0 +1,200 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class Board implements Serializable {
+
+ /**
+ * 직렬화 ID
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 게시물 ID
+ */
+ private int boardId;
+
+ /**
+ * 게시물 제목
+ */
+ private String title;
+
+ /**
+ * 조회수
+ */
+ private int visited;
+
+ /**
+ * 추천수
+ */
+ private int recom;
+
+ /**
+ * 글쓴이 IP ADDRESS
+ */
+ private String userIp;
+
+ /**
+ * 게시물의 HTML 여부(Y : HTML 문법 사용, N : HTML 문법 사용 안함)
+ */
+ private String htmlyn;
+
+ /**
+ * 게시물 입력일
+ */
+ private Date insertDate;
+
+ /**
+ * 게시물 내용
+ */
+ private String content;
+
+ /**
+ * 게시물 작성자의 사용자ID
+ */
+ private String userId;
+
+ /**
+ * @return the boardId
+ */
+ public int getBoardId() {
+ return boardId;
+ }
+
+ /**
+ * @param boardId
+ * the boardId to set
+ */
+ public void setBoardId(int boardId) {
+ this.boardId = boardId;
+ }
+
+ /**
+ * @return the content
+ */
+ public String getContent() {
+ return content;
+ }
+
+ /**
+ * @param content
+ * the content to set
+ */
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ /**
+ * @return the htmlyn
+ */
+ public String getHtmlyn() {
+ return htmlyn;
+ }
+
+ /**
+ * @param htmlyn
+ * the htmlyn to set
+ */
+ public void setHtmlyn(String htmlyn) {
+ this.htmlyn = htmlyn;
+ }
+
+ /**
+ * @return the insertDate
+ */
+ public Date getInsertDate() {
+ return insertDate;
+ }
+
+ /**
+ * @param insertDate
+ * the insertDate to set
+ */
+ public void setInsertDate(Date insertDate) {
+ this.insertDate = insertDate;
+ }
+
+ /**
+ * @return the recom
+ */
+ public int getRecom() {
+ return recom;
+ }
+
+ /**
+ * @param recom
+ * the recom to set
+ */
+ public void setRecom(int recom) {
+ this.recom = recom;
+ }
+
+ /**
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title
+ * the title to set
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return the userId
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * @param userId
+ * the userId to set
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ /**
+ * @return the userIp
+ */
+ public String getUserIp() {
+ return userIp;
+ }
+
+ /**
+ * @param userIp
+ * the userIp to set
+ */
+ public void setUserIp(String userIp) {
+ this.userIp = userIp;
+ }
+
+ /**
+ * @return the visited
+ */
+ public int getVisited() {
+ return visited;
+ }
+
+ /**
+ * @param visited
+ * the visited to set
+ */
+ public void setVisited(int visited) {
+ this.visited = visited;
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/domain/Memo.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/domain/Memo.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/domain/Memo.java (revision 3)
@@ -0,0 +1,117 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class Memo implements Serializable {
+
+ /**
+ * 직렬화 ID
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 메모 ID
+ */
+ private int memoId;
+
+ /**
+ * 메모가 속한 게시물 ID
+ */
+ private int boardId;
+
+ /**
+ * 메모 내용
+ */
+ private String content;
+
+ /**
+ * 메모 입력일
+ */
+ private Date insertDate;
+
+ /**
+ * 메모 작성자 사용자ID
+ */
+ private String userId;
+
+ /**
+ * @return the boardId
+ */
+ public int getBoardId() {
+ return boardId;
+ }
+
+ /**
+ * @param boardId the boardId to set
+ */
+ public void setBoardId(int boardId) {
+ this.boardId = boardId;
+ }
+
+ /**
+ * @return the content
+ */
+ public String getContent() {
+ return content;
+ }
+
+ /**
+ * @param content the content to set
+ */
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ /**
+ * @return the insertDate
+ */
+ public Date getInsertDate() {
+ return insertDate;
+ }
+
+ /**
+ * @param insertDate the insertDate to set
+ */
+ public void setInsertDate(Date insertDate) {
+ this.insertDate = insertDate;
+ }
+
+ /**
+ * @return the memoId
+ */
+ public int getMemoId() {
+ return memoId;
+ }
+
+ /**
+ * @param memoId the memoId to set
+ */
+ public void setMemoId(int memoId) {
+ this.memoId = memoId;
+ }
+
+ /**
+ * @return the userId
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * @param userId the userId to set
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/domain/logic/KyuriBoardFacade.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/domain/logic/KyuriBoardFacade.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/domain/logic/KyuriBoardFacade.java (revision 3)
@@ -0,0 +1,193 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.domain.logic;
+
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.samples.kyuriboard.domain.Memo;
+import org.springframework.samples.kyuriboard.domain.User;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public interface KyuriBoardFacade {
+
+ // -----------------------------------------------------------
+ // Board
+ // -----------------------------------------------------------
+
+ /**
+ * 주어진 게시물ID로 게시물 객체를 반환한다
+ * @param boardId 게시물ID
+ * @return Board 게시물 객체
+ * @throws DataAccessException
+ */
+ Board getBoardByBoardId(int boardId) throws DataAccessException;
+
+
+ /**
+ * 게시물의 총 리스트를 반환한다.
+ * @return java.util.List 게시물 총 리스트
+ * @throws DataAccessException
+ */
+ List getBoardList() throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자ID에 해당하는 게시물 리스트를 반환한다.
+ * @param userId 사용자ID
+ * @return java.util.List 게시물 리스트
+ * @throws DataAccessException
+ */
+ List getBoardListByUserId(String userId) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자명에 해당하는 게시물 리스트를 반환한다.
+ * @param userName 사용자명
+ * @return java.util.List 게시물 리스트
+ * @throws DataAccessException
+ */
+ List getBoardListByUserName(String userName) throws DataAccessException;
+
+
+ /**
+ * 주어진 제목에 해당하는 게시물 리스트를 반환한다.
+ * @param title 게시물 제목
+ * @return java.util.List 게시물 리스트
+ * @throws DataAccessException
+ */
+ List getBoardListByTitle(String title) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물을 입력한다.
+ * @param board 입력할 게시물
+ * @throws DataAccessException
+ */
+ void insertBoard(Board board) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물을 수정한다.
+ * @param board 입력할 게시물
+ * @throws DataAccessException
+ */
+ void updateBoard(Board board) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물을 삭제한다.
+ * @param boardId 삭제할 게시물 ID
+ * @throws DataAccessException
+ */
+ void deleteBoard(int boardId) throws DataAccessException;
+
+
+ // ---------------------------------------------------------
+ // Memo
+ // ---------------------------------------------------------
+
+
+ /**
+ * 주어진 메모ID에 해당하는 메모를 반환한다.
+ * @param memoId 메모ID
+ * @return Memo 메모 객체
+ * @throws DataAccessException
+ */
+ Memo getMemoByMemoId(int memoId) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물ID에 해당하는 메모 리스트를 반환한다.
+ * @param boardId 게시물ID
+ * @return java.util.List 메모 리스트
+ * @throws DataAccessException
+ */
+ List getMemoListByBoardId(int boardId) throws DataAccessException;
+
+
+ /**
+ * 주어진 메모를 입력한다.
+ * @param memo 입력할 메모
+ * @throws DataAccessException
+ */
+ void insertMemo(Memo memo) throws DataAccessException;
+
+
+ /**
+ * 주어진 메모를 수정한다.
+ * @param memo 수정할 메모
+ * @throws DataAccessException
+ */
+ void updateMemo(Memo memo) throws DataAccessException;
+
+
+ /**
+ * 주어진 메모ID에 해당하는 메모를 삭제한다.
+ * @param memoId 삭제할 메모 ID
+ * @throws DataAccessException
+ */
+ void deleteMemo(int memoId) throws DataAccessException;
+
+
+ /**
+ * 주어진 게시물ID에 해당하는 메모들을 삭제한다.
+ * @param boardId
+ * @throws DataAccessException
+ */
+ void deleteMemoByBoardId(int boardId) throws DataAccessException;
+
+
+ // ---------------------------------------------------------
+ // User
+ // ---------------------------------------------------------
+
+
+ /**
+ * 주어진 사용자ID에 해당하는 사용자를 반환한다.
+ * @param userId 사용자 ID
+ * @return User 사용자
+ * @throws DataAccessException
+ */
+ User getUserByUserId(String userId) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자ID와 비밀번호를 만족하는 사용자를 반환한다.
+ * @param userId 사용자 ID
+ * @param passwd 사용자 비밀번호
+ * @return User 사용자
+ * @throws DataAccessException
+ */
+ User getUserByUserIdAndPasswd(String userId, String passwd) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자를 등록한다.
+ * @param user 등록할 사용자
+ * @throws DataAccessException
+ */
+ void insertUser(User user) throws DataAccessException;
+
+
+ /**
+ * 주어진 사용자를 수정한다.
+ * @param user 수정할 사용자
+ * @throws DataAccessException
+ */
+ void updateUser(User user) throws DataAccessException;
+
+
+ /**
+ * 사용자 리스트를 반환한다.
+ * @return java.util.List 사용자 리스트
+ * @throws DataAccessException
+ */
+ List getUserList() throws DataAccessException;
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/domain/logic/UserValidator.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/domain/logic/UserValidator.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/domain/logic/UserValidator.java (revision 3)
@@ -0,0 +1,36 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.domain.logic;
+
+import org.springframework.samples.kyuriboard.domain.User;
+import org.springframework.validation.Errors;
+import org.springframework.validation.Validator;
+import org.springframework.validation.ValidationUtils;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class UserValidator implements Validator {
+
+ /* (non-Javadoc)
+ * @see org.springframework.validation.Validator#supports(java.lang.Class)
+ */
+ public boolean supports(Class clazz) {
+ // TODO Auto-generated method stub
+ return User.class.isAssignableFrom(clazz);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
+ */
+ public void validate(Object obj, Errors errors) {
+ // TODO Auto-generated method stub
+ ValidationUtils.rejectIfEmpty(errors, "userId", "USERID_REQUIRED", "사용자ID가 필요합니다");
+ ValidationUtils.rejectIfEmpty(errors, "userName", "USERNAME_REQUIRED", "사용자 이름이 필요합니다");
+ ValidationUtils.rejectIfEmpty(errors, "passwd", "PASSWD_REQUIRED", "비밀번호가 필요합니다");
+ ValidationUtils.rejectIfEmpty(errors, "email", "EMAIL_REQUIRED", "이메일 주소가 필요합니다");
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/domain/logic/BoardValidator.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/domain/logic/BoardValidator.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/domain/logic/BoardValidator.java (revision 3)
@@ -0,0 +1,34 @@
+/**
+ * BoardForm 객체에 대한 유효성 검증
+ */
+package org.springframework.samples.kyuriboard.domain.logic;
+
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.validation.Errors;
+import org.springframework.validation.Validator;
+import org.springframework.validation.ValidationUtils;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class BoardValidator implements Validator {
+
+ /* (non-Javadoc)
+ * @see org.springframework.validation.Validator#supports(java.lang.Class)
+ */
+ public boolean supports(Class clazz) {
+ // TODO Auto-generated method stub
+ return Board.class.isAssignableFrom(clazz);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
+ */
+ public void validate(Object obj, Errors errors) {
+ // TODO Auto-generated method stub
+ ValidationUtils.rejectIfEmpty(errors, "title", "TITLE_REQUIRED", "글 제목이 필요합니다");
+ ValidationUtils.rejectIfEmpty(errors, "content", "CONTENT_REQUIRED", "글 내용이 필요합니다");
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/domain/logic/KyuriBoardImpl.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/domain/logic/KyuriBoardImpl.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/domain/logic/KyuriBoardImpl.java (revision 3)
@@ -0,0 +1,205 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.domain.logic;
+
+import java.util.List;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.samples.kyuriboard.dao.BoardDao;
+import org.springframework.samples.kyuriboard.dao.MemoDao;
+import org.springframework.samples.kyuriboard.dao.UserDao;
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.samples.kyuriboard.domain.Memo;
+import org.springframework.samples.kyuriboard.domain.User;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class KyuriBoardImpl implements KyuriBoardFacade {
+
+ private BoardDao boardDao;
+
+ private MemoDao memoDao;
+
+ private UserDao userDao;
+
+ // -----------------------------------------------------
+ // Setter Injection
+ // -----------------------------------------------------
+
+ /**
+ * @param boardDao the boardDao to set
+ */
+ public void setBoardDao(BoardDao boardDao) {
+ this.boardDao = boardDao;
+ }
+
+ /**
+ * @param memoDao the memoDao to set
+ */
+ public void setMemoDao(MemoDao memoDao) {
+ this.memoDao = memoDao;
+ }
+
+ /**
+ * @param userDao the userDao to set
+ */
+ public void setUserDao(UserDao userDao) {
+ this.userDao = userDao;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#deleteBoard(int)
+ */
+ public void deleteBoard(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.boardDao.deleteBoard(boardId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#deleteMemo(int)
+ */
+ public void deleteMemo(int memoId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.memoDao.deleteMemo(memoId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getBoardByBoardId(int)
+ */
+ public Board getBoardByBoardId(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.boardDao.getBoardByBoardId(boardId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getBoardList()
+ */
+ public List getBoardList() throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.boardDao.getBoardList();
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getBoardListByTitle(java.lang.String)
+ */
+ public List getBoardListByTitle(String title) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.boardDao.getBoardListByTitle(title);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getBoardListByUserId(java.lang.String)
+ */
+ public List getBoardListByUserId(String userId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.boardDao.getBoardListByUserId(userId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getBoardListByUserName(java.lang.String)
+ */
+ public List getBoardListByUserName(String userName)
+ throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.boardDao.getBoardListByUserName(userName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getMemoByMemoId(int)
+ */
+ public Memo getMemoByMemoId(int memoId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.memoDao.getMemoByMemoId(memoId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getMemoListByBoardId(int)
+ */
+ public List getMemoListByBoardId(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.memoDao.getMemoListByBoardId(boardId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getUserByUserId(java.lang.String)
+ */
+ public User getUserByUserId(String userId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.userDao.getUserByUserId(userId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getUserByUserIdAndPasswd(java.lang.String, java.lang.String)
+ */
+ public User getUserByUserIdAndPasswd(String userId, String passwd)
+ throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.userDao.getUserByUserIdAndPasswd(userId, passwd);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#getUserList()
+ */
+ public List getUserList() throws DataAccessException {
+ // TODO Auto-generated method stub
+ return this.userDao.getUserList();
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#insertBoard(org.springframework.samples.kyuriboard.domain.Board)
+ */
+ public void insertBoard(Board board) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.boardDao.insertBoard(board);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#insertMemo(org.springframework.samples.kyuriboard.domain.Memo)
+ */
+ public void insertMemo(Memo memo) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.memoDao.insertMemo(memo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#insertUser(org.springframework.samples.kyuriboard.domain.User)
+ */
+ public void insertUser(User user) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.userDao.insertUser(user);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#updateBoard(org.springframework.samples.kyuriboard.domain.Board)
+ */
+ public void updateBoard(Board board) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.boardDao.updateBoard(board);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#updateMemo(org.springframework.samples.kyuriboard.domain.Memo)
+ */
+ public void updateMemo(Memo memo) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.memoDao.updateMemo(memo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade#updateUser(org.springframework.samples.kyuriboard.domain.User)
+ */
+ public void updateUser(User user) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.userDao.updateUser(user);
+ }
+
+ public void deleteMemoByBoardId(int boardId) throws DataAccessException {
+ // TODO Auto-generated method stub
+ this.memoDao.deleteMemoByBoardId(boardId);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/domain/User.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/domain/User.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/domain/User.java (revision 3)
@@ -0,0 +1,117 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class User implements Serializable {
+
+ /**
+ * 직렬화 ID
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 사용자 ID
+ */
+ private String userId;
+
+ /**
+ * 사용자 명
+ */
+ private String userName;
+
+ /**
+ * 사용자 비밀번호
+ */
+ private String passwd;
+
+ /**
+ * 사용자 이메일
+ */
+ private String email;
+
+ /**
+ * 사용자 등록일
+ */
+ private Date insertDate;
+
+ /**
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param email the email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * @return the insertDate
+ */
+ public Date getInsertDate() {
+ return insertDate;
+ }
+
+ /**
+ * @param insertDate the insertDate to set
+ */
+ public void setInsertDate(Date insertDate) {
+ this.insertDate = insertDate;
+ }
+
+ /**
+ * @return the passwd
+ */
+ public String getPasswd() {
+ return passwd;
+ }
+
+ /**
+ * @param passwd the passwd to set
+ */
+ public void setPasswd(String passwd) {
+ this.passwd = passwd;
+ }
+
+ /**
+ * @return the userId
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * @param userId the userId to set
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ /**
+ * @return the userName
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+ /**
+ * @param userName the userName to set
+ */
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/BoardFormController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/BoardFormController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/BoardFormController.java (revision 3)
@@ -0,0 +1,152 @@
+/**
+ * BoardForm에 대한 컨트롤러
+ * 게시물 수정/입력시 사용
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.validation.BindException;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.SimpleFormController;
+
+import org.apache.log4j.Logger;
+
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class BoardFormController extends SimpleFormController {
+
+ private Logger logger = Logger.getLogger(getClass());
+
+ public static final String[] HTMLYNS = {"Y", "N"};
+
+ // ----------------------------------------
+ // Setter Injection
+ // ----------------------------------------
+ private KyuriBoardFacade kyuriBoard;
+
+ public void setkyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+ public BoardFormController() {
+ setSessionForm(true);
+ setValidateOnBinding(false);
+ setCommandName("boardForm");
+ setFormView("boardForm");
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
+ */
+ protected Object formBackingObject(HttpServletRequest request) throws Exception {
+ // TODO Auto-generated method stub
+
+ if (logger.isInfoEnabled()) {
+ logger.info("formBackingObject() 호출");
+ }
+
+ if (request.getParameter("boardId") != null) {
+ return new BoardForm(this.kyuriBoard.getBoardByBoardId(new Integer(request.getParameter("boardId")).intValue()));
+ } else {
+ return new BoardForm();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.BaseCommandController#onBindAndValidate(javax.servlet.http.HttpServletRequest, java.lang.Object, org.springframework.validation.BindException)
+ */
+ protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors) throws Exception {
+ // TODO Auto-generated method stub
+
+ if (logger.isInfoEnabled()) {
+ logger.info("onBindAndValidate() 호출");
+ }
+
+ BoardForm boardForm = (BoardForm) command;
+ Board board = boardForm.getBoard();
+
+ // 구동서버가 톰캣일 경우에 한글 처리
+ // 나중에 리팩토링시 [구동 WAS] 변수를 사용하여 처리를 할 것.
+ board.setTitle(new String(board.getTitle().getBytes("8859_1"), "euc-kr"));
+ board.setContent(new String(board.getContent().getBytes("8859_1"), "euc-kr"));
+
+ errors.setNestedPath("board");
+ getValidator().validate(board, errors);
+ errors.setNestedPath("");
+
+ // 부가적인 유효성 검사
+ if ((boardForm.getBoard().getTitle() == null) || ((boardForm.getBoard().getTitle() != null) && (boardForm.getBoard().getTitle().length() < 10))) {
+ errors.reject("TITLE_NOTCORRECT", "제목은 10글자 이상이어야 합니다");
+ }
+
+ if ((boardForm.getBoard().getContent() == null) || ((boardForm.getBoard().getTitle() != null) && (boardForm.getBoard().getContent().length() < 10))) {
+ errors.reject("TITLE_NOTCORRECT", "내용은 10글자 이상이어야 합니다");
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest)
+ */
+ protected Map referenceData(HttpServletRequest request) throws Exception {
+ // TODO Auto-generated method stub
+ Map model = new HashMap();
+ model.put("htmlyns", HTMLYNS);
+ return model;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
+ */
+ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
+ // TODO Auto-generated method stub
+
+ if (logger.isInfoEnabled()) {
+ logger.info("onSubmit() 호출");
+ }
+
+ BoardForm boardForm = (BoardForm) command;
+ Board board = boardForm.getBoard();
+
+ UserSession userSession = (UserSession) request.getSession().getAttribute("userSession");
+ board.setUserIp(request.getRemoteAddr());
+ board.setUserId(userSession.getUser().getUserId());
+ board.setVisited(0);
+ board.setRecom(0);
+ board.setInsertDate(new java.util.Date());
+
+ if (logger.isInfoEnabled()) {
+ logger.info("userIp : " + board.getUserIp());
+ logger.info("userId : " + board.getUserId());
+ logger.info("title : " + board.getTitle());
+ logger.info("content : " + board.getContent());
+ logger.info("htmlyn : " + board.getHtmlyn());
+ }
+
+ try {
+ if (boardForm.isNewBoard()) {
+ this.kyuriBoard.insertBoard(board);
+ } else {
+ this.kyuriBoard.updateBoard(board);
+ }
+ } catch (Exception ex) {
+ System.out.println("에러 : " + ex.getMessage());
+ return showForm(request, response, errors);
+ }
+
+ return super.onSubmit(request, response, command, errors);
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/RecomBoardController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/RecomBoardController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/RecomBoardController.java (revision 3)
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class RecomBoardController implements Controller {
+
+ private KyuriBoardFacade kyuriBoard;
+
+ /**
+ * @param kyuriBoard the kyuriBoard to set
+ */
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+
+ // 추천수를 증가시킨다.
+ int boardId = new Integer(request.getParameter("boardId")).intValue();
+ Board board = this.kyuriBoard.getBoardByBoardId(boardId);
+ int curRecom = board.getRecom() + 1;
+ board.setRecom(curRecom);
+ this.kyuriBoard.updateBoard(board);
+
+ // 모델 객체를 탑재
+ Map model = new HashMap();
+ model.put("board", board);
+
+ return new ModelAndView("viewBoard", model);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogonController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogonController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogonController.java (revision 3)
@@ -0,0 +1,50 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.samples.kyuriboard.domain.User;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class LogonController implements Controller {
+
+ private KyuriBoardFacade kyuriBoard;
+
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+ String userId = request.getParameter("userId");
+ String passwd = request.getParameter("passwd");
+ User user = this.kyuriBoard.getUserByUserIdAndPasswd(userId, passwd);
+ if (user == null) {
+ return new ModelAndView("error", "message", "입력하신 ID와 비밀번호가 일치하지 않습니다.");
+ } else {
+ UserSession userSession = new UserSession(user);
+ request.getSession().setAttribute("userSession", userSession);
+ String forwardAction = request.getParameter("forwardAction");
+ if (forwardAction != null) {
+ response.sendRedirect(forwardAction);
+ return null;
+ } else {
+ return new ModelAndView("index");
+ }
+ }
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserForm.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserForm.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserForm.java (revision 3)
@@ -0,0 +1,85 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.io.Serializable;
+
+import org.springframework.samples.kyuriboard.domain.User;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class UserForm implements Serializable {
+
+ /**
+ * 직렬화 번호
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * User 객체
+ */
+ private User user;
+
+ /**
+ * 생성모드인지 수정모드인지 결정
+ */
+ private boolean newUser;
+
+
+ /**
+ * 비밀번호 확인
+ */
+ private String repeatedPasswd;
+
+ /**
+ * 디폴트 생성자
+ *
+ */
+ public UserForm() {
+ this.user = new User();
+ this.newUser = true;
+ }
+
+ /**
+ * 인자 생성자
+ * @param user User객체
+ */
+ public UserForm(User user) {
+ this.user = user;
+ this.newUser = false;
+ }
+
+ /**
+ * @return the newUser
+ */
+ public boolean isNewUser() {
+ return newUser;
+ }
+
+ /**
+ * @return the user
+ */
+ public User getUser() {
+ return user;
+ }
+
+ /**
+ * @return the repeatedPasswd
+ */
+ public String getRepeatedPasswd() {
+ return repeatedPasswd;
+ }
+
+ /**
+ * @param repeatedPasswd the repeatedPasswd to set
+ */
+ public void setRepeatedPasswd(String repeatedPasswd) {
+ this.repeatedPasswd = repeatedPasswd;
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserSession.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserSession.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserSession.java (revision 3)
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.io.Serializable;
+
+import org.springframework.samples.kyuriboard.domain.User;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class UserSession implements Serializable {
+
+ /**
+ * 직렬화 번호
+ */
+ private static final long serialVersionUID = 1L;
+
+ private User user;
+
+ public UserSession(User user) {
+ this.user = user;
+ }
+
+ /**
+ * @return the user
+ */
+ public User getUser() {
+ return user;
+ }
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/DeleteMemoController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/DeleteMemoController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/DeleteMemoController.java (revision 3)
@@ -0,0 +1,56 @@
+/**
+ * 메모를 삭제
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class DeleteMemoController implements Controller {
+
+ private KyuriBoardFacade kyuriBoard;
+
+
+ /**
+ * @param kyuriBoard the kyuriBoard to set
+ */
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+ int boardId = new Integer(request.getParameter("boardId")).intValue();
+ int memoId = new Integer(request.getParameter("memoId")).intValue();
+ this.kyuriBoard.deleteMemo(memoId);
+
+ Board board = this.kyuriBoard.getBoardByBoardId(boardId);
+ List memoList = this.kyuriBoard.getMemoListByBoardId(boardId);
+
+ Map model = new HashMap();
+ model.put("board", board);
+ model.put("memoList", memoList);
+
+ return new ModelAndView("viewBoard", model);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/InsertMemoController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/InsertMemoController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/InsertMemoController.java (revision 3)
@@ -0,0 +1,61 @@
+/**
+ * 게시물에 대한 메모를 등록
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.samples.kyuriboard.domain.Memo;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class InsertMemoController implements Controller {
+
+ private KyuriBoardFacade kyuriBoard;
+
+ /**
+ * @param kyuriBoard the kyuriBoard to set
+ */
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+ int boardId = new Integer(request.getParameter("boardId")).intValue();
+ String content = new String(request.getParameter("content").getBytes("8859_1"), "euc-kr");
+ UserSession userSession = (UserSession) request.getSession().getAttribute("userSession");
+ Memo memo = new Memo();
+ memo.setBoardId(boardId);
+ memo.setContent(content);
+ memo.setInsertDate(new java.util.Date());
+ memo.setUserId(userSession.getUser().getUserId());
+ this.kyuriBoard.insertMemo(memo);
+
+ Board board = this.kyuriBoard.getBoardByBoardId(boardId);
+ List memoList = this.kyuriBoard.getMemoListByBoardId(boardId);
+
+ Map model = new HashMap();
+ model.put("board", board);
+ model.put("memoList", memoList);
+
+ return new ModelAndView("viewBoard", model);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserFormController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserFormController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/UserFormController.java (revision 3)
@@ -0,0 +1,158 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.oro.text.perl.Perl5Util;
+
+import org.springframework.validation.BindException;
+import org.springframework.validation.ValidationUtils;
+
+import org.springframework.web.util.WebUtils;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.SimpleFormController;
+
+import org.springframework.dao.DataIntegrityViolationException;
+
+import org.springframework.samples.kyuriboard.domain.User;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class UserFormController extends SimpleFormController {
+
+ private static Logger logger = Logger.getLogger(UserFormController.class);
+
+ private KyuriBoardFacade kyuriBoard;
+
+ /**
+ * @param kyuriBoard the kyuriBoard to set
+ */
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+ /**
+ * Constructor
+ */
+ public UserFormController() {
+ setSessionForm(true);
+ setValidateOnBinding(false);
+ setCommandName("userForm");
+ setFormView("userForm");
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
+ */
+ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
+ // TODO Auto-generated method stub
+ UserForm userForm = (UserForm) command;
+ User user = userForm.getUser();
+
+ //user.setUserName(new String(user.getUserName().getBytes("8859_1"), "euc-kr"));
+ user.setInsertDate(new java.util.Date());
+
+ try {
+ if (userForm.isNewUser()) {
+ this.kyuriBoard.insertUser(user);
+ } else {
+ this.kyuriBoard.updateUser(user);
+ }
+ } catch (DataIntegrityViolationException ex) {
+ errors.rejectValue("user.userId", "USERID_ALREADY_EXISTS", "회원ID가 이미 존재합니다. 다른 ID를 입력해 주세요");
+ return showForm(request, response, errors);
+ }
+
+ // 새로운 세션 설정
+ UserSession userSession = new UserSession(this.kyuriBoard.getUserByUserId(userForm.getUser().getUserId()));
+ request.getSession().setAttribute("userSession", userSession);
+
+ return super.onSubmit(request, response, command, errors);
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
+ */
+ protected Object formBackingObject(HttpServletRequest request) throws Exception {
+ // TODO Auto-generated method stub
+ UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
+ if (userSession != null) {
+ return new UserForm(this.kyuriBoard.getUserByUserId(userSession.getUser().getUserId()));
+ } else {
+ return new UserForm();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.BaseCommandController#onBindAndValidate(javax.servlet.http.HttpServletRequest, java.lang.Object, org.springframework.validation.BindException)
+ */
+ protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors) throws Exception {
+ // TODO Auto-generated method stub
+ UserForm userForm = (UserForm) command;
+ User user = userForm.getUser();
+
+ if (user.getUserName() != null) {
+ user.setUserName(new String(user.getUserName().getBytes("8859_1"), "euc-kr"));
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("userName : " + user.getUserName());
+ }
+
+ errors.setNestedPath("user");
+ getValidator().validate(user, errors);
+ errors.setNestedPath("");
+
+ // 부가적인 유효성 검증
+ if (userForm.isNewUser()) {
+ ValidationUtils.rejectIfEmpty(errors, "user.userId", "USERID_REQUIRED", "회원ID가 필요합니다");
+ if (user.getPasswd() == null || user.getPasswd().length() < 1 ||
+ !user.getPasswd().equals(userForm.getRepeatedPasswd())) {
+ errors.reject("PASSWD_MISMATCH", "비밀번호가 존재하지 않거나 맞지 않습니다.");
+ }
+ } else if (user.getPasswd() != null && user.getPasswd().length() > 0) {
+ if (!user.getPasswd().equals(userForm.getRepeatedPasswd())) {
+ errors.reject("PASSWD_MISMATCH", "비밀번호가 존재하지 않거나 맞지 않습니다");
+ }
+ }
+
+ if (user.getPasswd() != null && user.getPasswd().length() < 4) {
+ errors.reject("PASSWD_TOO_SHORT", "비밀번호는 최소 4자리 이상이어야 합니다");
+ }
+
+ if (userForm.getRepeatedPasswd() != null && userForm.getRepeatedPasswd().length() < 4) {
+ errors.reject("REPEATEDPASSWD_TOO_SHORT", "확인 비밀번호는 최소 4자리 이상이어야 합니다");
+ }
+
+ if (user.getUserId() != null && user.getUserId().length() < 4) {
+ errors.reject("USERID_TOO_SHORT", "회원ID는 최소 4자리 이상이어야 합니다");
+ }
+
+ if (user.getUserName() != null && user.getUserName().length() < 2) {
+ errors.reject("USERNAME_TOO_SHORT", "회원 이름은 최소 2자리 이상이어야 합니다");
+ }
+
+ // 회원ID 영문 검사
+
+ // 이메일 검사
+ String EMAIL_REGEXP = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
+ Perl5Util perl5Util = new Perl5Util();
+ if (!perl5Util.match(EMAIL_REGEXP, user.getEmail())) {
+ errors.reject("INVALID_EMAIL", "이메일 형식이 잘못되었습니다");
+ }
+
+ }
+
+
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/ViewBoardController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/ViewBoardController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/ViewBoardController.java (revision 3)
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+import org.springframework.samples.kyuriboard.domain.Board;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class ViewBoardController implements Controller {
+
+ private KyuriBoardFacade kyuriBoard;
+
+ /**
+ * @param kyuriBoard the kyuriBoard to set
+ */
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+
+ int boardId = new Integer(request.getParameter("boardId")).intValue();
+ Board board = this.kyuriBoard.getBoardByBoardId(boardId);
+
+ // 조회수 증가
+ int curVisited = board.getVisited();
+ board.setVisited(curVisited + 1);
+ this.kyuriBoard.updateBoard(board);
+
+ // 메모 객체
+ List memoList = this.kyuriBoard.getMemoListByBoardId(boardId);
+
+ // 모델 객체 생성
+ Map model = new HashMap();
+ model.put("board", board);
+ model.put("memoList", memoList);
+
+ return new ModelAndView("viewBoard", model);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/ListBoardController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/ListBoardController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/ListBoardController.java (revision 3)
@@ -0,0 +1,149 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.beans.support.PagedListHolder;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class ListBoardController implements Controller {
+
+ protected Logger logger = Logger.getLogger(getClass());
+
+ private String successView;
+
+ // List화면인지 Search화면인지 구분하는 변수
+ private String mode;
+
+ private KyuriBoardFacade kyuriBoard;
+
+ /**
+ *
+ * @param mode the mode to set
+ */
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+ /**
+ *
+ * @param successView
+ */
+ public void setSuccessView(String successView) {
+ this.successView = successView;
+ }
+
+ /**
+ *
+ * @param kyuriBoard
+ */
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+
+ Map model = new HashMap();
+ String page = request.getParameter("page");
+ String searchKey = request.getParameter("searchKey");
+ String searchVal = request.getParameter("searchVal");
+
+ if (logger.isInfoEnabled()) {
+ logger.info("searchKey : " + searchKey);
+ logger.info("searchVal : " + searchVal);
+ }
+
+ if (searchVal != null) {
+ searchVal = new String(searchVal.getBytes("8859_1"), "euc-kr"); // 톰캣 문자열 처리
+ }
+
+ //System.out.println("searchKey : " + searchKey);
+ //System.out.println("searchVal : " + searchVal);
+
+ model.put("searchKey", searchKey);
+ model.put("searchVal", searchVal);
+
+ if (page == null) {
+ page = "1";
+ }
+
+ // 현재 페이지에 해당하는 게시물 리스트만 담음
+ PagedListHolder boardList = null;
+ if ("search".equals(this.mode)) {
+ if ("writer".equals(searchKey)) {
+ boardList = new PagedListHolder(this.kyuriBoard.getBoardListByUserName(searchVal));
+ } else {
+ boardList = new PagedListHolder(this.kyuriBoard.getBoardListByTitle(searchVal));
+ }
+ } else {
+ boardList = new PagedListHolder(this.kyuriBoard.getBoardList());
+ }
+ boardList.setPageSize(20); // 한 페이지의 레코드 수 20 개
+ boardList.setPage(new Integer(page).intValue() - 1); // PagedListHolder는 인덱스가 0부터 시작
+ model.put("boardList", boardList);
+
+ // 페이지 바로 가기
+ int pagedGroup = 10;
+ int nPage = new Integer(page).intValue(); // 현재 페이지를 정수형을 변환
+ int pagedLoop = pagedGroup; // 페이지를 Loop 돌릴 MAX 페이지 설정
+ if (pagedLoop > boardList.getPageCount()) {
+ pagedLoop = boardList.getPageCount(); // 페이지 Loop 변수가 전제 페이지 갯수보다 클 경우 보정
+ }
+ String deli = new String(" "); // 구분자
+ StringBuffer sb = new StringBuffer();
+
+ if ((boardList.getPageCount() > pagedGroup) && (nPage > pagedGroup)) {
+ sb.append("");
+ sb.append("[이전 " + pagedGroup + "개]");
+ sb.append(" ");
+ sb.append(deli);
+ }
+
+ for (int i = 0; i < pagedLoop; i++) {
+ sb.append("");
+ sb.append(i + 1);
+ sb.append(" ");
+ sb.append(deli);
+ }
+
+ if ((boardList.getPageCount() > pagedGroup) && (nPage < pagedGroup)) {
+ sb.append("");
+ sb.append("[다음 " + pagedGroup + "개]");
+ sb.append(" ");
+ }
+ model.put("pagedLink", sb.toString()); // 모델 객체에 삽입
+
+ return new ModelAndView(this.successView, model);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/BoardForm.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/BoardForm.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/BoardForm.java (revision 3)
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import java.io.Serializable;
+
+import org.springframework.samples.kyuriboard.domain.Board;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class BoardForm implements Serializable {
+
+ /**
+ * 직렬화 변수
+ */
+ private static final long serialVersionUID = 1L;
+
+ private Board board;
+
+ private boolean newBoard;
+
+ /**
+ * Default Constructor
+ *
+ */
+ public BoardForm() {
+ this.board = new Board();
+ this.newBoard = true;
+ }
+
+ public BoardForm(Board board) {
+ this.board = board;
+ this.newBoard = false;
+ }
+
+ /**
+ * @return the board
+ */
+ public Board getBoard() {
+ return board;
+ }
+
+ /**
+ * @return the newBoard
+ */
+ public boolean isNewBoard() {
+ return newBoard;
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogonInterceptor.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogonInterceptor.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogonInterceptor.java (revision 3)
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.ModelAndViewDefiningException;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+import org.springframework.web.util.WebUtils;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class LogonInterceptor extends HandlerInterceptorAdapter {
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object)
+ */
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
+ // TODO Auto-generated method stub
+ UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
+ if (userSession == null) {
+ String url = request.getServletPath();
+ String query = request.getQueryString();
+ ModelAndView modelAndView = new ModelAndView("logonForm");
+ if (query != null) {
+ modelAndView.addObject("logonForwardAction", url + "?" + query);
+ } else {
+ modelAndView.addObject("logonForwardAction", url);
+ }
+ throw new ModelAndViewDefiningException(modelAndView);
+ } else {
+ return true;
+ }
+ }
+
+
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogoutController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogoutController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/LogoutController.java (revision 3)
@@ -0,0 +1,39 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class LogoutController implements Controller {
+
+ private String successView;
+
+ /**
+ * @param successView the successView to set
+ */
+ public void setSuccessView(String successView) {
+ this.successView = successView;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+ request.getSession().removeAttribute("userSession");
+ request.getSession().invalidate();
+ return new ModelAndView(this.successView);
+ }
+
+}
Index: nextboard/src/org/springframework/samples/kyuriboard/web/spring/DeleteBoardController.java
===================================================================
--- nextboard/src/org/springframework/samples/kyuriboard/web/spring/DeleteBoardController.java (revision 3)
+++ nextboard/src/org/springframework/samples/kyuriboard/web/spring/DeleteBoardController.java (revision 3)
@@ -0,0 +1,52 @@
+/**
+ *
+ */
+package org.springframework.samples.kyuriboard.web.spring;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+import org.springframework.samples.kyuriboard.domain.logic.KyuriBoardFacade;
+
+/**
+ * @author DAMI(archy712@naver.com)
+ *
+ */
+public class DeleteBoardController implements Controller {
+
+ private KyuriBoardFacade kyuriBoard;
+
+ private String successView;
+
+ /**
+ * @param kyuriBoard the kyuriBoard to set
+ */
+ public void setKyuriBoard(KyuriBoardFacade kyuriBoard) {
+ this.kyuriBoard = kyuriBoard;
+ }
+
+
+ /**
+ * @param successView the successView to set
+ */
+ public void setSuccessView(String successView) {
+ this.successView = successView;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ModelAndView handleRequest(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ // TODO Auto-generated method stub
+ int boardId = new Integer(request.getParameter("boardId")).intValue();
+ this.kyuriBoard.deleteBoard(boardId);
+ this.kyuriBoard.deleteMemoByBoardId(boardId);
+ return new ModelAndView(this.successView);
+ }
+
+}
Index: nextboard/WebContent/META-INF/MANIFEST.MF
===================================================================
--- nextboard/WebContent/META-INF/MANIFEST.MF (revision 3)
+++ nextboard/WebContent/META-INF/MANIFEST.MF (revision 3)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Index: nextboard/WebContent/WEB-INF/kyuriboard-ibatis.xml
===================================================================
--- nextboard/WebContent/WEB-INF/kyuriboard-ibatis.xml (revision 3)
+++ nextboard/WebContent/WEB-INF/kyuriboard-ibatis.xml (revision 3)
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+ WEB-INF/jdbc.properties
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
200 OK
OK
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator,
admin@localhost and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.
More information about this error may be available
in the server error log.