using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Model.Dto;
using DOAN.Model.MES.base_;
using DOAN.Model.MES.base_.Dto;
using DOAN.Repository;
using DOAN.Service.MES.base_.IService;
namespace DOAN.Service.MES.base_
{
///
/// 组Service业务层处理
///
[AppService(ServiceType = typeof(IBaseGroupService), ServiceLifetime = LifeTime.Transient)]
public class BaseGroupService : BaseService, IBaseGroupService
{
///
/// 查询组列表
///
///
///
public PagedInfo GetList(BaseGroupQueryDto parm)
{
var predicate = Expressionable.Create()
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), it => it.GroupCode == parm.GroupCode)
.AndIF(!string.IsNullOrEmpty(parm.GroupName), it => it.GroupName == parm.GroupName)
.AndIF(parm.Status > 0, it => it.Status == parm.Status);
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
}
///
/// 获取详情
///
///
///
public BaseGroup GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
///
/// 添加组
///
///
///
public BaseGroup AddBaseGroup(BaseGroup model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
///
/// 修改组
///
///
///
public int UpdateBaseGroup(BaseGroup model)
{
//var response = Update(w => w.Id == model.Id, it => new BaseGroup()
//{
// GroupName = model.GroupName,
// Remark = model.Remark,
// Status = model.Status,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
}
}