-
Notifications
You must be signed in to change notification settings - Fork 0
test api 추가 #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test api 추가 #62
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||||||||||||||||||
| package com.example.FixLog.tset; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||||||||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||||||||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||||||||||||||||||||||||||||||||||
| import org.springframework.web.bind.annotation.RestController; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @RestController | ||||||||||||||||||||||||||||||||||||
| public class TestController { | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @Autowired | ||||||||||||||||||||||||||||||||||||
| private TestMemberRepository testMemberRepository; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @GetMapping("test/api") | ||||||||||||||||||||||||||||||||||||
| public String test() { | ||||||||||||||||||||||||||||||||||||
| return "this is test."; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @PostMapping("test/rds") | ||||||||||||||||||||||||||||||||||||
| public String testRds() { | ||||||||||||||||||||||||||||||||||||
| TestMember member = new TestMember(1L, "test", "1234"); | ||||||||||||||||||||||||||||||||||||
| testMemberRepository.save(member); | ||||||||||||||||||||||||||||||||||||
| return "ok"; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 하드코딩된 값과 수동 ID 설정 문제 하드코딩된 값 사용과 수동 ID 설정은 다음 문제들을 야기할 수 있습니다:
-@PostMapping("test/rds")
-public String testRds() {
- TestMember member = new TestMember(1L, "test", "1234");
- testMemberRepository.save(member);
- return "ok";
-}
+@PostMapping("test/rds")
+public ResponseEntity<String> testRds(@RequestBody TestMemberRequest request) {
+ try {
+ TestMember member = new TestMember(null, request.getName(), request.getPassword());
+ testMemberRepository.save(member);
+ return ResponseEntity.ok("Member saved successfully");
+ } catch (Exception e) {
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body("Failed to save member: " + e.getMessage());
+ }
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||||||||||||||
| package com.example.FixLog.tset; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import jakarta.persistence.Entity; | ||||||||||||||||||||||||||||||||||||||
| import jakarta.persistence.Id; | ||||||||||||||||||||||||||||||||||||||
| import jakarta.persistence.Table; | ||||||||||||||||||||||||||||||||||||||
| import lombok.AllArgsConstructor; | ||||||||||||||||||||||||||||||||||||||
| import lombok.NoArgsConstructor; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| @Entity | ||||||||||||||||||||||||||||||||||||||
| @Table | ||||||||||||||||||||||||||||||||||||||
| @NoArgsConstructor | ||||||||||||||||||||||||||||||||||||||
| @AllArgsConstructor | ||||||||||||||||||||||||||||||||||||||
| public class TestMember { | ||||||||||||||||||||||||||||||||||||||
| @Id | ||||||||||||||||||||||||||||||||||||||
| private Long id; | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion ID 필드에 @GeneratedValue 어노테이션 추가 필요 ID 필드에 @GeneratedValue 어노테이션이 없어서 수동으로 ID를 설정해야 합니다. 이는 중복 키 오류를 발생시킬 수 있습니다. @Id
+@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| private String name; | ||||||||||||||||||||||||||||||||||||||
| private String password; | ||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 보안 위험: 평문 비밀번호 저장 비밀번호를 평문으로 저장하는 것은 보안상 위험합니다. Spring Security의 PasswordEncoder를 사용하여 암호화하는 것을 권장합니다. 🤖 Prompt for AI Agents
Comment on lines
+11
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Getter/Setter 메서드 또는 @DaTa 어노테이션 누락 JPA 엔티티와 JSON 직렬화를 위해 getter/setter 메서드가 필요합니다. Lombok의 @DaTa 어노테이션을 추가하는 것을 권장합니다. @Entity
@Table
@NoArgsConstructor
@AllArgsConstructor
+@Data
public class TestMember {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.example.FixLog.tset; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface TestMemberRepository extends JpaRepository<TestMember, Long> { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
생성자 주입 방식 사용 권장
필드 주입(@Autowired) 대신 생성자 주입을 사용하는 것이 권장됩니다.
📝 Committable suggestion
🤖 Prompt for AI Agents