using System;
using System.Linq;
using DOAN.Model;
using DOAN.Model.MES.base_;
using DOAN.Model.MES.base_.Dto;
using DOAN.Repository;
using DOAN.Service.Business.IBusinessService;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using SqlSugar;
namespace DOAN.Service.Business
{
///
/// 工艺路线Service业务层处理
///
[AppService(ServiceType = typeof(IBaseWorkRouteService), ServiceLifetime = LifeTime.Transient)]
public class BaseWorkRouteService : BaseService, IBaseWorkRouteService
{
///
/// 查询工艺路线列表
///
///
///
public PagedInfo GetList(BaseWorkRouteQueryDto parm)
{
var predicate = Expressionable
.Create()
.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name))
.AndIF(!string.IsNullOrEmpty(parm.Code), it => it.Code.Contains(parm.Code))
.AndIF(parm.Status > -1, it => it.Status == parm.Status);
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public BaseWorkRoute GetInfo(int Id)
{
var response = Queryable().Where(x => x.Id == Id).First();
return response;
}
///
/// 添加工艺路线
///
///
///
public BaseWorkRoute AddBaseWorkRoute(BaseWorkRoute model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改工艺路线
///
///
///
public int UpdateBaseWorkRoute(BaseWorkRoute model)
{
//var response = Update(w => w.Id == model.Id, it => new BaseWorkRoute()
//{
// Name = model.Name,
// Status = model.Status,
// Remark = model.Remark,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
// Code = model.Code,
// LogicFlowData = model.LogicFlowData,
//});
//return response;
return Update(model, true);
}
}
}