Skip to content

Commit

Permalink
feat: 유저 임시 UUID 발급
Browse files Browse the repository at this point in the history
  • Loading branch information
osoohynn committed Nov 29, 2024
1 parent 14608b6 commit 511bf64
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/com/project/oof/user/controller/UserController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.project.oof.user.controller;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController
@RequestMapping("/users")
public class UserController {

@GetMapping("create")
public UUID getUserId() {
return UUID.randomUUID();
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/project/oof/user/service/UserService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.project.oof.user.service;

import com.project.oof.gpt.service.ChatHistoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Service
@RequiredArgsConstructor
public class UserService {

private final Map<UUID, ChatHistoryService> userChatHistories = new HashMap<>();

public ChatHistoryService getChatHistory(UUID userId) {
return userChatHistories.computeIfAbsent(userId, id -> new ChatHistoryService());
}

public void addUser(UUID userId) {
userChatHistories.putIfAbsent(userId, new ChatHistoryService());
}

}

0 comments on commit 511bf64

Please sign in to comment.