Skip to content
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

좋아요 스킴 초안. Ref #1 #6

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.mtudy.soundcloud.like.application.inputs;

import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@NoArgsConstructor
public class LikeAlbumInput {
@NotBlank
private String albumId;

public LikeAlbumInput(String albumId) {
this.albumId = albumId;
}

public String getAlbumId() {
return albumId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.mtudy.soundcloud.like.application.inputs;

import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@NoArgsConstructor
public class LikePlaylistInput {
@NotBlank
private String playlistId;

public LikePlaylistInput(String playlistId) {
this.playlistId = playlistId;
}

public String getPlaylistId() {
return playlistId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.mtudy.soundcloud.like.application.inputs;

import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@NoArgsConstructor
public class LikeTrackInput {
@NotBlank
private String trackId;

public LikeTrackInput(String trackId) {
this.trackId = trackId;
}

public String getTrackId() {
return trackId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.mtudy.soundcloud.like.application.interfaces.web.graphql;

import graphql.kickstart.tools.GraphQLMutationResolver;
import io.mtudy.soundcloud.like.application.inputs.LikeAlbumInput;
import io.mtudy.soundcloud.like.application.services.LikeAlbumService;
import io.mtudy.soundcloud.like.domain.entities.AlbumLike;
import org.springframework.stereotype.Component;

import javax.validation.Valid;

@Component
public class LikeAlbumMutationResolver implements GraphQLMutationResolver {
private final LikeAlbumService service;

public LikeAlbumMutationResolver(LikeAlbumService service) {
this.service = service;
}

public AlbumLike likeAlbum(@Valid LikeAlbumInput input) {
return this.service.run(input);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.mtudy.soundcloud.like.application.interfaces.web.graphql;

import graphql.kickstart.tools.GraphQLMutationResolver;
import io.mtudy.soundcloud.like.application.inputs.LikePlaylistInput;
import io.mtudy.soundcloud.like.application.services.LikePlaylistService;
import io.mtudy.soundcloud.like.domain.entities.PlaylistLike;
import org.springframework.stereotype.Component;

import javax.validation.Valid;

@Component
public class LikePlaylistMutationResolver implements GraphQLMutationResolver {
private final LikePlaylistService service;

public LikePlaylistMutationResolver(LikePlaylistService service) {
this.service = service;
}

public PlaylistLike likePlaylist(@Valid LikePlaylistInput input) {
return this.service.run(input);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.mtudy.soundcloud.like.application.interfaces.web.graphql;

import graphql.kickstart.tools.GraphQLMutationResolver;
import io.mtudy.soundcloud.like.application.inputs.LikeTrackInput;
import io.mtudy.soundcloud.like.application.services.LikeTrackService;
import io.mtudy.soundcloud.like.domain.entities.TrackLike;
import org.springframework.stereotype.Component;

import javax.validation.Valid;

@Component
public class LikeTrackMutationResolver implements GraphQLMutationResolver {
private final LikeTrackService service;

public LikeTrackMutationResolver(LikeTrackService service) {
this.service = service;
}

public TrackLike likeTrack(@Valid LikeTrackInput input) {
return this.service.run(input);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.mtudy.soundcloud.like.application.services;

import io.mtudy.soundcloud.like.application.inputs.LikeAlbumInput;
import io.mtudy.soundcloud.like.domain.entities.AlbumLike;
import io.mtudy.soundcloud.like.domain.repotitories.AlbumLikeRepository;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class LikeAlbumService {
private final AlbumLikeRepository repository;

public LikeAlbumService(AlbumLikeRepository repository) {
this.repository = repository;
}

public AlbumLike run(LikeAlbumInput request) {
return this.repository.save(new AlbumLike(
UUID.randomUUID().toString(), request.getAlbumId(), UUID.randomUUID().toString()
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.mtudy.soundcloud.like.application.services;

import io.mtudy.soundcloud.like.application.inputs.LikePlaylistInput;
import io.mtudy.soundcloud.like.domain.entities.PlaylistLike;
import io.mtudy.soundcloud.like.domain.repotitories.PlaylistLikeRepository;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class LikePlaylistService {
private final PlaylistLikeRepository repository;

public LikePlaylistService(PlaylistLikeRepository repository) {
this.repository = repository;
}

public PlaylistLike run(LikePlaylistInput request) {
return this.repository.save(new PlaylistLike(
UUID.randomUUID().toString(), request.getPlaylistId(), UUID.randomUUID().toString()
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.mtudy.soundcloud.like.application.services;

import io.mtudy.soundcloud.like.application.inputs.LikeAlbumInput;
import io.mtudy.soundcloud.like.application.inputs.LikeTrackInput;
import io.mtudy.soundcloud.like.domain.entities.TrackLike;
import io.mtudy.soundcloud.like.domain.repotitories.TrackLikeRepository;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class LikeTrackService {
private final TrackLikeRepository repository;

public LikeTrackService(TrackLikeRepository repository) {
this.repository = repository;
}

public TrackLike run(LikeTrackInput request) {
return this.repository.save(new TrackLike(
UUID.randomUUID().toString(), request.getTrackId(), UUID.randomUUID().toString()
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.mtudy.soundcloud.like.domain.entities;

import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@NoArgsConstructor
@Entity
@Table(name = "album_like")
public class AlbumLike {
@Id
@Column(columnDefinition = "VARCHAR(36)")
private String id;

@Column(columnDefinition = "VARCHAR(36)")
private String albumId;

@Column(columnDefinition = "VARCHAR(36)")
private String authorId;

public AlbumLike(String id, String albumId, String authorId) {
this.id = id;
this.albumId = albumId;
this.authorId = authorId;
}

public String getId() {
return id;
}

public String getAlbumId() {
return albumId;
}

public String getAuthorId() {
return authorId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.mtudy.soundcloud.like.domain.entities;

import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@NoArgsConstructor
@Entity
@Table(name = "playlist_like")
public class PlaylistLike {
@Id
@Column(columnDefinition = "VARCHAR(36)")
private String id;

@Column(columnDefinition = "VARCHAR(36)")
private String playlistId;

@Column(columnDefinition = "VARCHAR(36)")
private String authorId;

public PlaylistLike(String id, String playlistId, String authorId) {
this.id = id;
this.playlistId = playlistId;
this.authorId = authorId;
}

public String getId() {
return id;
}

public String getPlaylistId() {
return playlistId;
}

public String getAuthorId() {
return authorId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.mtudy.soundcloud.like.domain.entities;

import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@NoArgsConstructor
@Entity
@Table(name = "track_like")
public class TrackLike {
@Id
@Column(columnDefinition = "VARCHAR(36)")
private String id;

@Column(columnDefinition = "VARCHAR(36)")
private String trackId;

@Column(columnDefinition = "VARCHAR(36)")
private String authorId;

public TrackLike(String id, String trackId, String authorId) {
this.id = id;
this.trackId = trackId;
this.authorId = authorId;
}

public String getId() {
return id;
}

public String getTrackId() {
return trackId;
}

public String getAuthorId() {
return authorId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.mtudy.soundcloud.like.domain.repotitories;

import io.mtudy.soundcloud.like.domain.entities.AlbumLike;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface AlbumLikeRepository extends CrudRepository<AlbumLike, String> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.mtudy.soundcloud.like.domain.repotitories;

import io.mtudy.soundcloud.like.domain.entities.PlaylistLike;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface PlaylistLikeRepository extends CrudRepository<PlaylistLike, String> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.mtudy.soundcloud.like.domain.repotitories;

import io.mtudy.soundcloud.like.domain.entities.TrackLike;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface TrackLikeRepository extends CrudRepository<TrackLike, String> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create table playlist_like (
id varchar(36) not null,
authorId varchar(36) not null,
playlistId varchar(36) not null,
primary key (id)
) engine=InnoDB collate=utf8mb4_general_ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create table track_like (
id varchar(36) not null,
authorId varchar(36) not null,
trackId varchar(36) not null,
primary key (id)
) engine=InnoDB collate=utf8mb4_general_ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create table album_like (
id varchar(36) not null,
authorId varchar(36) not null,
albumId varchar(36) not null,
primary key (id)
) engine=InnoDB collate=utf8mb4_general_ci
Loading