Skip to content

Commit

Permalink
fix : dto record로 수정 (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboysj authored Nov 21, 2024
1 parent f8c3b42 commit 1abfb04
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public CreateBlockResponse createBlock(Long archiveId, CreateBlockRequest reques
throw new CustomException(ErrorCode.BLOCK_EXCEED_LIMIT);
}

String title = request.getTitle();
String title = request.title();
if (title == null || title.trim().isEmpty()) {
title = FigmaConstants.NEW_BLOCK_NAME;
}
Expand All @@ -51,26 +51,26 @@ public CreateBlockResponse createBlock(Long archiveId, CreateBlockRequest reques
blockRepository.save(
Block.createBlock(
title,
request.getXCoordinate(),
request.getYCoordinate(),
request.getHeight(),
request.getWidth(),
request.xCoordinate(),
request.yCoordinate(),
request.height(),
request.width(),
archive,
figma));

return new CreateBlockResponse(block);
return CreateBlockResponse.from(block);
}

public List<GetBlockResponse> getBlock(Long archiveId) {
return blockRepository.findByArchive_ArchiveIdAndDeletedAtIsNull(archiveId).stream()
.map(GetBlockResponse::new)
.map(GetBlockResponse::from)
.collect(Collectors.toList());
}

public CreateBlockResponse updateBlockTitle(Long blockId, UpdateBlockRequest request) {
Block block = getBlockById(blockId);
block.setTitle(request.getTitle());
return new CreateBlockResponse(block);
block.setTitle(request.title());
return CreateBlockResponse.from(block);
}

public void deleteBlock(Long blockId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
package gigedi.dev.domain.block.dto.request;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class CreateBlockRequest {
private String title;
private double xCoordinate;
private double yCoordinate;
private double height;
private double width;
}
public record CreateBlockRequest(
String title, double xCoordinate, double yCoordinate, double height, double width) {}
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
package gigedi.dev.domain.block.dto.request;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class UpdateBlockRequest {
private String title;
}
public record UpdateBlockRequest(String title) {}
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package gigedi.dev.domain.block.dto.response;

import gigedi.dev.domain.block.domain.Block;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class CreateBlockResponse {
private Long blockId;
private String title;
private double xCoordinate;
private double yCoordinate;
private double height;
private double width;

public CreateBlockResponse(Block block) {
this.blockId = block.getBlockId();
this.title = block.getTitle();
this.xCoordinate = block.getXCoordinate();
this.yCoordinate = block.getYCoordinate();
this.height = block.getHeight();
this.width = block.getWidth();
public record CreateBlockResponse(
Long blockId,
String title,
double xCoordinate,
double yCoordinate,
double height,
double width) {
public static CreateBlockResponse from(Block block) {
return new CreateBlockResponse(
block.getBlockId(),
block.getTitle(),
block.getXCoordinate(),
block.getYCoordinate(),
block.getHeight(),
block.getWidth());
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
package gigedi.dev.domain.block.dto.response;

import gigedi.dev.domain.block.domain.Block;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class GetBlockResponse {
private Long blockId;
private String title;
private int shootCount;
private double xCoordinate;
private double yCoordinate;
private double height;
private double width;

public GetBlockResponse(Block block) {
this.blockId = block.getBlockId();
this.title = block.getTitle();
this.shootCount = block.getShootCount();
this.xCoordinate = block.getXCoordinate();
this.yCoordinate = block.getYCoordinate();
this.height = block.getHeight();
this.width = block.getWidth();
public record GetBlockResponse(
Long blockId,
String title,
int shootCount,
double xCoordinate,
double yCoordinate,
double height,
double width) {
public static GetBlockResponse from(Block block) {
return new GetBlockResponse(
block.getBlockId(),
block.getTitle(),
block.getShootCount(),
block.getXCoordinate(),
block.getYCoordinate(),
block.getHeight(),
block.getWidth());
}
}

0 comments on commit 1abfb04

Please sign in to comment.