From 47ef4fca4cc20b70d363e972993be93c883e5c43 Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Tue, 21 May 2024 11:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebExtensions/EntityExtension.cs | 7 +++++- .../MES/dev/DeviceTypeController.cs | 23 +++++++++---------- ZR.Model/MES/dev/Dto/DeviceTypeDto.cs | 2 +- ZR.Service/MES/dev/DeviceTypeService.cs | 5 +++- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Infrastructure/WebExtensions/EntityExtension.cs b/Infrastructure/WebExtensions/EntityExtension.cs index 3022abf..c946e6d 100644 --- a/Infrastructure/WebExtensions/EntityExtension.cs +++ b/Infrastructure/WebExtensions/EntityExtension.cs @@ -1,6 +1,7 @@  using Infrastructure.Extensions; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.HttpResults; using System; using System.Reflection; @@ -15,8 +16,10 @@ namespace Infrastructure BindingFlags flag = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; types.GetProperty("CreateTime", flag)?.SetValue(source, DateTime.Now, null); + types.GetProperty("CreatedTime", flag)?.SetValue(source, DateTime.Now, null); types.GetProperty("AddTime", flag)?.SetValue(source, DateTime.Now, null); types.GetProperty("CreateBy", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("CreatedBy", flag)?.SetValue(source, context.GetName(), null); types.GetProperty("Create_by", flag)?.SetValue(source, context.GetName(), null); types.GetProperty("UserId", flag)?.SetValue(source, context.GetUId(), null); @@ -30,8 +33,10 @@ namespace Infrastructure BindingFlags flag = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; types.GetProperty("UpdateTime", flag)?.SetValue(source, DateTime.Now, null); + types.GetProperty("UpdatedTime", flag)?.SetValue(source, DateTime.Now, null); types.GetProperty("Update_time", flag)?.SetValue(source, DateTime.Now, null); - types.GetProperty("UpdateBy", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("UpdateBy", flag)?.SetValue(source, context.GetName(), null); + types.GetProperty("UpdatedBy", flag)?.SetValue(source, context.GetName(), null); types.GetProperty("Update_by", flag)?.SetValue(source, context.GetName(), null); return source; diff --git a/ZR.Admin.WebApi/Controllers/MES/dev/DeviceTypeController.cs b/ZR.Admin.WebApi/Controllers/MES/dev/DeviceTypeController.cs index db9249e..416cef2 100644 --- a/ZR.Admin.WebApi/Controllers/MES/dev/DeviceTypeController.cs +++ b/ZR.Admin.WebApi/Controllers/MES/dev/DeviceTypeController.cs @@ -56,8 +56,8 @@ namespace ZR.Admin.WebApi.Controllers /// 添加1.设备类型 /// /// - [HttpPost] - [ActionPermissionFilter(Permission = "business:devicetype:add")] + [HttpPost("insert")] + [Log(Title = "1.设备类型", BusinessType = BusinessType.INSERT)] public IActionResult AddDeviceType([FromBody] DeviceTypeDto parm) { @@ -72,8 +72,7 @@ namespace ZR.Admin.WebApi.Controllers /// 更新1.设备类型 /// /// - [HttpPut] - [ActionPermissionFilter(Permission = "business:devicetype:edit")] + [HttpPost("update")] [Log(Title = "1.设备类型", BusinessType = BusinessType.UPDATE)] public IActionResult UpdateDeviceType([FromBody] DeviceTypeDto parm) { @@ -87,15 +86,15 @@ namespace ZR.Admin.WebApi.Controllers /// 删除1.设备类型 /// /// - [HttpDelete("{ids}")] - [ActionPermissionFilter(Permission = "business:devicetype:delete")] - [Log(Title = "1.设备类型", BusinessType = BusinessType.DELETE)] - public IActionResult DeleteDeviceType(string ids) - { - int[] idsArr = Tools.SpitIntArrary(ids); - if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + [HttpGet("delete/{id}")] - var response = _DeviceTypeService.Delete(idsArr); + [Log(Title = "1.设备类型", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceType(long id) + { + + if (id <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceTypeService.Delete(id); return ToResponse(response); } diff --git a/ZR.Model/MES/dev/Dto/DeviceTypeDto.cs b/ZR.Model/MES/dev/Dto/DeviceTypeDto.cs index bb57b6a..dc31ae6 100644 --- a/ZR.Model/MES/dev/Dto/DeviceTypeDto.cs +++ b/ZR.Model/MES/dev/Dto/DeviceTypeDto.cs @@ -21,7 +21,7 @@ namespace ZR.Model.MES.dev.Dto /// public class DeviceTypeDto { - [Required(ErrorMessage = "id不能为空")] + public int Id { get; set; } [Required(ErrorMessage = "父id不能为空")] diff --git a/ZR.Service/MES/dev/DeviceTypeService.cs b/ZR.Service/MES/dev/DeviceTypeService.cs index 63e5629..2572c67 100644 --- a/ZR.Service/MES/dev/DeviceTypeService.cs +++ b/ZR.Service/MES/dev/DeviceTypeService.cs @@ -29,7 +29,7 @@ namespace ZR.Service.MES.dev { var predicate = Expressionable.Create(); predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name == parm.Name) - .AndIF(parm.Status > 0, it => it.Status == parm.Status); + .AndIF(parm.Status >= 0, it => it.Status == parm.Status); var response = Queryable() .Where(predicate.ToExpression()) @@ -60,6 +60,7 @@ namespace ZR.Service.MES.dev /// public DeviceType AddDeviceType(DeviceType model) { + return Context.Insertable(model).ExecuteReturnEntity(); } @@ -81,6 +82,8 @@ namespace ZR.Service.MES.dev // UpdatedTime = model.UpdatedTime, //}); //return response; + + return Update(model, true); }