| | |
| | | /// UnitValue |
| | | /// </summary> |
| | | [Route("Unit/Value")] |
| | | [ApiDescriptionSettings("Unit", Name = "单位值", Order = 8000)] |
| | | [ApiDescriptionSettings("Unit", Name = "单位值", Order = 80000)] |
| | | public class SysUnitValue_Controller : IDynamicApiController |
| | | { |
| | | private readonly Service.SysUnitValue _service = new(); |
| | |
| | | return vm_list; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region Insert |
| | |
| | | var type = new Service.SysUnitType().GetByID(input.TypeID); |
| | | if (type == null) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"TypeID:{input.TypeID} 数据不存在"); |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"TypeID:{input.TypeID} 数据不存在"); |
| | | } |
| | | if (_service.IsExistCode(input.TypeID, input.Code)) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.V001, $"Code:{input.Code} 编码已存在"); |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"Code:{input.Code} 编码已存在"); |
| | | } |
| | | var model = input.Adapt<AddSysUnitValueInput, Model.SysUnitValue>(); |
| | | model.SortCode = _service.GetMaxSortCode(input.TypeID) + 1; |
| | |
| | | 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} 数据不存在"); |
| | | } |
| | | if (_service.IsExistCodeExceptID(model.TypeID, input.Code, input.ID)) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.V001, $"Code:{input.Code} 编码已存在"); |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"Code:{input.Code} 编码已存在"); |
| | | } |
| | | var rhs = new Model.SysUnitValue(model); |
| | | input.Adapt(rhs); |
| | |
| | | { |
| | | var list = inputList.Select(x => x.Adapt<Model.Sorter>()).ToList(); |
| | | var bol = _service.UpdateSorter(list); |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新编码 |
| | | /// </summary> |
| | | [Route("UpdateCode@V1.0")] |
| | | [HttpPut] |
| | | public bool UpdateCode([Required] UpdateCodeInput input) |
| | | { |
| | | var model = _service.GetByID(input.ID); |
| | | if (model == null) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"ID:{input.ID} 数据不存在"); |
| | | } |
| | | if (_service.IsExistCodeExceptID(model.TypeID, input.Code, input.ID)) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"Code:{input.Code} 编码已存在"); |
| | | } |
| | | var bol = _service.UpdateCode(input.ID, input.Code); |
| | | return bol; |
| | | } |
| | | |
| | |
| | | var bol = _service.DeleteByID(input.ID, out string msg); |
| | | if (!bol) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.D999, msg); |
| | | throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D999, msg); |
| | | } |
| | | return bol; |
| | | } |