zhuangpei-mesbackend/DOAN.Service/MES/dev/DevicePartsSuppliersService.cs
qianhao.xu 64bf0d2886 1
2024-12-30 16:33:45 +08:00

96 lines
3.0 KiB
C#

using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Model.Dto;
using DOAN.Model.MES.dev.Dto;
using DOAN.Model.MES.dev;
using DOAN.Repository;
using DOAN.Service.MES.dev.IService;
using System.Linq;
namespace DOAN.Service.MES.dev
{
/// <summary>
/// 备品备件供应商Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IDevicePartsSuppliersService), ServiceLifetime = LifeTime.Transient)]
public class DevicePartsSuppliersService : BaseService<DevicePartsSuppliers>, IDevicePartsSuppliersService
{
/// <summary>
/// 查询备品备件供应商列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<DevicePartsSuppliersDto> GetList(DevicePartsSuppliersQueryDto parm)
{
var predicate = Expressionable.Create<DevicePartsSuppliers>();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<DevicePartsSuppliers, DevicePartsSuppliersDto>(parm);
return response;
}
public List<DevicePartsSuppliersDto> GetListSupplier(string query)
{
return Queryable()
.WhereIF(!string.IsNullOrEmpty(query),x => x.SupplierName.Contains(query))
.Select(x => new DevicePartsSuppliersDto()
{
SupplierId = x.SupplierId,
SupplierName = x.SupplierName
})
.ToList();
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="SupplierId"></param>
/// <returns></returns>
public DevicePartsSuppliers GetInfo(int SupplierId)
{
var response = Queryable()
.Where(x => x.SupplierId == SupplierId)
.First();
return response;
}
/// <summary>
/// 添加备品备件供应商
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DevicePartsSuppliers AddDevicePartsSuppliers(DevicePartsSuppliers model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改备品备件供应商
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateDevicePartsSuppliers(DevicePartsSuppliers model)
{
//var response = Update(w => w.SupplierId == model.SupplierId, it => new DevicePartsSuppliers()
//{
// SupplierName = model.SupplierName,
// ContactPerson = model.ContactPerson,
// Phone = model.Phone,
// Email = model.Email,
// Address = model.Address,
// CreatedAt = model.CreatedAt,
// UpdatedAt = model.UpdatedAt,
//});
//return response;
return Update(model, true);
}
}
}