Преглед на файлове

게시판 작성, 목록 추가

junekeunsong преди 4 години
родител
ревизия
e089ea2aa8

+ 7 - 0
pom.xml

@@ -125,6 +125,13 @@
             <artifactId>poi-ooxml</artifactId>
             <version>3.9</version>
         </dependency>
+        
+        <!-- 파일업로드/다운로드 -->
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>1.4</version>
+        </dependency>
 	</dependencies>
 
 	<build>

+ 126 - 6
src/main/java/com/lemon/lifecenter/controller/BoardController.java

@@ -1,29 +1,93 @@
 package com.lemon.lifecenter.controller;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.io.FilenameUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.FileCopyUtils;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.ModelAndView;
 
+import com.lemon.lifecenter.common.LifeCenterConfigVO;
 import com.lemon.lifecenter.common.LifeCenterController;
+import com.lemon.lifecenter.common.LifeCenterFileDownload;
+import com.lemon.lifecenter.common.LifeCenterFunction;
+import com.lemon.lifecenter.common.LifeCenterPaging;
 import com.lemon.lifecenter.common.LifeCenterSessionController;
+import com.lemon.lifecenter.dto.BoardDTO;
+import com.lemon.lifecenter.service.BoardService;
 
 @Controller
 @RequestMapping("/board")
 public class BoardController extends LifeCenterController {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    
+    @Autowired
+    private BoardService boardService;
+    
+    @Autowired
+    private LifeCenterConfigVO config;
+    
+    private LifeCenterPaging paging;
+    
     @RequestMapping("/list")
     public ModelAndView boardList(
-            @RequestParam(value="sData", required=false, defaultValue="") String sData,
-            @RequestParam(value="useYn", required=false, defaultValue="") String useYn,
+            @RequestParam(value="searchTxt", required=false, defaultValue="") String searchTxt,
+            @RequestParam(value="selectState", required=false, defaultValue="") String selectState,
             @RequestParam(value="page", required=false, defaultValue="1") int page,
             HttpServletRequest request, HttpServletResponse response) {
         String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
+        BoardDTO dto = new BoardDTO();
+        
+        if (!selectState.equals("")) {
+            if (selectState.equals("title")) {
+                dto.setTitle(searchTxt);
+            } else if (selectState.equals("content")) {
+                dto.setContent(searchTxt);
+            }
+        }
+        
+        dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
+        dto.setLimitMax( config.pageDataSize );
+        
+        List<BoardDTO> list = new ArrayList<BoardDTO>();
+        
+        int total = boardService.selectNoticeBoardListCount(dto);
+        if (total == 0) {
+        } else {
+            list = boardService.selectNoticeBoardList(dto);
+        }
+        
+        String param = "";
+        paging = LifeCenterPaging.getInstance();
+        paging.paging(config, total, page, param);
+        
         ModelAndView mv = setMV("board/list");
         mv.addObject("sesGroupIdx", sesGroupIdx);
+        mv.addObject("list", list);
+        mv.addObject("total", total);
+        mv.addObject("selectState", selectState);
+        mv.addObject("searchTxt", searchTxt);
+        mv.addObject("paging", paging);
+        mv.addObject("page", page);
+        mv.addObject("pageSize", dto.getLimitMax());
         return mv;
     }
     
@@ -34,14 +98,70 @@ public class BoardController extends LifeCenterController {
     }
     
     @RequestMapping("/new/insert")
-    public String boardNewInsert() {
-//        @ModelAttribute("dto") final CenterInfoDTO dto
+    @Transactional(propagation=Propagation.REQUIRED)
+    public String boardNewInsert(
+            HttpServletRequest request, HttpServletResponse response,
+            @ModelAttribute("dto") final BoardDTO dto,
+            MultipartFile file) {
+        
+        if (file.isEmpty() == false) {
+            UUID uuid = UUID.randomUUID();
+            String fileName = file.getOriginalFilename();
+            int fileSize = (int) file.getSize(); //단위는 byte
+            String ext = FilenameUtils.getExtension(fileName);
+            String saveFileName = uuid + "." + ext;
+            
+            try {
+                String tempPath = "../notice-temp";
+                File saveFile = new File(tempPath, saveFileName);
+                FileCopyUtils.copy(file.getBytes(),saveFile);
+            } catch (IOException e) {
+                e.printStackTrace();
+                LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '파일 업로드에 실패하였습니다.', callBack : function(){ history.back(); } });" );
+                return "/common/blank";
+            }
+            
+            dto.setFileOriginalName(fileName);
+            dto.setFileName(saveFileName);
+            dto.setFileExtension(ext);
+            dto.setFileSize(fileSize);
+        }
+
+        String sesId = LifeCenterSessionController.getSession(request, "sesId");
+        
+        String title = dto.getTitle().trim();
+        String content = dto.getContent().trim();
+        
+        dto.setTitle(title);
+        dto.setContent(content);
+        dto.setCreateBy(sesId);
         
-        return "redirect:/board/content?postSeq=" + 1;
+        boardService.noticeInsert(dto);
+        int postSeq = dto.getPostSeq();
+        
+        if (postSeq == 0) {
+            LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '게시물 등록에 실패하였습니다.', callBack : function(){ history.back(); } });" );
+            return "/common/blank";
+        } else {
+            if (file.isEmpty() == false) {
+                boardService.fileUploadDataInsert(dto);
+                int fileIdx = dto.getFileIdx();
+                if (fileIdx == 0) {
+                    LifeCenterFunction.scriptMessage( response, "alertBox({ txt : '게시물 등록에 실패하였습니다.', callBack : function(){ history.back(); } });" );
+                    return "/common/blank";
+                }
+            }
+        }
+        
+        return "redirect:/board/content?postSeq=" + dto.getPostSeq();
     }
     
     @RequestMapping("/content")
