관리 메뉴

거니의 velog

231205_SPRING 2 (10-2) 본문

대덕인재개발원/대덕인재개발원_웹기반 애플리케이션

231205_SPRING 2 (10-2)

Unlimited00 2023. 12. 5. 08:33


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>AdminLTE 3 | Simple Tables</title>

    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/resources/plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/resources/dist/css/adminlte.min.css">
    <script src="${pageContext.request.contextPath }/resources/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/resources/ckeditor/ckeditor.js"></script>
</head>

<c:if test="${not empty message }">
	<script type="text/javascript">
		alert("${message}");
		<c:remove var="message" scope="request"/>
		<c:remove var="message" scope="session"/>
	</script>
</c:if>

<body class="hold-transition sidebar-mini">
    <div class="wrapper">
        <!-- header 영역 -->
		<tiles:insertAttribute name="header" />
		
        <div class="content-wrapper">
            <!-- content 영역 -->
            <tiles:insertAttribute name="content" />
        </div>
        
        <!-- footer 영역 -->
        <tiles:insertAttribute name="footer" />
    </div>

    <script src="${pageContext.request.contextPath }/resources/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="${pageContext.request.contextPath }/resources/plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
    <script src="${pageContext.request.contextPath }/resources/dist/js/adminlte.min.js"></script>
    <script type="text/javascript">
    	$(function(){
    		bsCustomFileInput.init(); // 부트스트랩 openFile 이벤트 설정
    	});
    </script>
</body>

</html>


[form.jsp]

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<section class="content-header">

	<c:set value="등록" var="name" />
	<c:if test="${status eq 'u' }">
		<c:set value="수정" var="name" />
	</c:if>
	
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1>공지사항 등록/수정</h1>
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">DDIT HOME</a></li>
                    <li class="breadcrumb-item active">공지사항 등록/수정</li>
                </ol>
            </div>
        </div>
    </div>
</section>

