Skip to content

Commit

Permalink
feat: 新增部分文件管理后端 API
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Dec 23, 2023
1 parent fd0e05f commit 4c24aea
Show file tree
Hide file tree
Showing 48 changed files with 926 additions and 460 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package top.charles7c.continew.admin.system.enums;

import java.util.Collections;
import java.util.List;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import top.charles7c.continew.starter.data.mybatis.plus.base.IBaseEnum;

/**
* 文件分类枚举
*
* @author Charles7c
* @since 2023/12/23 13:38
*/
@Getter
@RequiredArgsConstructor
public enum FileTypeEnum implements IBaseEnum<Integer> {

/**
* 其他
*/
UNKNOWN(1, "其他", Collections.emptyList()),

/**
* 图片
*/
IMAGE(2, "图片", List.of("jpg", "png", "gif", "bmp", "webp", "ico", "psd", "tiff", "dwg", "jxr", "apng", "xcf")),

/**
* 文档
*/
DOC(3, "文档", List.of("txt", "pdf", "doc", "xls", "ppt", "docx", "xlsx", "pptx")),

/**
* 视频
*/
VIDEO(4, "视频", List.of("mp4", "avi", "mkv", "flv", "webm", "wmv", "m4v", "mov", "mpg", "rmvb", "3gp")),

/**
* 音频
*/
AUDIO(5, "音频", List.of("mp3", "flac", "wav", "ogg", "midi", "m4a", "aac", "amr", "ac3", "aiff")),;

private final Integer value;
private final String description;
private final List<String> extensions;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package top.charles7c.continew.admin.system.mapper;

import top.charles7c.continew.admin.system.model.entity.FileDO;
import top.charles7c.continew.starter.data.mybatis.plus.base.BaseMapper;

/**
* 文件 Mapper
*
* @author Charles7c
* @since 2023/12/23 10:38
*/
public interface FileMapper extends BaseMapper<FileDO> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package top.charles7c.continew.admin.system.model.entity;

import java.io.Serial;

import lombok.Data;

import com.baomidou.mybatisplus.annotation.TableName;

import top.charles7c.continew.admin.system.enums.FileTypeEnum;
import top.charles7c.continew.starter.extension.crud.base.BaseDO;

/**
* 文件实体
*
* @author Charles7c
* @since 2023/12/23 10:38
*/
@Data
@TableName("sys_file")
public class FileDO extends BaseDO {

@Serial
private static final long serialVersionUID = 1L;

/**
* 名称
*/
private String name;

/**
* 大小(字节)
*/
private Long size;

/**
* URL
*/
private String url;

/**
* 扩展名
*/
private String extension;

/**
* MIME类型
*/
private String mimeType;

/**
* 类型
*/
private FileTypeEnum type;

/**
* 存储库ID
*/
private Long storageId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package top.charles7c.continew.admin.system.model.query;

import java.io.Serial;
import java.io.Serializable;

import lombok.Data;

import io.swagger.v3.oas.annotations.media.Schema;

import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;

/**
* 文件查询条件
*
* @author Charles7c
* @since 2023/12/23 10:38
*/
@Data
@Schema(description = "文件查询条件")
public class FileQuery implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
* 名称
*/
@Schema(description = "名称")
@Query(type = QueryType.INNER_LIKE)
private String name;

/**
* 类型
*/
@Schema(description = "类型")
@Query(type = QueryType.EQUAL)
private Integer type;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package top.charles7c.continew.admin.system.model.req;

import java.io.Serial;

import lombok.Data;

import io.swagger.v3.oas.annotations.media.Schema;

import top.charles7c.continew.starter.extension.crud.base.BaseReq;

/**
* 创建或修改文件信息
*
* @author Charles7c
* @since 2023/12/23 10:38
*/
@Data
@Schema(description = "创建或修改文件信息")
public class FileReq extends BaseReq {

@Serial
private static final long serialVersionUID = 1L;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package top.charles7c.continew.admin.system.model.resp;

import java.io.Serial;

import lombok.Data;

import io.swagger.v3.oas.annotations.media.Schema;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;

import top.charles7c.continew.admin.system.enums.FileTypeEnum;
import top.charles7c.continew.starter.extension.crud.base.BaseDetailResp;

/**
* 文件详情信息
*
* @author Charles7c
* @since 2023/12/23 10:38
*/
@Data
@ExcelIgnoreUnannotated
@Schema(description = "文件详情信息")
public class FileDetailResp extends BaseDetailResp {

@Serial
private static final long serialVersionUID = 1L;

/**
* 名称
*/
@Schema(description = "名称")
@ExcelProperty(value = "名称")
private String name;

/**
* 大小(字节)
*/
@Schema(description = "大小(字节)")
@ExcelProperty(value = "大小(字节)")
private Long size;

/**
* URL
*/
@Schema(description = "URL")
@ExcelProperty(value = "URL")
private String url;

/**
* 扩展名
*/
@Schema(description = "扩展名")
@ExcelProperty(value = "扩展名")
private String extension;

/**
* MIME类型
*/
@Schema(description = "MIME类型")
@ExcelProperty(value = "MIME类型")
private String mimeType;

/**
* 类型
*/
@Schema(description = "类型")
@ExcelProperty(value = "类型")
private FileTypeEnum type;

/**
* 存储库ID
*/
@Schema(description = "存储库ID")
@ExcelProperty(value = "存储库ID")
private Long storageId;
}
Loading

0 comments on commit 4c24aea

Please sign in to comment.