-    public ModelAndView boardContent() {
+    public ModelAndView boardContent(
+            @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq,
+            HttpServletRequest request, HttpServletResponse response) {
+        String sesId  = LifeCenterSessionController.getSession( request, "sesId" );
+        String sesGroupIdx = LifeCenterSessionController.getSession( request, "sesGroupIdx" );
         ModelAndView mv = setMV("board/content");
         return mv;
     }

+ 40 - 32
src/main/java/com/lemon/lifecenter/controller/PatientController.java

@@ -588,6 +588,7 @@ public class PatientController extends LifeCenterController {
         Cell cell12 = row.createCell(11);
         Cell cell13 = row.createCell(12);
         Cell cell14 = row.createCell(13);
+        Cell cell15 = row.createCell(14);
 
         cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
         cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
@@ -603,38 +604,41 @@ public class PatientController extends LifeCenterController {
         cell12.setCellStyle(styleOfBoardFillFontBlackBold16);
         cell13.setCellStyle(styleOfBoardFillFontBlackBold16);
         cell14.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell15.setCellStyle(styleOfBoardFillFontBlackBold16);
         
         
         sheet1.setColumnWidth( 0, 5000); //센터명
         sheet1.setColumnWidth( 1, 3000); //환자명
         sheet1.setColumnWidth( 2, 4000); //동호실
-        sheet1.setColumnWidth( 3, 1500); //성별
-        sheet1.setColumnWidth( 4, 1500); //나이
-        sheet1.setColumnWidth( 5, 3500); //입소일자
-        sheet1.setColumnWidth( 6, 3500); //상태변경일
-        sheet1.setColumnWidth( 7, 3800); //상태
-        sheet1.setColumnWidth( 8, 6000); //체온
-        sheet1.setColumnWidth( 9, 10000); //혈압
-        sheet1.setColumnWidth( 10, 6200); //맥박
-        sheet1.setColumnWidth( 11, 6200); //산소포화도
-        sheet1.setColumnWidth( 12, 7000); //혈당
-        sheet1.setColumnWidth( 13, 14000); //임상증상
+        sheet1.setColumnWidth( 3, 2000); //성별
+        sheet1.setColumnWidth( 4, 3500); //나이
+        sheet1.setColumnWidth( 5, 3500); //생년월일
+        sheet1.setColumnWidth( 6, 3500); //입소일자
+        sheet1.setColumnWidth( 7, 3500); //상태변경일
+        sheet1.setColumnWidth( 8, 3800); //상태
+        sheet1.setColumnWidth( 9, 6000); //체온
+        sheet1.setColumnWidth( 10, 10000); //혈압
+        sheet1.setColumnWidth( 11, 6200); //맥박
+        sheet1.setColumnWidth( 12, 6200); //산소포화도
+        sheet1.setColumnWidth( 13, 7000); //혈당
+        sheet1.setColumnWidth( 14, 14000); //임상증상
         
         
         cell1.setCellValue("생활치료센터명");
         cell2.setCellValue("환자명");
         cell3.setCellValue("동,호실");
         cell4.setCellValue("성별/나이");
-        cell5.setCellValue("확진일자");
-        cell6.setCellValue("입소일자");
-        cell7.setCellValue("퇴소예정일");
-        cell8.setCellValue("상태(상태 변경일)");
-        cell9.setCellValue("체온");
-        cell10.setCellValue("혈압");
-        cell11.setCellValue("맥박");
-        cell12.setCellValue("산소포화도");
-        cell13.setCellValue("혈당");
-        cell14.setCellValue("임상증상");
+        cell5.setCellValue("생년월일");
+        cell6.setCellValue("확진일자");
+        cell7.setCellValue("입소일자");
+        cell8.setCellValue("퇴소예정일");
+        cell9.setCellValue("상태(상태 변경일)");
+        cell10.setCellValue("체온");
+        cell11.setCellValue("혈압");
+        cell12.setCellValue("맥박");
+        cell13.setCellValue("산소포화도");
+        cell14.setCellValue("혈당");
+        cell15.setCellValue("임상증상");
         
         for (PatientDTO dto : data) {
             row = sheet1.createRow(i);
@@ -652,6 +656,7 @@ public class PatientController extends LifeCenterController {
             cell12 = row.createCell(11);
             cell13 = row.createCell(12);
             cell14 = row.createCell(13);
+            cell15 = row.createCell(14);
             
             String patientName = dto.getPatientName();
             String roomWard    = ( dto.getWardNumber() == null || dto.getWardNumber().equals( "" ) ) ? "" : dto.getWardNumber()+"동";
@@ -659,6 +664,7 @@ public class PatientController extends LifeCenterController {
             
             String gender      = dto.getGender();
             String age         = dto.getAge();
+            String jumin       = dto.getJumin();
             
             String confirmationDate     = dto.getConfirmationDate();
             String hospitalizationDate  = dto.getHospitalizationDate();
@@ -694,21 +700,22 @@ public class PatientController extends LifeCenterController {
             cell2.setCellValue( patientName );
             cell3.setCellValue( roomWard );
             cell4.setCellValue( gender + "/" + age );
-            cell5.setCellValue( confirmationDate );
-            cell6.setCellValue( hospitalizationDate );
-            cell7.setCellValue( expecteDischargeDate );
+            cell5.setCellValue( jumin );
+            cell6.setCellValue( confirmationDate );
+            cell7.setCellValue( hospitalizationDate );
+            cell8.setCellValue( expecteDischargeDate );
             if (state.equals("입소")) {
-                cell8.setCellValue( state );
+                cell9.setCellValue( state );
             } else {
-                cell8.setCellValue( state + "(" + disisolationDate + ")" );
+                cell9.setCellValue( state + "(" + disisolationDate + ")" );
             }
             
-            cell9.setCellValue( ( temperature == null || temperature.equals("") ) ? notMeasured : temperature + " ˚C (" + temperatureCreateDate + ")" );
-            cell10.setCellValue( ( systolicBloodPressure == null || systolicBloodPressure.equals("") ) ? notMeasured : systolicBloodPressure + " mmHg / " + diastolicBloodPressure + " mmHg (" + systolicBloodPressureCreateDate + ")" );
-            cell11.setCellValue( ( pulseRate == null || pulseRate.equals("") ) ? notMeasured : pulseRate + " bpm (" + pulseRateCreateDate + ")" );
-            cell12.setCellValue( ( oxygenSaturation == null || oxygenSaturation.equals("") ) ? notMeasured : oxygenSaturation + " % (" + oxygenSaturationCreateDate + ")" );
-            cell13.setCellValue( ( bloodSugar == null || bloodSugar.equals("") ) ? notMeasured : bloodSugar + " mg/dL (" + bloodSugarCreateDate + ")" );
-            cell14.setCellValue( ( symptomContent == null || symptomDate == null || symptomContent.equals("")  || symptomDate.equals( "" ) ) ? notMeasured : symptomContent + " (" + symptomDate + ")" );
+            cell10.setCellValue( ( temperature == null || temperature.equals("") ) ? notMeasured : temperature + " ˚C (" + temperatureCreateDate + ")" );
+            cell11.setCellValue( ( systolicBloodPressure == null || systolicBloodPressure.equals("") ) ? notMeasured : systolicBloodPressure + " mmHg / " + diastolicBloodPressure + " mmHg (" + systolicBloodPressureCreateDate + ")" );
+            cell12.setCellValue( ( pulseRate == null || pulseRate.equals("") ) ? notMeasured : pulseRate + " bpm (" + pulseRateCreateDate + ")" );
+            cell13.setCellValue( ( oxygenSaturation == null || oxygenSaturation.equals("") ) ? notMeasured : oxygenSaturation + " % (" + oxygenSaturationCreateDate + ")" );
+            cell14.setCellValue( ( bloodSugar == null || bloodSugar.equals("") ) ? notMeasured : bloodSugar + " mg/dL (" + bloodSugarCreateDate + ")" );
+            cell15.setCellValue( ( symptomContent == null || symptomDate == null || symptomContent.equals("")  || symptomDate.equals( "" ) ) ? notMeasured : symptomContent + " (" + symptomDate + ")" );
 
             i++;
         }
@@ -728,6 +735,7 @@ public class PatientController extends LifeCenterController {
         cell12 = row.createCell(13);
         cell13 = row.createCell(14);
         cell14 = row.createCell(15);
+        cell15 = row.createCell(16);
         
         try {
 //            File file = new File(".");

+ 51 - 0
src/main/java/com/lemon/lifecenter/dto/BoardDTO.java

@@ -13,6 +13,15 @@ public class BoardDTO {
     private String answerDate    = null;
     private String answerId      = "";
     
+    private int fileIdx = 0;
+    private String fileOriginalName = "";
+    private String fileName = "";
+    private String fileExtension = "";
+    private int fileSize = 0;
+    
+    private int limit = 0;
+    private int limitMax = 0;
+    
     public int getPostSeq() {
         return postSeq;
     }
@@ -79,5 +88,47 @@ public class BoardDTO {
     public void setAnswerId(String answerId) {
         this.answerId = answerId;
     }
+    public int getFileIdx() {
+        return fileIdx;
+    }
+    public void setFileIdx(int fileIdx) {
+        this.fileIdx = fileIdx;
+    }
+    public String getFileOriginalName() {
+        return fileOriginalName;
+    }
+    public void setFileOriginalName(String fileOriginalName) {
+        this.fileOriginalName = fileOriginalName;
+    }
+    public String getFileName() {
+        return fileName;
+    }
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+    public String getFileExtension() {
+        return fileExtension;
+    }
+    public void setFileExtension(String fileExtension) {
+        this.fileExtension = fileExtension;
+    }
+    public int getFileSize() {
+        return fileSize;
+    }
+    public void setFileSize(int fileSize) {
+        this.fileSize = fileSize;
+    }
+    public int getLimit() {
+        return limit;
+    }
+    public void setLimit(int limit) {
+        this.limit = limit;
+    }
+    public int getLimitMax() {
+        return limitMax;
+    }
+    public void setLimitMax(int limitMax) {
+        this.limitMax = limitMax;
+    }
     
 }

+ 5 - 0
src/main/java/com/lemon/lifecenter/mapper/BoardMapper.java

@@ -1,5 +1,7 @@
 package com.lemon.lifecenter.mapper;
 
+import java.util.List;
+
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
@@ -9,4 +11,7 @@ import com.lemon.lifecenter.dto.BoardDTO;
 @Mapper
 public interface BoardMapper {
     public void noticeInsert(BoardDTO dto);
+    public int selectNoticeBoardListCount(BoardDTO dto);
+    public List<BoardDTO> selectNoticeBoardList(BoardDTO dto);
+    public void fileUploadDataInsert(BoardDTO dto);
 }

+ 14 - 0
src/main/java/com/lemon/lifecenter/service/BoardService.java

@@ -1,5 +1,7 @@
 package com.lemon.lifecenter.service;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -14,4 +16,16 @@ public class BoardService {
     public void noticeInsert(BoardDTO dto) {
         mapper.noticeInsert(dto);
     }
+    
+    public int selectNoticeBoardListCount(BoardDTO dto) {
+        return mapper.selectNoticeBoardListCount(dto);
+    }
+    
+    public List<BoardDTO> selectNoticeBoardList(BoardDTO dto) {
+        return mapper.selectNoticeBoardList(dto);
+    }
+    
+    public void fileUploadDataInsert(BoardDTO dto) {
+        mapper.fileUploadDataInsert(dto);
+    }
 }

+ 62 - 0
src/main/resources/mybatis/mapper/board/board.xml

@@ -2,6 +2,55 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="com.lemon.lifecenter.mapper.BoardMapper">
+    <select id="selectNoticeBoardListCount" parameterType="BoardDTO" resultType="int">
+        <![CDATA[
+            SELECT COUNT(*) AS cnt
+              FROM BOARD_NOTICE
+             WHERE 1 = 1
+         ]]>
+         <if test='title != null and title != ""'>
+             <![CDATA[
+                 AND UPPER(TITLE) LIKE CONCAT('%', UPPER(#{title}), '%')
+             ]]>
+         </if>
+         <if test='content != null and content != ""'>
+             <![CDATA[
+                 AND CONTENT LIKE CONCAT('%', #{content}, '%')
+             ]]>
+         </if>
+
+    </select>
+    <select id="selectNoticeBoardList" parameterType="BoardDTO" resultType="BoardDTO">
+        <![CDATA[
+            SELECT BN.POST_SEQ                                   AS postSeq,
+                   BN.TITLE                                      AS title,
+                   BN.CONTENT                                    AS content,
+                   BN.CREATE_BY                                  AS createBy,
+                   DATE_FORMAT(BN.CREATE_DATE, '%Y-%M-%D %H:%i:%s') AS createDate,
+                   BN.VIEWS                                      AS views,
+                   (SELECT FILE_EXTENSION 
+                     FROM BOARD_ATTACH_FILE BAF
+                    WHERE BN.POST_SEQ = BAF.POST_SEQ)            AS fileExtension
+              FROM BOARD_NOTICE BN
+             WHERE 1 = 1
+         ]]>
+         <if test='title != null and title != ""'>
+             <![CDATA[
+                 AND UPPER(TITLE) LIKE CONCAT('%', UPPER(#{title}), '%')
+             ]]>
+         </if>
+         <if test='content != null and content != ""'>
+             <![CDATA[
+                 AND CONTENT LIKE CONCAT('%', #{content}, '%')
+             ]]>
+         </if>
+         
+         <![CDATA[
+             ORDER BY BN.CREATE_DATE DESC
+             LIMIT ${limit}, ${limitMax}
+         ]]>
+    </select>
+    
     <insert id="noticeInsert" parameterType="BoardDTO">
         <selectKey keyProperty="postSeq" resultType="int" order="AFTER">
             <![CDATA[
@@ -14,4 +63,17 @@
                  VALUES (#{title}, #{content}, #{createBy}, DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s'))
         ]]>
     </insert>
+    
+    <insert id="fileUploadDataInsert" parameterType="BoardDTO">
+        <selectKey keyProperty="fileIdx" resultType="int" order="AFTER">
+            <![CDATA[
+                SELECT CURRENT_VAL AS fileIdx FROM db_serial WHERE NAME = 'board_attach_file_ai_idx'
+            ]]>
+        </selectKey>
+        <![CDATA[
+            INSERT INTO BOARD_ATTACH_FILE
+                        (POST_SEQ,   FILE_ORIGINAL_NAME,  FILE_NAME,   FILE_EXTENSION,   FILE_SIZE)
+                 VALUES (#{postSeq}, #{fileOriginalName}, #{fileName}, #{fileExtension}, #{fileSize})
+        ]]>
+    </insert>
 </mapper>

+ 1 - 0
src/main/resources/mybatis/mapper/patient/patient.xml

@@ -123,6 +123,7 @@
                         ELSE ''
                    END                                                                 AS gender,
                    (SELECT TRUNC((SYSDATE-TO_DATE(JUMIN, 'YYYYMMDD'))/365) + 1)        AS age,
+                   DATE_FORMAT(JUMIN, '%Y-%m-%d')                                      AS jumin,
                    ward_number                                                         AS wardNumber,
                    room_number                                                         AS roomNumber,
                    DATE_FORMAT(FINAL_CLINIC_DATE, '%Y-%m-%d')                          AS finamClinicDate,

+ 30 - 7
src/main/webapp/WEB-INF/jsp/board/content.jsp

@@ -36,23 +36,46 @@
                                     <div class="card-body">
                                         <table class="table mobile-table">
                                             <colgroup>
-                                                <col style="width:20%">
-                                                <col style="width:80%">
+<%--                                                 <col style="width:20%"> --%>
+<%--                                                 <col style="width:80%"> --%>
+        <col style="width:10%">
+        <%-- <col style="width:50%">
+        <col style="width:10%">
+        <col style="width:35%"> --%>
                                             </colgroup>
+                                            
                                             <tr>
-                                                <th><span class="fix">*</span>제목</th>
-                                                <td>제에목</td>
+                                                <th>번호</th>
+                                                <td colspan="5">
+                                                    1
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <th>제목</th>
+                                                <td>ㄴㅇㄹㄴㅇㄹ</td>
+                                                <th style="width:10%">작성자</th>
+                                                <td colspan="1">
+                                                    df
+                                                </td>
+                                            </tr>
+                                            <tr>
+                                                <td colspan="5">
+                                                    <div style="float: right;">
+                                                        sdfsdf
+                                                    </div>
+                                                    
+                                                    
+                                                </td>
                                             </tr>
-                                            
                                             <tr>
-                                                <th><span class="fix">*</span>내용</th>
+                                                <th>내용</th>
                                                 <td style="white-space: pre;">내에에ㅔ에에용</td>
                                             </tr>
                                             
                                             <tr>
                                                 <th>첨부파일</th>
                                                 <td>
-                                                    <input type="file" name="fileName" >
+                                                    <!-- <input type="file" name="fileName" > -->
                                                 </td>
                                             </tr>
                                         </table>

+ 45 - 49
src/main/webapp/WEB-INF/jsp/board/list.jsp

@@ -47,13 +47,13 @@
                                                     <div class="form-row">
                                                         <div class="col-6">
                                                             <select class="custom-select  form-control" id="selectState" name="selectState">
-                                                                <option value="nbTitle">제목</option>
-                                                                <option value="nbContent">내용</option>
+                                                                <option value="title">제목</option>
+                                                                <option value="content">내용</option>
 <%--                                                                 <option value="sCenterName" <c:if test="${selectState eq 'sCenterName'}"> selected="selected"</c:if>>치료센터명</option> --%>
                                                             </select>
                                                         </div>
                                                         <div class="col-6">
-                                                            <input type="text" class="form-control" name="sData" value="${searchTxt}" placeholder="검색어를 입력하세요.">
+                                                            <input type="text" class="form-control" name="searchTxt" value="${searchTxt}" placeholder="검색어를 입력하세요.">
                                                         </div>
                                                     </div>
                                                 </td>
@@ -101,54 +101,50 @@
                                                     <th>파일</th>
                                                 </tr>
                                             </thead>
+                                            
                                             <tbody>
-<%--                                                 <c:choose> --%>
-<%--                                                     <c:when test="${total > 0}"> --%>
-<%--                                                         <c:forEach var="l" items="${item}"> --%>
-<!--                                                             <tr> -->
-<%--                                                                 <td><c:out value="${l.num}" /></td> --%>
-<!--                                                                 <td> -->
-<%--                                                                     <a href="./info?staffId=${l.id}"><c:out value="${l.id}" /></a> --%>
-<!--                                                                 </td> -->
-<%--                                                                 <td><c:out value="${l.name}" /></td> --%>
-<%--                                                                 <td><c:out value="${l.centerName}" /></td> --%>
-<!--                                                                 <td> -->
-<%--                                                                     <c:if test="${l.groupIdx eq 1}">시스템관리자</c:if> --%>
-<%--                                                                     <c:if test="${l.groupIdx eq 2}">관리자</c:if> --%>
-<%--                                                                     <c:if test="${l.groupIdx eq 3}">일반사용자</c:if> --%>
-<!--                                                                 </td> -->
-<%--                                                                 <td><c:out value="${l.lastLoginTime}" /></td> --%>
-<%--                                                                 <td><c:out value="${l.createDate}" /></td> --%>
-<!--                                                                 <td> -->
-<%--                                                                     <c:choose> --%>
-<%--                                                                         <c:when test="${l.useYn == 'Y'}"> --%>
-<!--                                                                             <span class="text-success">활성</span> -->
-<%--                                                                         </c:when> --%>
-<%--                                                                         <c:otherwise> --%>
-<!--                                                                             <span class="text-danger">비활성</span> -->
-<%--                                                                         </c:otherwise> --%>
+                                                <c:choose>
+                                                
+                                                    <c:when test="${total > 0}">
+                                                        <c:forEach var="l" items="${list}" varStatus="lStatus">
+                                                        
+                                                            <c:set var="pageNum" value="${ ( total - lStatus.index ) - ( (page - 1) * pageSize ) }" />
+                                                            <tr>
+                                                                <td><c:out value="${pageNum}" /></td>
+                                                                <td>
+                                                                    <a href="./content?postSeq=${l.postSeq}"><c:out value="${l.title}" /></a>
+                                                                </td>
+                                                                <td><c:out value="${l.createBy}" /></td>
+                                                                <td><c:out value="${l.createDate}" /></td>
+                                                                <td><c:out value="${l.views}" /></td>
+                                                                <td>
+                                                                    <c:if test="${l.fileExtension eq ''}">
+                                                                        -
+                                                                    </c:if>
+                                                                    <c:if test="${l.fileExtension ne ''}">
+                                                                        <c:out value="${l.fileExtension}" />
+                                                                    </c:if>
                                                                     
-<%--                                                                     </c:choose> --%>
-<!--                                                                 </td> -->
-<!--                                                             </tr> -->
-<%--                                                         </c:forEach> --%>
-<%--                                                     </c:when> --%>
-<%--                                                     <c:otherwise> --%>
-<!--                                                         <tr> -->
-<!--                                                             <td colspan="9">등록된 게시글이 없습니다.</td> -->
-<!--                                                         </tr> -->
-<%--                                                     </c:otherwise> --%>
-<%--                                                 </c:choose> --%>
-                                                <tr>
-                                                    <td>1</td>
-                                                    <td>
-                                                        <a href="javscript:;">제목제목제목제목제목</a>
-                                                    </td>
-                                                    <td>시스템(system)</td>
-                                                    <td>2020-10-13 15:23</td>
-                                                    <td>1501</td>
-                                                    <td>-</td>
-                                                </tr>
+                                                                </td>
+                                                            </tr>
+                                                        </c:forEach>
+                                                    </c:when>
+                                                    <c:otherwise>
+                                                        <tr>
+                                                            <td colspan="9">등록된 게시글이 없습니다.</td>
+                                                        </tr>
+                                                    </c:otherwise>
+                                                </c:choose>
+<!--                                                 <tr> -->
+<!--                                                     <td>1</td> -->
+<!--                                                     <td> -->
+<!--                                                         <a href="javscript:;">제목제목제목제목제목</a> -->
+<!--                                                     </td> -->
+<!--                                                     <td>시스템(system)</td> -->
+<!--                                                     <td>2020-10-13 15:23</td> -->
+<!--                                                     <td>1501</td> -->
+<!--                                                     <td>-</td> -->
+<!--                                                 </tr> -->
                                             </tbody>
                                         </table>
                                     </div>

+ 54 - 4
src/main/webapp/WEB-INF/jsp/board/new.jsp

@@ -5,6 +5,56 @@
     pageEncoding="UTF-8"%>
 <jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
 <script>
+$( function(){
+    $( "#sendForm" ).validate({
+        rules: {
+            title : {
+                maxlength : 100
+            },
+            content: {
+                maxlength : 4000
+            },
+        },
+        messages : {
+            title : {
+                required : "제목을 입력해주세요."
+            },
+            content : {
+                required : "내용을 입력해주세요."
+            }
+        },
+        onkeyup: function( element, event ) {
+            $( element ).valid();
+        },
+        onfocusout: function (element) {
+            $( element ).val( $.trim( $( element ).val() ) );
+            $( element ).valid();
+        },
+        submitHandler: function(form) {
+            form.submit();
+        }
+    });
+})
+
+function checkFile(el){
+    // files 로 해당 파일 정보 얻기.
+    var file = el.files;
+
+    // file[0].size 는 파일 용량 정보입니다.
+    if(file[0].size > 1024 * 1024 * 10){
+        // 용량 초과시 경고후 해당 파일의 용량도 보여줌
+        alert('10MB 이하 파일만 등록할 수 있습니다.\n\n' + '현재파일 용량 : ' + (Math.round(file[0].size / 1024 / 1024 * 100) / 100) + 'MB');
+    } else {
+        // 체크를 통과했다면 종료.
+        return;
+    }
+
+    // 체크에 걸리면 선택된 내용 취소 처리를 해야함.
+    // 파일선택 폼의 내용은 스크립트로 컨트롤 할 수 없습니다.
+    // 그래서 그냥 새로 폼을 새로 써주는 방식으로 초기화 합니다.
+    // 이렇게 하면 간단 !?
+    el.outerHTML = el.outerHTML;
+}
 </script>
 </head>
 <body>
@@ -32,7 +82,7 @@
                     <div class="row">
                         <div class="col-12">
                             <div class="card">
-                                <form id="sendForm" action="?" method="post">
+                                <form id="sendForm" action="./new/insert" method="post" enctype="multipart/form-data">
                                     <div class="card-body">
                                         <table class="table mobile-table">
                                             <colgroup>
@@ -42,21 +92,21 @@
                                             <tr>
                                                 <th><span class="fix">*</span>제목</th>
                                                 <td>
-                                                    <input type="text" name="nbTitle" class="form-control" placeholder="제목을 입력하세요" maxlength="80" required>
+                                                    <input type="text" name="title" class="form-control" placeholder="제목을 입력하세요" maxlength="100" required>
                                                 </td>
                                             </tr>
                                             
                                             <tr>
                                                 <th><span class="fix">*</span>내용</th>
                                                 <td>
-                                                    <textarea  class="form-control" rows="10" cols="" name="nbContent" placeholder="내용을 입력하세요" maxlength="1000" required></textarea>
+                                                    <textarea  class="form-control" rows="10" cols="" name="content" placeholder="내용을 입력하세요" maxlength="4000" required></textarea>
                                                 </td>
                                             </tr>
                                             
                                             <tr>
                                                 <th>첨부파일</th>
                                                 <td>
-                                                    <input type="file" name="fileName" >
+                                                    <input type="file" name="file" onchange="checkFile(this);">
 <!--                                                     <div class="form-row"> -->
 <!--                                                         <div class="col-6"> -->
 <!--                                                             <select class="custom-select  form-control" id="selectState" name="selectState"> -->