<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="card card-dark">
                <div class="card-header">
                    <h3 class="card-title">공지사항 ${name }</h3>
                    <div class="card-tools"></div>
                </div>
                <form action="/notice/insert.do" method="post" id="noticeForm" name="noticeForm" enctype="multipart/form-data">
                
                	<c:if test="${status eq 'u' }">
                		<input type="hidden" name="boNo" value="${notice.boNo }" />
                	</c:if>
                	
	                <div class="card-body">
	                    <div class="form-group">
	                        <label for="boTitle">제목을 입력해주세요</label>
	                        <input type="text" id="boTitle" name="boTitle" class="form-control" placeholder="제목을 입력해주세요" value="${notice.boTitle }">
	                    </div>
	                    <div class="form-group">
	                        <label for="boContent">내용을 입력해주세요</label>
	                        <textarea id="boContent" name="boContent" class="form-control" rows="14">${notice.boContent }</textarea>
	                    </div>
	                    <div class="form-group">
	                        <div class="custom-file">
	                            <input type="file" class="custom-file-input" id="boFile" name="boFile" multiple="multiple">
	                            <label class="custom-file-label" for="boFile">파일을 선택해주세요</label>
	                        </div>
	                    </div>
	                </div>
	                <div class="card-footer bg-white">
	                    <ul class="mailbox-attachments d-flex align-items-stretch clearfix">
	                        <li>
	                            <span class="mailbox-attachment-icon"><i class="far fa-file-pdf"></i></span>
	
	                            <div class="mailbox-attachment-info">
	                                <a href="#" class="mailbox-attachment-name"><i class="fas fa-paperclip"></i> Sep2014-report.pdf</a>
	                                <span class="mailbox-attachment-size clearfix mt-1">
	                                    <span>1,245 KB</span>
	                                    <a href="#" class="btn btn-default btn-sm float-right"><i class="fas fa-times"></i></a>
	                                </span>
	                            </div>
	                        </li>
	                        <li>
	                            <span class="mailbox-attachment-icon"><i class="far fa-file-word"></i></span>
	
	                            <div class="mailbox-attachment-info">
	                                <a href="#" class="mailbox-attachment-name"><i class="fas fa-paperclip"></i> App Description.docx</a>
	                                <span class="mailbox-attachment-size clearfix mt-1">
	                                    <span>1,245 KB</span>
	                                    <a href="#" class="btn btn-default btn-sm float-right"><i class="fas fa-times"></i></a>
	                                </span>
	                            </div>
	                        </li>
	                        <li>
	                            <span class="mailbox-attachment-icon has-img"><img src="${pageContext.request.contextPath }/resources/dist/img/photo1.png" alt="Attachment"></span>
	
	                            <div class="mailbox-attachment-info">
	                                <a href="#" class="mailbox-attachment-name"><i class="fas fa-camera"></i> photo1.png</a>
	                                <span class="mailbox-attachment-size clearfix mt-1">
	                                    <span>2.67 MB</span>
	                                    <a href="#" class="btn btn-default btn-sm float-right"><i class="fas fa-times"></i></a>
	                                </span>
	                            </div>
	                        </li>
	                        <li>
	                            <span class="mailbox-attachment-icon has-img"><img src="${pageContext.request.contextPath }/resources/dist/img/photo2.png" alt="Attachment"></span>
	
	                            <div class="mailbox-attachment-info">
	                                <a href="#" class="mailbox-attachment-name"><i class="fas fa-camera"></i> photo2.png</a>
	                                <span class="mailbox-attachment-size clearfix mt-1">
	                                    <span>1.9 MB</span>
	                                    <a href="#" class="btn btn-default btn-sm float-right"><i class="fas fa-times"></i></a>
	                                </span>
	                            </div>
	                        </li>
	                    </ul>
	                </div>
	                <div class="card-footer bg-white">
	                    <div class="row">
	                        <div class="col-12">
	                            <input type="button" id="insertBtn" value="${name }" class="btn btn-secondary float-right">
	                            <c:if test="${status ne 'u' }">
		                            <input type="button" id="listBtn" value="목록" class="btn btn-dark float-right">
	                            </c:if>
	                            <c:if test="${status eq 'u' }">
		                            <input type="button" id="cancelBtn" value="취소" class="btn btn-dark float-right">
	                            </c:if>
	                        </div>
	                    </div>
	                </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
	$(function(){
		CKEDITOR.replace("boContent", {
			filebrowserUploadUrl: '/imageUpload.do'
		});
		CKEDITOR.config.height = "500px"; // CKEDITOR 높이 설정
		
		var noticeForm = $("#noticeForm");	// 등록 폼 Element
		var insertBtn = $("#insertBtn");	// 등록 버튼 Element
		var listBtn = $("#listBtn");		// 목록 버튼 Element
		var cancelBtn = $("#cancelBtn");	// 취소 버튼 Element
		
		// 등록 버튼 클릭 시, 등록 진행
		insertBtn.on("click", function(){
			var title = $("#boTitle").val();
			
			// 일반적인 textarea일 때 가져오는 방법
			// var content = $("#boContent").val();
			
			// CKEDITOR를 이용한 내용 데이터 가져오는 방법
			var content = CKEDITOR.instances.boContent.getData();
			
			if(!title) {
				alert("제목을 입력해 주세요!");
				$("#boTitle").focus();
				return false;
			}
			
			if(!content) {
				alert("제목을 입력해 주세요!");
				$("#boContent").focus();
				return false;
			}
			
			if($(this).val() == "수정") {
				noticeForm.attr("action", "/notice/update.do");
			}
			
			noticeForm.submit();
		});
		
		// 목록 버튼 클릭 시, 게시판 목록 화면으로 이동
		listBtn.on("click", function(){
			location.href = "/notice/list.do";
		});
		
		// 취소 버튼 클릭 시, 상세보기 화면으로 이동
		cancelBtn.on("click", function(){
			location.href = "/notice/detail.do?boNo=${notice.boNo }";
		});
	});
</script>
package kr.or.ddit.controller.crud.notice;

import java.util.HashMap;
import java.util.Map;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import kr.or.ddit.ServiceResult;
import kr.or.ddit.service.INoticeService;
import kr.or.ddit.vo.crud.NoticeMemberVO;
import kr.or.ddit.vo.crud.NoticeVO;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
@RequestMapping("/notice")
public class NoticeInsertController {
	
