├── .DS_Store ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.md ├── design ├── .DS_Store ├── DB_schema.pptx ├── DB_schema.xlsx ├── DDL.txt ├── DML.txt └── id&pwd.txt ├── mvnw ├── mvnw.cmd ├── pom.xml ├── screenshot ├── article.png ├── category.png ├── home.png ├── login.mov ├── mypage.png ├── set_profile_image.mov ├── view_by_category.png └── write_reply.png └── src ├── .DS_Store ├── main ├── .DS_Store ├── java │ └── com │ │ └── board │ │ └── demo │ │ ├── DemoApplication.java │ │ ├── controller │ │ ├── AdminController.java │ │ ├── BoardController.java │ │ ├── HelloController.java │ │ ├── MemberController.java │ │ └── MypageController.java │ │ ├── repository │ │ ├── BoardRepository.java │ │ ├── BoardlistRepository.java │ │ ├── CategoryRepository.java │ │ ├── MemberLikeBoardRepository.java │ │ ├── MemberRepository.java │ │ ├── MypageRepository.java │ │ ├── ReplyRepository.java │ │ └── ReplylistRepository.java │ │ ├── service │ │ ├── BoardService.java │ │ ├── BoardServiceImpl.java │ │ ├── CategoryService.java │ │ ├── CategoryServiceImpl.java │ │ ├── MemberLikeBoardService.java │ │ ├── MemberLikeBoardServiceImpl.java │ │ ├── MemberService.java │ │ ├── MemberServiceImpl.java │ │ ├── MypageService.java │ │ ├── MypageServiceImpl.java │ │ ├── ReplyService.java │ │ └── ReplyServiceImpl.java │ │ ├── util │ │ ├── Constants.java │ │ ├── Conversion.java │ │ ├── CurrentArticle.java │ │ ├── ErrorPage.java │ │ ├── FileIO.java │ │ └── HashFunction.java │ │ └── vo │ │ ├── Article.java │ │ ├── Board.java │ │ ├── Boardlist.java │ │ ├── Category.java │ │ ├── Member.java │ │ ├── MemberLikeBoard.java │ │ ├── Mypage.java │ │ ├── Reply.java │ │ └── Replylist.java ├── resources │ ├── .DS_Store │ ├── application.properties │ └── static │ │ ├── css │ │ ├── board.css │ │ ├── common.css │ │ ├── err_page.css │ │ ├── my_page.css │ │ ├── view_article.css │ │ └── write_form.css │ │ ├── img │ │ ├── heart_empty.png │ │ ├── heart_full.png │ │ ├── null_profile.png │ │ └── profile │ │ │ ├── 0 │ │ │ ├── admin 복사본.png │ │ │ ├── admin.png │ │ │ ├── rhks.png │ │ │ └── 관도장.png │ │ │ ├── 1 │ │ │ ├── KakaoTalk_Image_2020-06-0.png │ │ │ └── image_readtop_2018_116371.png │ │ │ ├── 2 │ │ │ └── 4수호자3신비3별.png │ │ │ ├── 9 │ │ │ └── 콜라보.jpg │ │ │ ├── 10 │ │ │ ├── 20111112175840_뿌까.jpg │ │ │ └── 뿌까.jpeg │ │ │ ├── 23 │ │ │ ├── ss.jpeg │ │ │ └── 존예.jpg │ │ │ ├── 24 │ │ │ └── 존예.jpg │ │ │ ├── 29 │ │ │ └── ebc60c08-721b-4572-8f51-8.png │ │ │ ├── 30 │ │ │ ├── craft.jpeg │ │ │ └── craftw.png │ │ │ ├── 31 │ │ │ └── xxlovets_112.jpg │ │ │ ├── 32 │ │ │ └── 스크린샷 2020-06-02 오ᄒ.png │ │ │ └── 33 │ │ │ └── 스크린샷 2020-06-02 오ᄒ.png │ │ └── js │ │ ├── board.js │ │ ├── common.js │ │ ├── login.js │ │ ├── modify_form.js │ │ ├── my_page.js │ │ ├── view_article.js │ │ └── write_form.js └── webapp │ ├── .DS_Store │ └── WEB-INF │ └── jsp │ ├── board.jsp │ ├── err_404.jsp │ ├── modify_form.jsp │ ├── my_page.jsp │ ├── show_profile.jsp │ ├── topbar.jsp │ ├── view_article.jsp │ └── write_form.jsp └── test └── java └── com └── board └── demo └── repository ├── BoardRepositoryTest.java ├── CategoryRepositoryTest.java ├── MemberLikeBoardRepositoryTest.java ├── MemberRepositoryTest.java └── ReplyRepositoryTest.java /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/web,java,maven,java-web,intellij 3 | # Edit at https://www.gitignore.io/?templates=web,java,maven,java-web,intellij 4 | 5 | ### Intellij ### 6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 8 | 9 | # User-specific stuff 10 | .idea/**/workspace.xml 11 | .idea/**/tasks.xml 12 | .idea/**/usage.statistics.xml 13 | .idea/**/dictionaries 14 | .idea/**/shelf 15 | 16 | # Generated files 17 | .idea/**/contentModel.xml 18 | 19 | # Sensitive or high-churn files 20 | .idea/**/dataSources/ 21 | .idea/**/dataSources.ids 22 | .idea/**/dataSources.local.xml 23 | .idea/**/sqlDataSources.xml 24 | .idea/**/dynamic.xml 25 | .idea/**/uiDesigner.xml 26 | .idea/**/dbnavigator.xml 27 | 28 | # Gradle 29 | .idea/**/gradle.xml 30 | .idea/**/libraries 31 | 32 | # Gradle and Maven with auto-import 33 | # When using Gradle or Maven with auto-import, you should exclude module files, 34 | # since they will be recreated, and may cause churn. Uncomment if using 35 | # auto-import. 36 | # .idea/modules.xml 37 | # .idea/*.iml 38 | # .idea/modules 39 | # *.iml 40 | # *.ipr 41 | 42 | # CMake 43 | cmake-build-*/ 44 | 45 | # Mongo Explorer plugin 46 | .idea/**/mongoSettings.xml 47 | 48 | # File-based project format 49 | *.iws 50 | 51 | # IntelliJ 52 | out/ 53 | 54 | # mpeltonen/sbt-idea plugin 55 | .idea_modules/ 56 | 57 | # JIRA plugin 58 | atlassian-ide-plugin.xml 59 | 60 | # Cursive Clojure plugin 61 | .idea/replstate.xml 62 | 63 | # Crashlytics plugin (for Android Studio and IntelliJ) 64 | com_crashlytics_export_strings.xml 65 | crashlytics.properties 66 | crashlytics-build.properties 67 | fabric.properties 68 | 69 | # Editor-based Rest Client 70 | .idea/httpRequests 71 | 72 | # Android studio 3.1+ serialized cache file 73 | .idea/caches/build_file_checksums.ser 74 | 75 | ### Intellij Patch ### 76 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 77 | 78 | # *.iml 79 | # modules.xml 80 | # .idea/misc.xml 81 | # *.ipr 82 | 83 | # Sonarlint plugin 84 | .idea/**/sonarlint/ 85 | 86 | # SonarQube Plugin 87 | .idea/**/sonarIssues.xml 88 | 89 | # Markdown Navigator plugin 90 | .idea/**/markdown-navigator.xml 91 | .idea/**/markdown-navigator/ 92 | 93 | ### Java ### 94 | # Compiled class file 95 | *.class 96 | 97 | # Log file 98 | *.log 99 | 100 | # BlueJ files 101 | *.ctxt 102 | 103 | # Mobile Tools for Java (J2ME) 104 | .mtj.tmp/ 105 | 106 | 107 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 108 | hs_err_pid* 109 | 110 | ### Java-Web ### 111 | ## ignoring target file 112 | target/ 113 | 114 | ### Maven ### 115 | pom.xml.tag 116 | pom.xml.releaseBackup 117 | pom.xml.versionsBackup 118 | pom.xml.next 119 | release.properties 120 | dependency-reduced-pom.xml 121 | buildNumber.properties 122 | .mvn/timing.properties 123 | .mvn/wrapper/maven-wrapper.jar 124 | .flattened-pom.xml 125 | 126 | 127 | ### etc ### 128 | .DS_Store 129 | *.DS_Store 130 | seokju2ng-board.pem 131 | application-db.properties 132 | 133 | 134 | # End of https://www.gitignore.io/api/web,java,maven,java-web,intellij 135 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 석주잉 게시판 2 | 3 | #### Web Board with Spring boot and JPA 4 | - 게시판 기본 서비스 제공 5 | - 회원 글 / 댓글 / 대댓글 작성, 글 추천(좋아요) 가능 6 | - 카테고리(말머리, 게시물 개수)별 목록보기, 페이징 등 7 | - 회원 서비스 제공 8 | - 회원가입, 로그인, 프로필 사진 등록, 마이페이지 등 9 | - 관리자 서비스 제공 10 | - 말머리 추가, 공지 작성(상단 노출), 회원의 글 / 댓글 삭제 등 11 | 12 |
13 |

