😂调整系统文件实体增加业务数据Id对应
This commit is contained in:
parent
3ae7bdeb3d
commit
d99c6f1f46
@ -99,8 +99,13 @@ public partial class SysFile : EntityTenantBaseData
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否公开
|
/// 是否公开
|
||||||
/// 若为true则所有人都可以查看,默认只有自己或有权限的可以查看
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "是否公开")]
|
[SugarColumn(ColumnDescription = "是否公开")]
|
||||||
public virtual bool IsPublic { get; set; } = false;
|
public virtual bool IsPublic { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 业务数据Id
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "业务数据Id")]
|
||||||
|
public long? DataId { get; set; }
|
||||||
}
|
}
|
||||||
@ -1,33 +0,0 @@
|
|||||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
|
||||||
//
|
|
||||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
|
||||||
//
|
|
||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
|
||||||
|
|
||||||
namespace Admin.NET.Core;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 系统文件关联表
|
|
||||||
/// </summary>
|
|
||||||
[SugarTable(null, "系统文件关联表")]
|
|
||||||
[SysTable]
|
|
||||||
public partial class SysFileRelation : EntityBaseId
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 业务数据Id
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "业务数据Id")]
|
|
||||||
public long DataId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件Id
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "文件Id")]
|
|
||||||
public long FileId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件
|
|
||||||
/// </summary>
|
|
||||||
[Navigate(NavigateType.OneToOne, nameof(FileId))]
|
|
||||||
public SysFile SysFile { get; set; }
|
|
||||||
}
|
|
||||||
@ -1,76 +0,0 @@
|
|||||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
|
||||||
//
|
|
||||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
|
||||||
//
|
|
||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
|
||||||
|
|
||||||
namespace Admin.NET.Core.Service;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 系统文件关联服务
|
|
||||||
/// </summary>
|
|
||||||
public class SysFileRelationService : ITransient
|
|
||||||
{
|
|
||||||
private readonly SqlSugarRepository<SysFileRelation> _sysFileRelationRep;
|
|
||||||
|
|
||||||
public SysFileRelationService(SqlSugarRepository<SysFileRelation> sysFileRelationRep)
|
|
||||||
{
|
|
||||||
_sysFileRelationRep = sysFileRelationRep;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取文件关联列表
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dataId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<List<SysFileRelation>> GetList(long dataId)
|
|
||||||
{
|
|
||||||
return await _sysFileRelationRep.AsQueryable()
|
|
||||||
.WhereIF(dataId > 0, u => u.DataId == dataId)
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 增加文件关联
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dataId"></param>
|
|
||||||
/// <param name="fileIds"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task AddFileRelation(long dataId, List<SysFileRelation> fileIds)
|
|
||||||
{
|
|
||||||
var fileRelations = fileIds.Select(u => new SysFileRelation
|
|
||||||
{
|
|
||||||
DataId = dataId,
|
|
||||||
FileId = u.FileId
|
|
||||||
}).ToList();
|
|
||||||
await _sysFileRelationRep.InsertRangeAsync(fileRelations);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新文件关联
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dataId"></param>
|
|
||||||
/// <param name="fileIds"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task UpdateFileRelation(long dataId, List<SysFileRelation> fileIds)
|
|
||||||
{
|
|
||||||
await _sysFileRelationRep.DeleteAsync(u => u.DataId == dataId);
|
|
||||||
|
|
||||||
var fileRelations = fileIds.Select(u => new SysFileRelation
|
|
||||||
{
|
|
||||||
DataId = dataId,
|
|
||||||
FileId = u.FileId
|
|
||||||
}).ToList();
|
|
||||||
await _sysFileRelationRep.InsertRangeAsync(fileRelations);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除文件关联
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dataId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task DeleteFileRelation(long dataId)
|
|
||||||
{
|
|
||||||
await _sysFileRelationRep.DeleteAsync(u => u.DataId == dataId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -55,11 +55,11 @@ public class SysFileService : IDynamicApiController, ITransient
|
|||||||
[DisplayName("获取文件分页列表")]
|
[DisplayName("获取文件分页列表")]
|
||||||
public async Task<SqlSugarPagedList<SysFile>> Page(PageFileInput input)
|
public async Task<SqlSugarPagedList<SysFile>> Page(PageFileInput input)
|
||||||
{
|
{
|
||||||
// 获取所有公开附件
|
// 获取所有公开文件
|
||||||
var publicList = _sysFileRep.AsQueryable().ClearFilter().Where(u => u.IsPublic == true);
|
var publicList = _sysFileRep.AsQueryable().ClearFilter().Where(u => u.IsPublic == true);
|
||||||
// 获取私有附件
|
// 获取私有文件
|
||||||
var privateList = _sysFileRep.AsQueryable().Where(u => u.IsPublic == false);
|
var privateList = _sysFileRep.AsQueryable().Where(u => u.IsPublic == false);
|
||||||
// 合并公开和私有附件并分页
|
// 合并公开和私有并分页
|
||||||
return await _sysFileRep.Context.UnionAll(publicList, privateList)
|
return await _sysFileRep.Context.UnionAll(publicList, privateList)
|
||||||
.WhereIF(!string.IsNullOrWhiteSpace(input.FileName), u => u.FileName.Contains(input.FileName.Trim()))
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FileName), u => u.FileName.Contains(input.FileName.Trim()))
|
||||||
.WhereIF(!string.IsNullOrWhiteSpace(input.FilePath), u => u.FilePath.Contains(input.FilePath.Trim()))
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FilePath), u => u.FilePath.Contains(input.FilePath.Trim()))
|
||||||
@ -344,46 +344,4 @@ public class SysFileService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
return sysFile;
|
return sysFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 修改附件关联对象 🔖
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="ids"></param>
|
|
||||||
///// <param name="relationName"></param>
|
|
||||||
///// <param name="relationId"></param>
|
|
||||||
///// <param name="belongId"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//[NonAction]
|
|
||||||
//public async Task<int> UpdateRelation(List<long> ids, string relationName, long relationId, long belongId = 0)
|
|
||||||
//{
|
|
||||||
// if (ids == null || ids.Count == 0)
|
|
||||||
// return 0;
|
|
||||||
// return await _sysFileRep.AsUpdateable()
|
|
||||||
// .SetColumns(u => u.RelationName == relationName)
|
|
||||||
// .SetColumns(u => u.RelationId == relationId)
|
|
||||||
// .SetColumns(u => u.BelongId == belongId)
|
|
||||||
// .Where(u => ids.Contains(u.Id))
|
|
||||||
// .ExecuteCommandAsync();
|
|
||||||
//}
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 根据关联查询附件 🔖
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="input"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
///// <exception cref="ArgumentNullException"></exception>
|
|
||||||
//[DisplayName("根据关联查询附件")]
|
|
||||||
//public async Task<List<SysFile>> GetRelationFiles([FromQuery] RelationQueryInput input)
|
|
||||||
//{
|
|
||||||
// return await _sysFileRep.AsQueryable()
|
|
||||||
// .WhereIF(input.RelationId is > 0, u => u.RelationId == input.RelationId)
|
|
||||||
// .WhereIF(input.BelongId is > 0, u => u.BelongId == input.BelongId.Value)
|
|
||||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.RelationName), u => u.RelationName == input.RelationName)
|
|
||||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.FileTypes), u => input.GetFileTypeBS().Contains(u.FileType))
|
|
||||||
// .Select(u => new SysFile
|
|
||||||
// {
|
|
||||||
// Url = SqlFunc.MergeString("/api/sysFile/Preview/", u.Id.ToString()),
|
|
||||||
// }, true)
|
|
||||||
// .ToListAsync();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
@ -205,10 +205,18 @@ export interface SysFile {
|
|||||||
fileAlias?: string | null;
|
fileAlias?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否公开 若为true则所有人都可以查看,默认只有自己或有权限的可以查看
|
* 是否公开
|
||||||
*
|
*
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @memberof SysFile
|
* @memberof SysFile
|
||||||
*/
|
*/
|
||||||
isPublic?: boolean;
|
isPublic?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务数据Id
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof SysFile
|
||||||
|
*/
|
||||||
|
dataId?: number | null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user