Skip to content

Commit

Permalink
Merge branch 'main' into feat/#310
Browse files Browse the repository at this point in the history
  • Loading branch information
Minjoo522 authored Aug 16, 2024
2 parents 46b68fb + 9f527c8 commit 58f327e
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 158 deletions.
30 changes: 30 additions & 0 deletions backend/src/main/java/develup/api/HashTagApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package develup.api;

import java.util.List;
import develup.api.common.ApiResponse;
import develup.application.hashtag.HashTagResponse;
import develup.application.hashtag.HashTagService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "해시태그 API")
class HashTagApi {

private final HashTagService hashTagService;

public HashTagApi(HashTagService hashTagService) {
this.hashTagService = hashTagService;
}

@GetMapping("/hash-tags")
@Operation(summary = "해시태그 목록 조회 API", description = "해시태그 목록을 조회합니다.")
public ResponseEntity<ApiResponse<List<HashTagResponse>>> getHashTags() {
List<HashTagResponse> responses = hashTagService.getHashTags();

return ResponseEntity.ok(new ApiResponse<>(responses));
}
}
2 changes: 1 addition & 1 deletion backend/src/main/java/develup/api/SolutionCommentApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import develup.api.common.ApiResponse;
import develup.application.auth.Accessor;
import develup.application.solution.comment.CreateSolutionCommentResponse;
import develup.application.solution.comment.SolutionCommentRepliesResponse;
import develup.application.solution.comment.SolutionCommentRequest;
import develup.application.solution.comment.SolutionCommentService;
import develup.application.solution.comment.SolutionCommentRepliesResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package develup.application.hashtag;

import java.util.List;
import develup.domain.hashtag.HashTagRepository;
import org.springframework.stereotype.Service;

@Service
public class HashTagService {

private final HashTagRepository hashTagRepository;

public HashTagService(HashTagRepository hashTagRepository) {
this.hashTagRepository = hashTagRepository;
}

public List<HashTagResponse> getHashTags() {
return hashTagRepository.findAll().stream()
.map(HashTagResponse::from)
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean equals(Object o) {
return false;
}
IdentifiableEntity that = (IdentifiableEntity) o;
return Objects.equals(getId(), that.getId());
return this.getId() != null && Objects.equals(getId(), that.getId());
}

@Override
Expand Down
34 changes: 3 additions & 31 deletions backend/src/main/java/develup/domain/hashtag/HashTag.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package develup.domain.hashtag;

import java.util.Objects;
import develup.domain.IdentifiableEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class HashTag {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public class HashTag extends IdentifiableEntity {

@Column(nullable = false)
private String name;
Expand All @@ -25,32 +18,11 @@ public HashTag(String name) {
}

public HashTag(Long id, String name) {
this.id = id;
super(id);
this.name = name;
}

public Long getId() {
return id;
}

public String getName() {
return name;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof HashTag hashTag)) {
return false;
}

return this.getId() != null && Objects.equals(getId(), hashTag.getId());
}

@Override
public int hashCode() {
return Objects.hash(getId());
}
}
33 changes: 3 additions & 30 deletions backend/src/main/java/develup/domain/member/Member.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package develup.domain.member;

import java.util.Objects;
import develup.domain.CreatedAtAuditableEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class Member {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public class Member extends CreatedAtAuditableEntity {

@Column
private String email;
Expand All @@ -40,6 +33,7 @@ public Member(String email, Provider provider, Long socialId, String name, Strin
}

public Member(Long id, String email, Provider provider, Long socialId, String name, String imageUrl) {
super(id);
this.id = id;
this.email = email;
this.provider = provider;
Expand All @@ -48,10 +42,6 @@ public Member(Long id, String email, Provider provider, Long socialId, String na
this.imageUrl = imageUrl;
}

public Long getId() {
return id;
}

public String getEmail() {
return email;
}
Expand All @@ -71,21 +61,4 @@ public String getName() {
public String getImageUrl() {
return imageUrl;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Member member)) {
return false;
}

return this.getId() != null && Objects.equals(getId(), member.getId());
}

@Override
public int hashCode() {
return Objects.hash(getId());
}
}
16 changes: 3 additions & 13 deletions backend/src/main/java/develup/domain/mission/Mission.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@

import java.util.List;
import java.util.Set;
import develup.domain.IdentifiableEntity;
import develup.domain.hashtag.HashTag;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class Mission {
public class Mission extends IdentifiableEntity {

private static final String DESCRIPTION_BASE_URL_PREFIX = "https://raw.githubusercontent.com/develup-mission/";
private static final String DESCRIPTION_BASE_URL_SUFFIX = "/main/README.md";

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
private String title;

Expand All @@ -43,7 +37,7 @@ public Mission(String title, String thumbnail, String summary, String url, List<
}

public Mission(Long id, String title, String thumbnail, String summary, String url, List<HashTag> hashTags) {
this.id = id;
super(id);
this.title = title;
this.thumbnail = thumbnail;
this.summary = summary;
Expand All @@ -61,10 +55,6 @@ public String getDescriptionUrl() {
return DESCRIPTION_BASE_URL_PREFIX + split[split.length - 1] + DESCRIPTION_BASE_URL_SUFFIX;
}

public Long getId() {
return id;
}

public String getTitle() {
return title;
}
Expand Down
16 changes: 3 additions & 13 deletions backend/src/main/java/develup/domain/mission/MissionHashTag.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package develup.domain.mission;

import develup.domain.IdentifiableEntity;
import develup.domain.hashtag.HashTag;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
public class MissionHashTag {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public class MissionHashTag extends IdentifiableEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
Expand All @@ -32,15 +26,11 @@ public MissionHashTag(Mission mission, HashTag hashTag) {
}

public MissionHashTag(Long id, Mission mission, HashTag hashTag) {
this.id = id;
super(id);
this.mission = mission;
this.hashTag = hashTag;
}

public Long getId() {
return id;
}

public Mission getMission() {
return mission;
}
Expand Down
20 changes: 5 additions & 15 deletions backend/src/main/java/develup/domain/solution/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Set;
import develup.api.exception.DevelupException;
import develup.api.exception.ExceptionType;
import develup.domain.CreatedAtAuditableEntity;
import develup.domain.member.Member;
import develup.domain.mission.Mission;
import develup.domain.mission.MissionHashTag;
Expand All @@ -12,25 +13,18 @@
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
public class Solution {
public class Solution extends CreatedAtAuditableEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@JoinColumn(nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
private Mission mission;

@JoinColumn(nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
private Member member;

@Embedded
Expand Down Expand Up @@ -69,7 +63,7 @@ public Solution(
String url,
SolutionStatus status
) {
this.id = id;
super(id);
this.mission = mission;
this.member = member;
this.title = title;
Expand Down Expand Up @@ -97,10 +91,6 @@ public boolean isInProgress() {
return status.isInProgress();
}

public Long getId() {
return id;
}

public Mission getMission() {
return mission;
}
Expand Down
Loading

0 comments on commit 58f327e

Please sign in to comment.