Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0.1 #381

Merged
merged 10 commits into from
Sep 17, 2024
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ jobs:

- name: docker image λΉŒλ“œ 및 ν‘Έμ‹œ (Spring)
run: |
docker build --platform linux/amd64 -t makerscrew/main .
docker push makerscrew/main
docker build --platform linux/amd64 -t makerscrew/main:develop .
docker push makerscrew/main:develop
working-directory: ${{ env.working-directory-spring }}

- name: docker image λΉŒλ“œ 및 ν‘Έμ‹œ (nestjs)
run: |
docker build --platform linux/amd64 -t makerscrew/server .
docker push makerscrew/server
docker build --platform linux/amd64 -t makerscrew/server:develop .
docker push makerscrew/server:develop
working-directory: ${{ env.working-directory-nestjs }}

- name: 도컀 μ»¨ν…Œμ΄λ„ˆ μ‹€ν–‰
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ jobs:

- name: docker image λΉŒλ“œ 및 ν‘Έμ‹œ (Spring)
run: |
docker build --platform linux/amd64 -t makerscrew/main .
docker push makerscrew/main
docker build --platform linux/amd64 -t makerscrew/main:production .
docker push makerscrew/main:production
working-directory: ${{ env.working-directory-spring }}

- name: docker image λΉŒλ“œ 및 ν‘Έμ‹œ (nestjs)
run: |
docker build --platform linux/amd64 -t makerscrew/server .
docker push makerscrew/server
docker build --platform linux/amd64 -t makerscrew/server:production .
docker push makerscrew/server:production
working-directory: ${{ env.working-directory-nestjs }}

