ÎļþÃû´Ó Yw.Application.Unit.Core/3-value/1-mgr/SysUnitValue_Controller.cs ÐÞ¸Ä |
| | |
| | | var type = new Service.SysUnitType().GetByID(input.TypeID); |
| | | if (type == null) |
| | | { |
| | | throw Oops.Oh(ErrorCodes.D001, $"TypeID:{input.TypeID}"); |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"TypeID:{input.TypeID} æ°æ®ä¸åå¨"); |
| | | } |
| | | if (_service.IsExistCode(input.TypeID, input.Code)) |
| | | { |
| | | throw Oops.Oh(ErrorCodes.V001, $"Code:{input.Code}", "ç¼ç å·²åå¨"); |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.V001, $"Code:{input.Code} ç¼ç å·²åå¨"); |
| | | } |
| | | var model = input.Adapt<AddSysUnitValueInput, Model.SysUnitValue>(); |
| | | model.SortCode = _service.GetMaxSortCodeByTypeID(input.TypeID) + 1; |
| | |
| | | var model = _service.GetByID(input.ID); |
| | | if (model == null) |
| | | { |
| | | throw Oops.Oh(ErrorCodes.D001, $"ID:{input.ID}"); |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.D001, $"ID:{input.ID} æ°æ®ä¸åå¨"); |
| | | } |
| | | if (_service.IsExistCodeExceptID(model.TypeID, input.Code, input.ID)) |
| | | { |
| | | throw Oops.Oh(ErrorCodes.V001, $"Code:{input.Code}", "ç¼ç å·²åå¨"); |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.V001, $"Code:{input.Code} ç¼ç å·²åå¨"); |
| | | } |
| | | var rhs = new Model.SysUnitValue(model); |
| | | input.Adapt(rhs); |
| | |
| | | [HttpPut] |
| | | public bool UpdateSortCode([Required] UpdateSortCodeInput input) |
| | | { |
| | | if (input == null) |
| | | return false; |
| | | var bol = _service.UpdateSortCode(input.ID, input.SortCode); |
| | | return bol; |
| | | } |
| | |
| | | [HttpPut] |
| | | public bool UpdateSorter([Required] List<UpdateSortCodeInput> inputList) |
| | | { |
| | | if (inputList == null || inputList.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var list = inputList.Select(x => x.Adapt<Model.Sorter>()).ToList(); |
| | | var bol = _service.UpdateSorter(list); |
| | | return bol; |
| | |
| | | /// </summary> |
| | | [Route("DeleteByID@V1.0")] |
| | | [HttpDelete] |
| | | public DeleteReasonOutput DeleteByID([FromQuery][Required] IDInput input) |
| | | public bool DeleteByID([FromQuery][Required] IDInput input) |
| | | { |
| | | var bol = _service.DeleteByID(input.ID, out string msg); |
| | | return new DeleteReasonOutput() { Success = bol, Reason = msg }; |
| | | if (!bol) |
| | | { |
| | | throw YOops.Oh(eResultCode.Alert, ErrorCodes.D999, msg); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | #endregion |