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
3 changes: 3 additions & 0 deletions src/backend/workspace_server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.kafka:spring-kafka-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

//common-module
implementation project(":common_module")
}

tasks.named('test') {
Expand Down
3 changes: 3 additions & 0 deletions src/backend/workspace_server/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
rootProject.name = 'workspace_server'

include(":common_module")
findProject(":common_module")?.projectDir = file("../common_module")
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;

@ConfigurationPropertiesScan
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {
"com.jootalkpia.workspace_server",
"com.jootalkpia.passport",
"com.jootalkpia.config",
})
public class WorkspaceServerApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public class WebConfig {
registry.addMapping("/**") // 모든 경로 허용
.allowedOrigins("*") // 프론트엔드 도메인 허용
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 허용할 HTTP 메서드
.allowedHeaders("*") // 모든 헤더 허용
.allowCredentials(false); // 쿠키 포함 요청 허용
.allowedHeaders("*"); // 모든 헤더 허용
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jootalkpia.workspace_server.controller;


//import com.jootalkpia.aop.JootalkpiaAuthenticationContext;
import com.jootalkpia.workspace_server.dto.ChannelListDTO;
import com.jootalkpia.workspace_server.dto.SimpleChannel;
import com.jootalkpia.workspace_server.service.WorkSpaceService;
Expand All @@ -15,6 +14,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jootalkpia.passport.anotation.CurrentUser;
import com.jootalkpia.passport.component.UserInfo;

@RestController
@Slf4j
Expand All @@ -23,39 +24,38 @@
public class WorkSpaceController {

private final WorkSpaceService workSpaceService;
private final Long userId = 1L;//JootalkpiaAuthenticationContext.getUserInfo().userId();

@GetMapping("/{workspaceId}/channels")
public ResponseEntity<ChannelListDTO> getChannels(@PathVariable Long workspaceId) {
public ResponseEntity<ChannelListDTO> getChannels(@PathVariable Long workspaceId, @CurrentUser UserInfo userInfo) {
// 유효성 검증
ValidationUtils.validateWorkSpaceId(workspaceId);
log.info("Getting channels for workspace with id: {}", workspaceId);

ChannelListDTO channelListDTO = workSpaceService.getChannels(userId, workspaceId);
ChannelListDTO channelListDTO = workSpaceService.getChannels(userInfo.userId(), workspaceId);
return ResponseEntity.ok().body(channelListDTO);
}

@PostMapping("/{workspaceId}/channels")
public ResponseEntity<SimpleChannel> createChannel(@PathVariable Long workspaceId, @RequestParam String channelName) {
public ResponseEntity<SimpleChannel> createChannel(@PathVariable Long workspaceId, @RequestParam String channelName, @CurrentUser UserInfo userInfo) {
// 유효성 검증
ValidationUtils.validateWorkSpaceId(workspaceId);
log.info("Creating channels for workspace with id: {}", workspaceId);

SimpleChannel channel = workSpaceService.createChannel(workspaceId, channelName,userId);
SimpleChannel channel = workSpaceService.createChannel(workspaceId, channelName, userInfo.userId());

// 유저를 생성된 채널에 가입시킴
workSpaceService.addMember(workspaceId, userId, channel.getChannelId());
workSpaceService.addMember(workspaceId, userInfo.userId(), channel.getChannelId());

return ResponseEntity.ok().body(channel);
}

@PostMapping("/{workspaceId}/channels/{channelId}/members")
public ResponseEntity<?> addMember(@PathVariable Long workspaceId, @PathVariable Long channelId) {
public ResponseEntity<?> addMember(@PathVariable Long workspaceId, @PathVariable Long channelId, @CurrentUser UserInfo userInfo) {

ValidationUtils.validateWorkSpaceId(workspaceId);
ValidationUtils.validateChannelId(channelId);
log.info("Adding member for workspace with id: {} {}", workspaceId, channelId);

return ResponseEntity.ok(workSpaceService.addMember(workspaceId, userId, channelId));
return ResponseEntity.ok(workSpaceService.addMember(workspaceId, userInfo.userId(), channelId));
}
}