mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-11 06:57:12 +08:00
feat: 新增部分文件管理后端 API
This commit is contained in:
@@ -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;
|
||||
}
|
@@ -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> {}
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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 java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.continew.admin.system.enums.FileTypeEnum;
|
||||
import top.charles7c.continew.starter.extension.crud.base.BaseResp;
|
||||
|
||||
/**
|
||||
* 文件信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/12/23 10:38
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "文件信息")
|
||||
public class FileResp extends BaseResp {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 大小(字节)
|
||||
*/
|
||||
@Schema(description = "大小(字节)")
|
||||
private Long size;
|
||||
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
@Schema(description = "URL")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 扩展名
|
||||
*/
|
||||
@Schema(description = "扩展名")
|
||||
private String extension;
|
||||
|
||||
/**
|
||||
* MIME类型
|
||||
*/
|
||||
@Schema(description = "MIME类型")
|
||||
private String mimeType;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型")
|
||||
private FileTypeEnum type;
|
||||
|
||||
/**
|
||||
* 存储库ID
|
||||
*/
|
||||
@Schema(description = "存储库ID")
|
||||
private Long storageId;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.service;
|
||||
|
||||
import top.charles7c.continew.admin.system.model.query.FileQuery;
|
||||
import top.charles7c.continew.admin.system.model.req.FileReq;
|
||||
import top.charles7c.continew.admin.system.model.resp.FileDetailResp;
|
||||
import top.charles7c.continew.admin.system.model.resp.FileResp;
|
||||
import top.charles7c.continew.starter.extension.crud.base.BaseService;
|
||||
|
||||
/**
|
||||
* 文件业务接口
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/12/23 10:38
|
||||
*/
|
||||
public interface FileService extends BaseService<FileResp, FileDetailResp, FileQuery, FileReq> {}
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import top.charles7c.continew.admin.system.mapper.FileMapper;
|
||||
import top.charles7c.continew.admin.system.model.entity.FileDO;
|
||||
import top.charles7c.continew.admin.system.model.query.FileQuery;
|
||||
import top.charles7c.continew.admin.system.model.req.FileReq;
|
||||
import top.charles7c.continew.admin.system.model.resp.FileDetailResp;
|
||||
import top.charles7c.continew.admin.system.model.resp.FileResp;
|
||||
import top.charles7c.continew.admin.system.service.FileService;
|
||||
import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl;
|
||||
|
||||
/**
|
||||
* 文件业务实现
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/12/23 10:38
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileResp, FileDetailResp, FileQuery, FileReq>
|
||||
implements FileService {}
|
Reference in New Issue
Block a user