Skip to content

Commit

Permalink
fix: Service 매개변수 수정
Browse files Browse the repository at this point in the history
KEEKE132 committed May 26, 2024
1 parent 02c9ff4 commit 6a68ff0
Showing 5 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -22,13 +22,11 @@ public void commentCreate(@RequestParam("issueId") Long issueid,@RequestBody Com

@DeleteMapping
public void commentDelete(@RequestParam("commentId") Long commentid){
Comment comment=this.commentService.getComment(commentid);
this.commentService.delete(comment);
this.commentService.delete(commentid);
}

@PatchMapping
public void commentModify(@RequestParam("commentId") Long commentid, @RequestBody CommentRequest commentRequest){
Comment comment = this.commentService.getComment(commentid);
this.commentService.modify(comment,commentRequest.getMessage());
this.commentService.modify(commentid,commentRequest.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
import org.springframework.stereotype.Service;
import se.issuetrackingsystem.comment.domain.Comment;
import se.issuetrackingsystem.comment.repository.CommentRepository;
import se.issuetrackingsystem.common.exception.CustomException;
import se.issuetrackingsystem.common.exception.ErrorCode;
import se.issuetrackingsystem.issue.domain.Issue;
import se.issuetrackingsystem.issue.repository.IssueRepository;
import se.issuetrackingsystem.user.domain.User;
@@ -32,12 +34,14 @@ public Comment create(Long issueid, String content, Long authorid){
return comment;
}

public void modify(Comment comment,String content){
public void modify(Long commentid,String content){
Comment comment = this.commentRepository.findById(commentid).orElseThrow(()->new CustomException(ErrorCode.COMMENT_NOT_FOUND));
comment.setMessage(content);
this.commentRepository.save(comment);
}

public void delete(Comment comment){
public void delete(Long commentid){
Comment comment = this.commentRepository.findById(commentid).orElseThrow(()->new CustomException(ErrorCode.COMMENT_NOT_FOUND));
this.commentRepository.delete(comment);
}

Original file line number Diff line number Diff line change
@@ -47,20 +47,17 @@ public ResponseEntity<IssueResponse> issueDetail(@RequestParam("issueId") Long i

@DeleteMapping
public void issueDelete(@RequestParam("issueId") Long issueid){
Issue issue = this.issueService.getIssue(issueid);
this.issueService.delete(issue);
this.issueService.delete(issueid);
}

@PatchMapping
public void issueModify(@RequestBody IssueRequest issueRequest,@RequestParam("issueId") Long issueid){
Issue issue = this.issueService.getIssue(issueid);
this.issueService.modify(issue,issueRequest.getDescription(),issueRequest.getPriority());
this.issueService.modify(issueid,issueRequest.getDescription(),issueRequest.getPriority());
}

@PostMapping("/assignees")
public void issueSetAssignee(@RequestBody IssueRequest issueRequest,@RequestParam("issueId") Long issueid){
Issue issue = this.issueService.getIssue(issueid);
this.issueService.setAssignee(issue,issueRequest.getUserid(),issueRequest.getAssigneeid());
this.issueService.setAssignee(issueid,issueRequest.getUserid(),issueRequest.getAssigneeid());
}

@GetMapping("/{status}")
@@ -75,8 +72,7 @@ public ResponseEntity<List<IssueResponse>> issueCheckByStatus(@PathVariable("sta

@PatchMapping("/status")
public void issueChangeStatus(@RequestBody IssueRequest issueRequest,@RequestParam("issueId") Long issueid){
Issue issue = this.issueService.getIssue(issueid);
this.issueService.changeStatus(issueRequest.getUserid(),issue);
this.issueService.changeStatus(issueRequest.getUserid(),issueid);
}

@GetMapping("/assigned")
@@ -91,7 +87,7 @@ public ResponseEntity<List<IssueResponse>> issueCheckByAssignee(@RequestParam("u

@GetMapping("/candidates")
public ResponseEntity<User> issueCandidate(@RequestParam("issueId") Long issueid) {
User user = this.issueService.candidateUser(this.issueService.getIssue(issueid)).get();
User user = this.issueService.candidateUser(issueid).get();
return ResponseEntity.ok(user);
}

Original file line number Diff line number Diff line change
@@ -71,18 +71,21 @@ public List<Issue> getList(Long projectid, Issue.Status status){
return issues;
}

public void modify(Issue issue, String description, Issue.Priority priority){
public void modify(Long issueid, String description, Issue.Priority priority){
Issue issue = this.issueRepository.findById(issueid).orElseThrow(()->new CustomException(ErrorCode.ISSUE_NOT_FOUND));
issue.setDescription(description);
issue.setUpdated_at(LocalDateTime.now());
issue.setPriority(priority);
this.issueRepository.save(issue);
}

public void delete(Issue issue){
public void delete(Long issueid){
Issue issue = this.issueRepository.findById(issueid).orElseThrow(()->new CustomException(ErrorCode.ISSUE_NOT_FOUND));
this.issueRepository.delete(issue);
}

public void setAssignee(Issue issue,Long userid ,Long assigneeid){
public void setAssignee(Long issueid,Long userid ,Long assigneeid){
Issue issue = this.issueRepository.findById(issueid).orElseThrow(()->new CustomException(ErrorCode.ISSUE_NOT_FOUND));
User user = this.userRepository.findById(userid).orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND));
if (user.getRole() != "PL") {
throw new CustomException(ErrorCode.ROLE_FORBIDDEN);
@@ -92,7 +95,8 @@ public void setAssignee(Issue issue,Long userid ,Long assigneeid){
this.issueRepository.save(issue);
}

public void changeStatus(Long userid, Issue issue){
public void changeStatus(Long userid, Long issueid){
Issue issue = this.issueRepository.findById(issueid).orElseThrow(()->new CustomException(ErrorCode.ISSUE_NOT_FOUND));
if(issue.getStatus()== Issue.Status.NEW){
issue.setStatus(Issue.Status.ASSIGNED);
}
@@ -114,8 +118,9 @@ else if(issue.getStatus()== Issue.Status.REOPENED){
}
this.issueRepository.save(issue);
}
public Optional<User> candidateUser(Issue issue)
public Optional<User> candidateUser(Long issueid)
{
Issue issue = this.issueRepository.findById(issueid).orElseThrow(()->new CustomException(ErrorCode.ISSUE_NOT_FOUND));
Project project = issue.getProject();
List<User> users = this.userRepository.findAll();
ArrayList<User> devs = new ArrayList<>();
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@ class IssueTrackingSystemApplicationTests {
/* JUnit Test용 Data
Admin: 27
Dev: 28,29
PL: 30
Tester: 31
Project: 27
Issue: 12,25 (Assigned 29)
@@ -65,7 +67,7 @@ public void testIssueGet(){

assertEquals(issue1,issue2);
}
@Transactional

@Test
public void testIssueGetList(){
List<Issue> issues1 = this.issueService.getList(27L);
@@ -76,7 +78,6 @@ public void testIssueGetList(){
assertEquals(issues1,issues2);
}

@Transactional
@Test
public void testIssueGetListWithStatus(){
List<Issue> issues1 = this.issueService.getList(27L, Issue.Status.NEW);
@@ -87,9 +88,8 @@ public void testIssueGetListWithStatus(){
assertEquals(issues1,issues2);
}

@Transactional
@Test
public void testIssueGetListByAssignee() {
public void testIssueGetListByAssignee() {
List<Issue> issues1 = this.issueService.getListByAssignee(29L);

User user = this.userRepository.findById(29L).orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND));
@@ -98,6 +98,10 @@ public void testIssueGetListByAssignee() {
assertEquals(issues1,issues2);
}

@Test
public void testIssueDelete(){
this.issueService.delete(12L);
}


}

0 comments on commit 6a68ff0

Please sign in to comment.