Skip to content
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
19 changes: 11 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'org.springframework.boot' version '3.5.7'
id 'io.spring.dependency-management' version '1.1.7'
id 'com.diffplug.spotless' version '6.25.0'
id 'checkstyle'
}

group = 'opensource'
Expand Down Expand Up @@ -66,26 +67,28 @@ tasks.named('test') {
useJUnitPlatform()
}

apply plugin: 'checkstyle'
tasks.register("checkstyle") {
dependsOn("checkstyleMain", "checkstyleTest")
}

checkstyle {
toolVersion = '10.12.0'
configFile = file('config/checkstyle/google_checks.xml')
toolVersion = "10.12.0"

configFile = file("${rootDir}/config/checkstyle/google_checks.xml")
}

tasks.withType(Checkstyle) {
tasks.withType(Checkstyle).configureEach {
reports {
xml.required.set(true)
html.required.set(true)
}
}

// Spotless 적용
apply plugin: 'com.diffplug.spotless'

spotless {
java {
googleJavaFormat()
eclipse().configFile file("${rootDir}/config/checkstyle/checkstyle_eclipse_format.xml")
target 'src/**/*.java'
trimTrailingWhitespace()
endWithNewline()
}
}
42 changes: 42 additions & 0 deletions config/checkstyle/checkstyle_eclipse_format.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="CheckstyleCompliant_v3" version="12">

<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.continuation_indentation" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="4"/>

<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>

<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="insert"/>

<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="false"/>

<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.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>

<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_around_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_around_binary_operator" value="insert"/>

<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
</profile>
</profiles>
42 changes: 39 additions & 3 deletions config/checkstyle/google_checks.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
<?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">
<property name="charset" value="UTF-8"/>

<module name="FileLength">
<property name="max" value="3000"/>
</module>

<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>

<module name="LineLength">
<property name="max" value="200"/>
</module>

<module name="TreeWalker">
<!-- 최소 규칙만 적용 -->
<module name="WhitespaceAfter"/>

<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="4"/>
<property name="tabWidth" value="4"/>
<property name="arrayInitIndent" value="16"/>
</module>

<module name="UnusedImports"/>

<module name="TypeName"/>
<module name="MethodName"/>
<module name="ParameterName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>

<module name="LeftCurly"/>
<module name="RightCurly"/>

<module name="EmptyStatement"/>
<module name="FallThrough"/>
</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