14 |
15 | 16 | #### 기술스택 17 | `Java` `Springboot` `Spring Data JPA` `MySQL` `JavaScript` `jQuery` `JSP` `Ajax` `CSS` `Git` 18 | 19 |
20 | 21 | #### 프로젝트 기간 22 | - 2020.05.12 ~ 2020.06.03 23 | 24 | #### 개발 25 | - 설계 / 백엔드 / 프론트엔드 / 퍼블리싱 : 김석중([@seokju2ng](https://github.com/seokju2ng)) 26 | -------------------------------------------------------------------------------- /design/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/design/.DS_Store -------------------------------------------------------------------------------- /design/DB_schema.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/design/DB_schema.pptx -------------------------------------------------------------------------------- /design/DB_schema.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/design/DB_schema.xlsx -------------------------------------------------------------------------------- /design/DDL.txt: -------------------------------------------------------------------------------- 1 | ### TABLE LIST ### 2 | 3 | CREATE TABLE member ( 4 | member_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 5 | id VARCHAR(20) NOT NULL UNIQUE, 6 | nickname VARCHAR(20) NOT NULL, 7 | pwd CHAR(64) NOT NULL, 8 | email VARCHAR(50) NOT NULL, 9 | attendance INT UNSIGNED NOT NULL DEFAULT 0, 10 | profile_photo VARCHAR(30) DEFAULT NULL 11 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; 12 | 13 | CREATE TABLE category ( 14 | category_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 15 | category_name VARCHAR(10) NOT NULL 16 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; 17 | 18 | CREATE TABLE board ( 19 | board_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 20 | title VARCHAR(60) NOT NULL, 21 | content TEXT NOT NULL, 22 | date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 23 | likes INT UNSIGNED NOT NULL DEFAULT 0, 24 | views INT UNSIGNED NOT NULL DEFAULT 0, 25 | writer INT UNSIGNED NOT NULL, 26 | category INT UNSIGNED NOT NULL, 27 | FOREIGN KEY (writer) REFERENCES member(member_id) 28 | ON DELETE CASCADE ON UPDATE CASCADE, 29 | FOREIGN KEY (category) REFERENCES category(category_id) 30 | ON DELETE CASCADE ON UPDATE CASCADE 31 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; 32 | 33 | CREATE TABLE reply ( 34 | reply_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 35 | parent INT UNSIGNED NOT NULL DEFAULT 0, 36 | sorts INT UNSIGNED NOT NULL DEFAULT 0, 37 | content TEXT NOT NULL, 38 | date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 39 | board INT UNSIGNED NOT NULL, 40 | writer INT UNSIGNED NOT NULL, 41 | FOREIGN KEY (board) REFERENCES board(board_id) 42 | ON DELETE CASCADE ON UPDATE CASCADE, 43 | FOREIGN KEY (writer) REFERENCES memberca(member_id) 44 | ON DELETE CASCADE ON UPDATE CASCADE 45 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; 46 | 47 | CREATE TABLE member_like_board ( 48 | mlb_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 49 | member_id INT UNSIGNED NOT NULL, 50 | board_id INT UNSIGNED NOT NULL, 51 | FOREIGN KEY (member_id) REFERENCES member(member_id) 52 | ON DELETE CASCADE ON UPDATE CASCADE, 53 | FOREIGN KEY (board_id) REFERENCES board(board_id) 54 | ON DELETE CASCADE ON UPDATE CASCADE, 55 | UNIQUE KEY unique_index(member_id, board_id) 56 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; 57 | 58 | 59 | 60 | 61 | ### VIEW LIST ### 62 | 63 | CREATE VIEW boardlist AS 64 | SELECT 65 | board_id, category_name AS category, title, content, B.date, M.member_id AS writer_id, 66 | M.nickname AS writer_nick, profile_photo, ifnull(MLB.likes, 0) AS likes, views, ifnull(rp, 0) AS replies 67 | FROM board AS B 68 | LEFT JOIN member AS M 69 | ON(B.writer = M.member_id) 70 | LEFT JOIN category AS C 71 | ON(B.category = C.category_id) 72 | LEFT JOIN (select board, count(*) AS rp from reply group by board) AS R 73 | ON(B.board_id = R.board) 74 | LEFT JOIN (select board_id, count(*) AS likes from member_like_board group by board_id) AS MLB 75 | USING(board_id) 76 | ORDER BY board_id desc; 77 | 78 | CREATE VIEW replylist AS 79 | SELECT 80 | reply_id, parent, sorts, content, date, member_id, nickname, profile_photo, board 81 | FROM reply AS R 82 | LEFT JOIN member AS M ON(R.writer = M.member_id) 83 | ORDER BY parent, reply_id; 84 | 85 | 86 | CREATE VIEW mypage AS 87 | SELECT member_id, id, nickname, attendance, profile_photo, 88 | ifnull(nob, 0) AS board_num, ifnull(nor, 0) AS reply_num 89 | FROM member AS M 90 | LEFT JOIN (SELECT writer, COUNT(*) AS nob FROM board GROUP BY writer) AS B 91 | ON(M.member_id = B.writer) 92 | LEFT JOIN (SELECT writer, COUNT(*) AS nor FROM reply GROUP BY writer) AS R 93 | ON(M.member_id = R.writer); 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /design/DML.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/design/DML.txt -------------------------------------------------------------------------------- /design/id&pwd.txt: -------------------------------------------------------------------------------- 1 | admin ehdgksmf 2 | Eodqjf5015 milk5239 3 | gyetol gyetol 4 | tororo gyetol 5 | qlkjds124 asdkafs 6 | dkqmfk klrjdfa 7 | qkrwnsrb qkrwnsrb 8 | parent1234 qwer25 9 | one_luffy xxlovets 10 | I_KEEP_CALM because 11 | denmark_alive person -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | com.board 12 | demo 13 | 0.0.1-SNAPSHOT 14 | demo 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.mybatis.spring.boot 29 | mybatis-spring-boot-starter 30 | 2.1.2 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-devtools 36 | true 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-data-jpa 42 | 43 | 44 | 45 | mysql 46 | mysql-connector-java 47 | runtime 48 | 49 | 50 | 51 | org.mariadb.jdbc 52 | mariadb-java-client 53 | 2.6.0 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-test 60 | test 61 | 62 | 63 | org.junit.vintage 64 | junit-vintage-engine 65 | 66 | 67 | 68 | 69 | org.springframework.security 70 | spring-security-test 71 | test 72 | 73 | 74 | 75 | 76 | javax.servlet 77 | jstl 78 | 79 | 80 | 81 | org.apache.tomcat.embed 82 | tomcat-embed-jasper 83 | 84 | 85 | 86 | 87 | org.projectlombok 88 | lombok 89 | true 90 | 91 | 92 | 93 | 94 | junit 95 | junit 96 | test 97 | 98 | 99 | 100 | 101 | com.googlecode.json-simple 102 | json-simple 103 | 1.1.1 104 | 105 | 106 | 107 | 108 | 109 | 110 | org.springframework.boot 111 | spring-boot-maven-plugin 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /screenshot/article.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/article.png -------------------------------------------------------------------------------- /screenshot/category.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/category.png -------------------------------------------------------------------------------- /screenshot/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/home.png -------------------------------------------------------------------------------- /screenshot/login.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/login.mov -------------------------------------------------------------------------------- /screenshot/mypage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/mypage.png -------------------------------------------------------------------------------- /screenshot/set_profile_image.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/set_profile_image.mov -------------------------------------------------------------------------------- /screenshot/view_by_category.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/view_by_category.png -------------------------------------------------------------------------------- /screenshot/write_reply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/screenshot/write_reply.png -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/.DS_Store -------------------------------------------------------------------------------- /src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/.DS_Store -------------------------------------------------------------------------------- /src/main/java/com/board/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.board.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoApplication.class, args); 11 | System.out.println("spring start..."); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/controller/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.controller; 2 | 3 | import com.board.demo.service.CategoryService; 4 | import com.board.demo.vo.Member; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.json.simple.JSONObject; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.servlet.ModelAndView; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import java.io.IOException; 17 | import java.util.Objects; 18 | 19 | import static com.board.demo.util.Constants.*; 20 | 21 | @Slf4j 22 | @Controller 23 | @RequestMapping("/admin") 24 | public class AdminController { 25 | @Autowired 26 | private CategoryService categoryService; 27 | 28 | @GetMapping 29 | public ModelAndView showAdminPage() { 30 | return null; 31 | } 32 | 33 | @GetMapping("add-category") 34 | public void addCategory(@RequestParam String category, 35 | HttpServletRequest request, 36 | HttpServletResponse response) throws IOException { 37 | JSONObject res = new JSONObject(); 38 | Member member = (Member) request.getSession().getAttribute("loginMember"); 39 | 40 | if (Objects.isNull(member) || member.getMemberId() != ADMIN_ID) { 41 | res.put(RESULT, INVALID_APPROACH); 42 | } 43 | else if (categoryService.addCategory(category)) { 44 | res.put(RESULT, SUCCESS); 45 | } 46 | else { 47 | res.put(RESULT, FAIL); 48 | } 49 | response.setContentType("application/json; charset=utf-8"); 50 | response.getWriter().print(res); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/controller/BoardController.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.controller; 2 | 3 | import com.board.demo.service.BoardService; 4 | import com.board.demo.service.CategoryService; 5 | import com.board.demo.service.MemberLikeBoardService; 6 | import com.board.demo.service.ReplyService; 7 | import com.board.demo.util.Conversion; 8 | import com.board.demo.util.CurrentArticle; 9 | import com.board.demo.util.ErrorPage; 10 | import com.board.demo.vo.*; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.json.simple.JSONObject; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.data.domain.Page; 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.web.bind.annotation.*; 17 | import org.springframework.web.servlet.ModelAndView; 18 | 19 | import javax.servlet.http.HttpServletRequest; 20 | import javax.servlet.http.HttpServletResponse; 21 | import java.io.IOException; 22 | import java.util.List; 23 | 24 | import static com.board.demo.util.Constants.*; 25 | import static java.util.Objects.isNull; 26 | 27 | @Slf4j 28 | @Controller 29 | @RequestMapping("/board") 30 | public class BoardController { 31 | private final String DEFAULT_CATEGORY = "전체보기"; 32 | private final String DEFAULT_PAGE = "1"; 33 | private final String DEFAULT_LIST_SIZE = "10"; 34 | private final String ON = "ON"; 35 | private final int MAIN_PAGE= 1; 36 | 37 | @Autowired 38 | private BoardService boardService; 39 | 40 | @Autowired 41 | private CategoryService categoryService; 42 | 43 | @Autowired 44 | private ReplyService replyService; 45 | 46 | @Autowired 47 | private MemberLikeBoardService memberLikeBoardService; 48 | 49 | @GetMapping 50 | public ModelAndView showBoard( 51 | @RequestParam(defaultValue = DEFAULT_CATEGORY, required = false) String category, 52 | @RequestParam(defaultValue = DEFAULT_PAGE, required = false) Integer page, 53 | @RequestParam(defaultValue = DEFAULT_LIST_SIZE, required = false) Integer size) { 54 | ModelAndView mav = new ModelAndView(); 55 | Page boardlistPage = boardService.getList(category, page - 1, size); 56 | List boards = boardlistPage.getContent(); 57 | 58 | boardService.convertArticleFormat(boards); 59 | List categories = categoryService.getList(); 60 | int totalPage = boardlistPage.getTotalPages(); 61 | int startPage = Conversion.calcStartPage(page); 62 | 63 | if ( category.equals(DEFAULT_CATEGORY) && 64 | page == MAIN_PAGE ) { 65 | List notices = boardService.getNotices(); 66 | List topLikes = boardService.getTopLikes(); 67 | boardService.convertArticleFormat(notices); 68 | boardService.convertArticleFormat(topLikes); 69 | mav.addObject("notices", notices); 70 | mav.addObject("topLikes", topLikes); 71 | } 72 | 73 | mav.setViewName("board"); 74 | mav.addObject("boards", boards); 75 | mav.addObject("categories", categories); 76 | mav.addObject("selectCategory", category); 77 | mav.addObject("selectSize", size); 78 | mav.addObject("curPage", page); 79 | mav.addObject("totalPage", totalPage); 80 | mav.addObject("startPage", startPage); 81 | return mav; 82 | } 83 | 84 | @GetMapping("/write") 85 | public ModelAndView showWriteForm(HttpServletRequest request) { 86 | ModelAndView mav = new ModelAndView(); 87 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 88 | 89 | if (isNull(loginMember)) { 90 | mav.setViewName("redirect:/board"); 91 | return mav; 92 | } 93 | mav.setViewName("write_form"); 94 | mav.addObject("categories", categoryService.getList()); 95 | return mav; 96 | } 97 | 98 | @PostMapping("/write") 99 | public void write(@RequestParam String title, 100 | @RequestParam String content, 101 | @RequestParam int category, 102 | HttpServletRequest request, 103 | HttpServletResponse response) throws IOException { 104 | JSONObject res = new JSONObject(); 105 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 106 | 107 | if (isNull(loginMember)) { 108 | res.put(RESULT, INVALID_APPROACH); 109 | } 110 | else if (boardService.write(loginMember.getMemberId(), title, content, category)) { 111 | res.put(RESULT, SUCCESS); 112 | } else { 113 | res.put(RESULT, FAIL); 114 | } 115 | 116 | response.setContentType("application/json; charset=utf-8"); 117 | response.getWriter().print(res); 118 | } 119 | 120 | @GetMapping("/{idx}") 121 | public ModelAndView showArticle(@PathVariable("idx") int boardId, 122 | HttpServletRequest request) { 123 | if (!boardService.addViews(boardId)) { 124 | return ErrorPage.show(); 125 | } 126 | Member member = (Member)request.getSession().getAttribute("loginMember"); 127 | ModelAndView mav = new ModelAndView(); 128 | if (!isNull(member)) { 129 | boolean isLike = memberLikeBoardService.isLike(boardId, member.getMemberId()); 130 | mav.addObject("isLike", isLike); 131 | } 132 | 133 | Boardlist article = boardService.getPostByIdForViewArticle(boardId); 134 | CurrentArticle currentArticle = boardService.getPrevAndNextArticle(boardId); 135 | List replies = replyService.getRepliesByBoardId(boardId); 136 | 137 | mav.setViewName("view_article"); 138 | mav.addObject("article", article); 139 | mav.addObject("replies", replies); 140 | mav.addObject("current", currentArticle); 141 | return mav; 142 | } 143 | 144 | @PostMapping("/write/reply") 145 | public ModelAndView writeReply(@RequestParam int boardId, 146 | @RequestParam int parent, 147 | @RequestParam String content, 148 | HttpServletRequest request) { 149 | Member member = (Member)request.getSession().getAttribute("loginMember"); 150 | boolean result = replyService.writeReply(boardId, parent, content, member); 151 | 152 | if (!result) { 153 | return ErrorPage.show(); 154 | } 155 | ModelAndView mav = new ModelAndView(); 156 | mav.setViewName("redirect:/board/"+boardId); 157 | return mav; 158 | } 159 | 160 | @PostMapping("/delete/reply") 161 | public ModelAndView deleteReply(@RequestParam int replyId, 162 | @RequestParam int parent, 163 | @RequestParam int boardId, 164 | HttpServletRequest request) { 165 | Member member = (Member)request.getSession().getAttribute("loginMember"); 166 | boolean result = replyService.deleteReply(replyId, parent, member); 167 | 168 | if (!result) { 169 | return ErrorPage.show(); 170 | } 171 | ModelAndView mav = new ModelAndView(); 172 | mav.setViewName("redirect:/board/"+boardId); 173 | return mav; 174 | } 175 | 176 | @GetMapping("/modify/{idx}") 177 | public ModelAndView showModifyForm(@PathVariable("idx") long boardId, 178 | HttpServletRequest request) { 179 | Boardlist article = boardService.getPostById(boardId); 180 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 181 | 182 | if ( isNull(article) || 183 | isNull(loginMember) || 184 | (loginMember.getMemberId() != article.getWriterId()) ) { 185 | return ErrorPage.show(); 186 | } 187 | 188 | ModelAndView mav = new ModelAndView(); 189 | mav.setViewName("modify_form"); 190 | mav.addObject("article", article); 191 | mav.addObject("categories", categoryService.getList()); 192 | return mav; 193 | } 194 | 195 | @PostMapping("/modify") 196 | public void modify(@RequestParam long boardId, 197 | @RequestParam String title, 198 | @RequestParam String content, 199 | @RequestParam int category, 200 | HttpServletRequest request, 201 | HttpServletResponse response) throws IOException { 202 | Board article = boardService.getBoardById(boardId); 203 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 204 | JSONObject res = new JSONObject(); 205 | 206 | if ( isNull(article) || 207 | isNull(loginMember) || 208 | (loginMember.getMemberId() != article.getWriter()) ) { 209 | res.put(RESULT, INVALID_APPROACH); 210 | } 211 | else if (boardService.modify(article, title, content, category)) { 212 | res.put(RESULT, SUCCESS); 213 | } 214 | else { 215 | res.put(RESULT, FAIL); 216 | } 217 | 218 | response.setContentType("application/json; charset=utf-8"); 219 | response.getWriter().print(res); 220 | } 221 | 222 | @PostMapping("/like") 223 | public void likeOnOff(@RequestParam long boardId, 224 | @RequestParam String flag, 225 | HttpServletRequest request, 226 | HttpServletResponse response) throws IOException { 227 | JSONObject res = new JSONObject(); 228 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 229 | 230 | if (isNull(loginMember)) { 231 | res.put(RESULT, INVALID_APPROACH); 232 | } 233 | else if (ON.equals(flag)) { // like on 234 | if (memberLikeBoardService.like(loginMember.getMemberId(), boardId)) { 235 | res.put(RESULT, SUCCESS); 236 | } else { 237 | res.put(RESULT, FAIL); 238 | } 239 | } 240 | else { // like off 241 | memberLikeBoardService.dislike(loginMember.getMemberId(), boardId); 242 | res.put(RESULT, SUCCESS); 243 | } 244 | 245 | response.setContentType("application/json; charset=utf-8"); 246 | response.getWriter().print(res); 247 | } 248 | 249 | @PostMapping("/delete") 250 | public ModelAndView deleteArticle(@RequestParam long boardId, 251 | HttpServletRequest request) { 252 | Board article = boardService.getBoardById(boardId); 253 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 254 | 255 | if ( isNull(article) || 256 | isNull(loginMember) || 257 | (loginMember.getMemberId() != article.getWriter() && 258 | loginMember.getMemberId() != ADMIN_ID )) { 259 | return ErrorPage.show(); 260 | } 261 | 262 | boardService.deleteArticle(boardId); 263 | 264 | ModelAndView mav = new ModelAndView(); 265 | mav.setViewName("redirect:/board"); 266 | return mav; 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | 6 | @Controller 7 | public class HelloController { 8 | @GetMapping("/") 9 | public String hello() { 10 | return "redirect:/board"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/controller/MemberController.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.controller; 2 | 3 | import com.board.demo.service.MemberService; 4 | import com.board.demo.util.FileIO; 5 | import com.board.demo.vo.Member; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.json.simple.JSONObject; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | import java.io.File; 15 | import java.io.FileInputStream; 16 | import java.io.IOException; 17 | import java.io.OutputStream; 18 | import java.security.NoSuchAlgorithmException; 19 | import java.util.List; 20 | import java.util.Objects; 21 | 22 | import static com.board.demo.util.Constants.*; 23 | 24 | @Slf4j 25 | @RestController 26 | @RequestMapping("/member") 27 | public class MemberController { 28 | 29 | @Autowired 30 | private MemberService memberService; 31 | 32 | @RequestMapping("/members") 33 | public List getMembers() { 34 | List list = memberService.getList(); 35 | return list; 36 | } 37 | 38 | @PostMapping("/login") 39 | public void login(@RequestParam String id, 40 | @RequestParam String pwd, 41 | HttpServletRequest request, 42 | HttpServletResponse response) throws IOException, NoSuchAlgorithmException { 43 | 44 | Member loginMember = memberService.login(id, pwd); 45 | JSONObject res = new JSONObject(); 46 | 47 | if (Objects.isNull(loginMember)) { 48 | res.put(RESULT, FAIL); 49 | log.info("** [" + id + "] Failed to log in **"); 50 | } else { 51 | HttpSession session = request.getSession(); 52 | session.setAttribute("loginMember", loginMember); 53 | if (loginMember.getMemberId() == 0) { 54 | res.put(RESULT, ADMIN_ID); 55 | log.info("** ADMIN has logged in **"); 56 | } else { 57 | res.put(RESULT, SUCCESS); 58 | res.put("nick", loginMember.getNickname()); 59 | log.info("** [" + id + "] has logged in **"); 60 | } 61 | } 62 | 63 | response.setContentType("application/json; charset=utf-8"); 64 | response.getWriter().print(res); 65 | } 66 | 67 | @GetMapping("/logout") 68 | public void logout(HttpServletRequest request, 69 | HttpServletResponse response) throws IOException { 70 | HttpSession session = request.getSession(); 71 | JSONObject res = new JSONObject(); 72 | Member member = (Member) session.getAttribute("loginMember"); 73 | 74 | if (Objects.isNull(member)) { 75 | log.warn("!! Invalid approach !!"); 76 | res.put(RESULT, INVALID_APPROACH); 77 | } else { 78 | log.info("** [" + member.getId() + "] has logged out **"); 79 | session.invalidate(); 80 | res.put(RESULT, SUCCESS); 81 | res.put("nick", member.getNickname()); 82 | } 83 | response.setContentType("application/json; charset=utf-8"); 84 | response.getWriter().print(res); 85 | } 86 | 87 | @GetMapping("/check-duplicate") 88 | public void checkDuplicate(@RequestParam String id, 89 | HttpServletResponse response) throws IOException { 90 | JSONObject res = new JSONObject(); 91 | 92 | if (memberService.isDuplicate(id)) { 93 | res.put(RESULT, DUPLICATE_ID); 94 | log.info("Duplicate id : " + id); 95 | } else { 96 | res.put(RESULT, SUCCESS); 97 | log.info("Available id : " + id); 98 | } 99 | response.setContentType("application/json; charset=utf-8"); 100 | response.getWriter().print(res); 101 | } 102 | 103 | @PostMapping("/join") 104 | public void join(@RequestParam String id, 105 | @RequestParam String pwd, 106 | @RequestParam String email, 107 | @RequestParam String nick, 108 | HttpServletResponse response) throws IOException, NoSuchAlgorithmException { 109 | JSONObject res = new JSONObject(); 110 | 111 | try { 112 | Member newMember = memberService.join(id, pwd, email, nick); 113 | log.info("New Member[ " + newMember.getMemberId() + " : " + id + " ] has just signed up."); 114 | res.put(RESULT, SUCCESS); 115 | } catch (Exception e) { 116 | log.warn(e.toString()); 117 | res.put(RESULT, FAIL); 118 | } 119 | 120 | response.setContentType("application/json; charset=utf-8"); 121 | response.getWriter().print(res); 122 | } 123 | 124 | @GetMapping("/get-profile") 125 | public void getProfilePhoto(@RequestParam String middlePath, 126 | @RequestParam String imageFileName, 127 | HttpServletRequest request, 128 | HttpServletResponse response) throws IOException { 129 | request.setCharacterEncoding("utf-8"); 130 | response.setContentType("text/html; charset=utf-8"); 131 | FileIO.loadImage(middlePath, imageFileName, response); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/controller/MypageController.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.controller; 2 | 3 | import com.board.demo.service.BoardService; 4 | import com.board.demo.service.MemberService; 5 | import com.board.demo.service.MypageService; 6 | import com.board.demo.service.ReplyService; 7 | import com.board.demo.util.Conversion; 8 | import com.board.demo.util.ErrorPage; 9 | import com.board.demo.util.FileIO; 10 | import com.board.demo.vo.Member; 11 | import com.board.demo.vo.Mypage; 12 | import com.sun.org.apache.xpath.internal.operations.Mod; 13 | import lombok.extern.slf4j.Slf4j; 14 | import org.json.simple.JSONObject; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Controller; 17 | import org.springframework.web.bind.annotation.GetMapping; 18 | import org.springframework.web.bind.annotation.PostMapping; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RequestParam; 21 | import org.springframework.web.multipart.MultipartFile; 22 | import org.springframework.web.servlet.ModelAndView; 23 | 24 | import javax.servlet.http.HttpServletRequest; 25 | import javax.servlet.http.HttpServletResponse; 26 | import java.io.IOException; 27 | import java.util.Objects; 28 | 29 | import static com.board.demo.util.Constants.*; 30 | import static java.util.Objects.isNull; 31 | 32 | @Slf4j 33 | @Controller 34 | @RequestMapping("/mypage") 35 | public class MypageController { 36 | private final String DEFAULT_PAGE = "1"; 37 | private final int DEFAULT_LIST_SIZE = 10; 38 | private final String DEFAULT_TYPE = "board"; 39 | 40 | @Autowired 41 | private BoardService boardService; 42 | 43 | @Autowired 44 | private MemberService memberService; 45 | 46 | @Autowired 47 | private ReplyService replyService; 48 | 49 | @Autowired 50 | private MypageService mypageService; 51 | 52 | @GetMapping 53 | public ModelAndView showMypage(@RequestParam(defaultValue = DEFAULT_TYPE, required = false) String type, 54 | @RequestParam(defaultValue = DEFAULT_PAGE, required = false) Integer page, 55 | @RequestParam(value = "id", required = false) Long memberId, 56 | HttpServletRequest request) { 57 | // log.info("mypage > id: "+memberId); 58 | ModelAndView mav = new ModelAndView(); 59 | 60 | if (isNull(memberId)) { 61 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 62 | if (isNull(loginMember)) { 63 | mav.setViewName("redirect:/board"); 64 | return mav; 65 | } 66 | memberId = loginMember.getMemberId(); 67 | } 68 | 69 | Mypage mypage = mypageService.getMypageInfo(memberId); 70 | if (isNull(mypage)) { 71 | return ErrorPage.show(); 72 | } 73 | 74 | if (type.equals(DEFAULT_TYPE)) { // 등록한 게시글 요청 75 | boardService.getListByMemberId(memberId, page - 1, DEFAULT_LIST_SIZE, mav); 76 | } else { // 등록한 댓글 요청 77 | replyService.getListByMemberId(memberId, page - 1, DEFAULT_LIST_SIZE, mav); 78 | } 79 | 80 | int startPage = Conversion.calcStartPage(page); 81 | mav.addObject("mypage", mypage); 82 | mav.addObject("type", type); 83 | mav.addObject("curPage", page); 84 | mav.addObject("startPage", startPage); 85 | mav.setViewName("my_page"); 86 | return mav; 87 | } 88 | 89 | @GetMapping("/show-profile") 90 | public ModelAndView showProfileImage(@RequestParam(value = "id") Long memberId) { 91 | ModelAndView mav = new ModelAndView(); 92 | Mypage mypage = mypageService.getMypageInfo(memberId); 93 | mav.addObject("mypage", mypage); 94 | mav.setViewName("show_profile"); 95 | return mav; 96 | } 97 | 98 | @PostMapping("/set-profile") 99 | public void setProfileImage(@RequestParam("file") MultipartFile file, 100 | HttpServletRequest request, 101 | HttpServletResponse response) throws IOException { 102 | // log.info("setProfileImage entered.. "); 103 | // log.info(file.getOriginalFilename()); 104 | // log.info(file.getName()); 105 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 106 | JSONObject res = new JSONObject(); 107 | if (isNull(loginMember) || file.isEmpty()) { 108 | // exception 109 | res.put("result", INVALID_APPROACH); 110 | } 111 | else { 112 | String folder = loginMember.getMemberId() + ""; 113 | String filename = Conversion.convertImageName(file.getOriginalFilename()); 114 | if (FileIO.saveImage(folder, filename, file.getBytes())) { 115 | if (memberService.setProfilePhoto(loginMember.getMemberId(), filename)) { 116 | res.put("result", SUCCESS); 117 | } else { 118 | res.put("result", FAIL); 119 | } 120 | } else { 121 | res.put("result", FAIL); 122 | } 123 | } 124 | 125 | response.setContentType("application/json; charset=utf-8"); 126 | response.getWriter().print(res); 127 | } 128 | 129 | @GetMapping("/set-default-profile") 130 | public void setDefaultProfileImage(@RequestParam int id, 131 | HttpServletRequest request, 132 | HttpServletResponse response) throws IOException { 133 | Member loginMember = (Member) request.getSession().getAttribute("loginMember"); 134 | JSONObject res = new JSONObject(); 135 | if (isNull(loginMember) || loginMember.getMemberId() != id) { 136 | res.put("result", INVALID_APPROACH); 137 | } 138 | else { 139 | if (memberService.setProfilePhoto(loginMember.getMemberId(), null)) { 140 | res.put("result", SUCCESS); 141 | } else { 142 | res.put("result", FAIL); 143 | } 144 | } 145 | response.setContentType("application/json; charset=utf-8"); 146 | response.getWriter().print(res); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/BoardRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | 4 | import com.board.demo.vo.Board; 5 | import com.board.demo.vo.Boardlist; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | 10 | import java.util.List; 11 | 12 | public interface BoardRepository extends JpaRepository { 13 | @Query(value = "SELECT * FROM (SELECT * FROM board WHERE board_id < :boardId ORDER BY board_id desc LIMIT 1) A UNION SELECT * FROM (SELECT * FROM board WHERE board_id > :boardId ORDER BY board_id asc LIMIT 1) B", nativeQuery = true) 14 | List findPrevAndNextBoardIdByBoardId(@Param("boardId") long boardId); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/BoardlistRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Boardlist; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.PageRequest; 6 | import org.springframework.data.domain.Pageable; 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | import org.springframework.data.jpa.repository.Query; 9 | 10 | import java.util.List; 11 | 12 | public interface BoardlistRepository extends JpaRepository{ 13 | Page findAllByCategory(String category, Pageable pageRequest); 14 | Page findAllByWriterId(long writerId, Pageable pageRequest); 15 | List findAllByCategory(String category); 16 | List findTop5ByOrderByLikesDesc(); 17 | 18 | @Query(value = "SELECT * FROM boardlist b WHERE b.category != '공지' ORDER BY b.likes DESC LIMIT 5", nativeQuery = true) 19 | List findTopLikes(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/CategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Category; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface CategoryRepository extends JpaRepository{ 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/MemberLikeBoardRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.MemberLikeBoard; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.Optional; 7 | 8 | public interface MemberLikeBoardRepository extends JpaRepository { 9 | Optional findByBoardIdAndMemberId(long boardId, long memberId); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Member; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.Optional; 7 | 8 | public interface MemberRepository extends JpaRepository{ 9 | Optional findByIdAndPwd(String id, String pwd); 10 | Optional findById(String id); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/MypageRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Mypage; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface MypageRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/ReplyRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Reply; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | import java.util.Optional; 8 | 9 | public interface ReplyRepository extends JpaRepository{ 10 | List findAllByBoard(long board_id); 11 | 12 | void deleteByReplyIdAndParentAndWriter(long replyId, long parent, long memberId); 13 | 14 | Optional findByReplyIdAndParentAndWriter(long replyId, long parent, long memberId); 15 | 16 | List findAllByParent(long parent); 17 | 18 | Optional findByReplyIdAndParent(long replyId, long parent); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/repository/ReplylistRepository.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Replylist; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.PageRequest; 6 | import org.springframework.data.domain.Pageable; 7 | import org.springframework.data.jpa.repository.JpaRepository; 8 | 9 | import java.util.List; 10 | 11 | public interface ReplylistRepository extends JpaRepository { 12 | List findAllByBoardId(long board_id); 13 | 14 | Page findAllByMemberId(long memberId, Pageable pageRequest); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/BoardService.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.util.CurrentArticle; 4 | import com.board.demo.vo.Board; 5 | import com.board.demo.vo.Boardlist; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.web.servlet.ModelAndView; 8 | 9 | import java.util.List; 10 | 11 | public interface BoardService { 12 | Page getList(String category, int page, int size); 13 | 14 | boolean write(Long memberId, String title, String content, long category); 15 | 16 | Boardlist getPostByIdForViewArticle(long boardId); 17 | 18 | Boardlist getPostById(long boardId); 19 | 20 | boolean addViews(long boardId); 21 | 22 | CurrentArticle getPrevAndNextArticle(long boardId); 23 | 24 | Board getBoardById(long boardId); 25 | 26 | boolean modify(Board article, String title, String content, long category); 27 | 28 | void deleteArticle(long boardId); 29 | 30 | int getListByMemberId(long memberId, int page, int size, ModelAndView mav); 31 | 32 | List getNotices(); 33 | 34 | List getTopLikes(); 35 | 36 | public void convertArticleFormat(List articles); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/BoardServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.repository.BoardRepository; 4 | import com.board.demo.repository.BoardlistRepository; 5 | import com.board.demo.util.Conversion; 6 | import com.board.demo.util.CurrentArticle; 7 | import com.board.demo.vo.Board; 8 | import com.board.demo.vo.Boardlist; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.data.domain.Page; 12 | import org.springframework.data.domain.PageRequest; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.web.servlet.ModelAndView; 15 | 16 | import java.util.List; 17 | import java.util.Objects; 18 | import java.util.Optional; 19 | 20 | @Service 21 | @Slf4j 22 | public class BoardServiceImpl implements BoardService { 23 | private final String ALL_POSTS = "전체보기"; 24 | private final String NOTICE = "공지"; 25 | private final int PREV_OR_NEXT = 0; 26 | private final int PREV_ARTICLE = 0; 27 | private final int NEXT_ARTICLE = 1; 28 | 29 | @Autowired 30 | private BoardRepository boardRepository; 31 | @Autowired 32 | private BoardlistRepository boardlistRepository; 33 | 34 | 35 | @Override 36 | public Page getList(String category, int page, int size) { 37 | Page boardlistPage; 38 | PageRequest pageRequest = PageRequest.of(page, size); 39 | if (ALL_POSTS.equals(category)) { 40 | boardlistPage = boardlistRepository.findAll(pageRequest); 41 | } else { 42 | boardlistPage = boardlistRepository.findAllByCategory(category, pageRequest); 43 | } 44 | 45 | return boardlistPage; 46 | } 47 | 48 | @Override 49 | public boolean write(Long memberId, String title, String content, long category) { 50 | Board board = Board.builder() 51 | .writer(memberId) 52 | .title(title) 53 | .content(content) 54 | .category(category) 55 | .build(); 56 | return !Objects.isNull(boardRepository.save(board)); 57 | } 58 | 59 | @Override 60 | public boolean modify(Board article, String title, String content, long category) { 61 | article.setTitle(title); 62 | article.setContent(content); 63 | article.setCategory(category); 64 | return !Objects.isNull(boardRepository.save(article)); 65 | } 66 | 67 | @Override 68 | public void deleteArticle(long boardId) { 69 | try { 70 | boardRepository.deleteById(boardId); 71 | } catch (Exception e) { 72 | log.error("\n >> " + e.toString() + "\n >> There isn't a board no." + boardId); 73 | } 74 | } 75 | 76 | @Override 77 | public int getListByMemberId(long memberId, int page, int size, ModelAndView mav) { 78 | PageRequest pageRequest = PageRequest.of(page, size); 79 | Page boardlistPage = boardlistRepository.findAllByWriterId(memberId, pageRequest); 80 | List boards = boardlistPage.getContent(); 81 | boards.forEach(Conversion::convertDateFormatForArticleList); 82 | Conversion.convertTitleLength(boards); 83 | int totalPages = boardlistPage.getTotalPages(); 84 | mav.addObject("boards", boards); 85 | mav.addObject("totalPages", totalPages); 86 | return boards.size(); 87 | } 88 | 89 | @Override 90 | public List getNotices() { 91 | return boardlistRepository.findAllByCategory(NOTICE); 92 | } 93 | 94 | @Override 95 | public List getTopLikes() { 96 | return boardlistRepository.findTopLikes(); 97 | } 98 | 99 | @Override 100 | public void convertArticleFormat(List articles) { 101 | articles.forEach(Conversion::convertDateFormatForArticleList); 102 | Conversion.convertTitleLength(articles); 103 | } 104 | 105 | @Override 106 | public Boardlist getPostByIdForViewArticle(long boardId) { 107 | Boardlist board = getPostById(boardId); 108 | Conversion.convertContent(board); 109 | Conversion.convertDateFormatForArticle(board); 110 | return board; 111 | } 112 | 113 | @Override 114 | public Boardlist getPostById(long boardId) { 115 | return boardlistRepository.findById(boardId).orElse(null); 116 | } 117 | 118 | @Override 119 | public Board getBoardById(long boardId) { 120 | return boardRepository.findById(boardId).orElse(null); 121 | } 122 | 123 | @Override 124 | public boolean addViews(long boardId) { 125 | Optional opBoard = boardRepository.findById(boardId); 126 | if (!opBoard.isPresent()) { 127 | return false; 128 | } 129 | Board board = opBoard.get(); 130 | long views = board.getViews() + 1; 131 | board.setViews(views); 132 | board = boardRepository.save(board); 133 | 134 | return board.getViews() == views; 135 | } 136 | 137 | @Override 138 | public CurrentArticle getPrevAndNextArticle(long boardId) { 139 | CurrentArticle currentArticle; 140 | List boards = boardRepository.findPrevAndNextBoardIdByBoardId(boardId); 141 | switch (boards.size()) { 142 | case 0: 143 | currentArticle = new CurrentArticle(); 144 | break; 145 | case 1: 146 | long prevOrNext = boards.get(PREV_OR_NEXT).getBoardId(); 147 | if (prevOrNext > boardId) { 148 | currentArticle = CurrentArticle.builder() 149 | .next(prevOrNext) 150 | .build(); 151 | break; 152 | } 153 | currentArticle = CurrentArticle.builder() 154 | .prev(prevOrNext) 155 | .build(); 156 | break; 157 | case 2: 158 | currentArticle = CurrentArticle.builder() 159 | .prev(boards.get(PREV_ARTICLE).getBoardId()) 160 | .next(boards.get(NEXT_ARTICLE).getBoardId()) 161 | .build(); 162 | break; 163 | default: 164 | currentArticle = null; 165 | break; 166 | } 167 | return currentArticle; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.vo.Category; 4 | 5 | import java.util.List; 6 | 7 | public interface CategoryService { 8 | List getList(); 9 | 10 | boolean addCategory(String category); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.repository.CategoryRepository; 4 | import com.board.demo.vo.Category; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Slf4j 12 | @Service 13 | public class CategoryServiceImpl implements CategoryService { 14 | @Autowired 15 | private CategoryRepository categoryRepository; 16 | 17 | @Override 18 | public List getList() { 19 | return categoryRepository.findAll(); 20 | } 21 | 22 | @Override 23 | public boolean addCategory(String categoryName) { 24 | Category category = Category.builder() 25 | .categoryName(categoryName) 26 | .build(); 27 | log.info(category.getCategoryId()+""); 28 | category = categoryRepository.save(category); 29 | log.info(category.getCategoryId()+""); 30 | return true; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/MemberLikeBoardService.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | public interface MemberLikeBoardService { 4 | boolean isLike(long boardId, long memberId); 5 | 6 | boolean like(long memberId, long boardId); 7 | 8 | void dislike(long memberId, long boardId); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/MemberLikeBoardServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.repository.MemberLikeBoardRepository; 4 | import com.board.demo.vo.MemberLikeBoard; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.swing.text.html.Option; 10 | import java.util.Optional; 11 | 12 | @Slf4j 13 | @Service 14 | public class MemberLikeBoardServiceImpl implements MemberLikeBoardService { 15 | @Autowired 16 | private MemberLikeBoardRepository memberLikeBoardRepository; 17 | 18 | 19 | @Override 20 | public boolean isLike(long boardId, long memberId) { 21 | return memberLikeBoardRepository.findByBoardIdAndMemberId(boardId, memberId) 22 | .isPresent(); 23 | } 24 | 25 | @Override 26 | public boolean like(long memberId, long boardId) { 27 | MemberLikeBoard mlb = MemberLikeBoard.builder() 28 | .memberId(memberId) 29 | .boardId(boardId) 30 | .build(); 31 | try { 32 | memberLikeBoardRepository.save(mlb); 33 | } catch (Exception e) { 34 | log.error(e.toString()); 35 | return false; 36 | } 37 | return true; 38 | } 39 | 40 | @Override 41 | public void dislike(long memberId, long boardId) { 42 | Optional mlb = memberLikeBoardRepository.findByBoardIdAndMemberId(boardId, memberId); 43 | mlb.ifPresent(memberLikeBoardRepository::delete); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/MemberService.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.vo.Member; 4 | 5 | import java.security.NoSuchAlgorithmException; 6 | import java.util.List; 7 | 8 | public interface MemberService { 9 | List getList(); 10 | Member login(String id, String pwd) throws NoSuchAlgorithmException; 11 | boolean isDuplicate(String id); 12 | Member join(String id, String pwd, String email, String nick) throws NoSuchAlgorithmException; 13 | boolean setProfilePhoto(long memberId, String profilePath); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/MemberServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.repository.MemberRepository; 4 | import com.board.demo.util.HashFunction; 5 | import com.board.demo.vo.Member; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.security.NoSuchAlgorithmException; 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | @Service 14 | public class MemberServiceImpl implements MemberService { 15 | @Autowired 16 | private MemberRepository memberRepository; 17 | 18 | @Override 19 | public List getList() { 20 | return memberRepository.findAll(); 21 | } 22 | 23 | @Override 24 | public Member login(String id, String pwd) throws NoSuchAlgorithmException { 25 | Optional loginMember = memberRepository.findByIdAndPwd(id, HashFunction.sha256(pwd)); 26 | 27 | if (!loginMember.isPresent()) { 28 | return null; 29 | } 30 | 31 | Member member = loginMember.get(); 32 | member.setAttendance(member.getAttendance() + 1); 33 | memberRepository.save(member); 34 | 35 | return member; 36 | } 37 | 38 | @Override 39 | public boolean isDuplicate(String id) { 40 | Optional member = memberRepository.findById(id); 41 | return member.isPresent(); 42 | } 43 | 44 | @Override 45 | public Member join(String id, String pwd, String email, String nick) throws NoSuchAlgorithmException { 46 | return memberRepository.save( 47 | Member.builder() 48 | .id(id) 49 | .pwd(HashFunction.sha256(pwd)) 50 | .email(email) 51 | .nickname(nick) 52 | .build() 53 | ); 54 | } 55 | 56 | @Override 57 | public boolean setProfilePhoto(long memberId, String profilePath) { 58 | Optional memberOptional = memberRepository.findById(memberId); 59 | if (!memberOptional.isPresent()) { 60 | return false; 61 | } 62 | Member member = memberOptional.get(); 63 | member.setProfilePhoto(profilePath); 64 | memberRepository.save(member); 65 | return true; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/MypageService.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.vo.Mypage; 4 | 5 | public interface MypageService { 6 | Mypage getMypageInfo(long memberId); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/MypageServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.repository.MypageRepository; 4 | import com.board.demo.vo.Mypage; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class MypageServiceImpl implements MypageService { 10 | @Autowired 11 | private MypageRepository mypageRepository; 12 | 13 | @Override 14 | public Mypage getMypageInfo(long memberId) { 15 | return mypageRepository.findById(memberId).orElse(null); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/ReplyService.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.vo.Member; 4 | import com.board.demo.vo.Replylist; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | import java.util.List; 9 | 10 | public interface ReplyService { 11 | List getRepliesByBoardId(long boardId); 12 | 13 | boolean writeReply(long boardId, long parent, String content, Member member); 14 | 15 | boolean deleteReply(long replyId, long parent, Member member); 16 | 17 | int getListByMemberId(long memberId, int page, int size, ModelAndView mav); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/service/ReplyServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.service; 2 | 3 | import com.board.demo.repository.ReplyRepository; 4 | import com.board.demo.repository.ReplylistRepository; 5 | import com.board.demo.util.Conversion; 6 | import com.board.demo.vo.Member; 7 | import com.board.demo.vo.Reply; 8 | import com.board.demo.vo.Replylist; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.data.domain.Page; 11 | import org.springframework.data.domain.PageRequest; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.web.servlet.ModelAndView; 14 | 15 | import java.text.SimpleDateFormat; 16 | import java.util.Date; 17 | import java.util.List; 18 | import java.util.Objects; 19 | import java.util.Optional; 20 | 21 | import static com.board.demo.util.Constants.ADMIN_ID; 22 | 23 | @Service 24 | public class ReplyServiceImpl implements ReplyService { 25 | private final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; 26 | private final int JUST_ONE_REPLY = 1; 27 | @Autowired 28 | private ReplylistRepository replylistRepository; 29 | 30 | @Autowired 31 | private ReplyRepository replyRepository; 32 | 33 | 34 | @Override 35 | public List getRepliesByBoardId(long boardId) { 36 | List replies = replylistRepository.findAllByBoardId(boardId); 37 | replies.stream() 38 | .peek(Conversion::convertContent) 39 | .forEach(Conversion::convertDateFormatForArticle); 40 | return replies; 41 | } 42 | 43 | @Override 44 | public boolean writeReply(long boardId, long parent, String content, Member member) { 45 | if (Objects.isNull(member)) { 46 | return false; 47 | } 48 | SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); 49 | String date = sdf.format(new Date()); 50 | 51 | Reply reply = Reply.builder() 52 | .parent(parent) 53 | .board(boardId) 54 | .writer(member.getMemberId()) 55 | .content(content) 56 | .date(date) 57 | .build(); 58 | 59 | reply = replyRepository.save(reply); 60 | if (parent == 0) { 61 | reply.setParent(reply.getReplyId()); 62 | reply = replyRepository.save(reply); 63 | } 64 | return true; 65 | } 66 | 67 | @Override 68 | public boolean deleteReply(long replyId, long parent, Member member) { 69 | if (Objects.isNull(member)) { 70 | return false; 71 | } 72 | Optional resReply = replyRepository.findByReplyIdAndParent(replyId, parent); 73 | 74 | if (!resReply.isPresent()) { 75 | return false; 76 | } 77 | if (resReply.get().getWriter() != member.getMemberId() && 78 | member.getMemberId() != ADMIN_ID ) { 79 | return false; 80 | } 81 | List replies = replyRepository.findAllByParent(parent); 82 | if ( (replies.size() > JUST_ONE_REPLY) && 83 | (parent == replyId) ) { 84 | Reply reply = resReply.get(); 85 | reply.setContent("NULL"); 86 | replyRepository.save(reply); 87 | return true; 88 | } 89 | replyRepository.deleteById(replyId); 90 | 91 | return !replyRepository.findById(replyId).isPresent(); 92 | } 93 | 94 | @Override 95 | public int getListByMemberId(long memberId, int page, int size, ModelAndView mav) { 96 | PageRequest pageRequest = PageRequest.of(page, size); 97 | Page replylistPage = replylistRepository.findAllByMemberId(memberId, pageRequest); 98 | List replies = replylistPage.getContent(); 99 | replies.forEach(Conversion::convertDateFormatForArticleList); 100 | Conversion.convertContentLength(replies); 101 | int totalPages = replylistPage.getTotalPages(); 102 | mav.addObject("replies", replies); 103 | mav.addObject("totalPages", totalPages); 104 | return replies.size(); 105 | } 106 | 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/util/Constants.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.util; 2 | 3 | public class Constants 4 | { 5 | public static final int ADMIN_ID = 0; 6 | public static final int SUCCESS = 1; 7 | 8 | 9 | public static final int FAIL = -1; 10 | public static final int INVALID_APPROACH = -2; 11 | public static final int DUPLICATE_ID = -3; 12 | 13 | public static final String RESULT = "result"; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/util/Conversion.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.util; 2 | 3 | import com.board.demo.vo.Boardlist; 4 | import com.board.demo.vo.Article; 5 | import com.board.demo.vo.Replylist; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | import java.util.List; 10 | import java.util.StringTokenizer; 11 | 12 | public class Conversion { 13 | private static final int DATE_START = 0; 14 | private static final int DATE_END = 10; 15 | private static final int TIME_START = 11; 16 | private static final int TIME_END = 16; 17 | private static final int BEGIN = 0; 18 | private static final int MAX_TITLE_LENGTH = 30; 19 | private static final int MAX_CONTENT_LENGTH = 45; 20 | private static final int MAX_IMAGE_LENGHT = 25; 21 | 22 | public static void convertDateFormatForArticleList(Article article) { 23 | if (article.getDate().length() != 21) 24 | return; 25 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 26 | String today = sdf.format(new Date()); 27 | if (article.getDate().substring(DATE_START, DATE_END).equals(today)) { 28 | article.setDate(article.getDate().substring(TIME_START, TIME_END)); 29 | } else { 30 | article.setDate(article.getDate().substring(DATE_START, DATE_END)); 31 | } 32 | } 33 | 34 | public static void convertTitleLength(List boards) { 35 | boards.forEach(board -> { 36 | if (board.getTitle().length() > MAX_TITLE_LENGTH) { 37 | StringBuilder title = new StringBuilder(board.getTitle().substring(BEGIN, MAX_TITLE_LENGTH)); 38 | title.append( "..."); 39 | board.setTitle(title.toString()); 40 | } 41 | }); 42 | } 43 | 44 | public static void convertContentLength(List replies) { 45 | replies.forEach(reply -> { 46 | if (reply.getContent().length() > MAX_CONTENT_LENGTH) { 47 | StringBuilder content = new StringBuilder(reply.getContent().substring(BEGIN, MAX_CONTENT_LENGTH)); 48 | content.append( "..."); 49 | reply.setContent(content.toString()); 50 | } 51 | }); 52 | } 53 | 54 | public static int calcStartPage(int page) { 55 | return ((page - 1) / 10) * 10 + 1; 56 | } 57 | 58 | public static void convertContent(Article article) { 59 | String oldContent = article.getContent(); 60 | article.setContent(oldContent.replace("\n", "
")); 61 | } 62 | 63 | public static void convertDateFormatForArticle(Article article) { 64 | article.setDate(article.getDate().substring(DATE_START, TIME_END)); 65 | } 66 | 67 | public static String convertImageName(String originalFilename) { 68 | if (originalFilename.length() > MAX_TITLE_LENGTH) { 69 | StringBuilder sb = new StringBuilder(); 70 | sb.append(originalFilename.substring(BEGIN, MAX_IMAGE_LENGHT)); 71 | sb.append(".png"); 72 | return sb.toString(); 73 | } 74 | return originalFilename; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/util/CurrentArticle.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.util; 2 | 3 | import lombok.*; 4 | 5 | @Setter 6 | @Getter 7 | @Builder 8 | @ToString 9 | @NoArgsConstructor 10 | @AllArgsConstructor 11 | public class CurrentArticle { 12 | private long prev; 13 | private long next; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/util/ErrorPage.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.util; 2 | 3 | import org.springframework.web.servlet.ModelAndView; 4 | 5 | public class ErrorPage { 6 | public static ModelAndView show() { 7 | ModelAndView mav = new ModelAndView(); 8 | mav.setViewName("err_404"); 9 | mav.addObject("err_msg", "요청하신 페이지를 찾을 수 없습니다."); 10 | return mav; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/util/FileIO.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import javax.servlet.http.HttpServletResponse; 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.io.IOException; 9 | import java.io.OutputStream; 10 | import java.nio.file.Files; 11 | import java.nio.file.Path; 12 | import java.nio.file.Paths; 13 | 14 | @Slf4j 15 | public class FileIO { 16 | private static final String REPOSITORY_PATH = "/Users/seokjung/Desktop/spring_board/src/main/resources/static/img/profile/"; 17 | 18 | public static boolean saveImage(String folder, String filename, byte[] imgBytes) { 19 | File uploadPath = new File(REPOSITORY_PATH, folder); 20 | if (!uploadPath.exists()) { 21 | uploadPath.mkdirs(); 22 | } 23 | try { 24 | // Get the file and save it somewhere 25 | Path path = Paths.get(uploadPath + "/" + filename); 26 | Files.write(path, imgBytes); 27 | } catch (IOException e) { 28 | log.error("upload image fail: " + e.toString()); 29 | return false; 30 | } 31 | return true; 32 | } 33 | 34 | public static void loadImage(String middlePath, String imageFileName, HttpServletResponse response) throws IOException { 35 | OutputStream out = response.getOutputStream(); 36 | String path = REPOSITORY_PATH + middlePath + "/" + imageFileName; 37 | File imageFile = new File(path); 38 | FileInputStream in = new FileInputStream(imageFile); 39 | 40 | response.setHeader("Cache-Control", "no-cache"); 41 | response.addHeader("Content-disposition", "attachment;fileName="+imageFileName); 42 | 43 | byte[] buffer = new byte[1024 * 8]; 44 | while(true) { 45 | int count = in.read(buffer); 46 | if(count == -1) 47 | break; 48 | out.write(buffer, 0, count); 49 | } 50 | in.close(); 51 | out.close(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/util/HashFunction.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.util; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | public class HashFunction { 7 | public static String sha256(String msg) throws NoSuchAlgorithmException { 8 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 9 | md.update(msg.getBytes()); 10 | return bytesToHex(md.digest()); 11 | } 12 | 13 | private static String bytesToHex(byte[] bytes) { 14 | StringBuilder builder = new StringBuilder(); 15 | for (byte b : bytes) { 16 | builder.append(String.format("%02x", b)); 17 | } 18 | return builder.toString(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Article.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | public interface Article { 4 | String getContent(); 5 | void setContent(String content); 6 | String getDate(); 7 | void setDate(String date); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Board.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.hibernate.annotations.DynamicInsert; 8 | import org.hibernate.annotations.DynamicUpdate; 9 | 10 | import javax.persistence.*; 11 | import java.io.Serializable; 12 | 13 | @Entity 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Data 17 | @DynamicInsert 18 | @DynamicUpdate 19 | @Builder 20 | public class Board implements Serializable { 21 | 22 | @Id 23 | @GeneratedValue(strategy = GenerationType.IDENTITY) 24 | @Column(name = "board_id", nullable = false) 25 | private long boardId; 26 | 27 | @Column(name = "title", nullable = false) 28 | private String title; 29 | 30 | @Column(name = "content", nullable = false) 31 | private String content; 32 | 33 | @Column(name = "date") 34 | private String date; 35 | 36 | @Column(name = "views", nullable = false) 37 | private long views; 38 | 39 | @Column(name = "writer", nullable = false) 40 | private long writer; 41 | 42 | @Column(name = "category", nullable = false) 43 | private long category; 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Boardlist.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import javax.persistence.*; 8 | import java.io.Serializable; 9 | 10 | @Entity 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | @Data 14 | public class Boardlist implements Serializable, Article { 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | @Column(name = "board_id") 19 | private long boardId; 20 | 21 | @Column(name = "category") 22 | private String category; 23 | 24 | @Column(name = "title") 25 | private String title; 26 | 27 | @Column(name = "content") 28 | private String content; 29 | 30 | @Column(name = "profile_photo") 31 | private String profile; 32 | 33 | @Column(name = "writer_id") 34 | private long writerId; 35 | 36 | @Column(name = "writer_nick") 37 | private String writerNickname; 38 | 39 | @Column(name = "date") 40 | private String date; 41 | 42 | @Column(name = "likes") 43 | private long likes; 44 | 45 | @Column(name = "views") 46 | private long views; 47 | 48 | @Column(name = "replies") 49 | private long replies; 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Category.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | 11 | @Entity 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Data 15 | @Builder 16 | public class Category implements Serializable { 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | @Column(name = "category_id", nullable = false) 21 | private Long categoryId; 22 | 23 | @Column(name = "category_name", nullable = false) 24 | private String categoryName; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Member.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.hibernate.annotations.DynamicUpdate; 8 | 9 | import javax.persistence.*; 10 | import java.io.Serializable; 11 | 12 | @Entity 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Data 16 | @DynamicUpdate 17 | @Builder 18 | public class Member implements Serializable { 19 | 20 | @Id 21 | @GeneratedValue(strategy = GenerationType.IDENTITY) 22 | @Column(name = "member_id", nullable = false) 23 | private long memberId; 24 | 25 | @Column(name = "id", nullable = false) 26 | private String id; 27 | 28 | @Column(name = "nickname", nullable = false) 29 | private String nickname; 30 | 31 | @Column(name = "pwd", nullable = false) 32 | private String pwd; 33 | 34 | @Column(name = "email", nullable = false) 35 | private String email; 36 | 37 | @Column(name = "attendance", nullable = false) 38 | private int attendance; 39 | 40 | @Column(name = "profile_photo") 41 | private String profilePhoto; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/MemberLikeBoard.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | 11 | @Table(name = "member_like_board") 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Data 15 | @Builder 16 | @Entity 17 | public class MemberLikeBoard implements Serializable { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | @Column(name = "mlb_id", nullable = false) 22 | private long id; 23 | 24 | @Column(name = "member_id", nullable = false) 25 | private long memberId; 26 | 27 | @Column(name = "board_id", nullable = false) 28 | private long boardId; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Mypage.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.io.Serializable; 10 | 11 | @Entity 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Data 15 | @Builder 16 | public class Mypage implements Serializable { 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | @Column(name = "member_id", nullable = false) 21 | private long memberId; 22 | 23 | @Column(nullable = false) 24 | private String id; 25 | 26 | @Column(nullable = false) 27 | private String nickname; 28 | 29 | @Column(nullable = false) 30 | private int attendance; 31 | 32 | @Column(name = "profile_photo") 33 | private String profilePhoto; 34 | 35 | @Column(name = "board_num", nullable = false) 36 | private int boardNum; 37 | 38 | @Column(name = "reply_num", nullable = false) 39 | private int replyNum; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Reply.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.hibernate.annotations.DynamicInsert; 8 | import org.hibernate.annotations.DynamicUpdate; 9 | 10 | import javax.persistence.*; 11 | import java.io.Serializable; 12 | 13 | @Entity 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Data 17 | @Builder 18 | @DynamicInsert 19 | @DynamicUpdate 20 | public class Reply implements Serializable { 21 | 22 | @Id 23 | @GeneratedValue(strategy = GenerationType.IDENTITY) 24 | @Column(name = "reply_id", nullable = false) 25 | private Long replyId; 26 | 27 | @Column(name = "parent", nullable = false) 28 | private Long parent; 29 | 30 | // @Column(name = "sorts", nullable = false) 31 | // private Long sorts; 32 | 33 | @Column(name = "content", nullable = false) 34 | private String content; 35 | 36 | @Column(name = "date") 37 | private String date; 38 | 39 | @Column(name = "board", nullable = false) 40 | private Long board; 41 | 42 | @Column(name = "writer", nullable = false) 43 | private Long writer; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/board/demo/vo/Replylist.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.hibernate.annotations.DynamicUpdate; 8 | 9 | import javax.persistence.*; 10 | import java.io.Serializable; 11 | 12 | @Entity 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Data 16 | @DynamicUpdate 17 | @Builder 18 | public class Replylist implements Serializable, Article { 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | @Column(name = "reply_id", nullable = false) 22 | private long replyId; 23 | 24 | @Column(nullable = false) 25 | private long parent; 26 | 27 | @Column(nullable = false) 28 | private String content; 29 | 30 | @Column 31 | private String date; 32 | 33 | @Column(name = "member_id", nullable = false) 34 | private long memberId; 35 | 36 | @Column(nullable = false) 37 | private String nickname; 38 | 39 | @Column(name = "profile_photo") 40 | private String profilePhoto; 41 | 42 | @Column(name = "board", nullable = false) 43 | private long boardId; 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/.DS_Store -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8080 2 | spring.mvc.view.prefix=/WEB-INF/jsp/ 3 | spring.mvc.view.suffix=.jsp 4 | spring.mvc.static-path-pattern=/static/** 5 | 6 | spring.servlet.multipart.max-file-size=10MB 7 | spring.servlet.multipart.max-request-size=10MB 8 | 9 | spring.profiles.include=db 10 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect -------------------------------------------------------------------------------- /src/main/resources/static/css/board.css: -------------------------------------------------------------------------------- 1 | /*div.wrap { height: 700px; }*/ 2 | /*div.board { height: 90%; }*/ 3 | 4 | div.title { 5 | height: 10%; 6 | text-align: center; 7 | font-size: 30px; 8 | vertical-align: bottom; 9 | margin: 80px auto; 10 | margin-bottom: 30px; 11 | } 12 | 13 | div.top-bar { 14 | width: 900px; 15 | margin: 0 auto; 16 | display: grid; 17 | grid-template-columns: 1fr 1fr; 18 | } 19 | 20 | div.bottom-bar { 21 | width: 900px; 22 | margin: 0 auto; 23 | margin-top: 30px; 24 | display: grid; 25 | grid-template-columns: 1fr 1fr; 26 | } 27 | 28 | div.top-bar > div { 29 | width: 100%; 30 | height: 100%; 31 | } 32 | div.top-bar > div:first-child { 33 | text-align: left; 34 | } 35 | div.top-bar > div:last-child, div.bottom-bar > div:last-child { 36 | text-align: right; 37 | } 38 | div.top-bar > div > select.swal2-select { 39 | min-width: 150px; 40 | } 41 | 42 | /*div.top-bar > div > select.swal2-select:first-child {*/ 43 | /*left: 0;*/ 44 | /*}*/ 45 | /*div.top-bar > div > select.swal2-select:last-child {*/ 46 | /*right: 0;*/ 47 | /*}*/ 48 | 49 | .swal2-input { 50 | text-align: center; 51 | } 52 | 53 | .popup_footer { 54 | color: #ff7799; 55 | font-weight: bold; 56 | } 57 | 58 | .popup_footer:hover { 59 | color: #ff6688; 60 | cursor: pointer; 61 | text-decoration: underline; 62 | } 63 | 64 | table.board { 65 | width : 900px; 66 | border-spacing: 0; 67 | margin: 0 auto; 68 | color: #333; 69 | font-size: 11pt; 70 | } 71 | 72 | /*@media (max-width: 740px) {*/ 73 | /*table.board {*/ 74 | /*width: 740px;*/ 75 | /*}*/ 76 | /*}*/ 77 | 78 | /*@media (min-width: 1000px) {*/ 79 | /*table.board {*/ 80 | /*width: 1000px;*/ 81 | /*}*/ 82 | /*}*/ 83 | 84 | table.board th { 85 | border-top: 1px solid #ff7799; 86 | border-bottom: 1px solid #ff7799; 87 | background-color: #fffafa; 88 | height: 35px; 89 | } 90 | 91 | table.board td { 92 | border-bottom: 1px solid #ffdcdc; 93 | height: 35px; 94 | } 95 | 96 | table.board tr:last-child td{ 97 | border-bottom: 1px solid #ff7799; 98 | } 99 | 100 | table.board tr th > img { width: 25px; height: 20px; } 101 | table.board tr td:first-child{ width: 9%; text-align: center;} 102 | table.board tr td:nth-child(2){ width: 50%; } 103 | table.board tr td:nth-child(3){ width: 13%; } 104 | table.board tr td:nth-child(4){ width: 12%; text-align: center;} 105 | table.board tr td:nth-child(5){ width: 8%; text-align: center;} 106 | table.board tr td:last-child{ width: 8%; text-align: center;} 107 | 108 | table.board tr td:nth-child(2):hover, 109 | .member:hover { 110 | text-decoration: underline; 111 | cursor: pointer; 112 | } 113 | 114 | span.category { color: #888888; } 115 | span.replies { color: red; } 116 | 117 | span.page-num { margin: 5px; } 118 | span.page-num:hover{ cursor: pointer; } 119 | 120 | .cur-page { 121 | color: #ff0066; 122 | font-weight: bold; 123 | } 124 | 125 | .profile_photo { 126 | vertical-align: sub; 127 | width: 20px; 128 | height: 20px; 129 | } 130 | tr.notice { 131 | background-color: #f9f9f8; 132 | } 133 | tr.notice td:first-child, 134 | tr.notice td:nth-child(2) { 135 | color: red; 136 | font-weight: bold; 137 | } 138 | tr.notice td:nth-child(3) { 139 | text-align: center; 140 | } 141 | 142 | tr.top_like td:first-child, 143 | tr.top_like td:nth-child(2) { 144 | font-weight: bold; 145 | } -------------------------------------------------------------------------------- /src/main/resources/static/css/common.css: -------------------------------------------------------------------------------- 1 | div.login { 2 | position: absolute; 3 | right: 10px; 4 | top: 10px; 5 | } 6 | 7 | .button1 { 8 | background:#ff99aa; 9 | color:#fff; 10 | border:none; 11 | position:relative; 12 | height:35px; 13 | font-size:1em; 14 | padding:0 2em; 15 | cursor:pointer; 16 | transition:800ms ease all; 17 | outline:none; 18 | } 19 | .button1:hover{ 20 | background:#fff; 21 | color:#ff99aa; 22 | } 23 | .button1:before, 24 | .button1:after{ 25 | content:''; 26 | position:absolute; 27 | top:0; 28 | right:0; 29 | height:2px; 30 | width:0; 31 | background: #ff99aa; 32 | transition:400ms ease all; 33 | } 34 | .button1:after{ 35 | right:inherit; 36 | top:inherit; 37 | left:0; 38 | bottom:0; 39 | } 40 | .button1:hover:before, 41 | .button1:hover:after{ 42 | width:100%; 43 | transition:800ms ease all; 44 | } 45 | 46 | .button2 { 47 | background:#fff; 48 | color:#ff99aa; 49 | border:none; 50 | position:relative; 51 | height:35px; 52 | font-size:1em; 53 | padding:0 2em; 54 | cursor:pointer; 55 | transition:800ms ease all; 56 | outline:none; 57 | } 58 | .button2:hover{ 59 | background:#ff99aa; 60 | color:#fff; 61 | } 62 | .button2:before, 63 | .button2:after{ 64 | content:''; 65 | position:absolute; 66 | top:0; 67 | right:0; 68 | height:2px; 69 | width:0; 70 | background: #fff; 71 | transition:400ms ease all; 72 | } 73 | .button2:after{ 74 | right:inherit; 75 | top:inherit; 76 | left:0; 77 | bottom:0; 78 | } 79 | .button2:hover:before, 80 | .button2:hover:after{ 81 | width:100%; 82 | transition:800ms ease all; 83 | } 84 | -------------------------------------------------------------------------------- /src/main/resources/static/css/err_page.css: -------------------------------------------------------------------------------- 1 | * { 2 | -webkit-box-sizing: border-box; 3 | box-sizing: border-box; 4 | } 5 | 6 | body { 7 | padding: 0; 8 | margin: 0; 9 | } 10 | 11 | #notfound { 12 | position: relative; 13 | height: 100vh; 14 | } 15 | 16 | #notfound .notfound { 17 | position: absolute; 18 | left: 50%; 19 | top: 50%; 20 | -webkit-transform: translate(-50%, -50%); 21 | -ms-transform: translate(-50%, -50%); 22 | transform: translate(-50%, -50%); 23 | } 24 | 25 | .notfound { 26 | max-width: 710px; 27 | width: 100%; 28 | text-align: center; 29 | padding: 0px 15px; 30 | line-height: 1.4; 31 | } 32 | 33 | .notfound .notfound-404 { 34 | height: 200px; 35 | line-height: 200px; 36 | } 37 | 38 | .notfound .notfound-404 h1 { 39 | font-family: 'Fredoka One', cursive; 40 | font-size: 168px; 41 | margin: 0px; 42 | color: #ff508e; 43 | text-transform: uppercase; 44 | } 45 | 46 | .notfound h2 { 47 | font-family: 'Raleway', sans-serif; 48 | font-size: 22px; 49 | font-weight: 400; 50 | text-transform: uppercase; 51 | color: #222; 52 | margin: 0; 53 | } 54 | 55 | .notfound-search { 56 | position: relative; 57 | padding-right: 123px; 58 | max-width: 420px; 59 | width: 100%; 60 | margin: 30px auto 22px; 61 | } 62 | 63 | .notfound-search input { 64 | font-family: 'Raleway', sans-serif; 65 | width: 100%; 66 | height: 40px; 67 | padding: 3px 15px; 68 | color: #222; 69 | font-size: 18px; 70 | background: #f8fafb; 71 | border: 1px solid rgba(34, 34, 34, 0.2); 72 | border-radius: 3px; 73 | } 74 | 75 | .notfound-search button { 76 | font-family: 'Raleway', sans-serif; 77 | position: absolute; 78 | right: 0px; 79 | top: 0px; 80 | width: 120px; 81 | height: 40px; 82 | text-align: center; 83 | border: none; 84 | background: #ff508e; 85 | cursor: pointer; 86 | padding: 0; 87 | color: #fff; 88 | font-weight: 700; 89 | font-size: 18px; 90 | border-radius: 3px; 91 | } 92 | 93 | .notfound a { 94 | font-family: 'Raleway', sans-serif; 95 | display: inline-block; 96 | font-weight: 700; 97 | border-radius: 15px; 98 | text-decoration: none; 99 | color: #39b1cb; 100 | } 101 | 102 | .notfound a>.arrow { 103 | position: relative; 104 | top: -2px; 105 | border: solid #39b1cb; 106 | border-width: 0 3px 3px 0; 107 | display: inline-block; 108 | padding: 3px; 109 | -webkit-transform: rotate(135deg); 110 | -ms-transform: rotate(135deg); 111 | transform: rotate(135deg); 112 | } 113 | 114 | @media only screen and (max-width: 767px) { 115 | .notfound .notfound-404 { 116 | height: 122px; 117 | line-height: 122px; 118 | } 119 | .notfound .notfound-404 h1 { 120 | font-size: 122px; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/resources/static/css/my_page.css: -------------------------------------------------------------------------------- 1 | .wrap { 2 | margin-top: 50px; 3 | } 4 | .profile_info { 5 | margin: 15px auto; 6 | width: 800px; 7 | } 8 | .profile_box { 9 | position: absolute; 10 | } 11 | .profile_photo { 12 | width: 80px; 13 | height: 80px; 14 | border-radius: 50%; 15 | } 16 | .profile_photo.my_profile:hover { 17 | cursor: pointer; 18 | } 19 | .text { 20 | margin-left: 100px; 21 | } 22 | .nick_area { 23 | padding: 6px 0; 24 | font-size: 25pt; 25 | } 26 | .desc { 27 | padding-bottom: 10px; 28 | display: grid; 29 | grid-template-columns: 1fr 1fr; 30 | } 31 | .desc > div:last-child { 32 | text-align: right; 33 | } 34 | .btn_default_profile { 35 | color: #777; 36 | font-size: 10pt; 37 | } 38 | .count { 39 | color: #999999; 40 | } 41 | .count::before { 42 | content: " ▪︎ "; 43 | } 44 | .count:first-child::before { 45 | content: ""; 46 | } 47 | .num { 48 | color: red; 49 | } 50 | .content_area { 51 | margin-top: 50px; 52 | } 53 | .content_area > div { 54 | width : 800px; 55 | margin: 0 auto; 56 | margin-top: 30px; 57 | } 58 | .content_area > div:first-child { margin-top: 0; } 59 | .content_subtitle { 60 | padding: 0 15px; 61 | } 62 | .content_subtitle:last-child { 63 | border-left: 1px solid #cccccc; 64 | } 65 | .not_selected:hover, 66 | .btn_default_profile:hover { 67 | text-decoration: underline; 68 | cursor: pointer; 69 | } 70 | .selected { 71 | color: #ff0066; 72 | font-weight: bold; 73 | } 74 | table { 75 | border-spacing: 0px; 76 | width: 100%; 77 | } 78 | table tr th { 79 | border-top: 1px solid #ff7799; 80 | border-bottom: 1px solid #ff7799; 81 | background-color: #fffafa; 82 | height: 35px; 83 | } 84 | table tr td { 85 | border-bottom: 1px solid #ffdcdc; 86 | height: 35px; 87 | text-align: center; 88 | } 89 | table tr:last-child td { 90 | border-bottom: 1px solid #ff7799; 91 | } 92 | 93 | table.board tr th img { width: 23px; } 94 | table.board tr th:first-child { width: 10%; } 95 | table.board tr th:nth-child(2) { width: 55%; } 96 | table.board tr th:nth-child(3) { width: 15%; } 97 | table.board tr th:nth-child(4) { width: 10%; } 98 | table.board tr th:last-child { width: 10%; } 99 | 100 | table.board tr td:nth-child(2) { text-align: left; } 101 | table.board tr td:nth-child(2):hover { text-decoration: underline; cursor: pointer; } 102 | 103 | table.reply tr th:first-child { width: 80%; } 104 | table.reply tr th:last-child { width: 20%; } 105 | table.reply tr td:first-child { text-align: left; padding-left: 30px; } 106 | table.reply tr td:first-child:hover { text-decoration: underline; cursor: pointer; } 107 | 108 | div.bottom-bar { 109 | width: 800px; 110 | margin: 0 auto; 111 | margin-top: 30px; 112 | display: grid; 113 | grid-template-columns: 1fr 1fr; 114 | } 115 | div.bottom-bar > div:last-child { 116 | text-align: right; 117 | } 118 | 119 | span.category { color: #888888; } 120 | span.replies { color: red; } 121 | 122 | span.page-num { margin: 5px; } 123 | span.page-num:hover{ cursor: pointer; } 124 | 125 | .cur-page { 126 | color: #ff0066; 127 | font-weight: bold; 128 | } 129 | -------------------------------------------------------------------------------- /src/main/resources/static/css/view_article.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #ffdcdc; 3 | margin: 0; 4 | } 5 | .swal2-input { 6 | text-align: center; 7 | } 8 | .wrap { 9 | margin: 60px 30px; 10 | } 11 | .article_wrap { 12 | padding: 15px; 13 | margin: 0 auto; 14 | background: white; 15 | border-radius: 10px; 16 | margin-bottom: 50px; 17 | max-width: 900px; 18 | min-width: 600px; 19 | } 20 | .article_content_box { 21 | } 22 | .article_header { 23 | padding-bottom: 20px; 24 | margin-bottom: 20px; 25 | border-bottom: 1px solid #ffdcdc; 26 | } 27 | .article_title { 28 | font-size: 20pt; 29 | margin-bottom: 12px; 30 | } 31 | .writer_info { 32 | height: 40px; 33 | display: grid; 34 | grid-template-columns: 1fr 1fr; 35 | } 36 | .writer_info > div > div{ 37 | display: inline-block; 38 | } 39 | .writer_profile_box { 40 | margin-right: 10px; 41 | } 42 | .view_profile { 43 | width: 36px; 44 | height: 36px; 45 | border-radius: 50%; 46 | } 47 | .writer_nickname > span { 48 | font-size: 15pt; 49 | } 50 | .write_time > span { 51 | font-size: 10pt; 52 | } 53 | div.views { 54 | text-align: right; 55 | } 56 | .article_viewer { 57 | padding: 0 10px; 58 | margin-bottom: 100px; 59 | } 60 | .reply_box > div { 61 | display: inline-block; 62 | } 63 | .like_article { 64 | margin-right: 30px; 65 | } 66 | .like_article:hover { 67 | cursor: pointer; 68 | text-decoration: underline; 69 | } 70 | .heart { 71 | width: 25px; 72 | height: 20px; 73 | } 74 | .comment_box { 75 | font-size: 11pt; 76 | } 77 | .comment_list { 78 | list-style: none; 79 | padding-left: 0; 80 | } 81 | .comment_area { 82 | border-top: 1px solid #ffdcdc; 83 | } 84 | .comment_area > img { 85 | position: absolute; 86 | } 87 | .comment_content { 88 | padding-left: 50px; 89 | } 90 | .comment_item_reply { 91 | padding-left: 50px; 92 | } 93 | .comment_nickname { 94 | font-weight: bold; 95 | } 96 | .comment_text_box { 97 | margin-bottom: 5px; 98 | } 99 | .comment_info_box { 100 | font-size: 10pt; 101 | display: grid; 102 | grid-template-columns: 1fr 1fr; 103 | } 104 | .comment_info_delete { 105 | text-align: right; 106 | padding-right: 15px; 107 | } 108 | .comment_delete_button { 109 | color: #888888; 110 | } 111 | .comment_delete_button:hover, 112 | .comment_info_button:hover, 113 | .view_profile:hover { 114 | cursor: pointer; 115 | } 116 | .comment_info_date { 117 | margin-right: 10px; 118 | color: gray; 119 | } 120 | .comment_writer { 121 | padding: 15px; 122 | margin: 15px auto; 123 | border: 2px solid #ffdcdc; 124 | border-radius: 10px; 125 | background-color: white; 126 | } 127 | .comment_area { 128 | padding-top: 10px; 129 | padding-bottom: 10px; 130 | } 131 | .comment_writer_name, .recomment_writer_name { 132 | font-size: 10pt; 133 | font-weight: bold; 134 | margin-bottom: 10px; 135 | } 136 | .comment_write_input, .recomment_write_input { 137 | font-size: 10pt; 138 | width: 100%; 139 | border: none; 140 | overflow: hidden; 141 | height: 17px; 142 | resize: none; 143 | outline: none; 144 | margin-bottom: 10px; 145 | } 146 | .comment_writer_button { 147 | text-align: right; 148 | } 149 | .article_container { 150 | margin-bottom: 15px; 151 | } 152 | .article_bottom_bar { 153 | display: grid; 154 | grid-template-columns: 1fr 1fr; 155 | } 156 | .article_bottom_left { 157 | text-align: left; 158 | } 159 | .article_bottom_right { 160 | text-align: right; 161 | } 162 | .delete_comment { 163 | color: #888888; 164 | } 165 | .member:hover { 166 | cursor: pointer; 167 | } 168 | -------------------------------------------------------------------------------- /src/main/resources/static/css/write_form.css: -------------------------------------------------------------------------------- 1 | div.form { 2 | margin: 50px; 3 | margin-top: 90px; 4 | border: 1px solid #ff7799; 5 | border-radius: 10px; 6 | background: #fff9f9; 7 | padding: 20px; 8 | } 9 | div.btn-submit { 10 | text-align: center; 11 | } 12 | 13 | input.swal2-input { 14 | background: white; 15 | } 16 | 17 | textarea.swal2-textarea { 18 | background: white; 19 | height: 270px; 20 | resize: none; 21 | } 22 | 23 | select.swal2-select { 24 | background: white; 25 | border: 1px solid #d9d9d9; 26 | min-width: 30%; 27 | } 28 | 29 | span.subtitle { 30 | display: block; 31 | margin-left: 5px; 32 | margin-top: 15px; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/static/img/heart_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/heart_empty.png -------------------------------------------------------------------------------- /src/main/resources/static/img/heart_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/heart_full.png -------------------------------------------------------------------------------- /src/main/resources/static/img/null_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/null_profile.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/0/admin 복사본.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/0/admin 복사본.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/0/admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/0/admin.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/0/rhks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/0/rhks.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/0/관도장.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/0/관도장.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/1/KakaoTalk_Image_2020-06-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/1/KakaoTalk_Image_2020-06-0.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/1/image_readtop_2018_116371.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/1/image_readtop_2018_116371.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/10/20111112175840_뿌까.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/10/20111112175840_뿌까.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/10/뿌까.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/10/뿌까.jpeg -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/2/4수호자3신비3별.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/2/4수호자3신비3별.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/23/ss.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/23/ss.jpeg -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/23/존예.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/23/존예.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/24/존예.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/24/존예.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/29/ebc60c08-721b-4572-8f51-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/29/ebc60c08-721b-4572-8f51-8.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/30/craft.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/30/craft.jpeg -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/30/craftw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/30/craftw.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/31/xxlovets_112.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/31/xxlovets_112.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/32/스크린샷 2020-06-02 오ᄒ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/32/스크린샷 2020-06-02 오ᄒ.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/33/스크린샷 2020-06-02 오ᄒ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/33/스크린샷 2020-06-02 오ᄒ.png -------------------------------------------------------------------------------- /src/main/resources/static/img/profile/9/콜라보.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seokju2ng/springboot_board/c4d7b8578259fdf85dc71be74c8ac6ccbda048eb/src/main/resources/static/img/profile/9/콜라보.jpg -------------------------------------------------------------------------------- /src/main/resources/static/js/board.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | $('span.page-num').eq(0).css('margin-left', '15px'); 3 | $('span.page-num').eq($('span.page-num').length - 1).css('margin-right', '15px'); 4 | // $.setImage(); 5 | 6 | $('button#write').click($.write); 7 | $('select#category').change($.reload); 8 | $('select#list-size').change($.reload); 9 | $('table.board tr td:nth-child(2)').click($.showBoard); 10 | $('td.member').click($.showMemberInfo); 11 | }); 12 | 13 | $.showMemberInfo = function () { 14 | let mid = $(this).closest('td').attr('id').substr(1); 15 | location.href = "/mypage?id="+mid; 16 | }; 17 | 18 | $.showBoard = function (event) { 19 | let idx = event.target.id; 20 | location.href = "/board/"+idx; 21 | }; 22 | 23 | // $.setImage = () => { 24 | // let profiles = $('.profile_photo'); 25 | // for (let i = 0; i < profiles.length; i++) { 26 | // let value = profiles[i].parentElement.children[1].value.split(':'); 27 | // let middlePath = value[0]; 28 | // let fileName = value[1]; 29 | // let src = '/member/get-profile?middlePath=' + encodeURI(middlePath) + '&imageFileName=' + encodeURI(fileName); 30 | // profiles[i].src = src; 31 | // } 32 | // }; 33 | 34 | 35 | $.prev = function (startPage) { 36 | $.reload(startPage - 1); 37 | }; 38 | 39 | $.next = function (endPage) { 40 | $.reload(endPage + 1); 41 | }; 42 | 43 | $.write = function () { 44 | if($('div.login button').attr('id') === 'login') { 45 | $.login('/board/write'); 46 | } else { 47 | location.href = "/board/write"; 48 | } 49 | }; 50 | 51 | $.reload = function (page) { 52 | let requrl = "/board?"; 53 | let category = $('select#category').val(); 54 | let listSize = $('select#list-size').val(); 55 | 56 | if (category !== '전체보기') { 57 | requrl += "category=" + category + "&"; 58 | } 59 | if (listSize !== '10') { 60 | requrl += "size=" + listSize + "&"; 61 | } 62 | if (typeof page !== "object") { 63 | requrl += "page=" + page; 64 | } 65 | location.href = requrl; 66 | }; 67 | 68 | -------------------------------------------------------------------------------- /src/main/resources/static/js/common.js: -------------------------------------------------------------------------------- 1 | const DUPLICATE = -3; 2 | const INVALID_APPROACH = -2; 3 | const FAIL = -1; 4 | const ADMIN = 0; 5 | const SUCCESS = 1; 6 | 7 | $.sendPost = function (action, objArray) 8 | { 9 | let form = document.createElement('form'); 10 | form.setAttribute('method', 'post'); 11 | form.setAttribute('action', action); 12 | 13 | objArray.forEach(obj => { 14 | let param = document.createElement('input'); 15 | param.setAttribute('type', 'hidden'); 16 | param.setAttribute('name', obj.name); 17 | param.setAttribute('value', obj.value); 18 | form.appendChild(param); 19 | }); 20 | 21 | document.body.appendChild(form); 22 | form.submit(); 23 | }; 24 | 25 | $.fn.swalClickCancel = function (backUrl) { 26 | $(this).click(function () { 27 | Swal.fire({ 28 | title: '취소', 29 | text: '정말로 취소하시겠습니까?', 30 | icon: 'warning', 31 | showCancelButton: true, 32 | cancelButtonText: '아니오', 33 | confirmButtonText: '예', 34 | confirmButtonColor: '#ff7799' 35 | }).then(result => { 36 | if (result.value) { 37 | location.replace(backUrl); 38 | } 39 | }); 40 | }); 41 | }; 42 | 43 | function defend(value) { 44 | value = value+""; 45 | value = value.trim(); 46 | // value = value.replace(//gi, ">"); 47 | // value = value.replace(/\\(/gi, "& #40;").replace(/\\)/gi, "& #41;"); 48 | value = value.replace(/'/gi, "'"); 49 | value = value.replace(/eval\\((.*)\\)/gi, ""); 50 | value = value.replace(/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/gi, "\"\""); 51 | value = value.replace(/ 187 | 188 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/err_404.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 404 PAGE NOT FOUND 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
32 |
33 |

