#24 simple sns: db settings(postgresql)
This commit is contained in:
@@ -53,8 +53,8 @@ task cleanFrontEnd(type: Delete) {
|
|||||||
delete "$projectDir/front-end/static", "$projectDir/front-end/node_modules"
|
delete "$projectDir/front-end/static", "$projectDir/front-end/node_modules"
|
||||||
}
|
}
|
||||||
|
|
||||||
npmBuild.dependsOn npmInstall
|
//npmBuild.dependsOn npmInstall
|
||||||
copyFrontEnd.dependsOn npmBuild
|
//copyFrontEnd.dependsOn npmBuild
|
||||||
compileJava.dependsOn copyFrontEnd
|
//compileJava.dependsOn copyFrontEnd
|
||||||
|
//
|
||||||
clean.dependsOn cleanFrontEnd
|
//clean.dependsOn cleanFrontEnd
|
||||||
@@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
@SpringBootApplication
|
||||||
public class SnsApplication {
|
public class SnsApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.example.sns.config;
|
||||||
|
|
||||||
|
import org.hibernate.boot.model.naming.Identifier;
|
||||||
|
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
public class ImprovedNamingStrategy implements PhysicalNamingStrategy {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier toPhysicalCatalogName(Identifier identifier, JdbcEnvironment jdbcEnv) {
|
||||||
|
return convert(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier toPhysicalColumnName(Identifier identifier, JdbcEnvironment jdbcEnv) {
|
||||||
|
return convert(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier toPhysicalSchemaName(Identifier identifier, JdbcEnvironment jdbcEnv) {
|
||||||
|
return convert(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier toPhysicalSequenceName(Identifier identifier, JdbcEnvironment jdbcEnv) {
|
||||||
|
return convert(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier toPhysicalTableName(Identifier identifier, JdbcEnvironment jdbcEnv) {
|
||||||
|
return convert(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Identifier convert(Identifier identifier) {
|
||||||
|
if (identifier == null || StringUtils.isEmpty(identifier.getText())) {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
String regex = "([a-z])([A-Z])";
|
||||||
|
String replacement = "$1_$2";
|
||||||
|
String newName = identifier.getText().replaceAll(regex, replacement).toLowerCase();
|
||||||
|
return Identifier.toIdentifier(newName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,9 @@ package com.example.sns.controller.response;
|
|||||||
import com.example.sns.model.User;
|
import com.example.sns.model.User;
|
||||||
import com.example.sns.model.UserRole;
|
import com.example.sns.model.UserRole;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class UserJoinResponse {
|
public class UserJoinResponse {
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import java.sql.Timestamp;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"user\"")
|
@Table(name = "users")
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
@SQLDelete(sql = "UPDATE \"user\" SET deleted_at = NOW() where id=?")
|
@SQLDelete(sql = "UPDATE users SET deleted_at = NOW() where id=?")
|
||||||
@Where(clause = "deleted_at IS NULL")
|
@Where(clause = "deleted_at IS NULL")
|
||||||
public class UserEntity {
|
public class UserEntity {
|
||||||
|
|
||||||
@@ -25,10 +25,12 @@ public class UserEntity {
|
|||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private UserRole role;
|
private UserRole role = UserRole.USER;
|
||||||
|
|
||||||
private Timestamp registeredAt;
|
private Timestamp registeredAt;
|
||||||
private Timestamp updatedAt;
|
private Timestamp updatedAt;
|
||||||
|
|
||||||
|
@Column(name = "deleted_at")
|
||||||
private Timestamp deletedAt;
|
private Timestamp deletedAt;
|
||||||
|
|
||||||
@PrePersist
|
@PrePersist
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
23
simple_sns/src/main/resources/application.yml
Normal file
23
simple_sns/src/main/resources/application.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
spring:
|
||||||
|
jpa:
|
||||||
|
database: postgresql
|
||||||
|
hibernate:
|
||||||
|
naming:
|
||||||
|
physical-strategy: com.example.sns.config.ImprovedNamingStrategy
|
||||||
|
dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
ddl-auto: update
|
||||||
|
properties:
|
||||||
|
hibernate:
|
||||||
|
format_sql: true
|
||||||
|
show-sql: true
|
||||||
|
|
||||||
|
datasource:
|
||||||
|
hikari:
|
||||||
|
maximum-pool-size: 4
|
||||||
|
url: jdbc:postgresql://ec2-44-209-24-62.compute-1.amazonaws.com/daipn3u0kdtqj
|
||||||
|
username: xckqpuxwsicvud
|
||||||
|
password: bc61f9c95d489227fe1a29eba14d2547c7185d449f081ef49f964b9d6bd1f110
|
||||||
|
platform: postgres
|
||||||
|
driver-class-name: org.postgresql.Driver
|
||||||
|
|
||||||
Reference in New Issue
Block a user