using System; using SqlSugar; using Infrastructure.Attribute; using Infrastructure.Extensions; using DOAN.Model; using DOAN.Model.MES.group.Dto; using DOAN.Model.MES.group; using DOAN.Repository; using DOAN.Service.group.IService; using System.Linq; using Mapster; namespace DOAN.Service.group { /// /// 班次Service业务层处理 /// [AppService(ServiceType = typeof(IGroupShiftService), ServiceLifetime = LifeTime.Transient)] public class GroupShiftService : BaseService, IGroupShiftService { /// /// 查询班次列表 /// /// /// public PagedInfo GetList(GroupShiftQueryDto parm) { var predicate = Expressionable.Create(); var response = Queryable() .Where(predicate.ToExpression()) .ToPage(parm); TypeAdapterConfig.NewConfig() .Map(dest => dest.StartTime, src => src.StartTime.Value.TimeOfDay) // 自定义映射规则 .Map(dest => dest.EndTime, src => src.EndTime.Value.TimeOfDay); // 自定义映射规则 List responseresult = new List(); foreach (var item in response.Result) { GroupShiftDto2 groupShiftDto2 = new GroupShiftDto2(); //groupShiftDto2.StartTime = item.StartTime.Value.TimeOfDay; //groupShiftDto2.EndTime = item.StartTime.Value.TimeOfDay; groupShiftDto2 = item.Adapt(); responseresult.Add(groupShiftDto2); } PagedInfo result= new PagedInfo(); result.PageSize= response.PageSize; result.PageIndex = response.PageIndex; result.TotalNum = response.TotalNum; result.TotalPage = response.TotalPage; result.Result = responseresult; return result; } /// /// 获取详情 /// /// /// public GroupShift GetInfo(int Id) { var response = Queryable() .Where(x => x.Id == Id) .First(); return response; } /// /// 添加班次 /// /// /// public GroupShift AddGroupShift(GroupShift model) { return Context.Insertable(model).ExecuteReturnEntity(); } /// /// 修改班次 /// /// /// public int UpdateGroupShift(GroupShift model) { //var response = Update(w => w.Id == model.Id, it => new GroupShift() //{ // Name = model.Name, // StartTime = model.StartTime, // EndTime = model.EndTime, // Status = model.Status, // Remark = model.Remark, // CreatedBy = model.CreatedBy, // CreatedTime = model.CreatedTime, // UpdatedBy = model.UpdatedBy, // UpdatedTime = model.UpdatedTime, //}); //return response; return Update(model, true); } } }