Skip to content

Commit

Permalink
[BE/#17] Merge : 이슈 목록 api 부분 코드 병합(ragdoll)
Browse files Browse the repository at this point in the history
- 이슈 생성 api는 hamill 코드로 병합할 예정
  • Loading branch information
hanurii committed Jun 12, 2020
1 parent efec6f4 commit 917ce35
Show file tree
Hide file tree
Showing 20 changed files with 1,300 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.codesquad.issuetracker.main.controller;

import com.codesquad.issuetracker.main.service.IssueService;
import com.codesquad.issuetracker.ragdoll.dto.ListOfIssuesDto;
import com.codesquad.issuetracker.ragdoll.response.ApiResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IssueController {

private final IssueService issueService;

public IssueController(IssueService issueService) {
this.issueService = issueService;
}

@GetMapping("/issues")
public ResponseEntity<ApiResponse<ListOfIssuesDto>> listing() {
return new ResponseEntity(issueService.findAllIssues(), HttpStatus.OK);
}
}
32 changes: 32 additions & 0 deletions BE/src/main/java/com/codesquad/issuetracker/main/dao/IssueDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.codesquad.issuetracker.main.dao;

import com.codesquad.issuetracker.ragdoll.domain.Issue;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;
import java.util.List;

@Repository
public class IssueDao {

private JdbcTemplate jdbcTemplate;

public IssueDao(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}


public List<Issue> findAllOpendIssues() {
String sql = "SELECT id, title, created_date_time, is_opened, user_id, milestone_id " +
"FROM issue WHERE is_opened = TRUE";
return jdbcTemplate.query(sql, (rs, rowNum) -> new Issue.Builder()
.id(rs.getLong("id"))
.title(rs.getString("title"))
.createdDateTime((rs.getTimestamp("created_date_time")).toLocalDateTime())
.opened(rs.getBoolean("is_opened"))
.userId(rs.getLong("user_id"))
.milestoneId(rs.getInt("milestone_id"))
.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.codesquad.issuetracker.main.domain;

public class Assignee {

private Integer id;

private Long issueId;

private Long userId;

public Assignee() {}

private Assignee(Integer id, Long issueId, Long userId) {
this.id = id;
this.issueId = issueId;
this.userId = userId;
}

public static Assignee create(Integer id, Long issueId, Long userId) {
return new Assignee(id, issueId, userId);
}

public Integer getId() { return id; }

public void setId(Integer id) {
this.id = id;
}

public Long getIssueId() {
return issueId;
}

public void setIssueId(Long issueId) {
this.issueId = issueId;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}
}
109 changes: 109 additions & 0 deletions BE/src/main/java/com/codesquad/issuetracker/main/domain/Comment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package com.codesquad.issuetracker.main.domain;

import java.time.LocalDateTime;

public class Comment {

private Long id;

private String description;

private LocalDateTime createdDateTime;

private Long issueId;

private Long userId;

public Comment() {}

private Comment(Long id, String description, LocalDateTime createdDateTime, Long issueId, Long userId) {
this.id = id;
this.description = description;
this.createdDateTime = createdDateTime;
this.issueId = issueId;
this.userId = userId;
}

public static Comment create(Long id, String description, LocalDateTime createdDateTime, Long issueId, Long userId) {
return new Comment(id, description, createdDateTime, issueId, userId);
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public LocalDateTime getCreatedDateTime() {
return createdDateTime;
}

public void setCreatedDateTime(LocalDateTime createdDateTime) {
this.createdDateTime = createdDateTime;
}

public Long getIssueId() {
return issueId;
}

public void setIssueId(Long issueId) {
this.issueId = issueId;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public static class Builder {
private Long id;
private String description;
private LocalDateTime createdDateTime;
private Long issueId;
private Long userId;

public Builder() {}

public Builder id(Long id) {
this.id = id;
return this;
}

public Builder description(String description) {
this.description = description;
return this;
}

public Builder createdDateTime(LocalDateTime createdDateTime) {
this.createdDateTime = createdDateTime;
return this;
}

public Builder issueId(Long issueId) {
this.issueId = issueId;
return this;
}

public Builder userId(Long userId) {
this.userId = userId;
return this;
}

public Comment build() {
return new Comment(id, description, createdDateTime, issueId, userId);
}
}
}
130 changes: 130 additions & 0 deletions BE/src/main/java/com/codesquad/issuetracker/main/domain/Issue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package com.codesquad.issuetracker.main.domain;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.time.LocalDateTime;

public class Issue {

private Long id;

private String title;

private LocalDateTime createdDateTime;

private boolean opened;

private Long userId;

private Integer milestoneId;

public Issue() {}

private Issue(Long id, String title, LocalDateTime createdDateTime, boolean opened, Long userId, Integer milestoneId) {
this.id = id;
this.title = title;
this.createdDateTime = createdDateTime;
this.opened = opened;
this.userId = userId;
this.milestoneId = milestoneId;
}

public static Issue create(Long id, String title, LocalDateTime createdDateTime, boolean opened, Long userId, Integer milestoneId) {
return new Issue(id, title, createdDateTime, opened, userId, milestoneId);
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public LocalDateTime getCreatedDateTime() {
return createdDateTime;
}

public void setCreatedDateTime(LocalDateTime createdDateTime) {
this.createdDateTime = createdDateTime;
}

@JsonProperty("isOpened")
public boolean isOpened() {
return opened;
}

@JsonProperty("isOpened")
public void setOpened(boolean opened) {
this.opened = opened;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public Integer getMilestoneId() {
return milestoneId;
}

public void setMilestoneId(Integer milestoneId) {
this.milestoneId = milestoneId;
}

public static class Builder {
private Long id;
private String title;
private LocalDateTime createdDateTime;
private boolean opened;
private Long userId;
private Integer milestoneId;

public Builder() {}

public Builder id(Long id) {
this.id = id;
return this;
}

public Builder title(String title) {
this.title = title;
return this;
}

public Builder createdDateTime(LocalDateTime createdDateTime) {
this.createdDateTime = createdDateTime;
return this;
}

public Builder opened(boolean opened) {
this.opened = opened;
return this;
}

public Builder userId(Long userId) {
this.userId = userId;
return this;
}

public Builder milestoneId(Integer milestoneId) {
this.milestoneId = milestoneId;
return this;
}

public Issue build() {
return new Issue(id, title, createdDateTime, opened, userId, milestoneId);
}
}
}
Loading

0 comments on commit 917ce35

Please sign in to comment.