Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Feb 27, 2024
1 parent d503004 commit 1e1fdfe
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 241 deletions.
41 changes: 28 additions & 13 deletions spring-code-for-deploy/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id 'jacoco'
id 'java'
id 'org.springframework.boot' version '3.0.9'
id 'io.spring.dependency-management' version '1.1.2'
Expand All @@ -17,34 +18,48 @@ configurations {
}
}

jacoco {
toolVersion = "0.8.11"
}

jacocoTestReport {
reports {
html.required = true
xml.required = true
}
}

jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.8
}
}
}

}


repositories {
mavenCentral()
}


dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

// runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
// actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.testng:testng:7.1.0'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

//h2
runtimeOnly 'com.h2database:h2'

// mysql
runtimeOnly 'com.mysql:mysql-connector-j'

// security
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'

}

tasks.named('test') {
useJUnitPlatform()
finalizedBy('jacocoTestReport')
}


This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ public class PostController {

private final PostService postService;

@GetMapping("{postId}")
public ResponseEntity<PostGetResponse> getPostById(
@PathVariable Long postId) {
return ResponseEntity.ok(postService.getById(postId));
}

@GetMapping
public ResponseEntity<List<PostGetResponse>> getPosts(
@RequestHeader(CUSTOM_AUTH_ID) Long memberId) {
return ResponseEntity.ok(postService.getPosts(memberId));
}

@PostMapping
public ResponseEntity<Void> createPost(
@RequestHeader(CUSTOM_AUTH_ID) Long memberId,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,15 @@ public class Post extends BaseTimeEntity {
@JoinColumn(name = "member_id")
private Member member;

@Column(name = "category_id")
private CategoryId categoryId;

@Builder
public Post(String title, String content, Member member) {
this.title = title;
this.content = content;
this.member = member;
}

public void updateContent(String content) {
public void updateContent(final String content) {
this.content = content;
}


public void addCategory(CategoryId categoryId) {
this.categoryId = categoryId;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.seminar.dto.response.post;

import com.example.seminar.domain.Category;
import com.example.seminar.domain.Post;
import lombok.Builder;

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

@Component
@RequiredArgsConstructor
public class MemberSaver {
public class MemberRegister {
private final MemberJpaRepository memberJpaRepository;

public Member save(Member member) {
public Member register(Member member) {
return memberJpaRepository.save(member);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Transactional(readOnly = true)
public class MemberService {

private final MemberSaver memberSaver;
private final MemberRegister memberRegister;
private final MemberRetriever memberRetriever;
private final MemberUpdater memberUpdater;
private final MemberRemover memberRemover;
Expand All @@ -36,7 +36,7 @@ public List<MemberGetResponse> getMembers() {
}
@Transactional
public String create(final MemberCreateRequest request) {
final Member member = memberSaver.save(Member.builder()
final Member member = memberRegister.register(Member.builder()
.name(request.name())
.nickname(request.nickname())
.age(request.age())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
@Component
@RequiredArgsConstructor
public class PostEditor {
public void updatePost() {

}

public void editContent(Post post, String content) {
post.updateContent(content);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.seminar.service.post;

import com.example.seminar.domain.Post;
import com.example.seminar.repository.PostJpaRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class PostRemover {

private final PostJpaRepository postJpaRepository;

public void remove(final Post post) {
postJpaRepository.delete(post);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.example.seminar.service.post;

import com.example.seminar.domain.Post;
import com.example.seminar.repository.PostJpaRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class PostSaver {

private final PostJpaRepository postJpaRepository;

public Post save(Post post) {
return postJpaRepository.save(post);
}
}
Loading

0 comments on commit 1e1fdfe

Please sign in to comment.