增加订阅通知
This commit is contained in:
132
src/WMS.Web.Api/Controllers/SubscribeNotificationController.cs
Normal file
132
src/WMS.Web.Api/Controllers/SubscribeNotificationController.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅通知
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("GetList")]
|
||||
public async Task<ResultPagedList<SubscribeNotificationQueryInfoResponse>> GetPagedList([FromBody] SubscribeNotificationQueryRequest dto)
|
||||
{
|
||||
var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]);
|
||||
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||
return ResultPagedList<SubscribeNotificationQueryInfoResponse>.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||
|
||||
var (list, count) = await _repositories.GetListAsync(dto);
|
||||
var result = ResultPagedList<SubscribeNotificationQueryInfoResponse>.ReSuccess(list, count);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("Save")]
|
||||
public async Task<Result> 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<SubscribeNotification>(dto);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
var res = await _repositories.Add(entity, true);
|
||||
|
||||
if (res == null) Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("Save")]
|
||||
public async Task<Result> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("Delete")]
|
||||
public async Task<Result> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,6 +499,39 @@
|
||||
<param name="serialNumber">序列号</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Api.Controllers.SubscribeNotificationController">
|
||||
<summary>
|
||||
订阅通知
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.SubscribeNotificationController.GetPagedList(WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryRequest)">
|
||||
<summary>
|
||||
列表
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.SubscribeNotificationController.Save(WMS.Web.Core.Dto.SubscribeNotification.SaveSubscribeNotificationRequest)">
|
||||
<summary>
|
||||
新增
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.SubscribeNotificationController.Edit(WMS.Web.Core.Dto.SubscribeNotification.EditSubscribeNotificationRequest)">
|
||||
<summary>
|
||||
修改
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Api.Controllers.SubscribeNotificationController.Sync(WMS.Web.Core.Dto.OperateRequest)">
|
||||
<summary>
|
||||
删除
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Api.Controllers.SysConfigController">
|
||||
<summary>
|
||||
系统配置
|
||||
|
||||
@@ -5213,6 +5213,141 @@
|
||||
编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.SubscribeNotification.EditSubscribeNotificationRequest">
|
||||
<summary>
|
||||
修改
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.EditSubscribeNotificationRequest.Id">
|
||||
<summary>
|
||||
主键
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.EditSubscribeNotificationRequest.CustomerName">
|
||||
<summary>
|
||||
客户名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.EditSubscribeNotificationRequest.CustomerNumber">
|
||||
<summary>
|
||||
客户编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.EditSubscribeNotificationRequest.Telephones">
|
||||
<summary>
|
||||
电话
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.EditSubscribeNotificationRequest.Emails">
|
||||
<summary>
|
||||
邮件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.SubscribeNotification.SaveSubscribeNotificationRequest">
|
||||
<summary>
|
||||
新增编辑订阅通知
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SaveSubscribeNotificationRequest.CustomerName">
|
||||
<summary>
|
||||
客户名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SaveSubscribeNotificationRequest.CustomerNumber">
|
||||
<summary>
|
||||
客户编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SaveSubscribeNotificationRequest.Telephones">
|
||||
<summary>
|
||||
电话
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SaveSubscribeNotificationRequest.Emails">
|
||||
<summary>
|
||||
邮件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse">
|
||||
<summary>
|
||||
订阅通知列表
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.Id">
|
||||
<summary>
|
||||
主键
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.CustomerName">
|
||||
<summary>
|
||||
客户名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.CustomerNumber">
|
||||
<summary>
|
||||
客户编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.Telephones">
|
||||
<summary>
|
||||
电话
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.Emails">
|
||||
<summary>
|
||||
邮件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.Creator">
|
||||
<summary>
|
||||
创建人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.Operate">
|
||||
<summary>
|
||||
操作人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.CreateTime">
|
||||
<summary>
|
||||
创建时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryInfoResponse.OperateTime">
|
||||
<summary>
|
||||
操作时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryRequest">
|
||||
<summary>
|
||||
订阅通知列表
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryRequest.CustomerName">
|
||||
<summary>
|
||||
客户名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryRequest.CustomerNumber">
|
||||
<summary>
|
||||
客户编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryRequest.Creator">
|
||||
<summary>
|
||||
操作人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryRequest.OperateBeginDate">
|
||||
<summary>
|
||||
操作时间 开始
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.SubscribeNotification.SubscribeNotificationQueryRequest.OperateEndDate">
|
||||
<summary>
|
||||
操作时间 结束
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Core.Dto.TakeStock.SaveTakeStockRequest">
|
||||
<summary>
|
||||
盘点单明细
|
||||
|
||||
@@ -2062,6 +2062,79 @@
|
||||
</summary>
|
||||
<param name="inStockBillNo">出库单号</param>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.SubscribeNotification">
|
||||
<summary>
|
||||
订阅通知信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.Id">
|
||||
<summary>
|
||||
主键
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.CustomerName">
|
||||
<summary>
|
||||
客户名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.CustomerNumber">
|
||||
<summary>
|
||||
客户编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.Telephones">
|
||||
<summary>
|
||||
电话
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.Emails">
|
||||
<summary>
|
||||
邮件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.IsDelete">
|
||||
<summary>
|
||||
是否删除
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.CreatorId">
|
||||
<summary>
|
||||
创建人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.OperateId">
|
||||
<summary>
|
||||
操作人
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.CreateTime">
|
||||
<summary>
|
||||
创建时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.SubscribeNotification.OperateTime">
|
||||
<summary>
|
||||
操作时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.SubscribeNotification.Create(System.Int32)">
|
||||
<summary>
|
||||
新增
|
||||
</summary>
|
||||
<param name="creatorId"></param>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.SubscribeNotification.Edit(System.Int32)">
|
||||
<summary>
|
||||
修改
|
||||
</summary>
|
||||
<param name="operateId"></param>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Entitys.SubscribeNotification.Delete(System.Int32)">
|
||||
<summary>
|
||||
删除
|
||||
</summary>
|
||||
<param name="operateId"></param>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.TakeStock">
|
||||
<summary>
|
||||
wms盘点单
|
||||
@@ -2870,6 +2943,33 @@
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.ISerialNumbersRepositories.EditEntityList(System.Collections.Generic.List{WMS.Web.Domain.Entitys.SerialNumbers},System.Boolean)">
|
||||
修改实体集合
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Infrastructure.ISubscribeNotificationRepositories">
|
||||
<summary>
|
||||
订阅通知
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.ISubscribeNotificationRepositories.IsExist(System.String,System.String)">
|
||||
<summary>
|
||||
根据客户名称和客户编码验重
|
||||
</summary>
|
||||
<param name="name"></param>
|
||||
<param name="number"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.ISubscribeNotificationRepositories.Get(System.Int32)">
|
||||
<summary>
|
||||
获取订阅通知
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.ISubscribeNotificationRepositories.GetList(System.Collections.Generic.List{System.Int32})">
|
||||
<summary>
|
||||
获取订阅通知
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.ITakeStockRepositories.AddRange(System.Collections.Generic.List{WMS.Web.Domain.Entitys.TakeStock},System.Boolean)">
|
||||
<summary>
|
||||
批量添加
|
||||
@@ -3887,6 +3987,11 @@
|
||||
<param name="destinationList"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Mappers.SubscribeNotificationMapper">
|
||||
<summary>
|
||||
订阅通知
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Options.AppOptions.DBConnectionString">
|
||||
<summary>
|
||||
数据库
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto.SubscribeNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
public class EditSubscribeNotificationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "Id不能为空")]
|
||||
public int Id { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "客户名称不能为空")]
|
||||
public string CustomerName { get; set; }
|
||||
/// <summary>
|
||||
/// 客户编码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "客户编码不能为空")]
|
||||
public string CustomerNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 电话
|
||||
/// </summary>
|
||||
public List<string> Telephones { get; set; }
|
||||
/// <summary>
|
||||
/// 邮件
|
||||
/// </summary>
|
||||
public List<string> Emails { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto.SubscribeNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// 新增编辑订阅通知
|
||||
/// </summary>
|
||||
public class SaveSubscribeNotificationRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "客户名称不能为空")]
|
||||
public string CustomerName { get; set; }
|
||||
/// <summary>
|
||||
/// 客户编码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "客户编码不能为空")]
|
||||
public string CustomerNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 电话
|
||||
/// </summary>
|
||||
public List<string> Telephones { get; set; }
|
||||
/// <summary>
|
||||
/// 邮件
|
||||
/// </summary>
|
||||
public List<string> Emails { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto.SubscribeNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅通知列表
|
||||
/// </summary>
|
||||
public class SubscribeNotificationQueryInfoResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
public string CustomerName { get; set; }
|
||||
/// <summary>
|
||||
/// 客户编码
|
||||
/// </summary>
|
||||
public string CustomerNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 电话
|
||||
/// </summary>
|
||||
public string Telephones { get; set; }
|
||||
/// <summary>
|
||||
/// 邮件
|
||||
/// </summary>
|
||||
public string Emails { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public string Creator { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public string Operate { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public string CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 操作时间
|
||||
/// </summary>
|
||||
public string OperateTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WMS.Web.Core.Dto.SubscribeNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅通知列表
|
||||
/// </summary>
|
||||
public class SubscribeNotificationQueryRequest : PaginationBaseRequestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
public string CustomerName { get; set; }
|
||||
/// <summary>
|
||||
/// 客户编码
|
||||
/// </summary>
|
||||
public string CustomerNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public string Creator { get; set; }
|
||||
/// <summary>
|
||||
/// 操作时间 开始
|
||||
/// </summary>
|
||||
public DateTime? OperateBeginDate { get; set; }
|
||||
/// <summary>
|
||||
/// 操作时间 结束
|
||||
/// </summary>
|
||||
public DateTime? OperateEndDate { get; set; }
|
||||
}
|
||||
}
|
||||
97
src/WMS.Web.Domain/Entitys/SubscribeNotification.cs
Normal file
97
src/WMS.Web.Domain/Entitys/SubscribeNotification.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅通知信息
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_wms_subscribe_notification")]
|
||||
public class SubscribeNotification : EntityBase
|
||||
{
|
||||
public SubscribeNotification() { }
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
[Column("CustomerName")]
|
||||
public string CustomerName { get; set; }
|
||||
/// <summary>
|
||||
/// 客户编码
|
||||
/// </summary>
|
||||
[Column("CustomerNumber")]
|
||||
public string CustomerNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 电话
|
||||
/// </summary>
|
||||
[Column("Telephones")]
|
||||
public List<string> Telephones { get; set; }
|
||||
/// <summary>
|
||||
/// 邮件
|
||||
/// </summary>
|
||||
[Column("Emails")]
|
||||
public List<string> Emails { get; set; }
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
/// </summary>
|
||||
[Column("IsDelete")]
|
||||
public bool IsDelete { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
public int CreatorId { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
[Column("OperateId")]
|
||||
public int OperateId { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[Column("CreateTime")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 操作时间
|
||||
/// </summary>
|
||||
[Column("OperateTime")]
|
||||
public DateTime OperateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId)
|
||||
{
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="operateId"></param>
|
||||
public void Edit(int operateId)
|
||||
{
|
||||
this.OperateId = operateId;
|
||||
this.OperateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="operateId"></param>
|
||||
public void Delete(int operateId)
|
||||
{
|
||||
this.IsDelete = true;
|
||||
this.OperateId = operateId;
|
||||
this.OperateTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅通知
|
||||
/// </summary>
|
||||
public interface ISubscribeNotificationRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据客户名称和客户编码验重
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExist(string name, string number);
|
||||
/// <summary>
|
||||
/// 获取订阅通知
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<SubscribeNotification> Get(int id);
|
||||
/// <summary>
|
||||
/// 获取订阅通知
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SubscribeNotification>> GetList(List<int> ids = null);
|
||||
// 新增
|
||||
Task<SubscribeNotification> Add(SubscribeNotification entity, bool isTransaction = true);
|
||||
// 修改
|
||||
Task<SubscribeNotification> Edit(SubscribeNotification entity, bool isTransaction = true);
|
||||
// 批量修改
|
||||
Task<bool> EditList(List<SubscribeNotification> entitys, bool isTransaction = true);
|
||||
// 获取列表
|
||||
Task<(List<SubscribeNotificationQueryInfoResponse> list, int total)> GetListAsync(SubscribeNotificationQueryRequest dto, int companyId = 0);
|
||||
}
|
||||
}
|
||||
22
src/WMS.Web.Domain/Mappers/SubscribeNotificationMapper.cs
Normal file
22
src/WMS.Web.Domain/Mappers/SubscribeNotificationMapper.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅通知
|
||||
/// </summary>
|
||||
public class SubscribeNotificationMapper : Profile
|
||||
{
|
||||
public SubscribeNotificationMapper()
|
||||
{
|
||||
CreateMap<SubscribeNotification, SubscribeNotification>();
|
||||
CreateMap<SaveSubscribeNotificationRequest, SubscribeNotification>();
|
||||
CreateMap<EditSubscribeNotificationRequest, SubscribeNotification>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,5 +85,7 @@ namespace WMS.Web.Domain.Values
|
||||
public static ValueTuple<int, string> TakeStockStockError = (610001, "一次不能盘多个仓库");
|
||||
public static ValueTuple<int, string> TakeStockErpSubStockError = (610005, "HD或GD仓时子仓库必填");
|
||||
public static ValueTuple<int, string> TakeStockBoxError = (610004, "一次只能盘一个箱");
|
||||
|
||||
public static ValueTuple<int, string> SubscribeNotificationNoData = (700001, "订阅通知信息不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,20 @@ namespace WMS.Web.Repositories.Configuration
|
||||
ent.ToTable("t_wms_materials");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
//订阅通知
|
||||
builder.Entity<SubscribeNotification>(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<List<string>>(v));
|
||||
|
||||
ent.Property(f => f.Emails).HasConversion(
|
||||
v => JsonConvert.SerializeObject(v),
|
||||
v => JsonConvert.DeserializeObject<List<string>>(v));
|
||||
});
|
||||
|
||||
base.OnModelCreating(builder);
|
||||
}
|
||||
@@ -413,5 +426,6 @@ namespace WMS.Web.Repositories.Configuration
|
||||
|
||||
public DbSet<Box> Box { get; set; }
|
||||
public DbSet<BoxDetails> BoxDetails { get; set; }
|
||||
public DbSet<SubscribeNotification> SubscribeNotification { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
services.AddTransient<IBoxMarkRepositories, BoxMarkRepositories>();
|
||||
services.AddTransient<IMaterialsRepositories, MaterialsRepositories>();
|
||||
|
||||
services.AddTransient<ISubscribeNotificationRepositories, SubscribeNotificationRepositories>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
224
src/WMS.Web.Repositories/SubscribeNotificationRepositories.cs
Normal file
224
src/WMS.Web.Repositories/SubscribeNotificationRepositories.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅通知
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SubscribeNotification> 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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SubscribeNotification> 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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量编辑
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EditList(List<SubscribeNotification> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
List<int> 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<SubscribeNotification> Get(int id)
|
||||
{
|
||||
return await _context.SubscribeNotification
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(f => f.Id == id);
|
||||
}
|
||||
|
||||
public async Task<List<SubscribeNotification>> GetList(List<int> ids = null)
|
||||
{
|
||||
if (ids == null)
|
||||
{
|
||||
return await _context.SubscribeNotification
|
||||
.AsNoTracking().ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _context.SubscribeNotification
|
||||
.AsNoTracking()
|
||||
.Where(w => ids.Contains(w.Id))
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<(List<SubscribeNotificationQueryInfoResponse> list, int total)> GetListAsync(SubscribeNotificationQueryRequest dto, int companyId = 0)
|
||||
{
|
||||
if (companyId == 0)
|
||||
companyId = _loginRepositories.CompanyId;
|
||||
List<int> ids = new List<int>();
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// 验重
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user