Skip to content

Commit

Permalink
Merge branch 'master' into test/#86
Browse files Browse the repository at this point in the history
  • Loading branch information
qlido authored Apr 21, 2024
2 parents 5201747 + ecc5400 commit 866d407
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class DocsValidator {
private final DocsRepository docsRepository;
private final DocsReader docsReader;

public void checkTitleAlreadyExist(Docs docs) {
if (docsRepository.existsByTitle(docs.getTitle())) {
public void checkTitleAlreadyExist(String title) {
if (docsRepository.existsByTitle(title)) {
throw new BumawikiException(ErrorCode.DOCS_TITLE_ALREADY_EXIST);
}
}
Expand All @@ -42,7 +42,6 @@ public void checkUpdateOneSelf(User user, Docs docs) {
throw new BumawikiException(ErrorCode.CANNOT_CHANGE_YOUR_DOCS);
}
}

public void checkUpdatableDocsType(DocsType docsType) {
if (docsType.equals(DocsType.READONLY)) {
throw new BumawikiException(ErrorCode.NO_UPDATABLE_DOCS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class CommandDocsService {
private final ThumbsUpDeleter thumbsUpDeleter;

public void create(Docs docs, User user, String contents) {
docsValidator.checkTitleAlreadyExist(docs);
docsValidator.checkTitleAlreadyExist(docs.getTitle());
docsCreator.create(docs, user, contents);
}

public void delete(Long id) {
docsDeleter.delete(id);
thumbsUpDeleter.deleteAllByDocsId(id);
docsDeleter.delete(id);
}

public void update(User user, String title, String contents, Integer updatingVersion) {
Expand All @@ -53,8 +53,8 @@ public void update(User user, String title, String contents, Integer updatingVer
}

public void titleUpdate(String title, String changedTitle) {
docsValidator.checkTitleAlreadyExist(changedTitle);
Docs docs = docsReader.findByTitle(title);
docsValidator.checkTitleAlreadyExist(docs);

docsUpdater.updateTitle(docs, changedTitle);
}
Expand All @@ -72,7 +72,7 @@ public void solveConflict(String title, String contents, Integer version, User u
throw new BumawikiException(ErrorCode.DOCS_CONFLICTED);
}

docsCreator.create(
docsCreator.createVersionDocs(
docs,
user,
contents
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/project/bumawiki/domain/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.List;

import com.project.bumawiki.domain.thumbsup.domain.ThumbsUp;
import com.project.bumawiki.domain.thumbsup.exception.AlreadyThumbsUpException;
import com.project.bumawiki.domain.thumbsup.exception.YouDontThumbsUpThisDocs;
import com.project.bumawiki.domain.thumbsup.presentation.dto.ThumbsUpResponseDto;
import com.project.bumawiki.domain.user.domain.authority.Authority;

Expand All @@ -18,6 +20,8 @@
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -42,24 +46,24 @@ public class User {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Max(32)
@Size(max = 32)
@Column(unique = true, length = 32)
private String email;

@Max(16)
@Size(max = 16)
@NotNull
@Column(length = 16)
private String name;

@Max(8)
@Column(length = 8)
private Integer enroll;

@Max(20)
@Column(length = 20)
private String nickName;

@Enumerated(EnumType.STRING)
@Column(length = 16)
@Enumerated(EnumType.STRING)
private Authority authority;

public List<ThumbsUpResponseDto> getList() {
Expand Down
Loading

0 comments on commit 866d407

Please sign in to comment.