10/20更新

This commit is contained in:
陈淳
2022-10-20 16:33:29 +08:00
parent 0755a4026a
commit ff7eecee55
11 changed files with 127 additions and 7 deletions

View File

@@ -150,6 +150,18 @@
<param name="ids"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.SkuController.PageList(Yi.Framework.Model.Models.SkuEntity,Yi.Framework.Common.Models.PageParModel)">
<summary>
动态条件分页查询
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.SpuController.PageList(Yi.Framework.Model.Models.SpuEntity,Yi.Framework.Common.Models.PageParModel)">
<summary>
动态条件分页查询
</summary>
<returns></returns>
</member>
<member name="T:Yi.Framework.ApiMicroservice.Controllers.AccountController">
<summary>
账户管理

View File

@@ -51,7 +51,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{
//如果标题为空默认为内容的前20个字符
entity.Title = string.IsNullOrEmpty(entity.Title) ?
(entity.Content.Length > 20 ? entity.Content.Substring(0, 20) : entity.Content) :
(entity.Content?.Length > 20 ? entity.Content.Substring(0, 20) : entity.Content) :
entity.Title;
entity.UserId = HttpContext.GetUserIdInfo();
return base.Add(entity);

View File

@@ -17,12 +17,22 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{
[ApiController]
[Route("api/[controller]/[action]")]
public class SkuController : BaseCrudController<SkuEntity>
public class SkuController : BaseSimpleCrudController<SkuEntity>
{
private ISkuService _iSkuService;
public SkuController(ILogger<SkuEntity> logger, ISkuService iSkuService) : base(logger, iSkuService)
{
_iSkuService = iSkuService;
}
/// <summary>
/// 动态条件分页查询
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<Result> PageList([FromQuery] SkuEntity eneity, [FromQuery] PageParModel page)
{
return Result.Success().SetData(await _iSkuService.SelctPageList(eneity, page));
}
}
}

View File

@@ -17,12 +17,22 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{
[ApiController]
[Route("api/[controller]/[action]")]
public class SpuController : BaseCrudController<SpuEntity>
public class SpuController : BaseSimpleCrudController<SpuEntity>
{
private ISpuService _iSpuService;
public SpuController(ILogger<SpuEntity> logger, ISpuService iSpuService) : base(logger, iSpuService)
{
_iSpuService = iSpuService;
}
/// <summary>
/// 动态条件分页查询
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<Result> PageList([FromQuery] SpuEntity eneity, [FromQuery] PageParModel page)
{
return Result.Success().SetData(await _iSpuService.SelctPageList(eneity, page));
}
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
public partial interface ISkuService:IBaseService<SkuEntity>
{
/// <summary>
/// 动态条件分页查询
/// </summary>
/// <param name="eneity"></param>
/// <param name="page"></param>
/// <returns></returns>
Task<PageModel<List<SkuEntity>>> SelctPageList(SkuEntity entity, PageParModel page);
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
public partial interface ISpuService:IBaseService<SpuEntity>
{
/// <summary>
/// 动态条件分页查询
/// </summary>
/// <param name="eneity"></param>
/// <param name="page"></param>
/// <returns></returns>
Task<PageModel<List<SpuEntity>>> SelctPageList(SpuEntity entity, PageParModel page);
}
}

View File

@@ -27,17 +27,17 @@ namespace Yi.Framework.Model.Models
/// 商品名称
///</summary>
[SugarColumn(ColumnName="SpuName" )]
public string SpuName { get; set; }
public string? SpuName { get; set; }
/// <summary>
/// 商品详情
///</summary>
[SugarColumn(ColumnName="Details" )]
public string Details { get; set; }
public string? Details { get; set; }
/// <summary>
/// 商品价格
///</summary>
[SugarColumn(ColumnName="Price" )]
public string Price { get; set; }
public string? Price { get; set; }
/// <summary>
/// 创建者

View File

@@ -20,7 +20,7 @@ namespace Yi.Framework.Model.Models
public List<SpecsSpuInfoModel>? SpecsSpuInfo { get; set; }
[Navigate(NavigateType.OneToMany, nameof(SkuEntity.SpuId))]
public List<SpuEntity>? Spus { get; set; }
public List<SkuEntity>? Skus { get; set; }
}
public class SpecsSpuAllInfoModel

View File

@@ -0,0 +1,25 @@
using SqlSugar;
using System.Collections.Generic;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Service
{
public partial class SkuService : BaseService<SkuEntity>, ISkuService
{
public async Task<PageModel<List<SkuEntity>>> SelctPageList(SkuEntity enetity, PageParModel page)
{
RefAsync<int> total = 0;
var data = await _repository._DbQueryable
.WhereIF(page.StartTime is not null && page.EndTime is not null, u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime)
.WhereIF(enetity.IsDeleted is not null, u => u.IsDeleted == enetity.IsDeleted)
.OrderBy(u => u.CreateTime, OrderByType.Desc)
.ToPageListAsync(page.PageNum, page.PageSize, total);
return new PageModel<List<SkuEntity>>(data, total);
}
}
}

View File

@@ -0,0 +1,25 @@
using SqlSugar;
using System.Collections.Generic;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Service
{
public partial class SpuService : BaseService<SpuEntity>, ISpuService
{
public async Task<PageModel<List<SpuEntity>>> SelctPageList(SpuEntity enetity, PageParModel page)
{
RefAsync<int> total = 0;
var data = await _repository._DbQueryable
.WhereIF(page.StartTime is not null && page.EndTime is not null, u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime)
.WhereIF(enetity.IsDeleted is not null, u => u.IsDeleted == enetity.IsDeleted)
.OrderBy(u => u.CreateTime, OrderByType.Desc)
.ToPageListAsync(page.PageNum, page.PageSize, total);
return new PageModel<List<SpuEntity>>(data, total);
}
}
}