404

34 |
35 |

${err_msg}

36 | <%----%> 40 | Return To Board 41 |
42 |
43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/modify_form.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 석주잉 게시판 - 수정하기 8 | 9 | 10 | 11 |
12 | 13 |
14 |
15 | 말머리 16 | 30 | 제목 31 | 32 | 내용 33 | 34 |
35 | 36 | 37 |
38 |
39 |
40 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/my_page.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 4 | 5 | 6 | 7 | 8 | 마이페이지 - ${mypage.nickname} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 20 |
21 |
22 | 23 | 24 | my_profile" onclick="$.fileUpload()"/> 25 | 26 | 27 | 30 | " onclick="$.fileUpload()"> 31 | 32 | 33 | view_profile"> 34 | 35 | 36 | 37 | 38 |
39 |
40 |
${mypage.nickname}(${mypage.id})
41 |
42 |
43 | 총 방문${mypage.attendance} 44 | 총 게시글${mypage.boardNum} 45 | 총 댓글${mypage.replyNum} 46 |
47 |
48 | 49 | 기본 프로필 사진으로 변경 50 | 51 |
52 |
53 |
54 |
55 |
56 |
57 | 58 | 59 | 등록한 게시글 60 | 등록한 댓글 61 | 62 | 63 | 등록한 게시글 64 | 등록한 댓글 65 | 66 | 67 |
68 | 69 | 70 |
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 94 | 95 | 96 | 97 | 98 | 99 |
글번호제목작성일조회
작성하신 게시글이 없습니다.
${board.boardId} 86 | 87 | [${board.category}] 88 | 89 | ${board.title} 90 | 91 | [${board.replies}] 92 | 93 | ${board.date}${board.views}${board.likes}
100 |
101 |
102 | 103 |
104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
댓글작성일
작성하신 댓글이 없습니다.
${reply.content}${reply.date}
121 |
122 |
123 |
124 |
125 |
126 | 127 | 128 | 129 |
130 |
131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | cur-page" onclick="$.reload(this.innerHTML)">${status.index} 145 | 146 | 147 | 148 | 149 | 150 |
151 |
152 |
153 |
154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/show_profile.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%> 2 | 3 | 4 | 5 | 6 | ${mypage.nickname}님의 프로필 사진 7 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/topbar.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/view_article.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | ${article.title} 8 | 9 | 10 | 11 |
12 | 13 |
14 |
15 |
16 |
17 | [${article.category}] ${article.title} 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
32 |
33 | ${article.writerNickname} 34 |
35 |
36 | ${article.date} 37 |
38 |
39 |
40 | 조회수 ${article.views} 41 |
42 |
43 |
44 |
45 |
46 | ${article.content} 47 |
48 |
49 | 61 |
댓글 ${article.replies}
62 |
63 |
64 |
    65 | 66 |
  • comment_item_reply"> 67 |
    68 | 69 | 70 | 71 | 72 | 73 | 74 | <%----%> 75 | <%----%> 76 | 77 | 78 |
    79 |
    80 | ${reply.nickname} 81 |
    82 |
    83 | 84 | 85 | 삭제된 댓글입니다. 86 | 87 | 88 | ${reply.content} 89 | 90 | 91 |
    92 |
    93 |
    94 | ${reply.date} 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 답글쓰기 105 | 106 |
    107 | 108 |
    109 | 삭제 110 |
    111 |
    112 |
    113 |
    114 |
    115 |
  • 116 |
    117 |
