-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
200c0a2
commit df428b6
Showing
55 changed files
with
652 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ out/ | |
### VS Code ### | ||
.vscode/ | ||
|
||
*.yml | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: '3' | ||
|
||
services: | ||
mysql: | ||
container_name: mysql_member | ||
image: mysql/mysql-server:5.7 | ||
environment: | ||
MYSQL_ROOT_HOST: '%' | ||
MYSQL_USER: "sausage" | ||
MYSQL_PASSWORD: "sausage" | ||
MYSQL_DATABASE: "member" | ||
ports: | ||
- "3306:3306" | ||
command: | ||
- "mysqld" | ||
- "--character-set-server=utf8mb4" | ||
- "--collation-server=utf8mb4_unicode_ci" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
rootProject.name = 'sausage-user-service' | ||
rootProject.name = 'sausage-member-api' |
11 changes: 7 additions & 4 deletions
11
...ervice/SausageUserServiceApplication.java → ...emberapi/SausageMemberApiApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
package com.ssg.sausageuserservice; | ||
package com.ssg.sausagememberapi; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
@EnableFeignClients | ||
@EnableJpaAuditing | ||
@EnableDiscoveryClient | ||
@SpringBootApplication | ||
public class SausageUserServiceApplication { | ||
public class SausageMemberApiApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SausageUserServiceApplication.class, args); | ||
SpringApplication.run(SausageMemberApiApplication.class, args); | ||
} | ||
} | ||
|
||
} |
18 changes: 9 additions & 9 deletions
18
...mon/advice/ControllerExceptionAdvice.java → ...mon/advice/ControllerExceptionAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...on/client/external/ExternalApiClient.java → ...on/client/external/ExternalApiClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ternal/dto/response/InternalResponse.java → ...ternal/dto/response/InternalResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/ssg/sausagememberapi/common/config/kafka/KafkaProducerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.ssg.sausagememberapi.common.config.kafka; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.apache.kafka.clients.producer.ProducerConfig; | ||
import org.apache.kafka.common.serialization.StringSerializer; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.kafka.core.DefaultKafkaProducerFactory; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
import org.springframework.kafka.core.ProducerFactory; | ||
|
||
|
||
@Configuration | ||
public class KafkaProducerConfig { | ||
|
||
@Value("${kafka.address}") | ||
private String bootstrapServer; | ||
|
||
@Bean | ||
public ProducerFactory<String, String> producerFactory() { | ||
Map<String, Object> configProps = producerFactoryConfig(); | ||
return new DefaultKafkaProducerFactory<>(configProps); | ||
} | ||
|
||
private Map<String, Object> producerFactoryConfig() { | ||
Map<String, Object> configProps = new HashMap<>(); | ||
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer); | ||
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); | ||
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); | ||
return configProps; | ||
} | ||
|
||
@Bean | ||
public KafkaTemplate<String, String> kafkaTemplate() { | ||
return new KafkaTemplate<>(producerFactory()); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/ssg/sausagememberapi/common/config/kafka/KafkaTopicConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.ssg.sausagememberapi.common.config.kafka; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.apache.kafka.clients.admin.AdminClientConfig; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.kafka.core.KafkaAdmin; | ||
|
||
@Configuration | ||
public class KafkaTopicConfig { | ||
|
||
@Value("${kafka.address}") | ||
private String bootstrapServer; | ||
|
||
@Bean | ||
public KafkaAdmin kafkaAdmin() { | ||
Map<String, Object> configs = new HashMap<>(); | ||
configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer); | ||
return new KafkaAdmin(configs); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ommon/config/querydsl/QueryDslConfig.java → ...ommon/config/querydsl/QueryDslConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/ssg/sausagememberapi/common/config/resolver/MbrId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.ssg.sausagememberapi.common.config.resolver; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface MbrId { | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/ssg/sausagememberapi/common/config/resolver/MbrIdResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.ssg.sausagememberapi.common.config.resolver; | ||
|
||
import com.ssg.sausagememberapi.common.exception.InternalServerException; | ||
import javax.validation.constraints.NotNull; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
|
||
@Component | ||
public class MbrIdResolver implements HandlerMethodArgumentResolver { | ||
|
||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
return parameter.hasParameterAnnotation(MbrId.class) && Long.class.equals(parameter.getParameterType()); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Object resolveArgument(@NotNull MethodParameter parameter, ModelAndViewContainer mavContainer, | ||
@NotNull NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { | ||
String mbrId = webRequest.getHeader("mbrId"); | ||
if (mbrId == null) { | ||
throw new InternalServerException( | ||
String.format("mbrId 를 가져오지 못했습니다. (%s - %s)", parameter.getClass(), parameter.getMethod())); | ||
} | ||
return Long.valueOf(mbrId); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../common/config/swagger/SwaggerConfig.java → .../common/config/swagger/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...erservice/common/dto/SuccessResponse.java → ...memberapi/common/dto/SuccessResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 19 additions & 6 deletions
25
...service/common/entity/BaseTimeEntity.java → ...gememberapi/common/entity/BaseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
package com.ssg.sausageuserservice.common.entity; | ||
package com.ssg.sausagememberapi.common.entity; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import java.time.LocalDateTime; | ||
import javax.persistence.Column; | ||
import javax.persistence.EntityListeners; | ||
import javax.persistence.MappedSuperclass; | ||
import lombok.Getter; | ||
import org.springframework.data.annotation.CreatedBy; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedBy; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class BaseTimeEntity { | ||
public class BaseEntity { | ||
|
||
@CreatedDate | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "Asia/Seoul") | ||
private LocalDateTime createdAt; | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") | ||
@Column(name = "REG_DTS") | ||
private LocalDateTime regDts; | ||
|
||
@LastModifiedDate | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "Asia/Seoul") | ||
private LocalDateTime updatedAt; | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") | ||
@Column(name = "MOD_DTS") | ||
private LocalDateTime modDts; | ||
|
||
@CreatedBy | ||
@Column(name = "REGPE_ID") | ||
private Long regpeId; | ||
|
||
@LastModifiedBy | ||
@Column(name = "MODPE_ID") | ||
private Long modpeId; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/ssg/sausagememberapi/common/entity/MbrAuditorAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.ssg.sausagememberapi.common.entity; | ||
|
||
import java.util.Optional; | ||
import javax.servlet.http.HttpServletRequest; | ||
import org.springframework.data.domain.AuditorAware; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.context.request.RequestContextHolder; | ||
import org.springframework.web.context.request.ServletRequestAttributes; | ||
|
||
@Component | ||
public class MbrAuditorAware implements AuditorAware<Long> { | ||
|
||
@Override | ||
public Optional<Long> getCurrentAuditor() { | ||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||
String mbrId = request.getHeader("mbrId"); | ||
|
||
if (mbrId == null) { | ||
return Optional.empty(); | ||
} | ||
return Optional.of(Long.valueOf(mbrId)); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...e/common/exception/BusinessException.java → ...i/common/exception/BusinessException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/common/exception/ConflictException.java → ...i/common/exception/ConflictException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.