Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ===== Build stage =====
FROM eclipse-temurin:17-jdk AS build
WORKDIR /app

# (1) Gradle wrapper & build files 먼저 복사 (캐시 효율)
COPY gradlew ./
COPY gradle gradle
COPY build.gradle* settings.gradle* ./

# gradlew 실행권한
RUN chmod +x gradlew

# (2) 소스 복사
COPY src src

# (3) 빌드 (테스트/체크 제외 + production 프로퍼티)
RUN ./gradlew --no-daemon clean bootJar -x test -x check -Pproduction

# ===== Run stage =====
FROM eclipse-temurin:17-jre
WORKDIR /app

COPY --from=build /app/build/libs/*.jar app.jar

# Railway는 PORT 환경변수를 줌
ENV PORT=8080
EXPOSE 8080

CMD ["sh", "-c", "java -Dserver.port=${PORT} -jar app.jar"]
34 changes: 18 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.7'
id 'java'
id 'org.springframework.boot' version '3.5.10'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.sprint.mission'
version = '0.0.1-SNAPSHOT'
description = 'Project for sprint mission'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.15'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
package com.sprint.mission.discodeit.controller;

import com.sprint.mission.discodeit.dto.LoginDto;
import com.sprint.mission.discodeit.dto.LoginResponseDto;
import com.sprint.mission.discodeit.service.AuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sprint.mission.discodeit.dto.LoginDto;
import com.sprint.mission.discodeit.dto.UserResponseDto;
import com.sprint.mission.discodeit.service.AuthService;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/auth")
@RequiredArgsConstructor
@Tag(name = "Auth", description = "Auth controller 입니다.")
public class AuthController {
private final AuthService authService;

@RequestMapping(value = "/login", method = RequestMethod.POST)
public ResponseEntity<UserResponseDto> login(@RequestBody LoginDto loginDto) {
return ResponseEntity.ok(authService.login(loginDto));
}
private final AuthService authService;

@RequestMapping(value = "/login", method = RequestMethod.POST)
@Operation(summary = "로그인", operationId = "login")
public ResponseEntity<LoginResponseDto> login(@Valid @RequestBody LoginDto loginDto) {
return ResponseEntity.ok(authService.login(loginDto));
}

}
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
package com.sprint.mission.discodeit.controller;

import com.sprint.mission.discodeit.dto.BinaryContentResponseDto;
import com.sprint.mission.discodeit.service.BinaryContentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.IOException;
import java.util.List;
import java.util.UUID;

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sprint.mission.discodeit.dto.BinaryContentResponseDto;
import com.sprint.mission.discodeit.service.BinaryContentService;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/binaryContent")
@RequestMapping("/api/binaryContents")
@RequiredArgsConstructor
@Tag(name = "BinaryContent", description = "BinaryContent contrlller 입니다.")
public class BinaryContentController {
private final BinaryContentService binaryContentService;

@RequestMapping(value = "/find", method = RequestMethod.GET)
public ResponseEntity<BinaryContentResponseDto> getBinaryContent(@RequestParam("binaryContentId") UUID id) throws
IOException {
return ResponseEntity.status(HttpStatus.OK).body(binaryContentService.findById(id));
}
private final BinaryContentService binaryContentService;

@RequestMapping(method = RequestMethod.GET)
@Operation(summary = "여러 첨부 파일 조회", operationId = "findAllByIdIn")
public ResponseEntity<List<BinaryContentResponseDto>> getBinaryContentByIds(
@Parameter(name = "binaryContentIds", description = "조회할 첨부 파일 ID 목록") @RequestParam("binaryContentIds") List<UUID> binaryContentIds)
throws
IOException {
return ResponseEntity.status(HttpStatus.OK)
.body(binaryContentService.findAllByIdIn(binaryContentIds));
}

@RequestMapping(value = "/{binaryContentId}", method = RequestMethod.GET)
@Operation(summary = "첨부 파일 조회", operationId = "find")
public ResponseEntity<BinaryContentResponseDto> getBinaryContent(
@Parameter(name = "binaryContentId", description = "조회할 첨부 파일 ID") @PathVariable("binaryContentId") UUID binaryContentId)
throws
IOException {
return ResponseEntity.status(HttpStatus.OK)
.body(binaryContentService.findById(binaryContentId));
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.sprint.mission.discodeit.controller;

import com.sprint.mission.discodeit.dto.ChannelPatchDto;
import com.sprint.mission.discodeit.dto.ChannelResponseDto;
import com.sprint.mission.discodeit.dto.PrivateChannelPostDto;
import com.sprint.mission.discodeit.dto.PublicChannelPostDto;
import com.sprint.mission.discodeit.service.ChannelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import java.util.UUID;

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -12,47 +21,52 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sprint.mission.discodeit.dto.ChannelPatchDto;
import com.sprint.mission.discodeit.dto.ChannelResponseDto;
import com.sprint.mission.discodeit.dto.PrivateChannelPostDto;
import com.sprint.mission.discodeit.dto.PublicChannelPostDto;
import com.sprint.mission.discodeit.service.ChannelService;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/channels")
@RequiredArgsConstructor
@Tag(name = "Channel", description = "Channel controller 입니다.")
public class ChannelController {
private final ChannelService channelService;

@RequestMapping(value = "/public", method = RequestMethod.POST)
public ResponseEntity<ChannelResponseDto> createPublicChannel(
@RequestBody PublicChannelPostDto publicChannelPostDto) {
return ResponseEntity.status(HttpStatus.CREATED).body(channelService.createPublicChannel(publicChannelPostDto));
}

@RequestMapping(value = "/private", method = RequestMethod.POST)
public ResponseEntity<ChannelResponseDto> createPrivateChannel(
@RequestBody PrivateChannelPostDto privateChannelPostDto) {
return ResponseEntity.status(HttpStatus.CREATED)
.body(channelService.createPrivateChannel(privateChannelPostDto));
}

@RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
public ResponseEntity<ChannelResponseDto> updatePublicChannel(@PathVariable UUID id,
@RequestBody ChannelPatchDto channelPatchDto) {
return ResponseEntity.status(HttpStatus.OK).body(channelService.update(id, channelPatchDto));
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<ChannelResponseDto> updatePublicChannel(@PathVariable UUID id) {
channelService.delete(id);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<ChannelResponseDto>> getChannelsByUserId(@RequestParam(value = "user") UUID userId) {
return ResponseEntity.status(HttpStatus.OK).body(channelService.findAllByUserId(userId));
}

private final ChannelService channelService;

@RequestMapping(value = "/public", method = RequestMethod.POST)
@Operation(summary = "Public Channel 생성", operationId = "create_3")
public ResponseEntity<ChannelResponseDto> createPublicChannel(
@Valid @RequestBody PublicChannelPostDto publicChannelPostDto) {
return ResponseEntity.status(HttpStatus.CREATED)
.body(channelService.createPublicChannel(publicChannelPostDto));
}

@RequestMapping(value = "/private", method = RequestMethod.POST)
@Operation(summary = "Private Channel 생성", operationId = "create_4")
public ResponseEntity<ChannelResponseDto> createPrivateChannel(
@RequestBody PrivateChannelPostDto privateChannelPostDto) {
return ResponseEntity.status(HttpStatus.CREATED)
.body(channelService.createPrivateChannel(privateChannelPostDto));
}

@RequestMapping(value = "/{channelId}", method = RequestMethod.PATCH)
@Operation(summary = "Channel 정보 수정", operationId = "update_3")
public ResponseEntity<ChannelResponseDto> updatePublicChannel(
@Parameter(name = "channelId", description = "수정할 Channel ID") @PathVariable UUID channelId,
@Valid @RequestBody ChannelPatchDto channelPatchDto) {
return ResponseEntity.status(HttpStatus.OK)
.body(channelService.update(channelId, channelPatchDto));
}

@RequestMapping(value = "/{channelId}", method = RequestMethod.DELETE)
@Operation(summary = "Channel 삭제", operationId = "delete_2")
public ResponseEntity<ChannelResponseDto> updatePublicChannel(
@Parameter(name = "channelId", description = "삭제할 Channel ID") @PathVariable UUID channelId) {
channelService.delete(channelId);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@RequestMapping(method = RequestMethod.GET)
@Operation(summary = "User가 참여 중인 Channel 목록 조회", operationId = "findAll_1")
public ResponseEntity<List<ChannelResponseDto>> getChannelsByUserId(
@Parameter(name = "userId", description = "조회할 User ID") @RequestParam(value = "userId") UUID userId) {
return ResponseEntity.status(HttpStatus.OK)
.body(channelService.findAllByUserId(userId));
}
}
Loading