	@Inject
	private INoticeService noticeService;

	@RequestMapping(value = "/form.do", method = RequestMethod.GET)
	public String noticeInsertForm() {
		return "notice/form";
	}
	
	@RequestMapping(value = "/insert.do", method = RequestMethod.POST)
	public String noticeInsert(
			HttpServletRequest req,
			NoticeVO noticeVO, 
			Model model, 
			RedirectAttributes ra
			) {
		String goPage = "";
		
		// 넘겨받은 데이터 검증 후, 에러가 발생한 데이터에 대한 에러정보를 담을 공간
		Map<String, String> errors = new HashMap<String, String>();
		
		// 라이브러리 추가해야 함.
		// 제목 데이터가 누락되었을 때 에러 정보 저장
		if(StringUtils.isBlank(noticeVO.getBoTitle())) {
			errors.put("boTitle", "제목을 입력해주세요.");
		}
		// 내용 데이터가 누락되었을 때 에러 정보 저장
		if(StringUtils.isBlank(noticeVO.getBoContent())) {
			errors.put("boContent", "내용을 입력해주세요.");
		}
		// 기본 데이터의 누락정보에 따른 에러정보 갯수로 분기 처리
		if(errors.size() > 0) { // 에러 갯수가 0보다 클 때(에러가 존재)
			model.addAttribute("errors", errors);
			model.addAttribute("noticeVO", noticeVO);
			goPage = "notice/form";
		}else { // 에러가 없을 때
			
			HttpSession session = req.getSession();
			NoticeMemberVO memberVO = (NoticeMemberVO) session.getAttribute("SessionInfo");
			
			// 세션 정보에서 꺼낸 회원 데이터가 null이 아닐 때(로그인을 진행)
			if(memberVO != null) {
				noticeVO.setBoWriter(memberVO.getMemId()); // 로그인된 회원 아이디를 작성자로 집어 넣기
				ServiceResult result = noticeService.insertNotice(req, noticeVO);
				if(result.equals(ServiceResult.OK)) {
					goPage = "redirect:/notice/detail.do?boNo=" + noticeVO.getBoNo();
					ra.addFlashAttribute("message", "게시글 등록이 완료되었습니다.");
				}else { // 등록 실패
					model.addAttribute("noticeVO", noticeVO);
					model.addAttribute("message", "서버 에러, 다시 시도해 주세요!");
					goPage = "notice/form";
				}
			}else { // 로그인을 진행하지 않았을 때
				// [방법1] - 등록을 진행하지만, 로그인 후에 가능하다는 걸 알려주기 위한 프로세스일 때
//				model.addAttribute("message", "로그인 후에 사용 가능합니다!");
//				model.addAttribute("notice", noticeVO);
//				goPage = "notice/form";
				
				// [방법2] - 등록을 진행하기 위해서는 로그인을 필수로 진행해야 합니다. 라는 프로세스일 때
				ra.addFlashAttribute("message", "로그인 후에 사용 가능합니다!");
				goPage = "redirect:/notice/login.do";
			}
			
		}
		
		return goPage;
	}
	
}


package kr.or.ddit.service;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import kr.or.ddit.ServiceResult;
import kr.or.ddit.vo.crud.NoticeMemberVO;
import kr.or.ddit.vo.crud.NoticeVO;
import kr.or.ddit.vo.crud.PaginationInfoVO;

public interface INoticeService {

	public int selectNoticeCount(PaginationInfoVO<NoticeVO> pagingVO);
	public List<NoticeVO> selectNoticeList(PaginationInfoVO<NoticeVO> pagingVO);
	public ServiceResult insertNotice(HttpServletRequest req, NoticeVO noticeVO);
	public NoticeVO selectNotice(int boNo);
	public ServiceResult updateNotice(NoticeVO noticeVO);
	public ServiceResult deleteNotice(int boNo);
	
	public NoticeMemberVO loginCheck(NoticeMemberVO member);
	public ServiceResult idCheck(String memId);
	public ServiceResult signup(HttpServletRequest req, NoticeMemberVO memberVO);

}
package kr.or.ddit.vo.crud;

