feat 添加涉及产品接口
This commit is contained in:
parent
72cbffd477
commit
235823f460
@ -19,14 +19,13 @@ namespace ARW.Model.Dto.Api.ProductsInvolveds
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 涉及产品详情输入对象Api
|
/// 订阅涉及产品
|
||||||
///
|
|
||||||
/// @author lwh
|
/// @author lwh
|
||||||
/// @date 2023-11-23
|
/// @date 2023-11-23
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProductsInvolvedDtoApi
|
public class ProductsInvolvedDtoApi
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "ProductsInvolvedGuid不能为空")]
|
[Required(ErrorMessage = "涉及产品不能为空")]
|
||||||
public long ProductsInvolvedGuid { get; set; }
|
public long ProductsInvolvedGuid { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,15 +13,6 @@ namespace ARW.Model.Vo.Api.ProductsInvolveds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProductsInvolvedVoApi
|
public class ProductsInvolvedVoApi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :
|
|
||||||
/// </summary>
|
|
||||||
[EpplusIgnore]
|
|
||||||
public int ProductsInvolvedId { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :
|
/// 描述 :
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -38,11 +29,10 @@ namespace ARW.Model.Vo.Api.ProductsInvolveds
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :排序
|
/// 描述 :是否订阅
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EpplusTableColumn(Header = "排序")]
|
[EpplusTableColumn(Header = "是否订阅")]
|
||||||
public int ProductsInvolvedSort { get; set; }
|
public bool IsSubscribe { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ using ARW.Service.Api.IBusinessService.ProductsInvolveds;
|
|||||||
using ARW.Model.Dto.Api.ProductsInvolveds;
|
using ARW.Model.Dto.Api.ProductsInvolveds;
|
||||||
using ARW.Model.Models.Business.ProductsInvolveds;
|
using ARW.Model.Models.Business.ProductsInvolveds;
|
||||||
using ARW.Model.Vo.Api.ProductsInvolveds;
|
using ARW.Model.Vo.Api.ProductsInvolveds;
|
||||||
|
using ARW.Repository.Business.SubscribeTasks;
|
||||||
|
|
||||||
namespace ARW.Service.Api.BusinessService.ProductsInvolveds
|
namespace ARW.Service.Api.BusinessService.ProductsInvolveds
|
||||||
{
|
{
|
||||||
@ -26,21 +27,23 @@ namespace ARW.Service.Api.BusinessService.ProductsInvolveds
|
|||||||
public class ProductsInvolvedServiceImplApi : BaseService<ProductsInvolved>, IProductsInvolvedServiceApi
|
public class ProductsInvolvedServiceImplApi : BaseService<ProductsInvolved>, IProductsInvolvedServiceApi
|
||||||
{
|
{
|
||||||
private readonly ProductsInvolvedRepository _ProductsInvolvedRepository;
|
private readonly ProductsInvolvedRepository _ProductsInvolvedRepository;
|
||||||
|
private readonly SubscribeTaskRepository _SubscribeTaskRepository;
|
||||||
|
|
||||||
public ProductsInvolvedServiceImplApi(ProductsInvolvedRepository ProductsInvolvedRepository)
|
public ProductsInvolvedServiceImplApi(ProductsInvolvedRepository ProductsInvolvedRepository, SubscribeTaskRepository subscribeTaskRepository)
|
||||||
{
|
{
|
||||||
this._ProductsInvolvedRepository = ProductsInvolvedRepository;
|
this._ProductsInvolvedRepository = ProductsInvolvedRepository;
|
||||||
|
_SubscribeTaskRepository = subscribeTaskRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Api接口代码
|
#region Api接口代码
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询涉及产品列表(Api)
|
/// 查询涉及产品列表(Api)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<PagedInfo<ProductsInvolvedVoApi>> GetProductsInvolvedListApi(ProductsInvolvedQueryDtoApi parm)
|
public async Task<PagedInfo<ProductsInvolvedVoApi>> GetProductsInvolvedListApi(ProductsInvolvedQueryDtoApi parm, long userId)
|
||||||
{
|
{
|
||||||
//开始拼装查询条件d
|
//开始拼装查询条件d
|
||||||
var predicate = Expressionable.Create<ProductsInvolved>();
|
var predicate = Expressionable.Create<ProductsInvolved>();
|
||||||
@ -49,44 +52,30 @@ namespace ARW.Service.Api.BusinessService.ProductsInvolveds
|
|||||||
var query = _ProductsInvolvedRepository
|
var query = _ProductsInvolvedRepository
|
||||||
.Queryable()
|
.Queryable()
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.OrderBy(s => s.ProductsInvolvedSort,OrderByType.Desc)
|
.OrderBy(s => s.ProductsInvolvedSort, OrderByType.Asc)
|
||||||
.Select(s => new ProductsInvolvedVoApi
|
.Select(s => new ProductsInvolvedVoApi
|
||||||
{
|
{
|
||||||
ProductsInvolvedId = s.ProductsInvolvedId,
|
ProductsInvolvedGuid = s.ProductsInvolvedGuid,
|
||||||
ProductsInvolvedGuid = s.ProductsInvolvedGuid,
|
ProductsInvolvedName = s.ProductsInvolvedName
|
||||||
ProductsInvolvedName = s.ProductsInvolvedName,
|
});
|
||||||
ProductsInvolvedSort = s.ProductsInvolvedSort,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
return await query.ToPageAsync(parm);
|
|
||||||
|
var list = await query.ToPageAsync(parm);
|
||||||
|
|
||||||
|
foreach (var item in list.Result)
|
||||||
|
{
|
||||||
|
var task = await _SubscribeTaskRepository.GetFirstAsync(s => s.SubscribeTaskBusinessGuid == item.ProductsInvolvedGuid && s.CustomerGuid == userId);
|
||||||
|
if (task != null)
|
||||||
|
{
|
||||||
|
item.IsSubscribe = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询涉及产品详情(Api)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<string> GetProductsInvolvedDetails(ProductsInvolvedDtoApi parm)
|
|
||||||
{
|
|
||||||
|
|
||||||
var query = _ProductsInvolvedRepository
|
#endregion
|
||||||
.Queryable()
|
|
||||||
.Where(s => s.ProductsInvolvedGuid == parm.ProductsInvolvedGuid)
|
|
||||||
.Select(s => new ProductsInvolvedApiDetailsVo
|
|
||||||
{
|
|
||||||
ProductsInvolvedId = s.ProductsInvolvedId,
|
|
||||||
ProductsInvolvedGuid = s.ProductsInvolvedGuid,
|
|
||||||
ProductsInvolvedName = s.ProductsInvolvedName,
|
|
||||||
ProductsInvolvedSort = s.ProductsInvolvedSort,
|
|
||||||
}).Take(1);
|
|
||||||
|
|
||||||
|
|
||||||
return await query.ToJsonAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,7 @@ namespace ARW.Service.Api.IBusinessService.ProductsInvolveds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<PagedInfo<ProductsInvolvedVoApi>> GetProductsInvolvedListApi(ProductsInvolvedQueryDtoApi parm);
|
Task<PagedInfo<ProductsInvolvedVoApi>> GetProductsInvolvedListApi(ProductsInvolvedQueryDtoApi parm,long userId);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取涉及产品详情(Api)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<string> GetProductsInvolvedDetails(ProductsInvolvedDtoApi parm);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,9 @@ namespace ARW.Service.Business.BusinessService.SubscribeTasks
|
|||||||
.Queryable()
|
.Queryable()
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.Where(s => s.SubscribeTaskStatus == 0)
|
.Where(s => s.SubscribeTaskStatus == 0)
|
||||||
.LeftJoin<Customer>((s,f) => s.CustomerGuid == f.CustomerGuid)
|
.LeftJoin<Customer>((s, f) => s.CustomerGuid == f.CustomerGuid)
|
||||||
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
||||||
.Select((s,f) => new SubscribeTaskVo
|
.Select((s, f) => new SubscribeTaskVo
|
||||||
{
|
{
|
||||||
SubscribeTaskId = s.SubscribeTaskId,
|
SubscribeTaskId = s.SubscribeTaskId,
|
||||||
SubscribeTaskGuid = s.SubscribeTaskGuid,
|
SubscribeTaskGuid = s.SubscribeTaskGuid,
|
||||||
@ -62,6 +62,24 @@ namespace ARW.Service.Business.BusinessService.SubscribeTasks
|
|||||||
return query.ToList();
|
return query.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<string> AddSubscribeTask(long customerGuid, long businessGuid, int templateId)
|
||||||
|
{
|
||||||
|
var model = new SubscribeTask
|
||||||
|
{
|
||||||
|
CustomerGuid = customerGuid,
|
||||||
|
SubscribeTaskBusinessGuid = businessGuid,
|
||||||
|
SubscribeTaskType = 1,
|
||||||
|
SubscribeTaskId = templateId,
|
||||||
|
SubscribeTaskStatus = 0
|
||||||
|
};
|
||||||
|
var res = await _SubscribeTaskRepository.InsertReturnSnowflakeIdAsync(model);
|
||||||
|
|
||||||
|
return "添加成功";
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,17 @@ namespace ARW.Service.Business.IBusinessService.SubscribeTasks
|
|||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<SubscribeTaskVo> GetSubscribeTaskList();
|
List<SubscribeTaskVo> GetSubscribeTaskList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加订阅任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customerGuid">客户guid</param>
|
||||||
|
/// <param name="businessGuid">业务guid</param>
|
||||||
|
/// <param name="templateId">模板id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> AddSubscribeTask(long customerGuid,long businessGuid,int templateId);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ using ARW.Model.Models.Business.ProductsInvolveds;
|
|||||||
using ARW.Model.Vo.Api.ProductsInvolveds;
|
using ARW.Model.Vo.Api.ProductsInvolveds;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Geocoding;
|
using Geocoding;
|
||||||
|
using ARW.Admin.WebApi.Framework;
|
||||||
|
using ARW.Service.Business.IBusinessService.SubscribeTasks;
|
||||||
|
using Senparc.Weixin.Open.WxOpenAPIs;
|
||||||
|
|
||||||
namespace ARW.WebApi.Controllers.Api.ProductsInvolveds
|
namespace ARW.WebApi.Controllers.Api.ProductsInvolveds
|
||||||
{
|
{
|
||||||
@ -29,14 +32,16 @@ namespace ARW.WebApi.Controllers.Api.ProductsInvolveds
|
|||||||
public class ProductsInvolvedApiController : BaseController
|
public class ProductsInvolvedApiController : BaseController
|
||||||
{
|
{
|
||||||
private readonly IProductsInvolvedServiceApi _ProductsInvolvedServiceApi;
|
private readonly IProductsInvolvedServiceApi _ProductsInvolvedServiceApi;
|
||||||
|
private readonly ISubscribeTaskService _SubscribeTaskService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖注入
|
/// 依赖注入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ProductsInvolvedServiceApi">涉及产品涉及产品Api服务</param>
|
/// <param name="ProductsInvolvedServiceApi">涉及产品涉及产品Api服务</param>
|
||||||
public ProductsInvolvedApiController(IProductsInvolvedServiceApi ProductsInvolvedServiceApi)
|
public ProductsInvolvedApiController(IProductsInvolvedServiceApi ProductsInvolvedServiceApi, ISubscribeTaskService subscribeTaskService)
|
||||||
{
|
{
|
||||||
_ProductsInvolvedServiceApi = ProductsInvolvedServiceApi;
|
_ProductsInvolvedServiceApi = ProductsInvolvedServiceApi;
|
||||||
|
_SubscribeTaskService = subscribeTaskService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,33 +53,39 @@ namespace ARW.WebApi.Controllers.Api.ProductsInvolveds
|
|||||||
[HttpGet("getProductsInvolvedList")]
|
[HttpGet("getProductsInvolvedList")]
|
||||||
public async Task<IActionResult> GetProductsInvolvedListApi([FromQuery] ProductsInvolvedQueryDtoApi parm)
|
public async Task<IActionResult> GetProductsInvolvedListApi([FromQuery] ProductsInvolvedQueryDtoApi parm)
|
||||||
{
|
{
|
||||||
var res = await _ProductsInvolvedServiceApi.GetProductsInvolvedListApi(parm);
|
var user = JwtUtil.GetLoginUser(App.HttpContext).UserId;
|
||||||
|
var res = await _ProductsInvolvedServiceApi.GetProductsInvolvedListApi(parm, user);
|
||||||
return SUCCESS(res);
|
return SUCCESS(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取ProductsInvolved详情(Api)
|
/// 订阅涉及产品
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm">查询参数</param>
|
/// <param name="parm">查询参数</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("getProductsInvolvedDetails")]
|
[HttpPost("subscribe")]
|
||||||
public async Task<IActionResult> GetProductsInvolvedDetails([FromQuery] ProductsInvolvedDtoApi parm)
|
public async Task<IActionResult> Subscribe([FromBody] ProductsInvolvedDtoApi parm)
|
||||||
{
|
{
|
||||||
//if (parm == null) throw new CustomException("参数错误!");
|
// 微信通知模板Id
|
||||||
|
var templateId = 1;
|
||||||
|
var user = JwtUtil.GetLoginUser(App.HttpContext).UserId;
|
||||||
|
var res = await _SubscribeTaskService.AddSubscribeTask(user, parm.ProductsInvolvedGuid, templateId);
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
var res = await _ProductsInvolvedServiceApi.GetProductsInvolvedDetails(parm);
|
/// <summary>
|
||||||
|
/// 取消订阅涉及产品
|
||||||
if (res != "[]")
|
/// </summary>
|
||||||
{
|
/// <param name="parm">查询参数</param>
|
||||||
res = res.Remove(0, 1);
|
/// <returns></returns>
|
||||||
res = res.Substring(0, res.Length - 1);
|
[HttpPost("cancelSubscribe")]
|
||||||
var data = res.FromJSON<ProductsInvolvedApiDetailsVo>();
|
public async Task<IActionResult> CancelSubscribe([FromBody] ProductsInvolvedDtoApi parm)
|
||||||
return SUCCESS(data);
|
{
|
||||||
}
|
// 微信通知模板Id
|
||||||
else
|
var templateId = 1;
|
||||||
{
|
var userId = JwtUtil.GetLoginUser(App.HttpContext).UserId;
|
||||||
return SUCCESS(res);
|
var res = await _SubscribeTaskService.DeleteAsync(s => s.SubscribeTaskBusinessGuid == parm.ProductsInvolvedGuid && s.CustomerGuid == userId);
|
||||||
}
|
return SUCCESS("取消成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user