lixiaojun
2025-01-20 3ef16fde2a5727bb4ae3c0204d80d7af34e5537a
Yw.Application.Bimface.Core/03-bimface-file-relation/BimfaceFileRelation_Controller.cs
@@ -8,7 +8,7 @@
    public class BimfaceFileRelation_Controller : IDynamicApiController
    {
        private readonly Service.BimfaceFileRelation _service = new();
        private readonly Yw.Service.BimfaceFileRelation _service = new();
        #region Query
@@ -61,6 +61,29 @@
            return vmList;
        }
        /// <summary>
        /// 通过 ObjectType 和 ObjectID 获取特定目的的列表
        /// </summary>
        [Route("GetByObjectTypeAndObjectIDOfPurpose@V1.0")]
        [HttpGet]
        public List<BimfaceFileRelationDto> GetByObjectTypeAndObjectIDOfPurpose([FromQuery][Required] ObjectOfPurposeInput input)
        {
            var list = _service.GetByObjectTypeAndObjectIDOfPurpose(input.ObjectType, input.ObjectID, input.Purpose);
            var vmList = list?.Select(x => new BimfaceFileRelationDto(x)).ToList();
            return vmList;
        }
        /// <summary>
        /// 通过 ObjectType 和 ObjectID 获取特定目的的默认数据
        /// </summary>
        [Route("GetDefaultByObjectTypeAndObjectIDOfPurpose@V1.0")]
        [HttpGet]
        public BimfaceFileRelationDto GetDefaultByObjectTypeAndObjectIDOfPurpose([FromQuery][Required] ObjectOfPurposeInput input)
        {
            var model = _service.GetDefaultByObjectTypeAndObjectIDOfPurpose(input.ObjectType, input.ObjectID, input.Purpose);
            return model == null ? null : new BimfaceFileRelationDto(model);
        }
        #endregion
@@ -76,7 +99,7 @@
            var bimfaceFile = new Yw.Service.BimfaceFile().GetByID(input.BimfaceFileID);
            if (bimfaceFile == null)
            {
                throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
            }
            var model = input.Adapt<AddBimfaceFileRelationInput, Model.BimfaceFileRelation>();
            model.SortCode = _service.GetMaxSortCode() + 1;
@@ -94,7 +117,7 @@
            var bimfaceFile = new Yw.Service.BimfaceFile().GetByID(input.BimfaceFileID);
            if (bimfaceFile == null)
            {
                throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
            }
            var model = input.Adapt<AddBimfaceFileRelationInput, Model.BimfaceFileRelation>();
            model.SortCode = _service.GetMaxSortCode(input.ObjectType, input.ObjectID) + 1;
@@ -112,7 +135,7 @@
            var bimfaceFile = new Yw.Service.BimfaceFile().GetByID(input.BimfaceFileID);
            if (bimfaceFile == null)
            {
                throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"BimfaceFileID:{input.BimfaceFileID} 数据不存在");
            }
            var model = input.Adapt<AddBimfaceFileRelationInput, Model.BimfaceFileRelation>();
            model.SortCode = _service.GetMaxSortCode(input.BimfaceFileID) + 1;
@@ -135,7 +158,7 @@
            var model = _service.GetByID(input.ID);
            if (model == null)
            {
                throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"ID:{input.ID} 数据不存在");
                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在");
            }
            var rhs = new Model.BimfaceFileRelation(model);
            input.Adapt(rhs);
@@ -190,6 +213,21 @@
        #endregion
        #region Exist
        /// <summary>
        /// 通过 BimfaceFileID 判断是否存在
        /// </summary>
        [Route("IsExistByBimfaceFileID@V1.0")]
        [HttpDelete]
        public bool IsExistByBimfaceFileID([FromQuery][Required] BimfaceFileIDInput input)
        {
            var bol = _service.IsExistByBimfaceFileID(input.BimfaceFileID);
            return bol;
        }
        #endregion
        #region Delete
        /// <summary>
@@ -202,7 +240,7 @@
            var bol = _service.DeleteByID(input.ID, out string Msg);
            if (!bol)
            {
                throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, Msg);
                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, Msg);
            }
            return bol;
        }
@@ -217,7 +255,22 @@
            var bol = _service.DeleteExByID(input.ID, out string Msg);
            if (!bol)
            {
                throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, Msg);
                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, Msg);
            }
            return bol;
        }
        /// <summary>
        /// 删除所有
        /// </summary>
        [Route("DeleteAllByID@V1.0")]
        [HttpDelete]
        public bool DeleteAllByID([FromQuery][Required] IDInput input)
        {
            var bol = _service.DeleteAllByID(input.ID, out string Msg);
            if (!bol)
            {
                throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, Msg);
            }
            return bol;
        }