import org.apache.commons.io.FileUtils;
import org.springframework.web.multipart.MultipartFile;

import lombok.Data;

@Data
public class NoticeFileVO {

	private MultipartFile item;
	private Integer boNo;
	private Integer fileNo;
	private String fileName;
	private long fileSize;
	private String fileFancysize;
	private String fileMime;
	private String fileSavepath;
	private int fileDowncount;
	
	public NoticeFileVO() {}	
	public NoticeFileVO(MultipartFile item) {
		this.item = item;
		this.fileName = item.getOriginalFilename();
		this.fileSize = item.getSize();
		this.fileMime = item.getContentType();
		this.fileFancysize = FileUtils.byteCountToDisplaySize(fileSize);
	}	
	
}
package kr.or.ddit.vo.crud;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import lombok.Data;

@Data
public class NoticeVO {

	private int boNo;
	private String boTitle;
	private String boContent;
	private String boWriter;
	private String boDate;
	private int boHit;
	
	private Integer[] delNoticeNo;
	private MultipartFile[] boFile;
	private List<NoticeFileVO> noticeFileList;
	
	public void setBoFile(MultipartFile[] boFile) {
		this.boFile = boFile;
		if(boFile != null) {
			List<NoticeFileVO> noticeFileList = new ArrayList<NoticeFileVO>();
			for(MultipartFile item : boFile) {
				if(StringUtils.isBlank(item.getOriginalFilename())) {
					continue;
				}
				
				NoticeFileVO noticeFileVO = new NoticeFileVO(item);
				noticeFileList.add(noticeFileVO);
			}
			this.noticeFileList = noticeFileList;
		}
	}
	
}
package kr.or.ddit.service.impl;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.UUID;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import kr.or.ddit.ServiceResult;
import kr.or.ddit.mapper.ILoginMapper;
import kr.or.ddit.mapper.INoticeMapper;
import kr.or.ddit.service.INoticeService;
import kr.or.ddit.vo.crud.NoticeFileVO;
import kr.or.ddit.vo.crud.NoticeMemberVO;
import kr.or.ddit.vo.crud.NoticeVO;
import kr.or.ddit.vo.crud.PaginationInfoVO;

@Service
public class NoticeServiceImpl implements INoticeService {

	@Inject
	private INoticeMapper noticeMapper;
	@Inject
	private ILoginMapper loginMapper;

	@Override
	public int selectNoticeCount(PaginationInfoVO<NoticeVO> pagingVO) {
		return noticeMapper.selectNoticeCount(pagingVO);
	}

	@Override
	public List<NoticeVO> selectNoticeList(PaginationInfoVO<NoticeVO> pagingVO) {
		return noticeMapper.selectNoticeList(pagingVO);
	}

	@Override
	public ServiceResult insertNotice(HttpServletRequest req, NoticeVO noticeVO) {
		ServiceResult result = null;

		int status = noticeMapper.insertNotice(noticeVO);
		if (status > 0) {	// 게시글 등록이 성공했을 때
			List<NoticeFileVO> noticeFileList = noticeVO.getNoticeFileList();
			try {
				// 공지사항 파일 업로드 처리
				noticeFileUpload(noticeFileList, noticeVO.getBoNo(), req);
			}catch(IOException e) {
				e.printStackTrace();
			}
			
			result = ServiceResult.OK;
		} else {
			result = ServiceResult.FAILED;
		}

		return result;
	}

	@Override
	public NoticeVO selectNotice(int boNo) {
		noticeMapper.incrementHit(boNo); // 게시글 조회수 증가
		return noticeMapper.selectNotice(boNo); // 게시글 번호에 해당하는 게시글 정보 가져오기
	}

	@Override
	public ServiceResult updateNotice(NoticeVO noticeVO) {
		ServiceResult result = null;

		int status = noticeMapper.updateNotice(noticeVO);
		if (status > 0) {
			result = ServiceResult.OK;
		} else {
			result = ServiceResult.FAILED;
		}

		return result;
	}

