文件模块初步完成
This commit is contained in:
@ -0,0 +1,78 @@
|
||||
package com.greenorange.promotion.model.dto.fileInfo;
|
||||
|
||||
import com.greenorange.promotion.annotation.EnumValue;
|
||||
import com.greenorange.promotion.model.enums.FileUploadBizEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件添加请求体
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Schema(description = "文件添加请求体", requiredProperties = {
|
||||
"name",
|
||||
"type",
|
||||
"path",
|
||||
"size",
|
||||
"fileView",
|
||||
"biz",
|
||||
})
|
||||
public class FileInfoAddRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
@NotBlank(message = "文件名不能为空")
|
||||
@Schema(description = "文件名", example = "file.png")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
@NotBlank(message = "文件类型不能为空")
|
||||
@Schema(description = "文件类型", example = "png")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@NotBlank(message = "文件路径不能为空")
|
||||
@Schema(description = "文件路径", example = "user_avatar/file.png")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件大小(KB)
|
||||
*/
|
||||
@Schema(description = "文件大小", example = "3000")
|
||||
private Double size;
|
||||
|
||||
/**
|
||||
* 文件view值
|
||||
*/
|
||||
@NotBlank(message = "文件view值不能为空")
|
||||
@Schema(description = "文件view值", example = "3E8U2AM8")
|
||||
private String fileView;
|
||||
|
||||
/**
|
||||
* 文件业务类型(头像,项目,富文本,默认)
|
||||
*/
|
||||
@EnumValue(enumClass = FileUploadBizEnum.class)
|
||||
@Schema(description = "文件业务类型(头像,项目,富文本,默认)", example = "avatar")
|
||||
private String biz;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.greenorange.promotion.model.dto.fileInfo;
|
||||
|
||||
import com.greenorange.promotion.annotation.EnumValue;
|
||||
import com.greenorange.promotion.model.enums.FileUploadBizEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import com.greenorange.promotion.common.PageRequest;
|
||||
|
||||
/**
|
||||
* 文件查询请求体,继承自分页请求 PageRequest
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "文件查询请求体", requiredProperties = {"current", "pageSize"})
|
||||
public class FileInfoQueryRequest extends PageRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@Min(value = 1L, message = "文件ID ID不能小于1")
|
||||
@Schema(description = "文件ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 文件view值
|
||||
*/
|
||||
@EnumValue(enumClass = FileUploadBizEnum.class)
|
||||
@Schema(description = "文件view值", example = "3E8U2AM8")
|
||||
private String fileView;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
package com.greenorange.promotion.model.dto.fileInfo;
|
||||
|
||||
import com.greenorange.promotion.annotation.EnumValue;
|
||||
import com.greenorange.promotion.model.enums.FileUploadBizEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件更新请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "文件更新请求体", requiredProperties = {
|
||||
"id",
|
||||
"name",
|
||||
"type",
|
||||
"path",
|
||||
"size",
|
||||
"fileView",
|
||||
"biz",
|
||||
})
|
||||
public class FileInfoUpdateRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@Min(value = 1L, message = "文件ID ID不能小于1")
|
||||
@Schema(description = "文件ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
@NotBlank(message = "文件名不能为空")
|
||||
@Schema(description = "文件名", example = "file.png")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
@NotBlank(message = "文件类型不能为空")
|
||||
@Schema(description = "文件类型", example = "png")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@NotBlank(message = "文件路径不能为空")
|
||||
@Schema(description = "文件路径", example = "user_avatar/file.png")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件大小(KB)
|
||||
*/
|
||||
@Min(value = 1L, message = "文件大小 ID不能小于1")
|
||||
@Schema(description = "文件大小", example = "3000")
|
||||
private Double size;
|
||||
|
||||
/**
|
||||
* 文件view值
|
||||
*/
|
||||
@NotBlank(message = "文件view值不能为空")
|
||||
@Schema(description = "文件view值", example = "3E8U2AM8")
|
||||
private String fileView;
|
||||
|
||||
/**
|
||||
* 文件业务类型(头像,项目,富文本,默认)
|
||||
*/
|
||||
@EnumValue(enumClass = FileUploadBizEnum.class)
|
||||
@Schema(description = "文件业务类型(头像,项目,富文本,默认)", example = "avatar")
|
||||
private String biz;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.greenorange.promotion.model.dto.fileInfo;
|
||||
|
||||
import com.greenorange.promotion.annotation.EnumValue;
|
||||
import com.greenorange.promotion.model.enums.FileUploadBizEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Schema(description = "文件上传请求体", requiredProperties = {"biz"})
|
||||
public class UploadFileRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 文件业务类型(头像,项目,富文本,默认)
|
||||
*/
|
||||
@EnumValue(enumClass = FileUploadBizEnum.class)
|
||||
@Schema(description = "文件业务类型(头像,项目,富文本,默认)", example = "avatar")
|
||||
private String biz;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.greenorange.promotion.model.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.Data;
|
||||
|
||||
/**
|
||||
* 文件上传列表
|
||||
* @TableName file_info
|
||||
*/
|
||||
@TableName(value ="file_info")
|
||||
@Data
|
||||
public class FileInfo implements Serializable {
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件大小(KB)
|
||||
*/
|
||||
private Double size;
|
||||
|
||||
/**
|
||||
* 文件view值
|
||||
*/
|
||||
private String fileView;
|
||||
|
||||
/**
|
||||
* 文件业务类型(头像,项目,富文本,默认)
|
||||
*/
|
||||
private String biz;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.greenorange.promotion.model.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 文件上传业务类型枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum FileUploadBizEnum {
|
||||
|
||||
AVATAR("用户头像", "avatar"),
|
||||
PROJECT("项目", "project"),
|
||||
RICH_TEXT("富文本", "richText");
|
||||
|
||||
private final String text;
|
||||
private final String value;
|
||||
|
||||
FileUploadBizEnum(String text, String value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值列表
|
||||
*/
|
||||
public static List<String> getValues() {
|
||||
return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据值获取对应的枚举对象
|
||||
*/
|
||||
public static FileUploadBizEnum getEnumByValue(String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return null;
|
||||
}
|
||||
for (FileUploadBizEnum anEnum : FileUploadBizEnum.values()) {
|
||||
if (anEnum.value.equals(value)) {
|
||||
return anEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 项目状态枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum ProjectStatusEnum {
|
||||
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.greenorange.promotion.model.vo.fileInfo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 文件 视图对象
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "文件 视图对象")
|
||||
public class FileInfoVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@Schema(description = "文件ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
@Schema(description = "文件名", example = "file.png")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
@Schema(description = "文件类型", example = "png")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@Schema(description = "文件路径", example = "user_avatar/file.png")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件大小(KB)
|
||||
*/
|
||||
@Schema(description = "文件大小", example = "3000")
|
||||
private Double size;
|
||||
|
||||
/**
|
||||
* 文件view值
|
||||
*/
|
||||
@Schema(description = "文件view值", example = "3E8U3A")
|
||||
private String fileView;
|
||||
|
||||
/**
|
||||
* 文件业务类型(头像,项目,富文本,默认)
|
||||
*/
|
||||
@Schema(description = "文件业务类型(头像,项目,富文本,默认)", example = "user_avatar")
|
||||
private String biz;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
Reference in New Issue
Block a user