289 lines
8.1 KiB
Java
289 lines
8.1 KiB
Java
package com.muse.dto;
|
||
|
||
import java.net.URI;
|
||
import java.util.Objects;
|
||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||
import com.fasterxml.jackson.annotation.JsonValue;
|
||
import com.muse.dto.ContentSourceSnapshot;
|
||
import org.springframework.lang.Nullable;
|
||
import java.io.Serializable;
|
||
import java.time.OffsetDateTime;
|
||
import jakarta.validation.Valid;
|
||
import jakarta.validation.constraints.*;
|
||
import io.swagger.v3.oas.annotations.media.Schema;
|
||
|
||
|
||
import java.util.*;
|
||
import jakarta.annotation.Generated;
|
||
|
||
/**
|
||
* 创建 Block 请求;服务端必须校验 work owner、chapterId 从属关系、commandId 幂等和 expectedChapterRevision。
|
||
*/
|
||
|
||
@Schema(name = "CreateBlockRequest", description = "创建 Block 请求;服务端必须校验 work owner、chapterId 从属关系、commandId 幂等和 expectedChapterRevision。")
|
||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2026-05-24T16:47:40.290595+08:00[Asia/Shanghai]", comments = "Generator version: 7.22.0")
|
||
public class CreateBlockRequest implements Serializable {
|
||
|
||
private static final long serialVersionUID = 1L;
|
||
|
||
private String commandId;
|
||
|
||
private String content;
|
||
|
||
/**
|
||
* Block 类型
|
||
*/
|
||
public enum BlockTypeEnum {
|
||
SCENE("scene"),
|
||
|
||
SECTION("section"),
|
||
|
||
NOTE("note");
|
||
|
||
private final String value;
|
||
|
||
BlockTypeEnum(String value) {
|
||
this.value = value;
|
||
}
|
||
|
||
@JsonValue
|
||
public String getValue() {
|
||
return value;
|
||
}
|
||
|
||
@Override
|
||
public String toString() {
|
||
return String.valueOf(value);
|
||
}
|
||
|
||
@JsonCreator
|
||
public static BlockTypeEnum fromValue(String value) {
|
||
for (BlockTypeEnum b : BlockTypeEnum.values()) {
|
||
if (b.value.equals(value)) {
|
||
return b;
|
||
}
|
||
}
|
||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||
}
|
||
}
|
||
|
||
private BlockTypeEnum blockType;
|
||
|
||
private Integer expectedChapterRevision;
|
||
|
||
private @Nullable Integer sortOrder;
|
||
|
||
private @Nullable String title;
|
||
|
||
private @Nullable ContentSourceSnapshot sourceSnapshot;
|
||
|
||
public CreateBlockRequest() {
|
||
super();
|
||
}
|
||
|
||
/**
|
||
* Constructor with only required parameters
|
||
*/
|
||
public CreateBlockRequest(String commandId, String content, BlockTypeEnum blockType, Integer expectedChapterRevision) {
|
||
this.commandId = commandId;
|
||
this.content = content;
|
||
this.blockType = blockType;
|
||
this.expectedChapterRevision = expectedChapterRevision;
|
||
}
|
||
|
||
public CreateBlockRequest commandId(String commandId) {
|
||
this.commandId = commandId;
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* 幂等键
|
||
* @return commandId
|
||
*/
|
||
@NotNull
|
||
@Schema(name = "commandId", description = "幂等键", requiredMode = Schema.RequiredMode.REQUIRED)
|
||
@JsonProperty("commandId")
|
||
public String getCommandId() {
|
||
return commandId;
|
||
}
|
||
|
||
@JsonProperty("commandId")
|
||
public void setCommandId(String commandId) {
|
||
this.commandId = commandId;
|
||
}
|
||
|
||
public CreateBlockRequest content(String content) {
|
||
this.content = content;
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* Block 正文内容(JSON 格式的 ProseMirror 文档)
|
||
* @return content
|
||
*/
|
||
@NotNull
|
||
@Schema(name = "content", description = "Block 正文内容(JSON 格式的 ProseMirror 文档)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||
@JsonProperty("content")
|
||
public String getContent() {
|
||
return content;
|
||
}
|
||
|
||
@JsonProperty("content")
|
||
public void setContent(String content) {
|
||
this.content = content;
|
||
}
|
||
|
||
public CreateBlockRequest blockType(BlockTypeEnum blockType) {
|
||
this.blockType = blockType;
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* Block 类型
|
||
* @return blockType
|
||
*/
|
||
@NotNull
|
||
@Schema(name = "blockType", description = "Block 类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||
@JsonProperty("blockType")
|
||
public BlockTypeEnum getBlockType() {
|
||
return blockType;
|
||
}
|
||
|
||
@JsonProperty("blockType")
|
||
public void setBlockType(BlockTypeEnum blockType) {
|
||
this.blockType = blockType;
|
||
}
|
||
|
||
public CreateBlockRequest expectedChapterRevision(Integer expectedChapterRevision) {
|
||
this.expectedChapterRevision = expectedChapterRevision;
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* 章节当前 revision(乐观锁)
|
||
* @return expectedChapterRevision
|
||
*/
|
||
@NotNull
|
||
@Schema(name = "expectedChapterRevision", description = "章节当前 revision(乐观锁)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||
@JsonProperty("expectedChapterRevision")
|
||
public Integer getExpectedChapterRevision() {
|
||
return expectedChapterRevision;
|
||
}
|
||
|
||
@JsonProperty("expectedChapterRevision")
|
||
public void setExpectedChapterRevision(Integer expectedChapterRevision) {
|
||
this.expectedChapterRevision = expectedChapterRevision;
|
||
}
|
||
|
||
public CreateBlockRequest sortOrder(@Nullable Integer sortOrder) {
|
||
this.sortOrder = sortOrder;
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* Get sortOrder
|
||
* @return sortOrder
|
||
*/
|
||
|
||
@Schema(name = "sortOrder", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||
@JsonProperty("sortOrder")
|
||
public @Nullable Integer getSortOrder() {
|
||
return sortOrder;
|
||
}
|
||
|
||
@JsonProperty("sortOrder")
|
||
public void setSortOrder(@Nullable Integer sortOrder) {
|
||
this.sortOrder = sortOrder;
|
||
}
|
||
|
||
public CreateBlockRequest title(@Nullable String title) {
|
||
this.title = title;
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* Get title
|
||
* @return title
|
||
*/
|
||
@Size(max = 500)
|
||
@Schema(name = "title", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||
@JsonProperty("title")
|
||
public @Nullable String getTitle() {
|
||
return title;
|
||
}
|
||
|
||
@JsonProperty("title")
|
||
public void setTitle(@Nullable String title) {
|
||
this.title = title;
|
||
}
|
||
|
||
public CreateBlockRequest sourceSnapshot(@Nullable ContentSourceSnapshot sourceSnapshot) {
|
||
this.sourceSnapshot = sourceSnapshot;
|
||
return this;
|
||
}
|
||
|
||
/**
|
||
* Get sourceSnapshot
|
||
* @return sourceSnapshot
|
||
*/
|
||
@Valid
|
||
@Schema(name = "sourceSnapshot", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||
@JsonProperty("sourceSnapshot")
|
||
public @Nullable ContentSourceSnapshot getSourceSnapshot() {
|
||
return sourceSnapshot;
|
||
}
|
||
|
||
@JsonProperty("sourceSnapshot")
|
||
public void setSourceSnapshot(@Nullable ContentSourceSnapshot sourceSnapshot) {
|
||
this.sourceSnapshot = sourceSnapshot;
|
||
}
|
||
|
||
@Override
|
||
public boolean equals(Object o) {
|
||
if (this == o) {
|
||
return true;
|
||
}
|
||
if (o == null || getClass() != o.getClass()) {
|
||
return false;
|
||
}
|
||
CreateBlockRequest createBlockRequest = (CreateBlockRequest) o;
|
||
return Objects.equals(this.commandId, createBlockRequest.commandId) &&
|
||
Objects.equals(this.content, createBlockRequest.content) &&
|
||
Objects.equals(this.blockType, createBlockRequest.blockType) &&
|
||
Objects.equals(this.expectedChapterRevision, createBlockRequest.expectedChapterRevision) &&
|
||
Objects.equals(this.sortOrder, createBlockRequest.sortOrder) &&
|
||
Objects.equals(this.title, createBlockRequest.title) &&
|
||
Objects.equals(this.sourceSnapshot, createBlockRequest.sourceSnapshot);
|
||
}
|
||
|
||
@Override
|
||
public int hashCode() {
|
||
return Objects.hash(commandId, content, blockType, expectedChapterRevision, sortOrder, title, sourceSnapshot);
|
||
}
|
||
|
||
@Override
|
||
public String toString() {
|
||
StringBuilder sb = new StringBuilder();
|
||
sb.append("class CreateBlockRequest {\n");
|
||
sb.append(" commandId: ").append(toIndentedString(commandId)).append("\n");
|
||
sb.append(" content: ").append(toIndentedString(content)).append("\n");
|
||
sb.append(" blockType: ").append(toIndentedString(blockType)).append("\n");
|
||
sb.append(" expectedChapterRevision: ").append(toIndentedString(expectedChapterRevision)).append("\n");
|
||
sb.append(" sortOrder: ").append(toIndentedString(sortOrder)).append("\n");
|
||
sb.append(" title: ").append(toIndentedString(title)).append("\n");
|
||
sb.append(" sourceSnapshot: ").append(toIndentedString(sourceSnapshot)).append("\n");
|
||
sb.append("}");
|
||
return sb.toString();
|
||
}
|
||
|
||
/**
|
||
* Convert the given object to string with each line indented by 4 spaces
|
||
* (except the first line).
|
||
*/
|
||
private String toIndentedString(@Nullable Object o) {
|
||
return o == null ? "null" : o.toString().replace("\n", "\n ");
|
||
}
|
||
}
|
||
|