	@Override
	public ServiceResult deleteNotice(int boNo) {
		ServiceResult result = null;

		int status = noticeMapper.deleteNotice(boNo);
		if (status > 0) {
			result = ServiceResult.OK;
		} else {
			result = ServiceResult.FAILED;
		}

		return result;
	}

	@Override
	public NoticeMemberVO loginCheck(NoticeMemberVO member) {
		return loginMapper.loginCheck(member);
	}

	@Override
	public ServiceResult idCheck(String memId) {
		ServiceResult result = null;

		NoticeMemberVO member = loginMapper.idCheck(memId);
		if (member != null) {
			result = ServiceResult.EXIST;
		} else {
			result = ServiceResult.NOTEXIST;
		}

		return result;
	}

	@Override
	public ServiceResult signup(HttpServletRequest req, NoticeMemberVO memberVO) {
		ServiceResult result = null;

		// 회원가입 시, 프로필 이미지로 파일을 업로드 하는데 이때 업로드 할 서버 경로
		String uploadPath = req.getServletContext().getRealPath("/resources/profile");
		File file = new File(uploadPath);
		if (!file.exists()) {
			file.mkdirs();
		}

		String proFileImg = ""; // 회원정보에 추가될 프로필 이미지 경로
		try {
			// 넘겨받은 회원정보에서 파일 데이터 가져오기
			MultipartFile proFileImgFile = memberVO.getImgFile();

			// 넘겨받은 파일 데이터가 존재할 때
			if (proFileImgFile.getOriginalFilename() != null && !proFileImgFile.getOriginalFilename().equals("")) {
				String fileName = UUID.randomUUID().toString(); // UUID 파일명 생성
				fileName += "_" + proFileImgFile.getOriginalFilename(); // UUID_원본파일명으로 파일명 생성
				uploadPath += "/" + fileName; // /resources/profile/uuid_원본파일명

				proFileImgFile.transferTo(new File(uploadPath)); // 해당 위치에 파일 복사
				proFileImg = "/resources/profile/" + fileName; // 파일 복사가 일어난 파일의 위치로 접근하기 위한 URI 설정
			}

			memberVO.setMemProfileImg(proFileImg);
		} catch (Exception e) {
			e.printStackTrace();
		}

		int status = loginMapper.signup(memberVO);

		if (status > 0) { // 등록 성공
			result = ServiceResult.OK;
		} else {
			result = ServiceResult.FAILED;
		}

		return result;
	}
	
	private void noticeFileUpload(
			List<NoticeFileVO> noticeFileList, 
			int boNo, 
			HttpServletRequest req
			) throws IOException {
		
		String savePath = "/resources/notice/";
		
		if(noticeFileList != null) { // 넘겨받은 파일 데이터가 존재할 때
			if(noticeFileList.size() > 0) {
				for(NoticeFileVO noticeFileVO : noticeFileList) {
					String saveName = UUID.randomUUID().toString(); // UUID의 랜덤 파일명 생성
					
					// 파일명을 설장할 때, 원본 파일명의 공백을 '_'로 변경한다.
					saveName = saveName + "_" + noticeFileVO.getFileName().replaceAll(" ", "_");
					// 디버깅 및 확장자 추출 참고
					String endFileName = noticeFileVO.getFileName().split("\\.")[1];
					
					String saveLocate = req.getServletContext().getRealPath(savePath + boNo);
					File file = new File(saveLocate);
					if(!file.exists()) {
						file.mkdirs();
					}
					saveLocate += "/" + saveName;
					
					noticeFileVO.setBoNo(boNo);						// 게시글 번호 설정
					noticeFileVO.setFileSavepath(saveLocate); 		// 파일 업로드 경로 설정
					noticeMapper.insertNoticeFile(noticeFileVO);	// 게시글 파일 데이터 추가
					
					File saveFile = new File(saveLocate);
					
					// 방법 1
//					InputStream is = noticeFileVO.getItem().getInputStream();
//					FileUtils.copyInputStreamToFile(is, saveFile);
					
					// 방법 2
					noticeFileVO.getItem().transferTo(saveFile); // 파일 복사
				}
			}
		}
		
	}

}
package kr.or.ddit.mapper;

