字典信息表查询删除接口
This commit is contained in:
@@ -102,6 +102,63 @@
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.PageList(Yi.Framework.Model.Models.DictionaryEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.Add(Yi.Framework.Model.Models.DictionaryEntity)">
|
||||
<summary>
|
||||
添加字典表
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.GetById(System.Int64)">
|
||||
<summary>
|
||||
根据字典id获取字典表
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.GetList">
|
||||
<summary>
|
||||
获取全部字典表
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.PageList(Yi.Framework.Model.Models.DictionaryInfoEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dicInfo"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.Add(Yi.Framework.Model.Models.DictionaryInfoEntity)">
|
||||
<summary>
|
||||
添加字典信息表
|
||||
</summary>
|
||||
<param name="dicInfo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.GetListByType(System.String)">
|
||||
<summary>
|
||||
根据字典类别获取字典信息
|
||||
</summary>
|
||||
<param name="type"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.DelList(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
id范围删除
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.FileController">
|
||||
<summary>
|
||||
文件
|
||||
|
||||
@@ -21,29 +21,57 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public class DictionaryController
|
||||
{
|
||||
private IDictionaryService _iDictionaryService;
|
||||
public DictionaryController(ILogger<DictionaryEntity> logger, IDictionaryService iDictionaryService)
|
||||
private IDictionaryInfoService _iDictionaryInfoService;
|
||||
public DictionaryController(ILogger<DictionaryEntity> logger, IDictionaryService iDictionaryService, IDictionaryInfoService iDictionaryInfoService)
|
||||
{
|
||||
_iDictionaryService = iDictionaryService;
|
||||
_iDictionaryInfoService = iDictionaryInfoService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] DictionaryEntity dic, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService.SelctPageList(dic, page));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加字典表
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(DictionaryEntity dic)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService._repository.InsertReturnSnowflakeIdAsync(dic));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典id获取字典表
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{type}")]
|
||||
public async Task<Result> GetListByType([FromRoute] string type)
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService._repository.GetListAsync(u=>u.DictType==type&&u.IsDeleted==false));
|
||||
return Result.Success().SetData(await _iDictionaryService._repository.GetByIdAsync(id));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部字典表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetList()
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService._repository.GetListAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class DictionaryInfoController
|
||||
{
|
||||
private IDictionaryService _iDictionaryService;
|
||||
private IDictionaryInfoService _iDictionaryInfoService;
|
||||
public DictionaryInfoController(ILogger<DictionaryEntity> logger, IDictionaryService iDictionaryService, IDictionaryInfoService iDictionaryInfoService)
|
||||
{
|
||||
_iDictionaryService = iDictionaryService;
|
||||
_iDictionaryInfoService = iDictionaryInfoService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dicInfo"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] DictionaryInfoEntity dicInfo, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService.SelctPageList(dicInfo, page));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加字典信息表
|
||||
/// </summary>
|
||||
/// <param name="dicInfo"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(DictionaryInfoEntity dicInfo)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService._repository.InsertReturnSnowflakeIdAsync(dicInfo));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典类别获取字典信息
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{type}")]
|
||||
public async Task<Result> GetListByType([FromRoute] string type)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService._repository.GetListAsync(u=>u.DictType==type&&u.IsDeleted==false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// id范围删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
|
||||
public async Task<Result> DelList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iDictionaryInfoService._repository.DeleteByIdsAsync(ids.ToDynamicArray()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
16
Yi.Framework.Net6/Yi.Framework.Common/Helper/IdHelper.cs
Normal file
16
Yi.Framework.Net6/Yi.Framework.Common/Helper/IdHelper.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public static class IdHelper
|
||||
{
|
||||
public static dynamic[] ToDynamicArray(this IEnumerable<long> ids)
|
||||
{
|
||||
return ids.Select(id => (dynamic)id).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
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 IDictionaryInfoService:IBaseService<DictionaryInfoEntity>
|
||||
{
|
||||
Task<PageModel<List<DictionaryInfoEntity>>> SelctPageList(DictionaryInfoEntity dicInfo, PageParModel page);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
using Yi.Framework.Model.Models;
|
||||
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 IDictionaryInfoService:IBaseService<DictionaryInfoEntity>
|
||||
{
|
||||
public partial interface IDictionaryInfoService : IBaseService<DictionaryInfoEntity>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace Yi.Framework.Model.Models
|
||||
/// <summary>
|
||||
/// 字典名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="DicName" )]
|
||||
public string DicName { get; set; }
|
||||
[SugarColumn(ColumnName= "DictName")]
|
||||
public string DictName { get; set; }
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
///</summary>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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 DictionaryInfoService : BaseService<DictionaryInfoEntity>, IDictionaryInfoService
|
||||
{
|
||||
public async Task<PageModel<List<DictionaryInfoEntity>>> SelctPageList(DictionaryInfoEntity dicInfo, PageParModel page)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var data = await _repository._DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(dicInfo.DictLabel), u => u.DictLabel.Contains(dicInfo.DictLabel))
|
||||
.WhereIF(!string.IsNullOrEmpty(dicInfo.DictType), u => u.DictType.Contains(dicInfo.DictType))
|
||||
.Where(u => u.IsDeleted == false)
|
||||
.OrderBy(u => u.OrderNum, OrderByType.Desc)
|
||||
.ToPageListAsync(page.PageNum, page.PageSize, total);
|
||||
|
||||
return new PageModel<List<DictionaryInfoEntity>>(data, total);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var data = await _repository._DbQueryable
|
||||
.WhereIF(!string.IsNullOrEmpty(dic.DicName), u => u.DicName.Contains(dic.DicName))
|
||||
.WhereIF(!string.IsNullOrEmpty(dic.DictName), u => u.DictName.Contains(dic.DictName))
|
||||
.WhereIF(!string.IsNullOrEmpty(dic.DictType), u => u.DictType.Contains(dic.DictType))
|
||||
.WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime)
|
||||
.Where(u => u.IsDeleted == false)
|
||||
|
||||
Reference in New Issue
Block a user