Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ out/

### VS Code ###
.vscode/

### DB 비밀번호 ###
/src/main/resources/db.properties
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'

// 테스트코드 @Slf4j 사용
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

// JDBC, MySQL
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
runtimeOnly 'com.mysql:mysql-connector-j'
}

tasks.named('test') {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/web/mzvoca/repository/ConnectionConst.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.web.mzvoca.repository;

public abstract class ConnectionConst {
public static final String URL = "";
public static final String userName = "root";
public static final String password = "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.web.mzvoca.repository;

public interface QuestionRepository {

public void questionWrongCountRead();

public void questionWrongCountUpdate();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.web.mzvoca.repository;

import org.springframework.stereotype.Repository;

@Repository
public class QuestionRepositoryImpl implements QuestionRepository {
@Override
public void questionWrongCountRead() {

}

@Override
public void questionWrongCountUpdate() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.web.mzvoca.repository;

public interface TotalCountRepository {

public int totalCountRead();

public void totalCountUpdate();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.web.mzvoca.repository;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;
import java.sql.*;
import java.util.NoSuchElementException;

@Repository
@RequiredArgsConstructor
@Slf4j
public class TotalCountRepositoryImpl implements TotalCountRepository {

private final DataSource dataSource;

@Override
public int totalCountRead() {
String sql = "select * from totalcount";

Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;

try {
con = getConnection();
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
// 가져온 데이터가 있을 때 실행할 부분
int totalCount = rs.getInt("total_count");
return totalCount;
} else {
throw new NoSuchElementException("값이 없습니다.");
}

} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
close(con, pstmt, rs);
}
}

@Override
public void totalCountUpdate() {
// Update문을 통해 totalCount 값을 1 증가
String sql = "update totalcount set total_count = total_count + 1";

Connection con = null;
PreparedStatement pstmt = null;

try {
con = getConnection();
pstmt = con.prepareStatement(sql);
int result = pstmt.executeUpdate();
log.info("실행된 행 개수={}", result);
} catch (SQLException e) {
log.info("db Error", e);
throw new RuntimeException(e);
} finally {
close(con, pstmt, null);
}
}

private Connection getConnection() throws SQLException {
// 트랜잭션 동기화를 위해 DataSourceUtils 메서드 사용
Connection con = DataSourceUtils.getConnection(dataSource);
return con;
}

private void close(Connection con, Statement stmt, ResultSet rs) {
JdbcUtils.closeResultSet(rs);
JdbcUtils.closeStatement(stmt);
// 트랜잭션 동기화를 위해 DataSourceUtils 메서드 사용
DataSourceUtils.releaseConnection(con, dataSource);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

# DB ?? ??
spring.profiles.include = db
65 changes: 60 additions & 5 deletions src/main/resources/templates/css/main.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

.mainbody{
margin-top:10px;
margin-bottom:10px;
padding-top:5px;
background: url("../images/v1_3.png");
text-align: center;
background-size:cover;
height:90vdh;
height:100dvh;
margin: 0 auto;
}
body{
background-color: pink;
margin: 0;
padding: 0;
}
ul{
border: 1px solid;
Expand All @@ -32,3 +31,59 @@ th{
*{
font-family: 'Noto Serif KR', serif;
}
@media (min-width: 1024px) {
.mainbody {
height: 100dvh;
width: 864px;
min-width: 864px;
font-size: 140px;

}
.container{
display: flex;
justify-content: center; /* 수평 가운데 정렬 */
align-items: center; /* 수직 가운데 정렬 */
text-align: center;
}
/* PC에 대한 추가 스타일 */
}
@media all and (min-width:768px) and (max-width:1023px) {
.mainbody {
height: 100dvh;
width: 100dvw;
font-size: 140px;
padding:0;
margin:0;
}
.container{
padding:0;
margin:0;
}
}
/*태블릿*/

/* 모바일 스타일 */
@media (max-width: 767px) {
.mainbody {
height: 100dvh;
width: 100dvw;
font-size:11vh;
}
.container {
padding:0;
margin:0;
}

}
@media (min-width: 280px)and (max-width: 319px) and (orientation: portrait) {
.mainbody {
height: 100%;
width: 100dvw;
font-size:80px;
}
.container {
padding:0;
margin:0;
}
}
/*갤럭시폴드*/
115 changes: 115 additions & 0 deletions src/main/resources/templates/css/questions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#qna{
display: none;
}
#result{
display:none;
}
#commentary{
display: none;
}
#ranking{
display: none;
}
.mainbody{
background: url("../images/v1_3.png");
text-align: center;
background-size:cover;
height:100dvh;
margin: 0 auto;

}

.questionstyle{
font-size: 0.30em;
}
.answerstyle{
font-size: 0.24em;
text-align: left;
}
.commentarystyle{
font-size:0.18em;
}
body{
background-color: pink;
margin: 0;
padding: 0;
}

.btn1{
background-color: gray;
color:black;
}
*{
font-family: 'Noto Serif KR', serif;
}
.answerbutton{
border-radius: 50%;
width: 33.6px;
height: 33.6px;
display: flex;
justify-content: center;
align-items: center;
float: left;
}
.answerbutton:active{
background-color: red;
}
@media (min-width: 1024px) {
.mainbody {
height: 100dvh;
width: 864px;
min-width: 864px;
font-size: 140px;

}
.container{
display: flex;
justify-content: center; /* 수평 가운데 정렬 */
align-items: center; /* 수직 가운데 정렬 */
text-align: center;
}
/* PC에 대한 추가 스타일 */
}
@media all and (min-width:768px) and (max-width:1023px) {
.mainbody {
height: 100dvh;
width: 100dvw;
font-size: 140px;
padding:0;
margin:0;

}
.container{
padding:0;
margin:0;
}
}
/*태블릿*/

/* 모바일 스타일 */
@media (max-width: 767px) {
.mainbody {
height: 100dvh;
width: 100dvw;
font-size:11vh;

}
.container {
padding:0;
margin:0;
}

}
@media (min-width: 280px)and (max-width: 319px) and (orientation: portrait) {
.mainbody {
height: 100%;
width: 100dvw;
font-size:80px;

}
.container {
padding:0;
margin:0;
}
}
/*갤럭시폴드*/
Loading