import java.util.List;

import kr.or.ddit.vo.crud.NoticeFileVO;
import kr.or.ddit.vo.crud.NoticeVO;
import kr.or.ddit.vo.crud.PaginationInfoVO;

public interface INoticeMapper {

	public int selectNoticeCount(PaginationInfoVO<NoticeVO> pagingVO);
	public List<NoticeVO> selectNoticeList(PaginationInfoVO<NoticeVO> pagingVO);
	public int insertNotice(NoticeVO noticeVO);
	public void incrementHit(int boNo);
	public NoticeVO selectNotice(int boNo);
	public int updateNotice(NoticeVO noticeVO);
	public int deleteNotice(int boNo);
	public void insertNoticeFile(NoticeFileVO noticeFileVO);

}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kr.or.ddit.mapper.INoticeMapper">
	
	<sql id="noticeSearch">
		<if test="searchType != null and searchType == 'title'">
			and (bo_title like '%' || #{searchWord} || '%')
		</if>
		<if test="searchType != null and searchType == 'writer'">
			and (bo_writer like '%' || #{searchWord} || '%')
		</if>
	</sql>
	
	<select id="selectNoticeCount" parameterType="pagingVO" resultType="int">
		select count(bo_no) from notice
		where 1=1 
		<include refid="noticeSearch" />
	</select>
	
	<select id="selectNoticeList" parameterType="pagingVO" resultType="noticeVO">
		select
			b.*
		from (
			select
				a.*, row_number() over (order by a.bo_no desc) rnum
			from (
				select 
					bo_no, bo_title, bo_content, bo_writer, bo_date, bo_hit 
				from notice 
				where 1=1 
				<include refid="noticeSearch" />
				order by bo_no desc
			) a
		) b
		<![CDATA[
			where b.rnum >= #{startRow} and b.rnum <= #{endRow}
		]]>
	</select>
	
	<insert id="insertNotice" parameterType="noticeVO" useGeneratedKeys="true">
		<selectKey keyProperty="boNo" resultType="int" order="BEFORE">
			select seq_notice.nextval from dual
		</selectKey>
		insert into notice (
			bo_no, bo_title, bo_content, bo_writer, bo_date
		) values (
			#{boNo}, #{boTitle}, #{boContent}, #{boWriter}, sysdate
		)
	</insert>
	
	<insert id="insertNoticeFile" parameterType="noticefileVO">
		insert into noticefile (
			file_no,
			bo_no,
			file_name,
			file_size,
			file_fancysize,
			file_mime,
			file_savepath,
			file_downcount
		) values (
			seq_noticefile.nextval,
			#{boNo},
			#{fileName},
			#{fileSize},
			#{fileFancysize},
			#{fileMime},
			#{fileSavepath},
			0
		)
	</insert>
	
	<update id="incrementHit" parameterType="int">
		update notice 
		set 
			bo_hit = bo_hit + 1 
		where bo_no = #{boNo}
	</update>
	
	<select id="selectNotice" parameterType="int" resultType="noticeVO">
		select 
			bo_no, bo_title, bo_content, bo_writer, bo_date, bo_hit 
		from notice 
		where bo_no = #{boNo}
	</select>
	
	<update id="updateNotice" parameterType="noticeVO">
		update notice 
		set 
			bo_title = #{boTitle},
			bo_content = #{boContent} 
		where bo_no = #{boNo}
	</update>
	
	<delete id="deleteNotice" parameterType="int">
		delete from notice 
		where bo_no = #{boNo}
	</delete>
	
</mapper>

- http://localhost/notice/detail.do?boNo=80


 

'대덕인재개발원 > 대덕인재개발원_웹기반 애플리케이션' 카테고리의 다른 글

231206_SPRING 2 (11-2)  (1) 2023.12.06
231206_SPRING 2 (11-1)  (1) 2023.12.06
231205_SPRING 2 (10-1)  (0) 2023.12.05
231204_SPRING 2 (9-3)  (0) 2023.12.04
231204_SPRING 2 (9-2)  (0) 2023.12.04