20240307 전자정부(DB-multiboard 만들기, 부트스트랩 사용하기)

2024. 3. 7. 17:462023.11.21-2024.05.31

 

새로운 BD만들기

 

 

multiboard

 

mtno             INT(11)                    PK,AI

mttitle            VARCHAR(100)     NU

mtcontent     LONGTEXT            NU

mno              INT(11)                   NU, FK          

mtdate          DATETIME            CURRENT_TIMESTAMP()

mtip              VARCHAR()           NULL

mtdel            INT(1)                    DV 1

mtread          INT(11)                  DV 1

mtcate          INT(1)                    NU

 

 

 

 

 

쿼리문

CREATE TABLE multiboard(
	mtno INT(11) NOT NULL AUTO_INCREMENT,
	mttitle VARCHAR(100) NOT NULL,
	mtcontent LONGTEXT NOT NULL,
	mno INT(11) NOT NULL,
	mtdate DATETIME NULL DEFAULT current_timestamp(),
	mtip VARCHAR(50) NULL DEFAULT NULL,
	mtdel INT(1) NULL DEFAULT 1,
	mtread INT(11) NULL DEFAULT 1,
	mtcate INT(1) NOT NULL DEFAULT 1,
	PRIMARY KEY (mtno),
	INDEX FK_board_member (mno),
	CONSTRAINT multiboardMno FOREIGN KEY (mno) REFERENCES member (mno) 
	ON UPDATE NO ACTION ON DELETE NO ACTION)

 

 

multiboard

만들어진 테이블

 

 

 

freeboard 만들기

IndexController > freeboard 생성

	   // 멀티보드
	   @GetMapping("/freeboard")
	   public String freeboard(Model model) {
	      List<BoardDTO> board = indexService.freeboard();
	      
	      model.addAttribute("board",board);
	      return "freeboard";
	   }

 

 

 

IndexService > freeboard 생성

	public List<BoardDTO> freeboard() {
		return indexDAO. freeboard();
	}

 

 

IndexDAO > freeboard 생성

	List<BoardDTO> freeboard();

 

 

 

BoardDTO 수정 > multiboard에 맞게 다시 수정

 

package com.mask.web.dto;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class BoardDTO {

		   private int mtno, mno, mtread, mtcate;
		   private String mttitle, mtdate, mid, mtip, mtdel, mname;   
}

 

 

indexMapper > freeboard 생성

   <select id="freeboard" resultType="BoardDTO">
      SELECT mtno, mttitle,
      mtcontent, mtdate, mtip, mtdel, mtread, mtcate, mno FROM multiboard
   </select>

 

 

 

 

 

freeboard.html

 

         <table class="table">
			<tr>
				<th>번호</th>
				<th>제목</th>
				<th>글쓴이</th>
				<th>날짜</th>
				<th>ip</th>
				<th>read</th>
			</tr>
			<tr th:each="row : ${board}">
				<td th:text="${row.mtno }"></td>
				<td>[[${row.mttitle }]]</td>
				<td th:text="${row.mno}"></td>
				<td th:text="${row.mtdate}"></td>
				<td th:text="${row.mtip}"></td>
				<td th:text="${row.mtread}"></td>
			</tr>
		</table>
		<a th:href="@{/write(mtcate=${board[0].mtcate})}">글쓰기</a>
            </div>

 

 

 

 

 

부트스트랩 사용하기

사용한 부트 스트랩

 

https://startbootstrap.com/theme/new-age

 

Start Bootstrap

 

startbootstrap.com

 

 

부트스트랩 파일 넣어주기.

templates > html

static > assets, css, js

 

 

아래는 잘 이해가 안가서 선생님 파일 복붙해왔다.

 

th:fragment > 구역을 나눠줌