728x90
반응형
2020/05/30 - [🌎Web Application/Spring] - [Spring] MVC Project part 1
2020/05/30 - [🌎Web Application/Spring] - [Spring] MVC Project part 2
2020/05/30 - [🌎Web Application/Spring] - [Spring] MVC Project part 3
1. spring/sqls/test.sql 생성
DROP SEQUENCE MYNOSEQ;
DROP TABLE MYBOARD;
CREATE SEQUENCE MYNOSEQ NOCACHE;
CREATE TABLE MYBOARD(
MYNO NUMBER PRIMARY KEY,
MYNAME VARCHAR2(1000) NOT NULL,
MYTITLE VARCHAR2(2000) NOT NULL,
MYCONTENT VARCHAR2(4000) NOT NULL,
MYDATE DATE NOT NULL
);
INSERT INTO MYBOARD
VALUES(MYNOSEQ.NEXTVAL,'관리자','스프링 테스트','Spring MVC 어렵다...',SYSDATE);
SELECT *
FROM MYBOARD;
2. 다음과 같이 java파일 생성
BoardDto.java
package com.mvc.upgrade.model.dto;
import java.util.Date;
public class BoardDto {
private int myno;
private String myname;
private String mytitle;
private String mycontent;
private Date mydate;
public BoardDto() {
super();
// TODO Auto-generated constructor stub
}
public BoardDto(int myno, String myname, String mytitle, String mycontent, Date mydate) {
super();
this.myno = myno;
this.myname = myname;
this.mytitle = mytitle;
this.mycontent = mycontent;
this.mydate = mydate;
}
public int getMyno() {
return myno;
}
public void setMyno(int myno) {
this.myno = myno;
}
public String getMyname() {
return myname;
}
public void setMyname(String myname) {
this.myname = myname;
}
public String getMytitle() {
return mytitle;
}
public void setMytitle(String mytitle) {
this.mytitle = mytitle;
}
public String getMycontent() {
return mycontent;
}
public void setMycontent(String mycontent) {
this.mycontent = mycontent;
}
public Date getMydate() {
return mydate;
}
public void setMydate(Date mydate) {
this.mydate = mydate;
}
}
BoardDao.java
package com.mvc.upgrade.model.dao;
import java.util.List;
import com.mvc.upgrade.model.dto.BoardDto;
public interface BoardDao {
String NAMESPACE = "myboard."; // 어떤 mapper를 사용할 지!
public List<BoardDto> selectList();
public BoardDto selectOne(int myno);
public int insert(BoardDto dto);
public int update(BoardDto dto);
}
BoardDaoImpl.java
package com.mvc.upgrade.model.dao;
import java.util.List;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.mvc.upgrade.model.dto.BoardDto;
//해당 클래스가 Dao임을 알리는 어노테이션
@Repository
public class BoardDaoImpl implements BoardDao{
@Autowired
private SqlSessionTemplate sqlSession;
@Override
public List<BoardDto> selectList() {
// TODO Auto-generated method stub
return null;
}
@Override
public BoardDto selectOne(int myno) {
// TODO Auto-generated method stub
return null;
}
@Override
public int insert(BoardDto dto) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int update(BoardDto dto) {
// TODO Auto-generated method stub
return 0;
}
}
BoardBiz.java
package com.mvc.upgrade.biz;
import java.util.List;
import com.mvc.upgrade.model.dto.BoardDto;
public interface BoardBiz {
public List<BoardDto> selectList();
public BoardDto selectOne(int myno);
public int insert(BoardDto dto);
public int update(BoardDto dto);
public int delete(int myno);
}
BoardBizImpl.java
package com.mvc.upgrade.biz;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mvc.upgrade.model.dao.BoardDao;
import com.mvc.upgrade.model.dto.BoardDto;
//해당 클래스가 Service 임을 알림
@Service
public class BoardBizImpl implements BoardBiz{
@Autowired
private BoardDao dao;
@Override
public List<BoardDto> selectList() {
// TODO Auto-generated method stub
return null;
}
@Override
public BoardDto selectOne(int myno) {
// TODO Auto-generated method stub
return null;
}
@Override
public int insert(BoardDto dto) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int update(BoardDto dto) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int delete(int myno) {
// TODO Auto-generated method stub
return 0;
}
}
728x90
반응형
'⚙️Backend > Spring' 카테고리의 다른 글
MyBatis 추가 정리 (0) | 2020.05.31 |
---|---|
[Spring] MVC Project part 5 (6) | 2020.05.30 |
[Spring] MVC Project part 3 (0) | 2020.05.30 |
[Spring] MVC Project part 2 (0) | 2020.05.30 |
[Spring] MVC Project part 1 (0) | 2020.05.30 |