118 |
119 | 120 |
121 |
122 |
${loginMember.nickname}
123 | 124 |
125 | 126 |
127 |
128 |
129 |
130 |
131 |
132 | 133 | 134 | 135 | 136 | 137 |
138 |
139 | 140 | 141 | 142 | 143 | 144 | 145 |
146 |
147 |
148 |
149 |
150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/jsp/write_form.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 석주잉 게시판 - 글쓰기 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 | 말머리 16 | 30 | 제목 31 | 32 | 내용 33 | 34 |
35 | 36 | 37 |
38 | 39 |
40 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/test/java/com/board/demo/repository/BoardRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.repository.BoardRepository; 4 | import com.board.demo.repository.BoardlistRepository; 5 | import com.board.demo.repository.ReplylistRepository; 6 | import com.board.demo.vo.Board; 7 | import com.board.demo.vo.Boardlist; 8 | import com.board.demo.vo.Replylist; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.junit.Assert; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.data.domain.PageRequest; 16 | import org.springframework.test.context.junit4.SpringRunner; 17 | 18 | import javax.transaction.Transactional; 19 | import java.util.List; 20 | import java.util.Optional; 21 | 22 | @Slf4j 23 | @RunWith(SpringRunner.class) 24 | @SpringBootTest 25 | public class BoardRepositoryTest { 26 | 27 | @Autowired 28 | private BoardRepository boardRepository; 29 | 30 | @Autowired 31 | private BoardlistRepository boardlistRepository; 32 | 33 | @Autowired 34 | private ReplylistRepository replylistRepository; 35 | 36 | @Test 37 | @Transactional 38 | public void create() { 39 | String title = "이건 제목입니다"; // 최대 60자 40 | String content = "이건 내용입니다"; 41 | long category = 2; 42 | long writer = 22; 43 | Board board = Board.builder() 44 | .title(title) 45 | .content(content) 46 | .writer(writer) 47 | .category(category) 48 | .build(); 49 | 50 | try { 51 | Board newBoard = boardRepository.save(board); 52 | log.info("insert success : " + newBoard); 53 | } catch (Exception e) { 54 | log.warn(e.toString()); 55 | } 56 | } 57 | 58 | @Test 59 | public void read() { 60 | Optional board = boardRepository.findById(1L); 61 | board.ifPresent(selectBoard -> { 62 | System.out.println("board:" + selectBoard); 63 | }); 64 | } 65 | 66 | @Test 67 | public void readAll() { 68 | List boards = boardlistRepository.findAll(); 69 | boards.forEach(board -> log.info(board.toString())); 70 | } 71 | 72 | @Test 73 | public void readPage() { 74 | String category = "잡담"; 75 | int page = 0; 76 | int size = 3; 77 | PageRequest pageRequest = PageRequest.of(page, size); 78 | List boards = boardlistRepository.findAllByCategory(category, pageRequest).getContent(); 79 | boards.forEach(board -> log.info(board.toString())); 80 | } 81 | 82 | @Test 83 | public void viewArticle() { 84 | long board_id = 6L; 85 | Optional board = boardlistRepository.findById(board_id); 86 | if (board.isPresent()) { 87 | log.info(board.get().toString()); 88 | List replies = replylistRepository.findAllByBoardId(board_id); 89 | replies.forEach(reply -> log.info(reply.toString())); 90 | } else { 91 | log.info("Board id = '" + board_id + "' is not exist."); 92 | } 93 | } 94 | 95 | @Test 96 | public void selectPrevAndNextArticle() { 97 | long board_id = 7L; 98 | List boards = boardRepository.findPrevAndNextBoardIdByBoardId(board_id); 99 | Assert.assertNotEquals(boards.size(), 0); 100 | // log.info(boards.toString()); 101 | if (boards.size() == 1) { 102 | log.info("?? : " + boards.get(0).getBoardId()); 103 | } else { 104 | long prevArticle = boards.get(0).getBoardId(); 105 | long nextArticle = boards.get(1).getBoardId(); 106 | log.info("prev Article No : " + prevArticle); 107 | log.info("next Article No : " + nextArticle); 108 | } 109 | } 110 | 111 | @Test 112 | @Transactional 113 | public void deleteArticle() { 114 | long board_id = 2L; 115 | try { 116 | boardRepository.deleteById(board_id); 117 | } catch (Exception e) { 118 | log.error(e.toString()); 119 | log.error( "There isn't a board no." + board_id); 120 | } 121 | } 122 | 123 | 124 | @Test 125 | public void selectNotice() { 126 | String notice = "공지"; 127 | List notices = boardlistRepository.findAllByCategory(notice); 128 | log.info(notices.toString()); 129 | } 130 | 131 | @Test 132 | public void selectToplikes() { 133 | List topLikes = boardlistRepository.findTopLikes(); 134 | topLikes.forEach(l -> { 135 | log.info(l.getBoardId() +": "+ l.getTitle() +" ("+l.getLikes()+")"); 136 | }); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/test/java/com/board/demo/repository/CategoryRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Category; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import javax.transaction.Transactional; 12 | import java.util.List; 13 | import java.util.Optional; 14 | 15 | @Slf4j 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class CategoryRepositoryTest { 19 | 20 | @Autowired 21 | private CategoryRepository categoryRepository; 22 | 23 | @Test 24 | @Transactional 25 | public void create() { 26 | String categoryName = "여행"; 27 | Category category = Category.builder() 28 | .categoryName(categoryName) 29 | .build(); 30 | category = categoryRepository.save(category); 31 | log.info(category.toString()); 32 | } 33 | 34 | @Test 35 | public void readAll() { 36 | List category = categoryRepository.findAll(); 37 | category.forEach(x -> log.info(x.toString())); 38 | } 39 | 40 | @Test 41 | @Transactional 42 | public void update() { 43 | Optional category = categoryRepository.findById(1L); 44 | category.ifPresent(selectCategory -> { 45 | selectCategory.setCategoryName("바바"); 46 | Category newCategory = categoryRepository.save(selectCategory); 47 | System.out.println("category: " + newCategory); 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/com/board/demo/repository/MemberLikeBoardRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.MemberLikeBoard; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | import javax.transaction.Transactional; 13 | import java.util.Optional; 14 | 15 | @Slf4j 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class MemberLikeBoardRepositoryTest { 19 | 20 | @Autowired 21 | private MemberLikeBoardRepository memberLikeBoardRepository; 22 | 23 | @Test 24 | @Transactional 25 | public void create() { // click to like 26 | long boardId = 30L; 27 | long memberId = 20L; 28 | 29 | MemberLikeBoard mlb = MemberLikeBoard.builder() 30 | .memberId(memberId) 31 | .boardId(boardId) 32 | .build(); 33 | 34 | mlb = memberLikeBoardRepository.save(mlb); 35 | Assert.assertNotEquals(mlb.getId(), 0L); 36 | } 37 | 38 | @Test 39 | @Transactional 40 | public void delete() { // cancel to like 41 | long boardId = 11L; 42 | long memberId = 20L; 43 | 44 | Optional mlb = memberLikeBoardRepository.findByBoardIdAndMemberId(boardId, memberId); 45 | mlb.ifPresent(memberLikeBoardRepository::delete); 46 | 47 | 48 | Assert.assertFalse(memberLikeBoardRepository.findByBoardIdAndMemberId(boardId, memberId).isPresent()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/com/board/demo/repository/MemberRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.util.HashFunction; 4 | import com.board.demo.vo.Member; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import javax.transaction.Transactional; 14 | import java.security.NoSuchAlgorithmException; 15 | import java.util.Optional; 16 | 17 | @Slf4j 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | public class MemberRepositoryTest { 21 | @Autowired 22 | private MemberRepository memberRepository; 23 | 24 | @Test 25 | @Transactional 26 | public void create() throws NoSuchAlgorithmException { 27 | String id = "user"; 28 | String pwd = "password"; 29 | String email = "email@email.com"; 30 | String nick = "nickname"; 31 | 32 | Member member = Member.builder() 33 | .id(id) 34 | .pwd(HashFunction.sha256(pwd)) 35 | .email(email) 36 | .nickname(nick) 37 | .build(); 38 | 39 | try { 40 | Member newMember = memberRepository.save(member); 41 | log.info("New Member[" + newMember.getMemberId() + " : " + id + "] has just signed up."); 42 | } catch (Exception e) { 43 | log.warn(e.toString()); 44 | } 45 | } 46 | 47 | @Test 48 | public void read() { 49 | long memberId = 1L; 50 | String title = "select member(" + memberId + ") : "; 51 | Optional member = memberRepository.findById(memberId); 52 | member.ifPresent(selectMember -> log.info(title + selectMember)); 53 | } 54 | 55 | @Test 56 | @Transactional 57 | public void update() { 58 | Optional member = memberRepository.findById(1L); 59 | 60 | member.ifPresent(selectMember -> { 61 | String id = "update_id"; 62 | String nick = "update_nick"; 63 | selectMember.setId(id); 64 | selectMember.setNickname(nick); 65 | Member newMember = memberRepository.save(selectMember); 66 | log.info("update user : " + newMember); 67 | }); 68 | } 69 | 70 | @Test 71 | @Transactional 72 | public void delete() { 73 | long id = 1L; 74 | 75 | Optional member = memberRepository.findById(id); 76 | 77 | Assert.assertTrue(member.isPresent()); 78 | member.ifPresent(memberRepository::delete); 79 | 80 | Optional deleteMember = memberRepository.findById(id); 81 | Assert.assertFalse(deleteMember.isPresent()); 82 | } 83 | 84 | @Test 85 | public void login() throws NoSuchAlgorithmException { 86 | String id = "gyetol"; 87 | String pwd = "gyetol2"; 88 | Optional loginMember = memberRepository.findByIdAndPwd(id, HashFunction.sha256(pwd)); 89 | 90 | if (loginMember.isPresent()) { 91 | Member member = loginMember.get(); 92 | log.info("Successfully logged in"); 93 | log.info("Attendance before update : " + member.getAttendance()); 94 | member.setAttendance(member.getAttendance() + 1); 95 | member = memberRepository.save(member); 96 | log.info("Attendance after update : " + member.getAttendance()); 97 | } else { 98 | log.warn("Login failed"); 99 | } 100 | } 101 | 102 | @Test 103 | public void checkDuplicate() { 104 | String id = "ehddnwnd2"; 105 | 106 | Optional member = memberRepository.findById(id); 107 | 108 | if (member.isPresent()) { 109 | log.info("[" + id + "] is duplicate "); 110 | } else { 111 | log.info("[" + id + "] is available"); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/test/java/com/board/demo/repository/ReplyRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.board.demo.repository; 2 | 3 | import com.board.demo.vo.Reply; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | import javax.transaction.Transactional; 13 | import java.text.SimpleDateFormat; 14 | import java.util.Date; 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | @Slf4j 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest 21 | public class ReplyRepositoryTest { 22 | 23 | @Autowired 24 | private ReplyRepository replyRepository; 25 | 26 | @Test 27 | @Transactional 28 | public void create() { 29 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 30 | Date today = new Date(); 31 | long boardId = 16L; 32 | long parent = 0L; 33 | long writer = 22L; 34 | String date = sdf.format(today); 35 | String content = "형 지나가다 뒤통수 조심하세요.."; 36 | 37 | Reply reply = Reply.builder() 38 | .parent(parent) 39 | .board(boardId) 40 | .writer(writer) 41 | .content(content) 42 | .date(date) 43 | .build(); 44 | 45 | try { 46 | reply = replyRepository.save(reply); 47 | if (parent == 0) { 48 | reply.setParent(reply.getReplyId()); 49 | reply = replyRepository.save(reply); 50 | } 51 | log.info("insert success: " + reply); 52 | } catch (Exception e) { 53 | log.warn(e.toString()); 54 | } 55 | } 56 | 57 | @Test 58 | @Transactional 59 | public void deleteFalse() { 60 | long replyId = 27L; 61 | long parent = 25L; 62 | long memberId = 2L; 63 | Optional opReply = replyRepository.findByReplyIdAndParentAndWriter(replyId, parent, memberId); 64 | Assert.assertFalse(opReply.isPresent()); 65 | } 66 | 67 | @Test 68 | @Transactional 69 | public void deleteParentTrue() { // 기본 댓글일 때 70 | long replyId = 16L; 71 | long parent = 16L; 72 | long memberId = 22L; 73 | Optional opReply = replyRepository.findByReplyIdAndParentAndWriter(replyId, parent, memberId); 74 | if (!opReply.isPresent()) { 75 | return; 76 | } 77 | if (parent == replyId) { 78 | List lists = replyRepository.findAllByParent(parent); 79 | if (lists.size() == 1) { 80 | replyRepository.deleteById(replyId); 81 | opReply = replyRepository.findById(replyId); 82 | Assert.assertFalse(opReply.isPresent()); 83 | } else { 84 | Reply reply = opReply.get(); 85 | reply.setContent("NULL"); 86 | replyRepository.save(reply); 87 | opReply = replyRepository.findById(replyId); 88 | Assert.assertEquals(opReply.get().getContent(), "NULL"); 89 | log.info(opReply.get().getContent()); 90 | } 91 | } 92 | } 93 | } 94 | --------------------------------------------------------------------------------