| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using Abp.Application.Services.Dto;
- using Abp.Auditing;
- using Abp.Authorization;
- using Abp.Domain.Repositories;
- using Microsoft.EntityFrameworkCore;
- using VberZero.AppService.Attaches.Dto;
- using VberZero.AppService.Base;
- using VberZero.AppService.Base.Dto;
- using VberZero.Auditing;
- using VberZero.BaseSystem;
- namespace VberZero.AppService.Attaches;
- [AbpAuthorize, AuditLog("文件上传")]
- public class AttachFilesAppServiceBase : VzAppServiceBase, IAttachFilesAppServiceBase
- {
- private readonly IRepository<SysAttach, int> _repository;
- public AttachFilesAppServiceBase(IRepository<SysAttach, int> repository)
- {
- _repository = repository;
- }
- /// <summary>
- /// 上传附件
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [DisableAuditing]
- public virtual Task FileUpload(AttachDto input)
- {
- return AttachManager.FileUpload(input);
- }
- /// <summary>
- /// 查询附件
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [DisableAuditing]
- public async Task<List<AttachFileDto>> QueryAttaches(QueryAttachDto input)
- {
- var dtos = await _repository.GetAll().Where(a =>
- a.CodeKey == input.CodeKey && a.SourceKey == input.Key).Select(a => new AttachFileDto()
- {
- Id = a.Id,
- CodeKey = a.CodeKey,
- SourceKey = a.SourceKey,
- FileExt = a.FileExt,
- FileName = a.FileName,
- FileTitle = a.FileTitle,
- FilePath = a.FilePath,
- FileType = a.FileType,
- }).ToListAsync();
- return dtos;
- }
- /// <summary>
- /// 查询附件
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [DisableAuditing]
- public async Task<AttachFileDto> QueryAttach(QueryAttachDto input)
- {
- var dto = await _repository.GetAll().Where(a =>
- a.CodeKey == input.CodeKey && a.SourceKey == input.Key).Select(a => new AttachFileDto()
- {
- Id = a.Id,
- CodeKey = a.CodeKey,
- SourceKey = a.SourceKey,
- Description = a.Description,
- FileExt = a.FileExt,
- FileName = a.FileName,
- FileTitle = a.FileTitle,
- FilePath = a.FilePath,
- FileType = a.FileType,
- }).FirstOrDefaultAsync();
- return dto;
- }
- /// <summary>
- /// 查询附件
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [AuditLog("删除文件")]
- public virtual async Task DeleteAttach(VzEntityDto<int> input)
- {
- var entity = await _repository.FirstOrDefaultAsync(a => a.Id == input.Id);
- if (entity != null)
- {
- await _repository.DeleteAsync(entity);
- }
- }
- [DisableAuditing]
- public async Task<string> GetSelectStrWithCodeKey(string codeKey)
- {
- var list = await _repository.GetAllListAsync(a => a.CodeKey == codeKey);
- string str = "<option value=\"\" selected>请选择...</option>";
- foreach (var l in list)
- {
- str += $"<option value=\"{l.Id}\">{l.FileTitle}</option>";
- }
- return str;
- }
- }
|