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
25 changes: 0 additions & 25 deletions .github/workflows/auto-assign.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/code-style-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Java Code Style Check

on:
pull_request:
branches: ['**']
push:
branches: ['**']
workflow_dispatch:

jobs:
style-check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run Spotless and Checkstyle
run: |
set -e
./gradlew spotlessCheck --no-daemon
./gradlew checkstyleMain checkstyleTest --no-daemon
shell: bash

- name: Show summary
run: |
if [ $? -eq 0 ]; then
echo "🎉 Code style checks passed!"
else
echo "❌ Code style violations detected!"
echo "Please run './gradlew spotlessApply' locally and fix Checkstyle issues."
exit 1
fi
shell: bash
25 changes: 25 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
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'
}

group = 'opensource'
Expand Down Expand Up @@ -64,3 +65,27 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

apply plugin: 'checkstyle'

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

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

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

spotless {
java {
googleJavaFormat()
target 'src/**/*.java'
}
}
10 changes: 10 additions & 0 deletions config/checkstyle/google_checks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!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>
</module>
7 changes: 3 additions & 4 deletions src/main/java/opensource/bravest/BravestApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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
@@ -1,9 +1,12 @@
package opensource.bravest.domain.chatList.controller;

import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListCreateRequest;
import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListResponse;
import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListUpdateRequest;
import static opensource.bravest.domain.chatList.dto.ChatListDto.ChatListCreateRequest;

import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import opensource.bravest.domain.chatList.service.ChatListService;
import opensource.bravest.global.apiPayload.ApiResponse;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -15,47 +18,42 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import jakarta.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/chatlists")
@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
@@ -1,53 +1,51 @@
package opensource.bravest.domain.chatList.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import opensource.bravest.domain.chatList.entity.ChatList;

import java.time.LocalDateTime;
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();
}
}
}
}
Loading
Loading