更新仓储层上下文对象与接口命名规范
This commit is contained in:
Binary file not shown.
@@ -6,11 +6,11 @@
|
||||
<members>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1">
|
||||
<summary>
|
||||
6666
|
||||
Json To Sql 类比模式,通用模型
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Get(System.Int64)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetById(System.Int64)">
|
||||
<summary>
|
||||
主键查询
|
||||
</summary>
|
||||
@@ -23,7 +23,7 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Page(Yi.Framework.Model.Query.QueryPageCondition)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.PageList(Yi.Framework.Model.Query.QueryPageCondition)">
|
||||
<summary>
|
||||
条件分页查询
|
||||
</summary>
|
||||
@@ -51,6 +51,12 @@
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.DbTest">
|
||||
<summary>
|
||||
仓储上下文对象测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.LocalTest">
|
||||
<summary>
|
||||
国际化测试
|
||||
|
||||
@@ -11,7 +11,7 @@ using Yi.Framework.WebCore.AttributeExtend;
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 6666
|
||||
/// Json To Sql 类比模式,通用模型
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[ApiController]
|
||||
@@ -35,7 +35,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:one")]
|
||||
[HttpGet]
|
||||
public async Task<Result> Get(long id)
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:page")]
|
||||
[HttpPost]
|
||||
public async Task<Result> Page(QueryPageCondition queryCondition)
|
||||
public async Task<Result> PageList(QueryPageCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.CommonPageAsync(queryCondition));
|
||||
}
|
||||
|
||||
@@ -22,10 +22,24 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public class TestController : ControllerBase
|
||||
{
|
||||
private IStringLocalizer<LocalLanguage> _local;
|
||||
private IUserService _iUserService;
|
||||
public TestController(ILogger<UserEntity> logger, IUserService iUserService, IStringLocalizer<LocalLanguage> local)
|
||||
{
|
||||
_local = local;
|
||||
_iUserService = iUserService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仓储上下文对象测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
/// 特点:仓储代理上下文对象,用起来就是爽
|
||||
public async Task<Result> DbTest()
|
||||
{
|
||||
return Result.Success().SetData(await _iUserService.DbTest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 国际化测试
|
||||
/// </summary>
|
||||
|
||||
@@ -19,8 +19,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class UserController : BaseCrudController<UserEntity>
|
||||
{
|
||||
private IUserService _iUserService;
|
||||
public UserController(ILogger<UserEntity> logger, IUserService iUserService) : base(logger, iUserService)
|
||||
{
|
||||
_iUserService = iUserService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
@@ -7,7 +8,27 @@ namespace Yi.Framework.Interface
|
||||
{
|
||||
public partial interface IUserService
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试仓储的上下文对象
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<List<UserEntity>> DbTest();
|
||||
|
||||
/// <summary>
|
||||
/// 登录方法
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="userAction"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> Login(string userName, string password, Action<UserEntity> userAction = null);
|
||||
|
||||
/// <summary>
|
||||
/// 注册方法
|
||||
/// </summary>
|
||||
/// <param name="userEntity"></param>
|
||||
/// <param name="userAction"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> Register(UserEntity userEntity, Action<UserEntity> userAction = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Yi.Framework.Repository
|
||||
{
|
||||
public interface IRepository<T> : ISimpleClient<T> where T : BaseModelEntity,new()
|
||||
{
|
||||
public ISqlSugarClient _Db { get; set; }
|
||||
public Task<T> InsertReturnEntityAsync(T entity);
|
||||
public Task<List<S>> StoreAsync<S>(string storeName, object para);
|
||||
public Task<PageModel<List<T>>> CommonPageAsync(QueryPageCondition pars);
|
||||
|
||||
@@ -14,13 +14,14 @@ namespace Yi.Framework.Repository
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class Repository<T> : DataContext<T>, IRepository<T> where T : BaseModelEntity,new()
|
||||
{
|
||||
|
||||
public ISqlSugarClient _Db { get; set; }
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public Repository(ISqlSugarClient context) : base(context)//注意这里要有默认值等于null
|
||||
{
|
||||
_Db = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Interface;
|
||||
@@ -10,6 +11,10 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
public partial class UserService
|
||||
{
|
||||
public async Task<List<UserEntity>> DbTest()
|
||||
{
|
||||
return await _repository._Db.Queryable<UserEntity>().ToListAsync();
|
||||
}
|
||||
public async Task<bool> Exist(Guid id, Action<UserEntity> userAction = null)
|
||||
{
|
||||
var user = await _repository.GetByIdAsync(id);
|
||||
|
||||
Reference in New Issue
Block a user