对象存储-初始化
This commit is contained in:
160
src/main/java/com/blog/entity/ArticleEntity.java
Normal file
160
src/main/java/com/blog/entity/ArticleEntity.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package com.blog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 文章表
|
||||
* @TableName sys_article
|
||||
*/
|
||||
@TableName(value ="sys_article")
|
||||
@Data
|
||||
@Builder
|
||||
public class ArticleEntity implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 作者ID
|
||||
*/
|
||||
private Long authorId;
|
||||
|
||||
/**
|
||||
* 0-草稿, 1-发布, 2下架, 3删除
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 浏览数
|
||||
*/
|
||||
private Long views;
|
||||
|
||||
/**
|
||||
* 收藏数
|
||||
*/
|
||||
private Long collectionCount;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Long likeCount;
|
||||
|
||||
/**
|
||||
* 点踩数
|
||||
*/
|
||||
private Long downvoteCount;
|
||||
|
||||
/**
|
||||
* 发布日期
|
||||
*/
|
||||
private Date releaseDate;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ArticleEntity other = (ArticleEntity) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
|
||||
&& (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
|
||||
&& (this.getAuthorId() == null ? other.getAuthorId() == null : this.getAuthorId().equals(other.getAuthorId()))
|
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
||||
&& (this.getViews() == null ? other.getViews() == null : this.getViews().equals(other.getViews()))
|
||||
&& (this.getCollectionCount() == null ? other.getCollectionCount() == null : this.getCollectionCount().equals(other.getCollectionCount()))
|
||||
&& (this.getLikeCount() == null ? other.getLikeCount() == null : this.getLikeCount().equals(other.getLikeCount()))
|
||||
&& (this.getDownvoteCount() == null ? other.getDownvoteCount() == null : this.getDownvoteCount().equals(other.getDownvoteCount()))
|
||||
&& (this.getReleaseDate() == null ? other.getReleaseDate() == null : this.getReleaseDate().equals(other.getReleaseDate()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
|
||||
&& (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
|
||||
result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
|
||||
result = prime * result + ((getAuthorId() == null) ? 0 : getAuthorId().hashCode());
|
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||
result = prime * result + ((getViews() == null) ? 0 : getViews().hashCode());
|
||||
result = prime * result + ((getCollectionCount() == null) ? 0 : getCollectionCount().hashCode());
|
||||
result = prime * result + ((getLikeCount() == null) ? 0 : getLikeCount().hashCode());
|
||||
result = prime * result + ((getDownvoteCount() == null) ? 0 : getDownvoteCount().hashCode());
|
||||
result = prime * result + ((getReleaseDate() == null) ? 0 : getReleaseDate().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", title=").append(title);
|
||||
sb.append(", content=").append(content);
|
||||
sb.append(", authorId=").append(authorId);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", views=").append(views);
|
||||
sb.append(", collectionCount=").append(collectionCount);
|
||||
sb.append(", likeCount=").append(likeCount);
|
||||
sb.append(", downvoteCount=").append(downvoteCount);
|
||||
sb.append(", releaseDate=").append(releaseDate);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", isDeleted=").append(isDeleted);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
152
src/main/java/com/blog/entity/FileEntity.java
Normal file
152
src/main/java/com/blog/entity/FileEntity.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package com.blog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 文件元数据映射表
|
||||
* @TableName sys_file
|
||||
*/
|
||||
@TableName(value ="sys_file")
|
||||
@Data
|
||||
@Builder
|
||||
public class FileEntity implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 别名
|
||||
*/
|
||||
private String aliasName;
|
||||
|
||||
/**
|
||||
* 文件原始名称
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* MinIO存储对象名(通常是UUID+后缀)
|
||||
*/
|
||||
private String storageName;
|
||||
|
||||
/**
|
||||
* 存储桶名称
|
||||
*/
|
||||
private String bucketName;
|
||||
|
||||
/**
|
||||
* 文件大小(bytes)
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 文件MIME类型
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* 访问地址(临时或持久)
|
||||
*/
|
||||
private String fileUrl;
|
||||
|
||||
/**
|
||||
* 上传者ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 关联的请求链路ID
|
||||
*/
|
||||
private String traceId;
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 上传时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
FileEntity other = (FileEntity) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getAliasName() == null ? other.getAliasName() == null : this.getAliasName().equals(other.getAliasName()))
|
||||
&& (this.getFileName() == null ? other.getFileName() == null : this.getFileName().equals(other.getFileName()))
|
||||
&& (this.getStorageName() == null ? other.getStorageName() == null : this.getStorageName().equals(other.getStorageName()))
|
||||
&& (this.getBucketName() == null ? other.getBucketName() == null : this.getBucketName().equals(other.getBucketName()))
|
||||
&& (this.getFileSize() == null ? other.getFileSize() == null : this.getFileSize().equals(other.getFileSize()))
|
||||
&& (this.getFileType() == null ? other.getFileType() == null : this.getFileType().equals(other.getFileType()))
|
||||
&& (this.getFileUrl() == null ? other.getFileUrl() == null : this.getFileUrl().equals(other.getFileUrl()))
|
||||
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
|
||||
&& (this.getTraceId() == null ? other.getTraceId() == null : this.getTraceId().equals(other.getTraceId()))
|
||||
&& (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getAliasName() == null) ? 0 : getAliasName().hashCode());
|
||||
result = prime * result + ((getFileName() == null) ? 0 : getFileName().hashCode());
|
||||
result = prime * result + ((getStorageName() == null) ? 0 : getStorageName().hashCode());
|
||||
result = prime * result + ((getBucketName() == null) ? 0 : getBucketName().hashCode());
|
||||
result = prime * result + ((getFileSize() == null) ? 0 : getFileSize().hashCode());
|
||||
result = prime * result + ((getFileType() == null) ? 0 : getFileType().hashCode());
|
||||
result = prime * result + ((getFileUrl() == null) ? 0 : getFileUrl().hashCode());
|
||||
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
|
||||
result = prime * result + ((getTraceId() == null) ? 0 : getTraceId().hashCode());
|
||||
result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", aliasName=").append(aliasName);
|
||||
sb.append(", fileName=").append(fileName);
|
||||
sb.append(", storageName=").append(storageName);
|
||||
sb.append(", bucketName=").append(bucketName);
|
||||
sb.append(", fileSize=").append(fileSize);
|
||||
sb.append(", fileType=").append(fileType);
|
||||
sb.append(", fileUrl=").append(fileUrl);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", traceId=").append(traceId);
|
||||
sb.append(", isDeleted=").append(isDeleted);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
120
src/main/java/com/blog/entity/InviteCodeEntity.java
Normal file
120
src/main/java/com/blog/entity/InviteCodeEntity.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package com.blog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 邀请码表
|
||||
* @TableName sys_invite_code
|
||||
*/
|
||||
@TableName(value ="sys_invite_code")
|
||||
@Data
|
||||
@Builder
|
||||
public class InviteCodeEntity implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 唯一邀请码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 生成人ID
|
||||
*/
|
||||
private Long creatorId;
|
||||
|
||||
/**
|
||||
* 最大使用次数
|
||||
*/
|
||||
private Integer maxUses;
|
||||
|
||||
/**
|
||||
* 已使用次数
|
||||
*/
|
||||
private Integer usedCount;
|
||||
|
||||
/**
|
||||
* 1-有效, 0-失效
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Date expireTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
InviteCodeEntity other = (InviteCodeEntity) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
|
||||
&& (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))
|
||||
&& (this.getMaxUses() == null ? other.getMaxUses() == null : this.getMaxUses().equals(other.getMaxUses()))
|
||||
&& (this.getUsedCount() == null ? other.getUsedCount() == null : this.getUsedCount().equals(other.getUsedCount()))
|
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
||||
&& (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
|
||||
result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());
|
||||
result = prime * result + ((getMaxUses() == null) ? 0 : getMaxUses().hashCode());
|
||||
result = prime * result + ((getUsedCount() == null) ? 0 : getUsedCount().hashCode());
|
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||
result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", code=").append(code);
|
||||
sb.append(", creatorId=").append(creatorId);
|
||||
sb.append(", maxUses=").append(maxUses);
|
||||
sb.append(", usedCount=").append(usedCount);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", expireTime=").append(expireTime);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
95
src/main/java/com/blog/entity/PathEntity.java
Normal file
95
src/main/java/com/blog/entity/PathEntity.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.blog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 文件目录映射表
|
||||
* @TableName sys_path
|
||||
*/
|
||||
@TableName(value ="sys_path")
|
||||
@Data
|
||||
@Builder
|
||||
public class PathEntity implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 目录名
|
||||
*/
|
||||
private String pathName;
|
||||
|
||||
/**
|
||||
* 上传者ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 父目录ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PathEntity other = (PathEntity) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getPathName() == null ? other.getPathName() == null : this.getPathName().equals(other.getPathName()))
|
||||
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
|
||||
&& (this.getParentId() == null ? other.getParentId() == null : this.getParentId().equals(other.getParentId()))
|
||||
&& (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getPathName() == null) ? 0 : getPathName().hashCode());
|
||||
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
|
||||
result = prime * result + ((getParentId() == null) ? 0 : getParentId().hashCode());
|
||||
result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", pathName=").append(pathName);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", parentId=").append(parentId);
|
||||
sb.append(", isDeleted=").append(isDeleted);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
71
src/main/java/com/blog/entity/PathFileEntity.java
Normal file
71
src/main/java/com/blog/entity/PathFileEntity.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.blog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 目录文件映射表
|
||||
* @TableName sys_path_file
|
||||
*/
|
||||
@TableName(value ="sys_path_file")
|
||||
@Data
|
||||
@Builder
|
||||
public class PathFileEntity implements Serializable {
|
||||
/**
|
||||
* 目录ID
|
||||
*/
|
||||
private Long pathId;
|
||||
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@TableId
|
||||
private Long fileId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PathFileEntity other = (PathFileEntity) that;
|
||||
return (this.getPathId() == null ? other.getPathId() == null : this.getPathId().equals(other.getPathId()))
|
||||
&& (this.getFileId() == null ? other.getFileId() == null : this.getFileId().equals(other.getFileId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getPathId() == null) ? 0 : getPathId().hashCode());
|
||||
result = prime * result + ((getFileId() == null) ? 0 : getFileId().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", pathId=").append(pathId);
|
||||
sb.append(", fileId=").append(fileId);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
112
src/main/java/com/blog/entity/RoleEntity.java
Normal file
112
src/main/java/com/blog/entity/RoleEntity.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.blog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 角色表
|
||||
* @TableName sys_role
|
||||
*/
|
||||
@TableName(value ="sys_role")
|
||||
@Data
|
||||
@Builder
|
||||
public class RoleEntity implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色名称(如:超级管理员)
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色标识(如:ROLE_ADMIN)
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态(1:正常, 0:禁用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
RoleEntity other = (RoleEntity) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
|
||||
&& (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
|
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
|
||||
result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
|
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", name=").append(name);
|
||||
sb.append(", code=").append(code);
|
||||
sb.append(", description=").append(description);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
178
src/main/java/com/blog/entity/UserEntity.java
Normal file
178
src/main/java/com/blog/entity/UserEntity.java
Normal file
@@ -0,0 +1,178 @@
|
||||
package com.blog.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.blog.dto.UserRegisterDto;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户表
|
||||
* @TableName sys_user
|
||||
*/
|
||||
@TableName(value ="sys_user")
|
||||
@Data
|
||||
@Builder
|
||||
public class UserEntity implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码(BCrypt加密)
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 头像URL
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别: 1男, 2女, 0未知
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 状态: 1启用, 0禁用
|
||||
*/
|
||||
private Integer enabled;
|
||||
|
||||
/**
|
||||
* 使用的邀请码ID
|
||||
*/
|
||||
private Long inviteCodeId;
|
||||
|
||||
/**
|
||||
* 解禁日期
|
||||
*/
|
||||
private Date releaseDate;
|
||||
|
||||
/**
|
||||
* 注册时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 最后修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记:0-未删, 1-已删
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static UserEntity castFromRegisterDto(UserRegisterDto userDto, String password, Long inviteCodeId) {
|
||||
return UserEntity.builder()
|
||||
.username(userDto.getUsername())
|
||||
.password(password)
|
||||
.email(userDto.getEmail())
|
||||
.inviteCodeId(inviteCodeId)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
UserEntity other = (UserEntity) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
|
||||
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
|
||||
&& (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname()))
|
||||
&& (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
|
||||
&& (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone()))
|
||||
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
|
||||
&& (this.getGender() == null ? other.getGender() == null : this.getGender().equals(other.getGender()))
|
||||
&& (this.getEnabled() == null ? other.getEnabled() == null : this.getEnabled().equals(other.getEnabled()))
|
||||
&& (this.getInviteCodeId() == null ? other.getInviteCodeId() == null : this.getInviteCodeId().equals(other.getInviteCodeId()))
|
||||
&& (this.getReleaseDate() == null ? other.getReleaseDate() == null : this.getReleaseDate().equals(other.getReleaseDate()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
|
||||
&& (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
|
||||
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
|
||||
result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode());
|
||||
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
|
||||
result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode());
|
||||
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
|
||||
result = prime * result + ((getGender() == null) ? 0 : getGender().hashCode());
|
||||
result = prime * result + ((getEnabled() == null) ? 0 : getEnabled().hashCode());
|
||||
result = prime * result + ((getInviteCodeId() == null) ? 0 : getInviteCodeId().hashCode());
|
||||
result = prime * result + ((getReleaseDate() == null) ? 0 : getReleaseDate().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", username=").append(username);
|
||||
sb.append(", password=").append(password);
|
||||
sb.append(", nickname=").append(nickname);
|
||||
sb.append(", email=").append(email);
|
||||
sb.append(", phone=").append(phone);
|
||||
sb.append(", avatar=").append(avatar);
|
||||
sb.append(", gender=").append(gender);
|
||||
sb.append(", enabled=").append(enabled);
|
||||
sb.append(", inviteCodeId=").append(inviteCodeId);
|
||||
sb.append(", releaseDate=").append(releaseDate);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", isDeleted=").append(isDeleted);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
18
src/main/java/com/blog/mapper/ArticleMapper.java
Normal file
18
src/main/java/com/blog/mapper/ArticleMapper.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.blog.mapper;
|
||||
|
||||
import com.blog.entity.ArticleEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_article(文章表)】的数据库操作Mapper
|
||||
* @createDate 2026-02-05 11:17:35
|
||||
* @Entity com.blog.entity.ArticleEntity
|
||||
*/
|
||||
public interface ArticleMapper extends BaseMapper<ArticleEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
18
src/main/java/com/blog/mapper/FileMapper.java
Normal file
18
src/main/java/com/blog/mapper/FileMapper.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.blog.mapper;
|
||||
|
||||
import com.blog.entity.FileEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_file(文件元数据映射表)】的数据库操作Mapper
|
||||
* @createDate 2026-02-05 11:17:30
|
||||
* @Entity com.blog.entity.FileEntity
|
||||
*/
|
||||
public interface FileMapper extends BaseMapper<FileEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
26
src/main/java/com/blog/mapper/InviteCodeMapper.java
Normal file
26
src/main/java/com/blog/mapper/InviteCodeMapper.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.blog.mapper;
|
||||
|
||||
import com.blog.entity.InviteCodeEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_invite_code(邀请码表)】的数据库操作Mapper
|
||||
* @createDate 2026-02-05 11:17:26
|
||||
* @Entity com.blog.entity.InviteCodeEntity
|
||||
*/
|
||||
public interface InviteCodeMapper extends BaseMapper<InviteCodeEntity> {
|
||||
|
||||
@Update("UPDATE sys_invite_code " +
|
||||
"SET used_count = used_count + 1 " +
|
||||
"WHERE code = #{code} " +
|
||||
" AND status = 1 " +
|
||||
" AND used_count < max_uses ")
|
||||
int subUsedCount(@Param("code") String code);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
18
src/main/java/com/blog/mapper/PathFileMapper.java
Normal file
18
src/main/java/com/blog/mapper/PathFileMapper.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.blog.mapper;
|
||||
|
||||
import com.blog.entity.PathFileEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_path_file(目录文件映射表)】的数据库操作Mapper
|
||||
* @createDate 2026-02-05 11:17:18
|
||||
* @Entity com.blog.entity.PathFileEntity
|
||||
*/
|
||||
public interface PathFileMapper extends BaseMapper<PathFileEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
18
src/main/java/com/blog/mapper/PathMapper.java
Normal file
18
src/main/java/com/blog/mapper/PathMapper.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.blog.mapper;
|
||||
|
||||
import com.blog.entity.PathEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_path(文件目录映射表)】的数据库操作Mapper
|
||||
* @createDate 2026-02-05 11:17:22
|
||||
* @Entity com.blog.entity.PathEntity
|
||||
*/
|
||||
public interface PathMapper extends BaseMapper<PathEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
18
src/main/java/com/blog/mapper/RoleMapper.java
Normal file
18
src/main/java/com/blog/mapper/RoleMapper.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.blog.mapper;
|
||||
|
||||
import com.blog.entity.RoleEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_role(角色表)】的数据库操作Mapper
|
||||
* @createDate 2026-02-05 11:17:06
|
||||
* @Entity com.blog.entity.RoleEntity
|
||||
*/
|
||||
public interface RoleMapper extends BaseMapper<RoleEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
18
src/main/java/com/blog/mapper/UserMapper.java
Normal file
18
src/main/java/com/blog/mapper/UserMapper.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.blog.mapper;
|
||||
|
||||
import com.blog.entity.UserEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_user(用户表)】的数据库操作Mapper
|
||||
* @createDate 2026-02-05 11:16:45
|
||||
* @Entity com.blog.entity.UserEntity
|
||||
*/
|
||||
public interface UserMapper extends BaseMapper<UserEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
15
src/main/java/com/blog/service/ArticleService.java
Normal file
15
src/main/java/com/blog/service/ArticleService.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.blog.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.blog.entity.ArticleEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_article(文章表)】的数据库操作Service
|
||||
* @createDate 2026-02-05 11:17:35
|
||||
*/
|
||||
public interface ArticleService {
|
||||
|
||||
boolean getarticles(Long userId, Page<Object> of);
|
||||
}
|
||||
13
src/main/java/com/blog/service/FileService.java
Normal file
13
src/main/java/com/blog/service/FileService.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.blog.service;
|
||||
|
||||
import com.blog.entity.FileEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_file(文件元数据映射表)】的数据库操作Service
|
||||
* @createDate 2026-02-05 11:17:30
|
||||
*/
|
||||
public interface FileService {
|
||||
|
||||
}
|
||||
13
src/main/java/com/blog/service/InviteCodeService.java
Normal file
13
src/main/java/com/blog/service/InviteCodeService.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.blog.service;
|
||||
|
||||
import com.blog.entity.InviteCodeEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_invite_code(邀请码表)】的数据库操作Service
|
||||
* @createDate 2026-02-05 11:17:26
|
||||
*/
|
||||
public interface InviteCodeService {
|
||||
|
||||
}
|
||||
13
src/main/java/com/blog/service/PathFileService.java
Normal file
13
src/main/java/com/blog/service/PathFileService.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.blog.service;
|
||||
|
||||
import com.blog.entity.PathFileEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_path_file(目录文件映射表)】的数据库操作Service
|
||||
* @createDate 2026-02-05 11:17:18
|
||||
*/
|
||||
public interface PathFileService {
|
||||
|
||||
}
|
||||
14
src/main/java/com/blog/service/PathService.java
Normal file
14
src/main/java/com/blog/service/PathService.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.blog.service;
|
||||
|
||||
import com.blog.entity.PathEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_path(文件目录映射表)】的数据库操作Service
|
||||
* @createDate 2026-02-05 11:17:22
|
||||
*/
|
||||
public interface PathService {
|
||||
|
||||
boolean listPath(Long userId);
|
||||
}
|
||||
13
src/main/java/com/blog/service/RoleService.java
Normal file
13
src/main/java/com/blog/service/RoleService.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.blog.service;
|
||||
|
||||
import com.blog.entity.RoleEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_role(角色表)】的数据库操作Service
|
||||
* @createDate 2026-02-05 11:17:06
|
||||
*/
|
||||
public interface RoleService {
|
||||
|
||||
}
|
||||
24
src/main/java/com/blog/service/UserService.java
Normal file
24
src/main/java/com/blog/service/UserService.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.blog.service;
|
||||
|
||||
import com.blog.context.RequestContext;
|
||||
import com.blog.dto.UserLoginDto;
|
||||
import com.blog.dto.UserRegisterDto;
|
||||
import com.blog.entity.UserEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_user(用户表)】的数据库操作Service
|
||||
* @createDate 2026-02-05 11:16:45
|
||||
*/
|
||||
public interface UserService {
|
||||
|
||||
String register(UserRegisterDto userDto);
|
||||
|
||||
boolean exist(String username);
|
||||
|
||||
boolean refreshToken(RequestContext requestContext);
|
||||
|
||||
<T> T login(UserLoginDto user);
|
||||
}
|
||||
26
src/main/java/com/blog/service/impl/ArticleServiceImpl.java
Normal file
26
src/main/java/com/blog/service/impl/ArticleServiceImpl.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.blog.entity.ArticleEntity;
|
||||
import com.blog.service.ArticleService;
|
||||
import com.blog.mapper.ArticleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_article(文章表)】的数据库操作Service实现
|
||||
* @createDate 2026-02-05 11:17:35
|
||||
*/
|
||||
@Service
|
||||
public class ArticleServiceImpl implements ArticleService{
|
||||
|
||||
@Override
|
||||
public boolean getarticles(Long userId, Page<Object> of) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
21
src/main/java/com/blog/service/impl/FileServiceImpl.java
Normal file
21
src/main/java/com/blog/service/impl/FileServiceImpl.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.blog.entity.FileEntity;
|
||||
import com.blog.service.FileService;
|
||||
import com.blog.mapper.FileMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_file(文件元数据映射表)】的数据库操作Service实现
|
||||
* @createDate 2026-02-05 11:17:30
|
||||
*/
|
||||
@Service
|
||||
public class FileServiceImpl implements FileService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.blog.entity.InviteCodeEntity;
|
||||
import com.blog.service.InviteCodeService;
|
||||
import com.blog.mapper.InviteCodeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_invite_code(邀请码表)】的数据库操作Service实现
|
||||
* @createDate 2026-02-05 11:17:26
|
||||
*/
|
||||
@Service
|
||||
public class InviteCodeServiceImpl extends ServiceImpl<InviteCodeMapper, InviteCodeEntity>
|
||||
implements InviteCodeService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
22
src/main/java/com/blog/service/impl/PathFileServiceImpl.java
Normal file
22
src/main/java/com/blog/service/impl/PathFileServiceImpl.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.blog.entity.PathFileEntity;
|
||||
import com.blog.service.PathFileService;
|
||||
import com.blog.mapper.PathFileMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_path_file(目录文件映射表)】的数据库操作Service实现
|
||||
* @createDate 2026-02-05 11:17:18
|
||||
*/
|
||||
@Service
|
||||
public class PathFileServiceImpl extends ServiceImpl<PathFileMapper, PathFileEntity>
|
||||
implements PathFileService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
40
src/main/java/com/blog/service/impl/PathServiceImpl.java
Normal file
40
src/main/java/com/blog/service/impl/PathServiceImpl.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.blog.entity.PathEntity;
|
||||
import com.blog.holder.RequestImplicitContextHolder;
|
||||
import com.blog.service.PathService;
|
||||
import com.blog.mapper.PathMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_path(文件目录映射表)】的数据库操作Service实现
|
||||
* @createDate 2026-02-05 11:17:22
|
||||
*/
|
||||
@Service
|
||||
public class PathServiceImpl implements PathService{
|
||||
|
||||
@Autowired
|
||||
private PathMapper pathMapper;
|
||||
|
||||
@Override
|
||||
public boolean listPath(Long userId) {
|
||||
String username = RequestImplicitContextHolder.getUsername();
|
||||
List<PathEntity> pathEntities = pathMapper.selectList(Page.of(0, 20),
|
||||
new LambdaQueryWrapper<PathEntity>()
|
||||
.eq(PathEntity::getUserId, userId)
|
||||
.eq(PathEntity::getParentId, username));
|
||||
RequestImplicitContextHolder.setData(pathEntities);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
21
src/main/java/com/blog/service/impl/RoleServiceImpl.java
Normal file
21
src/main/java/com/blog/service/impl/RoleServiceImpl.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.blog.entity.RoleEntity;
|
||||
import com.blog.service.RoleService;
|
||||
import com.blog.mapper.RoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_role(角色表)】的数据库操作Service实现
|
||||
* @createDate 2026-02-05 11:17:06
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
132
src/main/java/com/blog/service/impl/UserServiceImpl.java
Normal file
132
src/main/java/com/blog/service/impl/UserServiceImpl.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package com.blog.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.blog.common.constant.UserConstant;
|
||||
import com.blog.common.constant.message.error.UserErrorMessage;
|
||||
import com.blog.context.RequestContext;
|
||||
import com.blog.dto.UserLoginDto;
|
||||
import com.blog.dto.UserRegisterDto;
|
||||
import com.blog.entity.InviteCodeEntity;
|
||||
import com.blog.entity.UserEntity;
|
||||
import com.blog.helper.UserHelper;
|
||||
import com.blog.holder.RequestImplicitContextHolder;
|
||||
import com.blog.mapper.InviteCodeMapper;
|
||||
import com.blog.pipeline.RegisterPipeline;
|
||||
import com.blog.service.UserService;
|
||||
import com.blog.mapper.UserMapper;
|
||||
import com.blog.utils.ChartsGenerator;
|
||||
import com.blog.validator.UserValidator;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 29203
|
||||
* @description 针对表【sys_user(用户表)】的数据库操作Service实现
|
||||
* @createDate 2026-02-05 11:16:45
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService{
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private UserHelper userHelper;
|
||||
|
||||
@Autowired
|
||||
private UserValidator userValidator;
|
||||
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private InviteCodeMapper inviteCodeMapper;
|
||||
|
||||
@Autowired
|
||||
private RegisterPipeline registerPipeline;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean refreshToken(RequestContext requestContext) {
|
||||
String token = requestContext.getReqValue(UserConstant.REFRESH_TOKEN).toString();
|
||||
boolean validated = userHelper.validateToken(token);
|
||||
if (!validated) {
|
||||
RequestImplicitContextHolder.pushErrorMessage(UserErrorMessage.INVALID_REFRESH_TOKEN);
|
||||
return false;
|
||||
}
|
||||
Claims claims = userHelper.parseToken(token);
|
||||
UserEntity userEntity = userMapper.selectOne(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getUsername, claims.get(UserConstant.USERNAME)));
|
||||
if(userEntity == null){
|
||||
RequestImplicitContextHolder.pushErrorMessage(UserErrorMessage.INVALID_USER);
|
||||
return false;
|
||||
}
|
||||
Map<String, String> newToken = userHelper.obtainJWT(userEntity);
|
||||
RequestImplicitContextHolder.setData(newToken);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T login(UserLoginDto user) {
|
||||
LambdaQueryWrapper<UserEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(UserEntity::getUsername, user.getUsername());
|
||||
UserEntity userEntity = userMapper.selectOne(lambdaQueryWrapper);
|
||||
String errMsg = userValidator.validateUser(user,userEntity);
|
||||
if(errMsg!=null) return (T) errMsg;
|
||||
return (T) userHelper.obtainJWT(userEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String register(UserRegisterDto userDto) {
|
||||
LambdaQueryWrapper<UserEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(UserEntity::getUsername, userDto.getUsername());
|
||||
UserEntity userEntity = userMapper.selectOne(lambdaQueryWrapper);
|
||||
InviteCodeEntity inviteCodeEntity = inviteCodeMapper.selectOne(new LambdaQueryWrapper<InviteCodeEntity>().eq(InviteCodeEntity::getCode, userDto.getInviteCode()));
|
||||
String errMsg = userValidator.validateRegister(userEntity,inviteCodeEntity);
|
||||
if (errMsg != null) return errMsg;
|
||||
UserEntity newUser = UserEntity.castFromRegisterDto(userDto,passwordEncoder.encode(userDto.getPassword()),inviteCodeEntity.getId());
|
||||
newUser.setNickname("游客"+ ChartsGenerator.generateCode());
|
||||
transactionTemplate.execute(status -> {
|
||||
try {
|
||||
userMapper.insert(newUser);
|
||||
int affectedRows = inviteCodeMapper.subUsedCount(inviteCodeEntity.getCode());
|
||||
if(affectedRows<=0){
|
||||
status.setRollbackOnly();
|
||||
return false;
|
||||
}
|
||||
RequestImplicitContextHolder.setUserId(newUser.getId());
|
||||
boolean re = registerPipeline.start(userDto);
|
||||
if(!re){
|
||||
status.setRollbackOnly();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
RequestImplicitContextHolder.pushErrorMessage(e.getMessage());
|
||||
e.printStackTrace();
|
||||
status.setRollbackOnly(); // 显式标记回滚
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exist(String username) {
|
||||
UserEntity userEntity = userMapper.selectOne(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getUsername, username));
|
||||
if (userEntity == null) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user