파일 목록
-
📁 .metadata
-
📁 .mylyn
-
📁 contexts
- repositories.xml.zip
-
-
📁 .plugins
-
📁 org.eclipse.buildship.core
-
📁 init.d
-
📁 project-preferences
-
-
📁 org.eclipse.buildship.ui
-
📁 org.eclipse.core.resources
-
📁 .history
-
📁 22
-
📁 28
-
📁 6a
-
📁 78
-
📁 7e
-
📁 83
-
📁 ca
-
📁 e
-
📁 fe
-
-
📁 .projects
-
📁 .org.eclipse.egit.core.cmp
-
📁 BookMarket
-
📁 .indexes
-
📁 af
-
-
📁 org.eclipse.jdt.apt.core
-
📁 org.eclipse.jdt.core
- .location
- .markers
- .markers.snap
- .syncinfo.snap
-
-
📁 Chap02
-
📁 org.eclipse.jdt.apt.core
-
📁 org.eclipse.jdt.core
- .markers
- .markers.snap
- .syncinfo.snap
-
-
-
📁 .root
-
📁 .safetable
- 10.snap
-
-
📁 org.eclipse.core.runtime
-
📁 .settings
- Docker.prefs
- org.eclipse.buildship.ui.prefs
- org.eclipse.core.resources.prefs
- org.eclipse.debug.ui.prefs
- org.eclipse.egit.core.prefs
- org.eclipse.epp.mpc.ui.prefs
- org.eclipse.jdt.core.prefs
- org.eclipse.jdt.debug.ui.prefs
- org.eclipse.jdt.junit.prefs
- org.eclipse.jdt.launching.prefs
- org.eclipse.jdt.ui.prefs
- org.eclipse.jsch.core.prefs
- org.eclipse.jst.j2ee.webservice.ui.prefs
- org.eclipse.m2e.apt.prefs
- org.eclipse.m2e.discovery.prefs
- org.eclipse.mylyn.context.core.prefs
- org.eclipse.mylyn.monitor.ui.prefs
- org.eclipse.mylyn.tasks.ui.prefs
- org.eclipse.pde.api.tools.prefs
- org.eclipse.ui.browser.prefs
- org.eclipse.ui.ide.prefs
- org.eclipse.ui.navigator.prefs
- org.eclipse.ui.prefs
- org.eclipse.ui.workbench.prefs
- org.eclipse.wst.jsdt.ui.prefs
- org.eclipse.wst.jsdt.web.core.prefs
- org.eclipse.wst.sse.ui.prefs
- org.eclipse.wst.ws.service.policy.prefs
- org.springframework.ide.eclipse.boot.dash.prefs
- org.springframework.ide.eclipse.boot.launch.prefs
- org.springframework.ide.eclipse.boot.prefs
- org.springframework.ide.eclipse.imports.prefs
- org.springsource.ide.eclipse.commons.ui.prefs
-
-
📁 org.eclipse.datatools.connectivity
-
📁 org.eclipse.debug.core
-
📁 org.eclipse.debug.ui
-
📁 org.eclipse.e4.workbench
-
📁 org.eclipse.eclemma.core
-
📁 .execdata
-
-
📁 org.eclipse.egit.core
-
📁 .org.eclipse.egit.core.cmp
-
📁 .settings
- .project
-
-
-
📁 org.eclipse.emf.common.ui
-
📁 org.eclipse.epp.mpc.ui
-
📁 org.eclipse.equinox.p2.ui
-
📁 org.eclipse.jdt.core
- 1032664556.index
- 1046776222.index
- 1085918923.index
- 1098367511.index
- 1103990142.index
- 114257520.index
- 1259591260.index
- 1306943540.index
- 1342465706.index
- 1343725884.index
- 1406489186.index
- 1423644118.index
- 1499060772.index
- 150191461.index
- 153282544.index
- 1561259185.index
- 1587038330.index
- 1591058950.index
- 163494242.index
- 1737725865.index
- 1795320714.index
- 1802910406.index
- 1814875633.index
- 1823358352.index
- 1829605366.index
- 1855262625.index
- 1865797976.index
- 1877692097.index
- 1899050622.index
- 1901848277.index
- 1908842224.index
- 1950052445.index
- 203363936.index
- 2093080152.index
- 213132002.index
- 2158070117.index
- 2187926128.index
- 2208116219.index
- 2239392838.index
- 2270640161.index
- 2300481235.index
- 2323862626.index
- 2327230697.index
- 2361831942.index
- 2403806799.index
- 2425170697.index
- 2428421529.index
- 243173088.index
- 243444292.index
- 246872496.index
- 2574092214.index
- 2606035263.index
- 2642855571.index
- 2673762025.index
- 2687063221.index
- 2694330660.index
- 2716873423.index
- 2735274666.index
- 2762635672.index
- 2785578155.index
- 281274800.index
- 2874808635.index
- 2910265552.index
- 2922188548.index
- 2940098355.index
- 2947743441.index
- 2960267103.index
- 3005342323.index
- 3039149765.index
- 3092362395.index
- 3171200218.index
- 3185776176.index
- 3289718304.index
- 3343647032.index
- 3350778374.index
- 3368243042.index
- 3394968329.index
- 3413701618.index
- 3413725848.index
- 3463701276.index
- 3550271171.index
- 3552686602.index
- 3553503214.index
- 3554740767.index
- 3593383410.index
- 3667659376.index
- 3680454040.index
- 3691127648.index
- 376211574.index
- 3767840844.index
- 3806757576.index
- 3822504139.index
- 3830692465.index
- 3847922432.index
- 3851352355.index
- 3896498729.index
- 4019127980.index
- 4032350038.index
- 4094206136.index
- 4097592731.index
- 4141668602.index
- 4236191647.index
- 426763299.index
- 437405910.index
- 479256431.index
- 509260333.index
- 521676379.index
- 523827649.index
- 524399751.index
- 553796313.index
- 578923137.index
- 594698515.index
- 671830540.index
- 761271397.index
- 766539937.index
- 773662974.index
- 804699012.index
- 83750376.index
- 838434006.index
- 862373323.index
- 869691404.index
- 901893090.index
- 904368330.index
- 924643285.index
- 926828645.index
- 97507228.index
- 976341134.index
- assumedExternalFilesCache
- externalFilesCache
- externalLibsTimeStamps
- indexNamesMap.txt
- javaLikeNames.txt
- nonChainingJarsCache
- savedIndexNames.txt
- variablesAndContainers.dat
-
📁 org.eclipse.jdt.junit.core
-
📁 history
-
-
📁 org.eclipse.jdt.launching
-
📁 org.eclipse.jdt.ui
-
📁 org.eclipse.linuxtools.docker.core
-
📁 org.eclipse.linuxtools.docker.ui
-
📁 org.eclipse.ltk.core.refactoring
-
📁 .refactorings
-
📁 .workspace
-
📁 2025
-
📁 3
-
-
-
📁 Chap02
-
📁 2025
-
📁 3
-
-
-
-
-
📁 org.eclipse.ltk.ui.refactoring
-
📁 org.eclipse.m2e.core
-
📁 org.eclipse.m2e.logback
-
📁 org.eclipse.mylyn.context.core
-
📁 contexts
-
-
📁 org.eclipse.mylyn.github.ui
-
📁 org.eclipse.mylyn.tasks.ui
-
📁 org.eclipse.oomph.setup
-
📁 org.eclipse.oomph.setup.ui
-
📁 org.eclipse.pde.api.tools
-
📁 org.eclipse.pde.core
-
📁 .cache
-
📁 .p2
-
📁 org.eclipse.equinox.p2.engine
-
📁 profileRegistry
-
-
-
-
📁 org.eclipse.tips.ide
-
📁 org.eclipse.tm.terminal.view.ui
-
📁 .executables
-
-
📁 org.eclipse.ui.editors
-
📁 org.eclipse.ui.ide
-
📁 org.eclipse.ui.intro
-
📁 org.eclipse.ui.workbench
-
📁 org.eclipse.userstorage.oauth
-
📁 org.eclipse.wildwebdeveloper.embedder.node
-
📁 org.eclipse.wst.common.modulecore
-
📁 org.eclipse.wst.internet.cache
-
📁 org.eclipse.wst.jsdt.core
-
📁 indexes
-
📁 libraries
- externalLibsTimeStamps
- variablesAndContainers.dat
-
-
📁 org.eclipse.wst.jsdt.ui
-
📁 org.eclipse.wst.jsdt.web.core
-
📁 JSWebResourceEventManager
-
-
📁 org.eclipse.wst.server.core
-
📁 org.eclipse.wst.sse.core
-
📁 org.eclipse.wst.sse.ui
-
📁 org.eclipse.wst.xml.core
-
📁 org.springframework.ide.eclipse.boot
-
📁 installs
-
-
📁 org.springframework.ide.eclipse.boot.dash
-
📁 org.springframework.tooling.boot.ls
-
- .lock
- .log
- version.ini
-
-
📁 BookMarket
-
📁 .apt_generated
-
📁 .apt_generated_tests
-
📁 .gradle
-
📁 8.5
-
📁 checksums
-
📁 dependencies-accessors
-
📁 executionHistory
-
📁 fileChanges
-
📁 fileHashes
-
📁 vcsMetadata
- gc.properties
-
-
📁 buildOutputCleanup
-
📁 vcs-1
- file-system.probe
-
-
📁 bin
-
📁 default
-
📁 main
-
📁 com
-
📁 springboot
-
📁 interceptor
- BookMarketApplication.class
-
-
📁 logging
-
📁 static
-
📁 css
-
📁 images
-
📁 js
- welcome.html
-
-
📁 templates
- application.properties
- messages.properties
-
-
📁 test
-
📁 com
-
📁 springboot
-
-
-
-
📁 build
-
📁 classes
-
📁 java
-
📁 main
-
-
-
📁 generated
-
📁 sources
-
📁 annotationProcessor
-
📁 java
-
📁 main
-
-
-
📁 headers
-
📁 java
-
📁 main
-
-
-
-
-
📁 tmp
-
📁 compileJava
-
-
-
📁 gradle
-
📁 wrapper
-
-
📁 src
-
📁 main
-
📁 java
-
📁 com
-
📁 springboot
-
📁 interceptor
- BookMarketApplication.java
-
-
-
📁 resources
-
📁 logging
-
📁 static
-
📁 css
-
📁 images
-
📁 js
- welcome.html
-
-
📁 templates
- application.properties
- messages.properties
-
-
-
📁 test
-
📁 java
-
📁 com
-
📁 springboot
-
-
-
-
- .classpath
- .gitignore
- .project
- build.gradle
- gradlew
- gradlew.bat
- HELP.md
- settings.gradle
-
- .project
- Title.png
package com.springboot.repository;
import com.springboot.domain.Board;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
@Repository
public class BoardRepositoryImpl implements BoardRepository {
private final JdbcTemplate jdbcTemplate;
@Autowired
public BoardRepositoryImpl(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
// RowMapper 정의 (DB 컬럼 이름과 Board 필드 매핑)
private RowMapper<Board> boardRowMapper = new RowMapper<Board>() {
@Override
public Board mapRow(ResultSet rs, int rowNum) throws SQLException {
Board board = new Board();
board.setId(rs.getLong("id"));
board.setWriterid(rs.getString("writerid"));
board.setWriter(rs.getString("writer"));
board.setTitle(rs.getString("title"));
board.setContent(rs.getString("content"));
// createdDate, modifiedDate는 DB에 TIMESTAMP로 저장되어 있다고 가정
board.setCreatedDate(rs.getTimestamp("createdDate") != null ? rs.getTimestamp("createdDate").toLocalDateTime() : null);
board.setModifiedDate(rs.getTimestamp("modifiedDate") != null ? rs.getTimestamp("modifiedDate").toLocalDateTime() : null);
return board;
}
};
@Override
public Long save(Board board) {
if (board.getId() == null || board.getId() == 0) { // 새 게시글 (ID가 없거나 0이면 새 글)
String sql = "INSERT INTO board (writerid, writer, title, content, createdDate, modifiedDate) VALUES (?, ?, ?, ?, NOW(), NOW())";
jdbcTemplate.update(sql, board.getWriterid(), board.getWriter(), board.getTitle(), board.getContent());
// JDBC는 save 후 자동 생성 ID 반환이 JpaRepository처럼 간단하지 않으므로,
// 필요시 PreparedStatementCreatorFactory와 KeyHolder를 사용해야 합니다.
// 여기서는 임시로 0L을 반환하지만, 실제 ID를 얻으려면 추가 로직 필요.
// 또는 savePost 로직에서 ID가 필요 없다면 Long 대신 void로 변경.
return 0L;
} else { // 게시글 수정
String sql = "UPDATE board SET writerid = ?, writer = ?, title = ?, content = ?, modifiedDate = NOW() WHERE id = ?";
jdbcTemplate.update(sql, board.getWriterid(), board.getWriter(), board.getTitle(), board.getContent(), board.getId());
return board.getId();
}
}
@Override
public Board findById(Long id) {
String sql = "SELECT id, writerid, writer, title, content, createdDate, modifiedDate FROM board WHERE id = ?";
try {
return jdbcTemplate.queryForObject(sql, boardRowMapper, id);
} catch (org.springframework.dao.EmptyResultDataAccessException e) {
return null; // 찾는 게시글이 없으면 null 반환
}
}
@Override
public List<Board> findAll() {
String sql = "SELECT id, writerid, writer, title, content, createdDate, modifiedDate FROM board ORDER BY createdDate DESC";
return jdbcTemplate.query(sql, boardRowMapper);
}
@Override
public void deleteById(Long id) {
String sql = "DELETE FROM board WHERE id = ?";
jdbcTemplate.update(sql, id);
}
@Override
public int count() {
String sql = "SELECT COUNT(*) FROM board";
Integer count = jdbcTemplate.queryForObject(sql, Integer.class);
return count != null ? count : 0;
}
@Override
public List<Board> findPage(int pageNum, int pageSize, String sortField, String sortDir) {
// ORDER BY 절 구성
String orderBy = "";
if (sortField != null && !sortField.isEmpty()) {
orderBy = " ORDER BY " + sortField + " " + sortDir;
} else {
orderBy = " ORDER BY id DESC"; // 기본 정렬
}
// LIMIT 및 OFFSET 구성 (MySQL 기준)
String sql = "SELECT id, writerid, writer, title, content, createdDate, modifiedDate FROM board" + orderBy + " LIMIT ? OFFSET ?";
int offset = (pageNum - 1) * pageSize;
return jdbcTemplate.query(sql, boardRowMapper, pageSize, offset);
}
}