设备类型

This commit is contained in:
qianhao.xu 2024-05-21 11:09:04 +08:00
parent cc17ebfaba
commit 47ef4fca4c
4 changed files with 22 additions and 15 deletions

View File

@ -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;

View File

@ -56,8 +56,8 @@ namespace ZR.Admin.WebApi.Controllers
/// 添加1.设备类型
/// </summary>
/// <returns></returns>
[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.设备类型
/// </summary>
/// <returns></returns>
[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.设备类型
/// </summary>
/// <returns></returns>
[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);
}

View File

@ -21,7 +21,7 @@ namespace ZR.Model.MES.dev.Dto
/// </summary>
public class DeviceTypeDto
{
[Required(ErrorMessage = "id不能为空")]
public int Id { get; set; }
[Required(ErrorMessage = "父id不能为空")]

View File

@ -29,7 +29,7 @@ namespace ZR.Service.MES.dev
{
var predicate = Expressionable.Create<DeviceType>();
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
/// <returns></returns>
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);
}