Skip to content

Commit

Permalink
Merge pull request #32 from neorang/clemado1/add-interface
Browse files Browse the repository at this point in the history
add: label dto & service interface & repository & test
  • Loading branch information
yeongever0 authored Oct 12, 2022
2 parents b4c6c9a + d57e708 commit 93d9193
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/neorang/neims/issue/domain/Label.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.neorang.neims.issue.domain;

import com.neorang.neims.globals.BaseEntity;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Label extends BaseEntity {

@Id
Expand All @@ -21,4 +27,11 @@ public class Label extends BaseEntity {
@Enumerated(EnumType.STRING)
private Color color;

@Builder
public Label(long labelId, String label, Color color) {
this.labelId = labelId;
this.label = label;
this.color = color;
}

}
32 changes: 32 additions & 0 deletions src/main/java/com/neorang/neims/issue/dto/LabelForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.neorang.neims.issue.dto;

import com.neorang.neims.issue.domain.Color;
import com.neorang.neims.issue.domain.Label;
import lombok.Builder;
import lombok.Getter;

@Getter
public class LabelForm {

private long labelId;

private String label;

private Color color;

@Builder
public LabelForm(long labelId, String label, Color color) {
this.labelId = labelId;
this.label = label;
this.color = color;
}

public Label toEntity() {
return Label.builder()
.labelId(labelId)
.label(label)
.color(color)
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.neorang.neims.issue.repository;

import com.neorang.neims.issue.domain.Label;
import org.springframework.data.jpa.repository.JpaRepository;

public interface LabelRepository extends JpaRepository<Label, Long> {
}
16 changes: 16 additions & 0 deletions src/main/java/com/neorang/neims/issue/service/LabelService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.neorang.neims.issue.service;

import com.neorang.neims.issue.domain.Label;
import com.neorang.neims.issue.dto.LabelForm;

public interface LabelService {

Label create(LabelForm form);

Label update(LabelForm form);

Label findById(long issueId);

void delete(long issueId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.neorang.neims.issue.service;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@Slf4j
@SpringBootTest
class LabelServiceTest {

@Autowired
LabelService labelService;

@Test
void create() {
}

@Test
void update() {
}

@Test
void findById() {
}

@Test
void delete() {
}

}

0 comments on commit 93d9193

Please sign in to comment.