using learun.iapplication; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; namespace learun.application { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2019.09.25 /// 描 述:附件管理 /// public class AnnexesFileService : ServiceBase { #region 属性 构造函数 private readonly string fieldSql; /// /// /// public AnnexesFileService() { fieldSql = @" t.F_Id, t.F_FolderId, t.F_FileName, t.F_FilePath, t.F_FileSize, t.F_FileExtensions, t.F_FileType, t.F_DownloadCount, t.F_CreateDate, t.F_CreateUserId, t.F_CreateUserName "; } #endregion 属性 构造函数 #region 获取数据 /// /// 获取实体列表 /// /// 文件夹值 /// public Task> GetList(string folderId) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT " + fieldSql + " FROM LR_Base_AnnexesFile t WHERE t.F_FolderId = @folderId Order By t.F_CreateDate "); return this.BaseRepository().FindList(strSql.ToString(), new { folderId }); } /// /// 获取附件名称集合 /// /// 主键值 /// public async Task GetFileNames(string folderId) { string res = ""; IEnumerable list = await GetList(folderId); foreach (var item in list) { if (!string.IsNullOrEmpty(res)) { res += ","; } res += item.F_FileName; } return res; } /// /// 获取附件实体 /// /// 主键 /// public Task GetEntity(string keyValue) { return this.BaseRepository().FindEntityByKey(keyValue); } #endregion 获取数据 #region 提交数据 /// /// 保存数据实体 /// /// 附件夹主键 /// 附件实体数据 public async Task SaveEntity(string folderId, AnnexesFileEntity annexesFileEntity) { annexesFileEntity.F_CreateDate = DateTime.Now; annexesFileEntity.F_FolderId = folderId; await this.BaseRepository().Insert(annexesFileEntity); } /// /// 删除附件 /// /// 文件主键 public async Task DeleteEntity(string fileId) { await this.BaseRepository().DeleteAny(new { F_Id = fileId }); } #endregion 提交数据 } }