Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ apply plugin: 'com.diffplug.spotless'

spotless {
java {
googleJavaFormat()
target 'src/**/*.java'

// Checkstyle XML 규칙을 완전히 재현할 수는 없지만, 기본 규칙 적용
// 들여쓰기 4칸, 중괄호 스타일, 라인 길이 제한
eclipse().configFile 'config/checkstyle/checkstyle_eclipse_format.xml'

// 혹은 Google Java Format 사용
// googleJavaFormat('1.16.0')
}
}

}
26 changes: 26 additions & 0 deletions config/checkstyle/checkstyle_eclipse_format.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<profiles version="12">
<profile kind="CodeFormatterProfile" name="CheckstyleLike" version="12">
<!-- 탭/공백 설정: 들여쓰기 4칸, 스페이스 사용 -->
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>

```
<!-- 한 줄 최대 길이 -->
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>

<!-- 클래스/메소드/블록 중괄호 위치 -->
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>

<!-- 빈 타입, 메소드 블록에서 줄바꿈 -->
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="true"/>
</profile>
```

</profiles>
34 changes: 31 additions & 3 deletions config/checkstyle/google_checks.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
<!-- 공통 규칙 적용 -->
<module name="TreeWalker">
<!-- 최소 규칙만 적용 -->
<!-- 클래스/인터페이스 이름은 대문자로 시작 -->
<module name="TypeName"/>

<!-- 메소드 이름은 소문자로 시작, camelCase -->
<module name="MethodName"/>

<!-- 변수 이름은 소문자로 시작, camelCase -->
<module name="LocalVariableName"/>

<!-- 들여쓰기: 4칸 -->
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="tabWidth" value="4"/>
<property name="braceAdjustment" value="0"/>
</module>

<!-- 한 줄 최대 길이 제한 -->
<module name="LineLength">
<property name="max" value="120"/>
</module>

