😎修复文件上次错误
This commit is contained in:
parent
d877c0569d
commit
d5e4a6e188
@ -100,12 +100,12 @@ public partial class SysFile : EntityTenantBaseData
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "文件类别", Length = 128)]
|
[SugarColumn(ColumnDescription = "文件类别", Length = 128)]
|
||||||
[MaxLength(128)]
|
[MaxLength(128)]
|
||||||
public string? FileType { get; set; }
|
public virtual string? FileType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否公开
|
/// 是否公开
|
||||||
/// 若为true则所有人都可以查看,默认只有自己或有权限的可以查看
|
/// 若为true则所有人都可以查看,默认只有自己或有权限的可以查看
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "是否公开")]
|
[SugarColumn(ColumnDescription = "是否公开")]
|
||||||
public bool IsPublic { get; set; } = false;
|
public virtual bool IsPublic { get; set; } = false;
|
||||||
}
|
}
|
||||||
@ -56,6 +56,16 @@ public class UploadFileInput : SysFile
|
|||||||
[Required]
|
[Required]
|
||||||
public IFormFile File { get; set; }
|
public IFormFile File { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件类别
|
||||||
|
/// </summary>
|
||||||
|
public override string FileType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否公开
|
||||||
|
/// </summary>
|
||||||
|
public override bool IsPublic { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件路径
|
/// 文件路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -274,7 +274,6 @@ public class SysFileService : IDynamicApiController, ITransient
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[ApiDescriptionSettings(Name = "File"), HttpGet]
|
|
||||||
[DisplayName("获取文件")]
|
[DisplayName("获取文件")]
|
||||||
public async Task<SysFile> GetFile([FromQuery] long id)
|
public async Task<SysFile> GetFile([FromQuery] long id)
|
||||||
{
|
{
|
||||||
@ -286,29 +285,26 @@ public class SysFileService : IDynamicApiController, ITransient
|
|||||||
/// 获取文件路径 🔖
|
/// 获取文件路径 🔖
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[ApiDescriptionSettings(Name = "Folder"), HttpGet]
|
|
||||||
[DisplayName("获取文件路径")]
|
[DisplayName("获取文件路径")]
|
||||||
public async Task<dynamic> GetFolder()
|
public async Task<dynamic> GetFolder()
|
||||||
{
|
{
|
||||||
var files = await _sysFileRep.AsQueryable().ToListAsync();
|
var files = await _sysFileRep.AsQueryable().ToListAsync();
|
||||||
var folders = files.GroupBy(x => x.FilePath).Select(g => g.First().FilePath).ToList();
|
var folders = files.GroupBy(u => u.FilePath).Select(u => u.First().FilePath).ToList();
|
||||||
var result = folders
|
var result = folders
|
||||||
.GroupBy(p => p.Split('/').First())
|
.GroupBy(u => u.Split('/').First())
|
||||||
.Select((g, index) => new
|
.Select((u, index) => new
|
||||||
{
|
{
|
||||||
id = index + 1, // 组的索引加1作为id
|
Id = index + 1, // 组的索引加1作为Id
|
||||||
pid = 0,
|
Pid = 0,
|
||||||
name = g.Key,
|
Name = u.Key,
|
||||||
children = g.Select((item, subIndex) => new
|
Children = u.Select((item, subIndex) => new
|
||||||
{
|
{
|
||||||
id = (index + 1 * 100) + subIndex + 1, // 子项的索引加1作为id
|
Id = (index + 1 * 100) + subIndex + 1, // 子项的索引加1作为Id
|
||||||
pid = index + 1,
|
Pid = index + 1,
|
||||||
name = item.Split('/').Last(),
|
Name = item.Split('/').Last(),
|
||||||
children = new List<string>()
|
Children = new List<string>()
|
||||||
})
|
}).ToList()
|
||||||
.ToList()
|
}).ToList();
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -97,7 +97,7 @@ export interface PageFileInput {
|
|||||||
* @memberof PageFileInput
|
* @memberof PageFileInput
|
||||||
*/
|
*/
|
||||||
filePath?: string | null;
|
filePath?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件后缀
|
* 文件后缀
|
||||||
*
|
*
|
||||||
|
|||||||
@ -35,6 +35,22 @@ export interface SysFileUploadFileBody {
|
|||||||
*/
|
*/
|
||||||
file: Blob;
|
file: Blob;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件类别
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof SysFileUploadFileBody
|
||||||
|
*/
|
||||||
|
fileType?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否公开
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof SysFileUploadFileBody
|
||||||
|
*/
|
||||||
|
isPublic?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件路径
|
* 文件路径
|
||||||
*
|
*
|
||||||
@ -155,22 +171,6 @@ export interface SysFileUploadFileBody {
|
|||||||
*/
|
*/
|
||||||
belongId?: number;
|
belongId?: number;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件类别
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof SysFileUploadFileBody
|
|
||||||
*/
|
|
||||||
fileType?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否公开 若为true则所有人都可以查看,默认只有自己或有权限的可以查看
|
|
||||||
*
|
|
||||||
* @type {boolean}
|
|
||||||
* @memberof SysFileUploadFileBody
|
|
||||||
*/
|
|
||||||
isPublic?: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户Id
|
* 租户Id
|
||||||
*
|
*
|
||||||
|
|||||||
@ -85,6 +85,14 @@ export interface SysOAuthUser {
|
|||||||
*/
|
*/
|
||||||
isDelete?: boolean;
|
isDelete?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof SysOAuthUser
|
||||||
|
*/
|
||||||
|
email?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户Id
|
* 系统用户Id
|
||||||
*
|
*
|
||||||
@ -147,14 +155,6 @@ export interface SysOAuthUser {
|
|||||||
*/
|
*/
|
||||||
avatar?: string | null;
|
avatar?: string | null;
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof SysOAuthUser
|
|
||||||
*/
|
|
||||||
email?: string | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号码
|
* 手机号码
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template lang="">
|
<template lang="">
|
||||||
<el-card class="box-card" shadow="hover" body-style="height:100%; overflow:auto;padding:5px;">
|
<el-card class="box-card" shadow="hover" body-style="height:100%; overflow:auto;padding:5px;">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div class="tree-h-flex">
|
<div class="tree-h-flex">
|
||||||
<div class="tree-h-left">
|
<div class="tree-h-left">
|
||||||
@ -42,7 +42,7 @@
|
|||||||
:load="loadNode"
|
:load="loadNode"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@ -79,13 +79,11 @@ const loadNode = async (node: any, resolve: any) => {
|
|||||||
console.log(node);
|
console.log(node);
|
||||||
if (node.data == undefined || Array.isArray(node.data)) return;
|
if (node.data == undefined || Array.isArray(node.data)) return;
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
var data = state.folderData.find(u => u.id == node.data.id);
|
var data = state.folderData.find((u) => u.id == node.data.id);
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (data)
|
if (data) resolve(data.children);
|
||||||
resolve(data.children);
|
else resolve([]);
|
||||||
else
|
|
||||||
resolve([]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取已经选择
|
// 获取已经选择
|
||||||
|
|||||||
@ -277,7 +277,7 @@ const handleChange = (file: any, fileList: []) => {
|
|||||||
// 上传
|
// 上传
|
||||||
const handleUpload = async () => {
|
const handleUpload = async () => {
|
||||||
if (state.fileList.length < 1) return;
|
if (state.fileList.length < 1) return;
|
||||||
await getAPI(SysFileApi).apiSysFileUploadFilePostForm(state.fileList[0].raw, state.fileType, state.isPublic, undefined);
|
await getAPI(SysFileApi).apiSysFileUploadFilePostForm(state.fileList[0].raw, state.fileType, state.isPublic);
|
||||||
handleQuery();
|
handleQuery();
|
||||||
ElMessage.success('上传成功');
|
ElMessage.success('上传成功');
|
||||||
state.visible = false;
|
state.visible = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user