diff --git a/src/WMS.Web.Api/Controllers/SubscribeNotificationController.cs b/src/WMS.Web.Api/Controllers/SubscribeNotificationController.cs new file mode 100644 index 00000000..1d8504ac --- /dev/null +++ b/src/WMS.Web.Api/Controllers/SubscribeNotificationController.cs @@ -0,0 +1,132 @@ +using AutoMapper; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WMS.Web.Core.Dto; +using WMS.Web.Core.Dto.SubscribeNotification; +using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Entitys; +using WMS.Web.Domain.Infrastructure; +using WMS.Web.Domain.IService.Public; +using WMS.Web.Domain.Values; + +namespace WMS.Web.Api.Controllers +{ + /// + /// 订阅通知 + /// + [Route("api/[controller]")] + [ApiController] + public class SubscribeNotificationController : ControllerBase + { + private readonly IMapper _mapper; + private readonly ILoginService _loginService; + private readonly ISubscribeNotificationRepositories _repositories; + public SubscribeNotificationController(IMapper mapper, ILoginService loginService, ISubscribeNotificationRepositories repositories) + { + _mapper = mapper; + _loginService = loginService; + _repositories = repositories; + } + + /// + /// 列表 + /// + /// + /// + [HttpPost] + [Route("GetList")] + public async Task> GetPagedList([FromBody] SubscribeNotificationQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + + var (list, count) = await _repositories.GetListAsync(dto); + var result = ResultPagedList.ReSuccess(list, count); + return result; + } + /// + /// 新增 + /// + /// + /// + [HttpPost] + [Route("Save")] + public async Task Save(SaveSubscribeNotificationRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + + //新增 + var isExist = await _repositories.IsExist(dto.CustomerName, dto.CustomerNumber); + if (isExist) return Result.ReFailure($"客户名称:{dto.CustomerName} 客户编码:{dto.CustomerName} 已经存在,无需再次添加!", 700000); + + var entity = _mapper.Map(dto); + entity.Create(loginInfo.UserInfo.StaffId); + var res = await _repositories.Add(entity, true); + + if (res == null) Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + + /// + /// 修改 + /// + /// + /// + [HttpPost] + [Route("Save")] + public async Task Edit(EditSubscribeNotificationRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + + var entity = await _repositories.Get(dto.Id); + if (entity == null) + return Result.ReFailure(ResultCodes.SubscribeNotificationNoData); + //修改 + //修改了名字或者编码后 验重 + if (entity.CustomerName != dto.CustomerName || entity.CustomerNumber != dto.CustomerNumber) + { + var isExist = await _repositories.IsExist(dto.CustomerName, dto.CustomerNumber); + if (isExist) return Result.ReFailure($"客户名称:{dto.CustomerName} 客户编码:{dto.CustomerName} 已经存在,无需再次添加!", 700000); + } + _mapper.Map(dto, entity); + entity.Edit(loginInfo.UserInfo.StaffId); + var res = await _repositories.Edit(entity, true); + + if (res == null) Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + + /// + /// 删除 + /// + /// + /// + [HttpPost] + [Route("Delete")] + public async Task Sync(OperateRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return Result.ReFailure(ResultCodes.Token_Invalid_Error); + + var list = await _repositories.GetList(dto.Ids); + foreach (var e in list) + { + e.Delete(loginInfo.UserInfo.StaffId); + } + var res = await _repositories.EditList(list, true); + + if (!res) Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + } +} diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml index f19909ea..7abf32d1 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml @@ -499,6 +499,39 @@ 序列号 + + + 订阅通知 + + + + + 列表 + + + + + + + 新增 + + + + + + + 修改 + + + + + + + 删除 + + + + 系统配置 diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml index aa4d46da..addc7cb7 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml @@ -5213,6 +5213,141 @@ 编码 + + + 修改 + + + + + 主键 + + + + + 客户名称 + + + + + 客户编码 + + + + + 电话 + + + + + 邮件 + + + + + 新增编辑订阅通知 + + + + + 客户名称 + + + + + 客户编码 + + + + + 电话 + + + + + 邮件 + + + + + 订阅通知列表 + + + + + 主键 + + + + + 客户名称 + + + + + 客户编码 + + + + + 电话 + + + + + 邮件 + + + + + 创建人 + + + + + 操作人 + + + + + 创建时间 + + + + + 操作时间 + + + + + 订阅通知列表 + + + + + 客户名称 + + + + + 客户编码 + + + + + 操作人 + + + + + 操作时间 开始 + + + + + 操作时间 结束 + + 盘点单明细 diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 38c56b1a..3347ea21 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -2062,6 +2062,79 @@ 出库单号 + + + 订阅通知信息 + + + + + 主键 + + + + + 客户名称 + + + + + 客户编码 + + + + + 电话 + + + + + 邮件 + + + + + 是否删除 + + + + + 创建人 + + + + + 操作人 + + + + + 创建时间 + + + + + 操作时间 + + + + + 新增 + + + + + + 修改 + + + + + + 删除 + + + wms盘点单 @@ -2870,6 +2943,33 @@ 修改实体集合 + + + 订阅通知 + + + + + 根据客户名称和客户编码验重 + + + + + + + + 获取订阅通知 + + + + + + + 获取订阅通知 + + + + 批量添加 @@ -3887,6 +3987,11 @@ + + + 订阅通知 + + 数据库 diff --git a/src/WMS.Web.Core/Dto/SubscribeNotification/EditSubscribeNotificationRequest.cs b/src/WMS.Web.Core/Dto/SubscribeNotification/EditSubscribeNotificationRequest.cs new file mode 100644 index 00000000..9a5a8b9f --- /dev/null +++ b/src/WMS.Web.Core/Dto/SubscribeNotification/EditSubscribeNotificationRequest.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace WMS.Web.Core.Dto.SubscribeNotification +{ + /// + /// 修改 + /// + public class EditSubscribeNotificationRequest + { + /// + /// 主键 + /// + [Required(ErrorMessage = "Id不能为空")] + public int Id { get; set; } = 0; + /// + /// 客户名称 + /// + [Required(ErrorMessage = "客户名称不能为空")] + public string CustomerName { get; set; } + /// + /// 客户编码 + /// + [Required(ErrorMessage = "客户编码不能为空")] + public string CustomerNumber { get; set; } + /// + /// 电话 + /// + public List Telephones { get; set; } + /// + /// 邮件 + /// + public List Emails { get; set; } + } +} diff --git a/src/WMS.Web.Core/Dto/SubscribeNotification/SaveSubscribeNotificationRequest.cs b/src/WMS.Web.Core/Dto/SubscribeNotification/SaveSubscribeNotificationRequest.cs new file mode 100644 index 00000000..f3af0dde --- /dev/null +++ b/src/WMS.Web.Core/Dto/SubscribeNotification/SaveSubscribeNotificationRequest.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace WMS.Web.Core.Dto.SubscribeNotification +{ + /// + /// 新增编辑订阅通知 + /// + public class SaveSubscribeNotificationRequest + { + /// + /// 客户名称 + /// + [Required(ErrorMessage = "客户名称不能为空")] + public string CustomerName { get; set; } + /// + /// 客户编码 + /// + [Required(ErrorMessage = "客户编码不能为空")] + public string CustomerNumber { get; set; } + /// + /// 电话 + /// + public List Telephones { get; set; } + /// + /// 邮件 + /// + public List Emails { get; set; } + } +} diff --git a/src/WMS.Web.Core/Dto/SubscribeNotification/SubscribeNotificationQueryInfoResponse.cs b/src/WMS.Web.Core/Dto/SubscribeNotification/SubscribeNotificationQueryInfoResponse.cs new file mode 100644 index 00000000..d25b205f --- /dev/null +++ b/src/WMS.Web.Core/Dto/SubscribeNotification/SubscribeNotificationQueryInfoResponse.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.SubscribeNotification +{ + /// + /// 订阅通知列表 + /// + public class SubscribeNotificationQueryInfoResponse + { + /// + /// 主键 + /// + public int Id { get; set; } + /// + /// 客户名称 + /// + public string CustomerName { get; set; } + /// + /// 客户编码 + /// + public string CustomerNumber { get; set; } + /// + /// 电话 + /// + public string Telephones { get; set; } + /// + /// 邮件 + /// + public string Emails { get; set; } + /// + /// 创建人 + /// + public string Creator { get; set; } + /// + /// 操作人 + /// + public string Operate { get; set; } + /// + /// 创建时间 + /// + public string CreateTime { get; set; } + /// + /// 操作时间 + /// + public string OperateTime { get; set; } + } +} diff --git a/src/WMS.Web.Core/Dto/SubscribeNotification/SubscribeNotificationQueryRequest.cs b/src/WMS.Web.Core/Dto/SubscribeNotification/SubscribeNotificationQueryRequest.cs new file mode 100644 index 00000000..6725892b --- /dev/null +++ b/src/WMS.Web.Core/Dto/SubscribeNotification/SubscribeNotificationQueryRequest.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.SubscribeNotification +{ + /// + /// 订阅通知列表 + /// + public class SubscribeNotificationQueryRequest : PaginationBaseRequestDto + { + /// + /// 客户名称 + /// + public string CustomerName { get; set; } + /// + /// 客户编码 + /// + public string CustomerNumber { get; set; } + /// + /// 操作人 + /// + public string Creator { get; set; } + /// + /// 操作时间 开始 + /// + public DateTime? OperateBeginDate { get; set; } + /// + /// 操作时间 结束 + /// + public DateTime? OperateEndDate { get; set; } + } +} diff --git a/src/WMS.Web.Domain/Entitys/SubscribeNotification.cs b/src/WMS.Web.Domain/Entitys/SubscribeNotification.cs new file mode 100644 index 00000000..007ae926 --- /dev/null +++ b/src/WMS.Web.Domain/Entitys/SubscribeNotification.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using WMS.Web.Core; + +namespace WMS.Web.Domain.Entitys +{ + /// + /// 订阅通知信息 + /// + [Serializable] + [Table("t_wms_subscribe_notification")] + public class SubscribeNotification : EntityBase + { + public SubscribeNotification() { } + /// + /// 主键 + /// + [Column("Id")] + public override int Id { get; set; } + /// + /// 客户名称 + /// + [Column("CustomerName")] + public string CustomerName { get; set; } + /// + /// 客户编码 + /// + [Column("CustomerNumber")] + public string CustomerNumber { get; set; } + /// + /// 电话 + /// + [Column("Telephones")] + public List Telephones { get; set; } + /// + /// 邮件 + /// + [Column("Emails")] + public List Emails { get; set; } + /// + /// 是否删除 + /// + [Column("IsDelete")] + public bool IsDelete { get; set; } = false; + /// + /// 创建人 + /// + [Column("CreatorId")] + public int CreatorId { get; set; } + /// + /// 操作人 + /// + [Column("OperateId")] + public int OperateId { get; set; } + /// + /// 创建时间 + /// + [Column("CreateTime")] + public DateTime CreateTime { get; set; } = DateTime.Now; + /// + /// 操作时间 + /// + [Column("OperateTime")] + public DateTime OperateTime { get; set; } + /// + /// 新增 + /// + /// + public void Create(int creatorId) + { + this.CreatorId = creatorId; + this.CreateTime = DateTime.Now; + } + /// + /// 修改 + /// + /// + public void Edit(int operateId) + { + this.OperateId = operateId; + this.OperateTime = DateTime.Now; + } + + /// + /// 删除 + /// + /// + public void Delete(int operateId) + { + this.IsDelete = true; + this.OperateId = operateId; + this.OperateTime = DateTime.Now; + } + } +} diff --git a/src/WMS.Web.Domain/Infrastructure/ISubscribeNotificationRepositories.cs b/src/WMS.Web.Domain/Infrastructure/ISubscribeNotificationRepositories.cs new file mode 100644 index 00000000..9ceaefbd --- /dev/null +++ b/src/WMS.Web.Domain/Infrastructure/ISubscribeNotificationRepositories.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto.SubscribeNotification; +using WMS.Web.Domain.Entitys; + +namespace WMS.Web.Domain.Infrastructure +{ + /// + /// 订阅通知 + /// + public interface ISubscribeNotificationRepositories + { + /// + /// 根据客户名称和客户编码验重 + /// + /// + /// + /// + Task IsExist(string name, string number); + /// + /// 获取订阅通知 + /// + /// + /// + Task Get(int id); + /// + /// 获取订阅通知 + /// + /// + /// + Task> GetList(List ids = null); + // 新增 + Task Add(SubscribeNotification entity, bool isTransaction = true); + // 修改 + Task Edit(SubscribeNotification entity, bool isTransaction = true); + // 批量修改 + Task EditList(List entitys, bool isTransaction = true); + // 获取列表 + Task<(List list, int total)> GetListAsync(SubscribeNotificationQueryRequest dto, int companyId = 0); + } +} diff --git a/src/WMS.Web.Domain/Mappers/SubscribeNotificationMapper.cs b/src/WMS.Web.Domain/Mappers/SubscribeNotificationMapper.cs new file mode 100644 index 00000000..13bcc485 --- /dev/null +++ b/src/WMS.Web.Domain/Mappers/SubscribeNotificationMapper.cs @@ -0,0 +1,22 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Text; +using WMS.Web.Core.Dto.SubscribeNotification; +using WMS.Web.Domain.Entitys; + +namespace WMS.Web.Domain.Mappers +{ + /// + /// 订阅通知 + /// + public class SubscribeNotificationMapper : Profile + { + public SubscribeNotificationMapper() + { + CreateMap(); + CreateMap(); + CreateMap(); + } + } +} diff --git a/src/WMS.Web.Domain/Values/ResultCodes.cs b/src/WMS.Web.Domain/Values/ResultCodes.cs index 62c15924..8ee4de32 100644 --- a/src/WMS.Web.Domain/Values/ResultCodes.cs +++ b/src/WMS.Web.Domain/Values/ResultCodes.cs @@ -85,5 +85,7 @@ namespace WMS.Web.Domain.Values public static ValueTuple TakeStockStockError = (610001, "一次不能盘多个仓库"); public static ValueTuple TakeStockErpSubStockError = (610005, "HD或GD仓时子仓库必填"); public static ValueTuple TakeStockBoxError = (610004, "一次只能盘一个箱"); + + public static ValueTuple SubscribeNotificationNoData = (700001, "订阅通知信息不存在"); } } diff --git a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs index cfcfac1c..790d539d 100644 --- a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs +++ b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs @@ -375,7 +375,20 @@ namespace WMS.Web.Repositories.Configuration ent.ToTable("t_wms_materials"); ent.HasKey(x => x.Id); }); + //订阅通知 + builder.Entity(ent => + { + ent.ToTable("t_wms_subscribe_notification"); + ent.HasKey(x => x.Id); + ent.Property(f => f.Telephones).HasConversion( + v => JsonConvert.SerializeObject(v), + v => JsonConvert.DeserializeObject>(v)); + + ent.Property(f => f.Emails).HasConversion( + v => JsonConvert.SerializeObject(v), + v => JsonConvert.DeserializeObject>(v)); + }); base.OnModelCreating(builder); } @@ -413,5 +426,6 @@ namespace WMS.Web.Repositories.Configuration public DbSet Box { get; set; } public DbSet BoxDetails { get; set; } + public DbSet SubscribeNotification { get; set; } } } diff --git a/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs b/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs index 37f9847a..00475c06 100644 --- a/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs +++ b/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs @@ -80,6 +80,8 @@ namespace Microsoft.Extensions.DependencyInjection services.AddTransient(); services.AddTransient(); + services.AddTransient(); + } } } diff --git a/src/WMS.Web.Repositories/SubscribeNotificationRepositories.cs b/src/WMS.Web.Repositories/SubscribeNotificationRepositories.cs new file mode 100644 index 00000000..796e34ce --- /dev/null +++ b/src/WMS.Web.Repositories/SubscribeNotificationRepositories.cs @@ -0,0 +1,224 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto.SubscribeNotification; +using WMS.Web.Core.Help; +using WMS.Web.Domain.Entitys; +using WMS.Web.Domain.Infrastructure; +using WMS.Web.Domain.IService.Public; +using WMS.Web.Domain.Mappers; +using WMS.Web.Domain.Values.Single; +using WMS.Web.Repositories.Configuration; + +namespace WMS.Web.Repositories +{ + /// + /// 订阅通知 + /// + public class SubscribeNotificationRepositories : ISubscribeNotificationRepositories + { + private readonly IMapper _mapper; + private readonly IServiceProvider _serviceProvider; + private readonly RepositoryDbContext _context; + private readonly ISingleDataService _singleDataService; + private readonly ILoginRepositories _loginRepositories; + private readonly IBasicsRepositories _basicsRepositories; + + public SubscribeNotificationRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider, + ISingleDataService singleDataService, ILoginRepositories loginRepositories, IBasicsRepositories basicsRepositories) + { + _context = context; + _mapper = mapper; + _serviceProvider = serviceProvider; + _singleDataService = singleDataService; + _loginRepositories = loginRepositories; + _basicsRepositories = basicsRepositories; + } + /// + /// 增加 + /// + /// + /// + /// + public async Task Add(SubscribeNotification entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.SubscribeNotification.AddAsync(entity); + await _context.SaveChangesAsync(); + + + if (_transaction != null) + _transaction.Commit(); + return entity; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + } + /// + /// 编辑 + /// + /// + /// + /// + public async Task Edit(SubscribeNotification entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + + try + { + var res = await _context.SubscribeNotification + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (res == null) return null; + + _mapper.Map(entity, res); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + + return res; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + } + /// + /// 批量编辑 + /// + /// + /// + /// + public async Task EditList(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + List list = entitys.Select(s => s.Id).ToList(); + + var res = await _context.SubscribeNotification + .Where(f => list.Contains(f.Id)).ToListAsync(); + + _mapper.ToMapList(entitys, res); + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + } + + public async Task Get(int id) + { + return await _context.SubscribeNotification + .AsNoTracking() + .FirstOrDefaultAsync(f => f.Id == id); + } + + public async Task> GetList(List ids = null) + { + if (ids == null) + { + return await _context.SubscribeNotification + .AsNoTracking().ToListAsync(); + } + else + { + return await _context.SubscribeNotification + .AsNoTracking() + .Where(w => ids.Contains(w.Id)) + .ToListAsync(); + } + } + + /// + /// 列表 + /// + /// + /// + /// + public async Task<(List list, int total)> GetListAsync(SubscribeNotificationQueryRequest dto, int companyId = 0) + { + if (companyId == 0) + companyId = _loginRepositories.CompanyId; + List ids = new List(); + if (!string.IsNullOrEmpty(dto.Creator)) + { + var staffList = await _basicsRepositories.GetStaffListAsync(companyId); + if (staffList != null) + ids = staffList.Where(w => w.Name.Contains(dto.Creator)).Select(s => s.Id).ToList(); + } + + var query = _context.SubscribeNotification + .OrderByDescending(o => o.Id) + .Where(adv => 1 == 1 && adv.IsDelete != true); + + if (!string.IsNullOrEmpty(dto.Creator)) + query = query.Where(w => ids.Contains(w.CreatorId)); + + if (!string.IsNullOrEmpty(dto.CustomerName)) + query = query.Where(w => EF.Functions.Like(w.CustomerName, "%" + dto.CustomerName + "%")); + if (!string.IsNullOrEmpty(dto.CustomerNumber)) + query = query.Where(w => EF.Functions.Like(w.CustomerNumber, "%" + dto.CustomerNumber + "%")); + if (dto.OperateBeginDate != null) + query = query.Where(w => w.OperateTime >= dto.OperateBeginDate); + if (dto.OperateEndDate != null) + query = query.Where(w => w.OperateTime <= dto.OperateEndDate); + //组装 + int total = await query.CountAsync(); + var list = await query.Select(s => new SubscribeNotificationQueryInfoResponse() + { + #region dto组装 + Id = s.Id, + CustomerName = s.CustomerName, + CustomerNumber = s.CustomerNumber, + Telephones = s.CustomerName, + Emails = s.CustomerName, + Operate = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.OperateId), + OperateTime = s.OperateTime.DateToStringSeconds(), + Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.CreatorId), + CreateTime = s.CreateTime.DateToStringSeconds() + #endregion + + }).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + return (list, total); + } + /// + /// 验重 + /// + /// + /// + /// + public async Task IsExist(string name, string number) + { + var res = await _context.SubscribeNotification + .FirstOrDefaultAsync(f => f.CustomerName.Equals(name) && f.CustomerNumber.Equals(number)); + if (res == null) return false; + return true; + } + } +}