<!-- 중괄호 스타일 체크 -->
<module name="LeftCurly">
<property name="option" value="eol"/>
</module>
<module name="RightCurly">
<property name="option" value="alone"/>
</module>
</module>
</module>
</module>
6 changes: 3 additions & 3 deletions src/main/java/opensource/bravest/BravestApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@SpringBootApplication
public class BravestApplication {

public static void main(String[] args) {
SpringApplication.run(BravestApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(BravestApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,36 @@
@RequiredArgsConstructor
public class ChatListController {

private final ChatListService chatListService;

@PostMapping
public ApiResponse<ChatListResponse> createChatList(
@Valid @RequestBody ChatListCreateRequest request) {
ChatListResponse response = chatListService.createChatList(request);
return ApiResponse.onSuccess(response);
}

@GetMapping("/room/{roomId}")
public ApiResponse<List<ChatListResponse>> getChatListsByRoomId(@PathVariable Long roomId) {
List<ChatListResponse> response = chatListService.getChatListsByRoomId(roomId);
return ApiResponse.onSuccess(response);
}

@GetMapping("/{id}")
public ApiResponse<ChatListResponse> getChatListById(@PathVariable Long id) {
ChatListResponse response = chatListService.getChatListById(id);
return ApiResponse.onSuccess(response);
}

@PutMapping("/{id}")
public ApiResponse<ChatListResponse> updateChatList(
@PathVariable Long id, @Valid @RequestBody ChatListUpdateRequest request) {
ChatListResponse response = chatListService.updateChatList(id, request);
return ApiResponse.onSuccess(response);
}

@DeleteMapping("/{id}")
public ApiResponse<Void> deleteChatList(@PathVariable Long id) {
chatListService.deleteChatList(id);
return ApiResponse.onSuccess(null);
}
private final ChatListService chatListService;

@PostMapping
public ApiResponse<ChatListResponse> createChatList(@Valid @RequestBody ChatListCreateRequest request) {
ChatListResponse response = chatListService.createChatList(request);
return ApiResponse.onSuccess(response);
}

@GetMapping("/room/{roomId}")
public ApiResponse<List<ChatListResponse>> getChatListsByRoomId(@PathVariable Long roomId) {
List<ChatListResponse> response = chatListService.getChatListsByRoomId(roomId);
return ApiResponse.onSuccess(response);
}

@GetMapping("/{id}")
public ApiResponse<ChatListResponse> getChatListById(@PathVariable Long id) {
ChatListResponse response = chatListService.getChatListById(id);
return ApiResponse.onSuccess(response);
}

@PutMapping("/{id}")
public ApiResponse<ChatListResponse> updateChatList(@PathVariable Long id,
@Valid @RequestBody ChatListUpdateRequest request) {
ChatListResponse response = chatListService.updateChatList(id, request);
return ApiResponse.onSuccess(response);
}

@DeleteMapping("/{id}")
public ApiResponse<Void> deleteChatList(@PathVariable Long id) {
chatListService.deleteChatList(id);
return ApiResponse.onSuccess(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,40 @@

public class ChatListDto {

// 1. 아이디어 생성 요청 DTO (Create Request)
@Getter
@Setter
public static class ChatListCreateRequest {

private Long roomId;

private String content;

private Long registeredBy;
}

// 2. 아이디어 수정 요청 DTO (Update Request)
@Getter
@Setter
public static class ChatListUpdateRequest {

// 아이디어 내용 수정만 가정
private String content;
}

@Getter
@Builder
public static class ChatListResponse {
private Long id;
private Long roomId;
private String content;
private Long registeredBy;
private LocalDateTime createdAt;

public static ChatListResponse fromEntity(ChatList chatList) {
return ChatListResponse.builder()
.id(chatList.getId())
.roomId(chatList.getRoomId())
.content(chatList.getContent())
.registeredBy(chatList.getRegisteredBy().getId())
.createdAt(chatList.getCreatedAt())
.build();
// 1. 아이디어 생성 요청 DTO (Create Request)
@Getter
@Setter
public static class ChatListCreateRequest {

private Long roomId;

private String content;

private Long registeredBy;
}

// 2. 아이디어 수정 요청 DTO (Update Request)
@Getter
@Setter
public static class ChatListUpdateRequest {

// 아이디어 내용 수정만 가정
private String content;
}

@Getter
@Builder
public static class ChatListResponse {
private Long id;
private Long roomId;
private String content;
private Long registeredBy;
private LocalDateTime createdAt;

public static ChatListResponse fromEntity(ChatList chatList) {
return ChatListResponse.builder().id(chatList.getId()).roomId(chatList.getRoomId())
.content(chatList.getContent()).registeredBy(chatList.getRegisteredBy().getId())
.createdAt(chatList.getCreatedAt()).build();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,41 @@
@Table(name = "chat_list")
public class ChatList {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "room_id", nullable = false)
private AnonymousRoom room;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "room_id", nullable = false)
private AnonymousRoom room;

@NotNull
@Column(length = 255)
private String content;
@NotNull
@Column(length = 255)
private String content;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "profile_id", nullable = false)
private AnonymousProfile registeredBy;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "profile_id", nullable = false)
private AnonymousProfile registeredBy;

@CreationTimestamp private LocalDateTime createdAt;
@CreationTimestamp
private LocalDateTime createdAt;

@Builder
public ChatList(AnonymousRoom room, String content, AnonymousProfile registeredBy) {
this.room = room;
this.content = content;
this.registeredBy = registeredBy;
}
@Builder
public ChatList(AnonymousRoom room, String content, AnonymousProfile registeredBy) {
this.room = room;
this.content = content;
this.registeredBy = registeredBy;
}

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

public Long getRoomId() {
return this.room.getId();
}
public Long getRoomId() {
return this.room.getId();
}

public Long getProfileId() {
return this.registeredBy.getId();
}
public Long getProfileId() {
return this.registeredBy.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

public interface ChatListRepository extends JpaRepository<ChatList, Long> {

@Query("SELECT c FROM ChatList c WHERE c.room.id = :roomId ORDER BY c.createdAt DESC")
List<ChatList> findAllByRoomId(Long roomId);
@Query("SELECT c FROM ChatList c WHERE c.room.id = :roomId ORDER BY c.createdAt DESC")
List<ChatList> findAllByRoomId(Long roomId);
}
Loading
Loading