lixiaojun
2022-08-18 9d0a6e97890b44f2b71d2425684082100bed07a9
Application/IStation.Application4Basic/attachment_file/AttachmentFile_Controller.cs
ÎļþÃû´Ó Application/IStation.Application4Basic/attachment_file/AttachmentFile_StandardController.cs ÐÞ¸Ä
@@ -7,7 +7,7 @@
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using Furion.FriendlyException;
namespace IStation.Application
{
@@ -16,7 +16,7 @@
    /// </summary>
    [Route("Basic/AttachmentFile")]
    [ApiDescriptionSettings("Basic", Name = "附件", Order = 100)]
    public class AttachmentFile_StandardController : IDynamicApiController
    public class AttachmentFile_Controller : IDynamicApiController
    {
        private readonly Service.AttachmentFile _service = new Service.AttachmentFile();
@@ -253,7 +253,36 @@
        [HttpDelete]
        public DeleteReasonOutput DeleteByID([FromQuery][Required] IDUnderCorpInput input)
        {
            var model = _service.GetByID(input.CorpID,input.ID);
            if (model == null)
            {
                throw Oops.Oh(ErrorCodes.D001, $"ID:{input.ID}");
            }
            var bol = _service.DeleteByID(input.CorpID, input.ID, out string Msg);
            if (bol)
            {
                FileHelper.Delete(model.StorageHouse,model.StorageCode);
            }
            return new DeleteReasonOutput() { Success = bol, Reason = Msg };
        }
        /// <summary>
        /// é€šè¿‡ AttachType å’Œ AttachID åˆ é™¤
        /// </summary>
        [Route("DeleteByAttachTypeAndAttachID@V1.0")]
        [HttpDelete]
        public DeleteReasonOutput DeleteByAttachTypeAndAttachID([FromQuery][Required] AttachmentUnderCorpInput input)
        {
            var list = _service.GetByAttachTypeAndAttachID(input.CorpID,input.AttachType,input.AttachID);
            if (list == null || list.Count < 1)
            {
                throw Oops.Oh(ErrorCodes.D001, $"AttachType:{input.AttachType},AttachID:{input.AttachID}");
            }
            var bol = _service.DeleteByAttachTypeAndAttachID(input.CorpID, input.AttachType,input.AttachID, out string Msg);
            if (bol)
            {
                list.ForEach(x=>FileHelper.Delete(x.StorageHouse,x.StorageCode));
            }
            return new DeleteReasonOutput() { Success = bol, Reason = Msg };
        }