安全与效率优化,引入Redis,包名修改
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package com.linkerbot.vibemake.bean;
|
||||
|
||||
import com.linkerbot.vibemake.bean.Contracts.ProjectInput;
|
||||
import com.linkerbot.vibemake.bean.Contracts.ProjectView;
|
||||
import com.linkerbot.vibemake.bean.Contracts.UrdfConfirmInput;
|
||||
import com.linkerbot.vibemake.bean.Contracts.UrdfFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public final class AdminContracts {
|
||||
private AdminContracts() {}
|
||||
|
||||
public record LoginInput(
|
||||
@NotBlank @Email @Size(max = 254) String email,
|
||||
@NotBlank @Size(max = 128) String password) {}
|
||||
|
||||
public record PasswordInput(
|
||||
@NotBlank @Size(max = 128) String oldPassword,
|
||||
@NotBlank @Size(min = 12, max = 128) String newPassword) {}
|
||||
|
||||
public record AdminView(String userCode, String email, String nickname, String role) {}
|
||||
|
||||
public record LoginView(String token, String tokenType, long expiresIn, AdminView admin) {}
|
||||
|
||||
public record NicknameInput(@NotBlank @Size(max = 64) String nickname) {}
|
||||
|
||||
public record StatusInput(@NotBlank @Pattern(regexp = "ACTIVE|DISABLED") String status) {}
|
||||
|
||||
public record ReasonInput(@NotBlank @Size(max = 500) String reason) {}
|
||||
|
||||
public record UserView(
|
||||
String userCode,
|
||||
String nickname,
|
||||
String email,
|
||||
String status,
|
||||
String role,
|
||||
long projectCount,
|
||||
LocalDateTime createdAt) {}
|
||||
|
||||
public record CreateProjectInput(String ownerUserCode, @NotNull @Valid ProjectInput project) {}
|
||||
|
||||
public record ManagedProjectView(
|
||||
ProjectView project,
|
||||
String moderationStatus,
|
||||
String moderationReason,
|
||||
boolean deleted) {}
|
||||
|
||||
public record PreviewInput(@NotBlank @Size(max = 2048) String repositoryUrl) {}
|
||||
|
||||
public record ImportUrdfUploadInput(
|
||||
@NotBlank @Size(max = 2048) String repositoryUrl,
|
||||
@NotNull List<@NotNull @Valid UrdfFile> files) {}
|
||||
|
||||
public record ImportInput(
|
||||
@NotBlank @Size(max = 2048) String repositoryUrl,
|
||||
String ownerUserCode,
|
||||
@NotNull @Valid ProjectInput project,
|
||||
@Valid UrdfConfirmInput urdf) {}
|
||||
|
||||
public record ImportPreview(
|
||||
String repositoryUrl,
|
||||
String defaultBranch,
|
||||
String name,
|
||||
String description,
|
||||
String license,
|
||||
String existingProjectCode) {}
|
||||
|
||||
public record TaskView(
|
||||
String taskCode,
|
||||
String projectCode,
|
||||
String status,
|
||||
String phase,
|
||||
String errorCode,
|
||||
boolean canRetry,
|
||||
String retryMessage,
|
||||
List<String> warnings,
|
||||
LocalDateTime createdAt,
|
||||
LocalDateTime startedAt,
|
||||
LocalDateTime finishedAt) {}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.linkerbot.vibemake.bean;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class Contracts {
|
||||
private Contracts() {}
|
||||
|
||||
public record LoginRequest(
|
||||
@NotBlank @Email @Size(max = 254) String email,
|
||||
@NotBlank String captchaCode,
|
||||
@NotBlank String captchaAnswer) {}
|
||||
|
||||
public record UserView(String userCode, String nickname, String email) {}
|
||||
|
||||
public record PublicUser(String userCode, String nickname) {}
|
||||
|
||||
public record LoginView(String token, String tokenType, long expiresIn, UserView user) {}
|
||||
|
||||
public record CaptchaView(String captchaCode, String image, long expiresIn) {}
|
||||
|
||||
public record ProjectInput(
|
||||
@NotBlank @Size(max = 100) String name,
|
||||
@Size(max = 2000) String description,
|
||||
@NotBlank @Size(max = 64) String projectType,
|
||||
String coverUrl) {}
|
||||
|
||||
public record CoverUploadInput(
|
||||
@NotBlank String contentType, @NotNull @Positive Long fileSize) {}
|
||||
|
||||
public record CoverUploadSignature(
|
||||
String uploadUrl,
|
||||
String objectKey,
|
||||
String coverUrl,
|
||||
LocalDateTime expiresAt,
|
||||
Map<String, String> formFields) {}
|
||||
|
||||
public record PublicationInput(@NotBlank String commitSha) {}
|
||||
|
||||
public record UrdfFile(
|
||||
@NotBlank String relativePath, @NotNull @PositiveOrZero Long sizeBytes) {}
|
||||
|
||||
public record UrdfUploadInput(@NotNull List<@NotNull @Valid UrdfFile> files) {}
|
||||
|
||||
public record UrdfConfirmInput(
|
||||
@NotBlank @Pattern(regexp = "[a-f0-9]{32}") String batchCode,
|
||||
@NotNull List<@NotNull @Valid UrdfFile> files) {}
|
||||
|
||||
public record UrdfFileSignature(
|
||||
String relativePath, String objectKey, Map<String, String> formFields) {}
|
||||
|
||||
public record UrdfUploadSignature(
|
||||
String batchCode,
|
||||
String mainRelativePath,
|
||||
String uploadUrl,
|
||||
LocalDateTime expiresAt,
|
||||
List<UrdfFileSignature> files) {}
|
||||
|
||||
public record ForkInput(
|
||||
@NotBlank String publishedCommitSha, @NotBlank @Size(max = 100) String name) {}
|
||||
|
||||
public record CommentInput(@NotBlank @Size(max = 2000) String content) {}
|
||||
|
||||
public record TypeView(String code, String name) {}
|
||||
|
||||
public record ProjectView(
|
||||
String projectCode,
|
||||
String name,
|
||||
String description,
|
||||
String coverUrl,
|
||||
String urdfMainUrl,
|
||||
String urdfBaseUrl,
|
||||
String projectType,
|
||||
PublicUser owner,
|
||||
String repoStatus,
|
||||
String publishStatus,
|
||||
String publishedCommitSha,
|
||||
LocalDateTime publishedAt,
|
||||
String sourceProjectCode,
|
||||
String sourceCommitSha,
|
||||
long likeCount,
|
||||
long commentCount,
|
||||
boolean liked,
|
||||
String sourceRepositoryUrl,
|
||||
String sourceLicense,
|
||||
LocalDateTime createdAt,
|
||||
LocalDateTime updatedAt) {}
|
||||
|
||||
public record CommentView(
|
||||
String commentCode, PublicUser author, String content, LocalDateTime createdAt) {}
|
||||
|
||||
public enum ChangeAction {
|
||||
CREATE_FILE,
|
||||
UPDATE_FILE,
|
||||
DELETE_FILE,
|
||||
CREATE_DIRECTORY
|
||||
}
|
||||
|
||||
public record FileChange(@NotNull ChangeAction action, @NotBlank String path, String content) {}
|
||||
|
||||
public record CommitInput(
|
||||
@NotBlank String expectedCommitSha,
|
||||
@NotBlank @Size(max = 1000) String message,
|
||||
@NotEmpty @Size(max = 500) List<@Valid FileChange> changes) {}
|
||||
|
||||
public record CommitView(String commitSha, String message) {}
|
||||
|
||||
public record TreeEntry(String path, String name, String type, long size, String blobSha) {}
|
||||
|
||||
public record TreeView(String commitSha, String path, List<TreeEntry> entries) {}
|
||||
|
||||
public record FileView(
|
||||
String commitSha,
|
||||
String path,
|
||||
String blobSha,
|
||||
long size,
|
||||
String encoding,
|
||||
String content,
|
||||
boolean editable) {}
|
||||
|
||||
public record HistoryEntry(
|
||||
String commitSha, String message, String authorName, String authorDate) {}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.linkerbot.vibemake.bean.ai;
|
||||
|
||||
import com.linkerbot.vibemake.bean.Contracts.ProjectView;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
/** Maker AI 的公开协议;对话仅随请求传递,不持久化。 */
|
||||
public final class AiContracts {
|
||||
private AiContracts() {}
|
||||
|
||||
public record Message(
|
||||
@NotBlank @Pattern(regexp = "user|assistant") String role,
|
||||
@NotBlank @Size(max = 2000) String content) {}
|
||||
|
||||
public record ChatRequest(
|
||||
@NotBlank @Size(max = 2000) String message,
|
||||
@Size(max = 12) List<@NotNull @Valid Message> history,
|
||||
@Size(max = 5) List<@NotBlank @Size(max = 32) String> previousProjectCodes) {
|
||||
public ChatRequest {
|
||||
history = history == null ? List.of() : List.copyOf(history);
|
||||
previousProjectCodes = previousProjectCodes == null
|
||||
? List.of() : List.copyOf(previousProjectCodes);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Status { CHAT, MATCHED, NO_MATCH, NEEDS_CLARIFICATION, NEEDS_SELECTION, CREATED, FORKED }
|
||||
|
||||
public record Evidence(String field, String quote, String requirement) {}
|
||||
|
||||
public record ProjectCard(
|
||||
ProjectView project,
|
||||
String reason,
|
||||
List<Evidence> evidence,
|
||||
List<String> unverifiedRequirements) {}
|
||||
|
||||
public record ChatResult(Status status, String reply, List<ProjectCard> projects, ProjectView project) {
|
||||
public ChatResult(Status status, String reply, List<ProjectCard> projects) {
|
||||
this(status, reply, projects, null);
|
||||
}
|
||||
}
|
||||
|
||||
public record Progress(String stage, String message) {}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.linkerbot.vibemake.bean.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class BaseEntity {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.linkerbot.vibemake.bean.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("project")
|
||||
public class Project extends BaseEntity {
|
||||
private String projectCode;
|
||||
private Long ownerUserId;
|
||||
private String name;
|
||||
private String description;
|
||||
private String coverUrl;
|
||||
private String urdfMainObjectKey = "";
|
||||
private String urdfFiles = "[]";
|
||||
private String urdfPrefix = "";
|
||||
private String projectType;
|
||||
private Long giteaRepoId;
|
||||
private String giteaOwner;
|
||||
private String giteaRepoName;
|
||||
private String repoStatus;
|
||||
private String publishStatus;
|
||||
private String publishedCommitSha;
|
||||
private LocalDateTime publishedAt;
|
||||
private Long sourceProjectId;
|
||||
private String sourceCommitSha;
|
||||
private Boolean deleted;
|
||||
private String moderationReason;
|
||||
|
||||
@com.baomidou.mybatisplus.annotation.TableField(
|
||||
updateStrategy = com.baomidou.mybatisplus.annotation.FieldStrategy.NEVER)
|
||||
private String repoWriteStatus = "IDLE";
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.linkerbot.vibemake.bean.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("project_comment")
|
||||
public class ProjectComment extends BaseEntity {
|
||||
private String commentCode;
|
||||
private Long projectId;
|
||||
private Long userId;
|
||||
private String content;
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.linkerbot.vibemake.bean.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("project_import_task")
|
||||
public class ProjectImportTask extends BaseEntity {
|
||||
private String taskCode;
|
||||
private String projectCode;
|
||||
private String operatorUserCode;
|
||||
private Long sourceRepositoryId;
|
||||
private String sourceRepositoryUrl;
|
||||
private String sourceDefaultBranch;
|
||||
private String sourceLicense;
|
||||
private String status;
|
||||
private String phase;
|
||||
private String receiptJson;
|
||||
private String targetSha;
|
||||
private String errorCode;
|
||||
private String warningsJson;
|
||||
private java.time.LocalDateTime startedAt;
|
||||
private java.time.LocalDateTime finishedAt;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.linkerbot.vibemake.bean.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("project_like")
|
||||
public class ProjectLike {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long projectId;
|
||||
private Long userId;
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.linkerbot.vibemake.bean.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_user")
|
||||
public class User extends BaseEntity {
|
||||
private String userCode;
|
||||
private String email;
|
||||
private String nickname;
|
||||
private String status;
|
||||
private String role = "USER";
|
||||
private String passwordHash;
|
||||
private Long sessionVersion = 0L;
|
||||
}
|
||||
Reference in New Issue
Block a user