feat 初始化涉及产品接口
This commit is contained in:
parent
1151844c07
commit
72cbffd477
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ARW.Model.Models.Business.ProductsInvolveds;
|
||||||
|
|
||||||
|
namespace ARW.Model.Dto.Api.ProductsInvolveds
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 涉及产品查询对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-11-23
|
||||||
|
/// </summary>
|
||||||
|
public class ProductsInvolvedQueryDtoApi : PagerInfo
|
||||||
|
{
|
||||||
|
public string ProductsInvolvedName { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 涉及产品详情输入对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-11-23
|
||||||
|
/// </summary>
|
||||||
|
public class ProductsInvolvedDtoApi
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "ProductsInvolvedGuid不能为空")]
|
||||||
|
public long ProductsInvolvedGuid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
66
ARW.Model/Vo/Api/ProductsInvolveds/ProductsInvolvedApiVo.cs
Normal file
66
ARW.Model/Vo/Api/ProductsInvolveds/ProductsInvolvedApiVo.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using OfficeOpenXml.Attributes;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ARW.Model.Vo.Api.ProductsInvolveds
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 涉及产品展示对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-11-23
|
||||||
|
/// </summary>
|
||||||
|
public class ProductsInvolvedVoApi
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// </summary>
|
||||||
|
[EpplusIgnore]
|
||||||
|
public int ProductsInvolvedId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
[EpplusIgnore]
|
||||||
|
public long ProductsInvolvedGuid { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :名称
|
||||||
|
/// </summary>
|
||||||
|
[EpplusTableColumn(Header = "名称")]
|
||||||
|
public string ProductsInvolvedName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :排序
|
||||||
|
/// </summary>
|
||||||
|
[EpplusTableColumn(Header = "排序")]
|
||||||
|
public int ProductsInvolvedSort { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 涉及产品详情展示对象Api
|
||||||
|
/// </summary>
|
||||||
|
public class ProductsInvolvedApiDetailsVo
|
||||||
|
{
|
||||||
|
[EpplusIgnore]
|
||||||
|
public int ProductsInvolvedId { get; set; }
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
[EpplusIgnore]
|
||||||
|
public long ProductsInvolvedGuid { get; set; }
|
||||||
|
[EpplusTableColumn(Header = "名称")]
|
||||||
|
public string ProductsInvolvedName { get; set; }
|
||||||
|
[EpplusTableColumn(Header = "排序")]
|
||||||
|
public int ProductsInvolvedSort { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
using Infrastructure.Attribute;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ARW.Model;
|
||||||
|
using ARW.Repository;
|
||||||
|
using ARW.Repository.Business.ProductsInvolveds;
|
||||||
|
using ARW.Service.Api.IBusinessService.ProductsInvolveds;
|
||||||
|
using ARW.Model.Dto.Api.ProductsInvolveds;
|
||||||
|
using ARW.Model.Models.Business.ProductsInvolveds;
|
||||||
|
using ARW.Model.Vo.Api.ProductsInvolveds;
|
||||||
|
|
||||||
|
namespace ARW.Service.Api.BusinessService.ProductsInvolveds
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 涉及产品接口实现类Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-11-23
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceType = typeof(IProductsInvolvedServiceApi), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class ProductsInvolvedServiceImplApi : BaseService<ProductsInvolved>, IProductsInvolvedServiceApi
|
||||||
|
{
|
||||||
|
private readonly ProductsInvolvedRepository _ProductsInvolvedRepository;
|
||||||
|
|
||||||
|
public ProductsInvolvedServiceImplApi(ProductsInvolvedRepository ProductsInvolvedRepository)
|
||||||
|
{
|
||||||
|
this._ProductsInvolvedRepository = ProductsInvolvedRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Api接口代码
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询涉及产品列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<PagedInfo<ProductsInvolvedVoApi>> GetProductsInvolvedListApi(ProductsInvolvedQueryDtoApi parm)
|
||||||
|
{
|
||||||
|
//开始拼装查询条件d
|
||||||
|
var predicate = Expressionable.Create<ProductsInvolved>();
|
||||||
|
|
||||||
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.ProductsInvolvedName), s => s.ProductsInvolvedName.Contains(parm.ProductsInvolvedName));
|
||||||
|
var query = _ProductsInvolvedRepository
|
||||||
|
.Queryable()
|
||||||
|
.Where(predicate.ToExpression())
|
||||||
|
.OrderBy(s => s.ProductsInvolvedSort,OrderByType.Desc)
|
||||||
|
.Select(s => new ProductsInvolvedVoApi
|
||||||
|
{
|
||||||
|
ProductsInvolvedId = s.ProductsInvolvedId,
|
||||||
|
ProductsInvolvedGuid = s.ProductsInvolvedGuid,
|
||||||
|
ProductsInvolvedName = s.ProductsInvolvedName,
|
||||||
|
ProductsInvolvedSort = s.ProductsInvolvedSort,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return await query.ToPageAsync(parm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询涉及产品详情(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> GetProductsInvolvedDetails(ProductsInvolvedDtoApi parm)
|
||||||
|
{
|
||||||
|
|
||||||
|
var query = _ProductsInvolvedRepository
|
||||||
|
.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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ARW.Model;
|
||||||
|
using ARW.Model.Dto.Api.ProductsInvolveds;
|
||||||
|
using ARW.Model.Models.Business.ProductsInvolveds;
|
||||||
|
using ARW.Model.Vo.Api.ProductsInvolveds;
|
||||||
|
|
||||||
|
namespace ARW.Service.Api.IBusinessService.ProductsInvolveds
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 涉及产品接口类Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-11-23
|
||||||
|
/// </summary>
|
||||||
|
public interface IProductsInvolvedServiceApi : IBaseService<ProductsInvolved>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取涉及产品分页列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<PagedInfo<ProductsInvolvedVoApi>> GetProductsInvolvedListApi(ProductsInvolvedQueryDtoApi parm);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取涉及产品详情(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> GetProductsInvolvedDetails(ProductsInvolvedDtoApi parm);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
using Infrastructure;
|
||||||
|
using Infrastructure.Attribute;
|
||||||
|
using Infrastructure.Enums;
|
||||||
|
using Infrastructure.Model;
|
||||||
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using ARW.Admin.WebApi.Extensions;
|
||||||
|
using ARW.Admin.WebApi.Filters;
|
||||||
|
using ARW.Common;
|
||||||
|
using ARW.Admin.WebApi.Controllers;
|
||||||
|
using ARW.Model.Dto.Api.ProductsInvolveds;
|
||||||
|
using ARW.Service.Api.IBusinessService.ProductsInvolveds;
|
||||||
|
using ARW.Model.Models.Business.ProductsInvolveds;
|
||||||
|
using ARW.Model.Vo.Api.ProductsInvolveds;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Geocoding;
|
||||||
|
|
||||||
|
namespace ARW.WebApi.Controllers.Api.ProductsInvolveds
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 涉及产品控制器Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-11-23
|
||||||
|
/// </summary>
|
||||||
|
[Verify]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ProductsInvolvedApiController : BaseController
|
||||||
|
{
|
||||||
|
private readonly IProductsInvolvedServiceApi _ProductsInvolvedServiceApi;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 依赖注入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ProductsInvolvedServiceApi">涉及产品涉及产品Api服务</param>
|
||||||
|
public ProductsInvolvedApiController(IProductsInvolvedServiceApi ProductsInvolvedServiceApi)
|
||||||
|
{
|
||||||
|
_ProductsInvolvedServiceApi = ProductsInvolvedServiceApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取涉及产品列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm">查询参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getProductsInvolvedList")]
|
||||||
|
public async Task<IActionResult> GetProductsInvolvedListApi([FromQuery] ProductsInvolvedQueryDtoApi parm)
|
||||||
|
{
|
||||||
|
var res = await _ProductsInvolvedServiceApi.GetProductsInvolvedListApi(parm);
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取ProductsInvolved详情(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm">查询参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getProductsInvolvedDetails")]
|
||||||
|
public async Task<IActionResult> GetProductsInvolvedDetails([FromQuery] ProductsInvolvedDtoApi parm)
|
||||||
|
{
|
||||||
|
//if (parm == null) throw new CustomException("参数错误!");
|
||||||
|
|
||||||
|
var res = await _ProductsInvolvedServiceApi.GetProductsInvolvedDetails(parm);
|
||||||
|
|
||||||
|
if (res != "[]")
|
||||||
|
{
|
||||||
|
res = res.Remove(0, 1);
|
||||||
|
res = res.Substring(0, res.Length - 1);
|
||||||
|
var data = res.FromJSON<ProductsInvolvedApiDetailsVo>();
|
||||||
|
return SUCCESS(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user