Skip to content

Commit

Permalink
refactor: 클래스명 시작 대문자로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jucheolkang committed Jan 14, 2024
1 parent a9bd5ea commit c55dc0d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import org.idiot.yesslave.global.exception.BusinessExceptionHandler;
import org.idiot.yesslave.global.exception.errorCode;
import org.idiot.yesslave.todo.domain.todo;
import org.idiot.yesslave.todo.dto.saveDto;
import org.idiot.yesslave.todo.dto.updateDto;
import org.idiot.yesslave.todo.repository.todoRepository;
import org.idiot.yesslave.todo.dto.SaveDto;
import org.idiot.yesslave.todo.dto.UpdateDto;
import org.idiot.yesslave.todo.repository.TodoRepository;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
Expand All @@ -16,19 +16,19 @@
@Service
@RequiredArgsConstructor
@Transactional
public class todoService {
private final todoRepository todoRepository ;
public class TodoService {
private final TodoRepository todoRepository ;

// 저장
public void save(saveDto saveDto) {
public void save(SaveDto saveDto) {
todoRepository.save(todo.builder()
.todo(saveDto.getTodo())
.registerDate(time())
.build());
}

// 수정
public void update(Long id, updateDto updateDto) {
public void update(Long id, UpdateDto updateDto) {
todo todo = existId(id);
deleteStatus(todo);
todo.update(updateDto.getTodo(), time());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
// cannot deserialize from Object value (no delegate- or property-based Creator)에러로 인해 기본 생성자 필요
public class saveDto {
public class SaveDto {
private String todo;
@Builder
public saveDto(String todo) {
public SaveDto(String todo) {
this.todo = todo;
}

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

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class updateDto {
public class UpdateDto {
private String todo;

public updateDto(String todo) {
public UpdateDto(String todo) {
this.todo = todo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import org.idiot.yesslave.todo.domain.todo;
import org.springframework.data.jpa.repository.JpaRepository;

public interface todoRepository extends JpaRepository<todo,Long>{
public interface TodoRepository extends JpaRepository<todo,Long>{
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
package org.idiot.yesslave.todo.ui;

import lombok.RequiredArgsConstructor;
import org.idiot.yesslave.todo.application.todoService;
import org.idiot.yesslave.todo.dto.saveDto;
import org.idiot.yesslave.todo.dto.updateDto;
import org.idiot.yesslave.todo.application.TodoService;
import org.idiot.yesslave.todo.dto.SaveDto;
import org.idiot.yesslave.todo.dto.UpdateDto;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.net.URI;

@RestController
@RequestMapping("/todo")
@RequiredArgsConstructor
public class todoController {
public class TodoController {

private final todoService todoService;
private final TodoService todoService;

@PostMapping
public ResponseEntity todoSave(@RequestBody saveDto saveDto) {
public ResponseEntity todoSave(@RequestBody SaveDto saveDto) {
todoService.save(saveDto);
return ResponseEntity.ok("Todo save successfully");
}

@PatchMapping("/{id}")
public ResponseEntity todoUpdate(@PathVariable Long id, @RequestBody updateDto updateDto) {
public ResponseEntity todoUpdate(@PathVariable Long id, @RequestBody UpdateDto updateDto) {
todoService.update(id, updateDto);
return ResponseEntity.ok("Todo updated successfully");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import org.assertj.core.api.Assertions;
import org.idiot.yesslave.todo.domain.todo;
import org.idiot.yesslave.todo.dto.saveDto;
import org.idiot.yesslave.todo.repository.todoRepository;
import org.idiot.yesslave.todo.dto.SaveDto;
import org.idiot.yesslave.todo.repository.TodoRepository;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -23,15 +23,15 @@

@SpringBootTest
@AutoConfigureMockMvc
public class todoControllerTest {
public class TodoControllerTest {
@Autowired
ObjectMapper mapper;

@Autowired
MockMvc mvc;

@Autowired
private todoRepository todoRepository;
private TodoRepository todoRepository;

private static final String BASE_URL = "/todo";

Expand All @@ -43,7 +43,7 @@ void save_test() throws Exception {

//when
String body = mapper.writeValueAsString(
saveDto.builder()
SaveDto.builder()
.todo(text)
.build()
);
Expand Down Expand Up @@ -73,7 +73,7 @@ void patch_test() throws Exception {
.build());

String body = mapper.writeValueAsString(
saveDto.builder()
SaveDto.builder()
.todo(change_text)
.build()
);
Expand Down Expand Up @@ -103,7 +103,7 @@ void change_check_test() throws Exception {
.build());

//then
mvc.perform(post(BASE_URL + "/1")
mvc.perform(post(BASE_URL + "/2")
.contentType(MediaType.APPLICATION_JSON)
)
.andExpect(status().isOk())
Expand Down

0 comments on commit c55dc0d

Please sign in to comment.