- name: 도컀 μ»¨ν…Œμ΄λ„ˆ μ‹€ν–‰
Expand Down
3 changes: 3 additions & 0 deletions main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ dependencies {

// csv κ΄€λ ¨
implementation 'com.opencsv:opencsv:5.5.2'

// prometheus
implementation 'io.micrometer:micrometer-registry-prometheus'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.sopt.makers.crew.main.advertisement.dto;

import java.time.LocalDateTime;

import org.sopt.makers.crew.main.entity.advertisement.Advertisement;

import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -12,6 +14,10 @@
@Schema(name = "AdvertisementImageDto", description = "κ΄‘κ³  ꡬ쒌 이미지 Dto")
public class AdvertisementGetDto {

@Schema(description = "κ΄‘κ³  id", example = "3")
@NotNull
private final Integer advertisementId;

@Schema(description = "[Desktop] κ΄‘κ³  ꡬ쒌 이미지 url", example = "[pc 버전 url ν˜•μ‹]")
@NotNull
private final String desktopImageUrl;
Expand All @@ -24,8 +30,13 @@ public class AdvertisementGetDto {
@NotNull
private final String advertisementLink;

@Schema(description = "κ΄‘κ³  κ²Œμ‹œ μ‹œμž‘μΌ", example = "2024-07-31T00:00:00")
@NotNull
private final LocalDateTime advertisementStartDate;

public static AdvertisementGetDto of(Advertisement advertisement) {
return new AdvertisementGetDto(advertisement.getAdvertisementDesktopImageUrl(),
advertisement.getAdvertisementMobileImageUrl(), advertisement.getAdvertisementLink());
return new AdvertisementGetDto(advertisement.getId(), advertisement.getAdvertisementDesktopImageUrl(),
advertisement.getAdvertisementMobileImageUrl(), advertisement.getAdvertisementLink(),
advertisement.getAdvertisementStartDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,6 @@ ResponseEntity<CommentV2GetCommentsResponseDto> getComments(
@Valid @ModelAttribute @Parameter(hidden = true) CommentV2GetCommentsQueryDto request,
Principal principal);

@Operation(summary = "[TEMP] λͺ¨μž„ κ²Œμ‹œκΈ€ λŒ“κΈ€ 리슀트 쑰회")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "성곡"),
})
@Parameters({
@Parameter(name = "page", description = "νŽ˜μ΄μ§€, default = 1", example = "1", schema = @Schema(type = "integer", format = "int32")),
@Parameter(name = "take", description = "κ°€μ Έμ˜¬ 데이터 개수, default = 12", example = "50", schema = @Schema(type = "integer", format = "int32")),
@Parameter(name = "postId", description = "κ²Œμ‹œκΈ€ id", example = "3", schema = @Schema(type = "integer", format = "int32"))})
ResponseEntity<TempResponseDto<CommentV2GetCommentsResponseDto>> getCommentsTemp(
@Valid @ModelAttribute @Parameter(hidden = true) CommentV2GetCommentsQueryDto request,
Principal principal);

@Operation(summary = "λͺ¨μž„ κ²Œμ‹œκΈ€ λŒ“κΈ€ μ’‹μ•„μš” ν† κΈ€")
@ResponseStatus(HttpStatus.CREATED)
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,6 @@ public ResponseEntity<CommentV2GetCommentsResponseDto> getComments(
return ResponseEntity.status(HttpStatus.OK).body(commentDtos);
}

@Override
@GetMapping("/temp")
public ResponseEntity<TempResponseDto<CommentV2GetCommentsResponseDto>> getCommentsTemp(
@Valid @ModelAttribute @Parameter(hidden = true) CommentV2GetCommentsQueryDto request,
Principal principal) {

Integer userId = UserUtil.getUserId(principal);
CommentV2GetCommentsResponseDto commentDtos = commentV2Service.getComments(request.getPostId(),
request.getPage(), request.getTake(), userId);

return ResponseEntity.status(HttpStatus.OK).body(TempResponseDto.of(commentDtos));
}

@Override
@PostMapping("/{commentId}/like")
public ResponseEntity<CommentV2SwitchCommentLikeResponseDto> switchCommentLike(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.sopt.makers.crew.main.common.config;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "org.sopt.makers.crew.main.entity", // 첫번째 DBκ°€ μžˆλŠ” νŒ¨ν‚€μ§€(폴더) 경둜
entityManagerFactoryRef = "primaryEntityManagerFactory", // EntityManager의 이름
transactionManagerRef = "primaryTransactionManager" // νŠΈλžœμž­μ…˜ λ§€λ‹ˆμ €μ˜ 이름
)
@Profile({"local", "dev", "prod"})
public class CrewDatabaseConfig {

@Bean
@Primary
@ConfigurationProperties("spring.datasource")
public DataSource primaryDatasourceProperties() {
return DataSourceBuilder.create().build();
}

@Bean(name = "primaryEntityManagerFactory")
@Primary
public LocalContainerEntityManagerFactoryBean primaryEntityManagerFactory() {
DataSource dataSource = primaryDatasourceProperties();

LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPackagesToScan("org.sopt.makers.crew.main.entity");

HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setShowSql(true);
em.setJpaVendorAdapter(vendorAdapter);

Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
properties.put("hibernate.hbm2ddl.auto", "validate");
properties.put("hibernate.format_sql", true);
properties.put("hibernate.physical_naming_strategy", "org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy");
properties.put("hibernate.globally_quoted_identifiers", true);
em.setJpaPropertyMap(properties);

return em;
}

@Bean(name = "primaryTransactionManager")
@Primary
public PlatformTransactionManager primaryTransactionManager(
final @Qualifier("primaryEntityManagerFactory") LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean
) {
return new JpaTransactionManager(Objects.requireNonNull(localContainerEntityManagerFactoryBean.getObject()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.sopt.makers.crew.main.common.config;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "org.sopt.makers.crew.main.external.playground.entity",
entityManagerFactoryRef = "secondEntityManagerFactory",
transactionManagerRef = "secondTransactionManager"
)
@Profile({"local", "dev", "prod"})
public class PlaygroundDataSourceConfig {
@Bean
@ConfigurationProperties("spring.playground-datasource")
public DataSource secondDatasourceProperties() {
return DataSourceBuilder.create().build();
}

@Bean(name = "secondEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean secondEntityManagerFactory() {
DataSource dataSource = secondDatasourceProperties();

LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPackagesToScan("org.sopt.makers.crew.main.external.playground.entity");

HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setShowSql(true);
em.setJpaVendorAdapter(vendorAdapter);

Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
properties.put("hibernate.hbm2ddl.auto", "validate");
properties.put("hibernate.format_sql", true);
properties.put("hibernate.physical_naming_strategy", "org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy");
properties.put("hibernate.globally_quoted_identifiers", true);
em.setJpaPropertyMap(properties);

return em;
}

@Bean(name = "secondTransactionManager")
public PlatformTransactionManager secondTransactionManager(
final @Qualifier("secondEntityManagerFactory") LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean
) {
return new JpaTransactionManager(Objects.requireNonNull(localContainerEntityManagerFactoryBean.getObject()));
}
}
Loading
Loading