完善大部分问题
This commit is contained in:
@@ -10,13 +10,6 @@
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.#ctor(Microsoft.Extensions.Logging.ILogger{`0},Yi.Framework.Repository.IRepository{`0})">
|
||||
<summary>
|
||||
jb
|
||||
</summary>
|
||||
<param name="logger"></param>
|
||||
<param name="iRepository"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Get(System.Object)">
|
||||
<summary>
|
||||
主键查询
|
||||
@@ -24,13 +17,13 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetList">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetList(Yi.Framework.Model.Query.QueryCondition)">
|
||||
<summary>
|
||||
列表查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Page(Yi.Framework.Model.Query.QueryCondition)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Page(Yi.Framework.Model.Query.QueryPageCondition)">
|
||||
<summary>
|
||||
条件分页查询
|
||||
</summary>
|
||||
@@ -51,7 +44,7 @@
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.DeleteList(System.Object[])">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.DeleteList(System.Collections.Generic.List{System.Guid})">
|
||||
<summary>
|
||||
列表删除
|
||||
</summary>
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
@@ -21,9 +22,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public class AccountController :ControllerBase
|
||||
{
|
||||
private IUserService _iUserService;
|
||||
public AccountController(ILogger<UserEntity> logger, IUserService iUserService)
|
||||
private JwtInvoker _jwtInvoker;
|
||||
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker)
|
||||
{
|
||||
_iUserService = iUserService;
|
||||
_jwtInvoker = jwtInvoker;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
@@ -32,8 +35,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
UserEntity user=new();
|
||||
if (await _iUserService.Login(loginDto.UserName, loginDto.Password,o=> user=o))
|
||||
{
|
||||
return Result.Success("登录成功!").SetData(user);
|
||||
{
|
||||
return Result.Success("登录成功!").SetData(new { user, token = _jwtInvoker.GetAccessToken(user)});
|
||||
}
|
||||
return Result.SuccessError("登录失败!用户名或者密码错误!");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.Query;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
@@ -12,19 +14,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class BaseCrudController<T> : ControllerBase where T : class,new()
|
||||
public class BaseCrudController<T> : ControllerBase where T : BaseModelEntity,new()
|
||||
{
|
||||
private readonly ILogger<T> _logger;
|
||||
public IRepository<T> _iRepository;
|
||||
/// <summary>
|
||||
/// jb
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="iRepository"></param>
|
||||
public BaseCrudController(ILogger<T> logger, IRepository<T> iRepository)
|
||||
public readonly ILogger<T> _logger;
|
||||
public IBaseService<T> _baseService;
|
||||
public IRepository<T> _repository;
|
||||
|
||||
public BaseCrudController(ILogger<T> logger, IBaseService<T> iBaseService)
|
||||
{
|
||||
_logger = logger;
|
||||
_iRepository = iRepository;
|
||||
_baseService = iBaseService;
|
||||
_repository = iBaseService._repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +36,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpGet]
|
||||
public async Task<Result> Get(object id)
|
||||
{
|
||||
return Result.Success().SetData(await _iRepository.GetByIdAsync(id));
|
||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,10 +44,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:list")]
|
||||
[HttpGet]
|
||||
public async Task<Result> GetList()
|
||||
[HttpPost]
|
||||
public async Task<Result> GetList(QueryCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _iRepository.GetListAsync());
|
||||
return Result.Success().SetData(await _repository.GetListAsync(queryCondition));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,9 +57,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:page")]
|
||||
[HttpPost]
|
||||
public async Task<Result> Page(QueryCondition queryCondition)
|
||||
public async Task<Result> Page(QueryPageCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _iRepository.CommonPage(queryCondition));
|
||||
return Result.Success().SetData(await _repository.CommonPage(queryCondition));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +71,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(T entity)
|
||||
{
|
||||
return Result.Success().SetData(await _iRepository.InsertReturnEntityAsync(entity));
|
||||
return Result.Success().SetData(await _repository.InsertReturnEntityAsync(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,7 +83,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPut]
|
||||
public async Task<Result> Update(T entity)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRepository.UpdateAsync(entity));
|
||||
return Result.Success().SetStatus(await _repository.UpdateAsync(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -93,9 +93,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:delete:list")]
|
||||
[HttpDelete]
|
||||
public async Task<Result> DeleteList(object[] ids)
|
||||
public async Task<Result> DeleteList(List<Guid> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRepository.DeleteByIdsAsync(ids));
|
||||
return Result.Success().SetStatus(await _repository.DeleteByLogic(ids));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ ServiceLocator.Instance = app.Services;
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseErrorHandlingService();
|
||||
//app.UseErrorHandlingService();
|
||||
#region
|
||||
//<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
|
||||
@@ -38,10 +38,14 @@
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]"
|
||||
]
|
||||
},
|
||||
"JWTTokenOptions": {
|
||||
"Audience": "http://localhost:7000",
|
||||
"Issuer": "http://localhost:7000",
|
||||
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
|
||||
"JwtAuthorize": {
|
||||
"Issuer": "cc",
|
||||
"Audience": "cc",
|
||||
"PolicyName": "permission",
|
||||
"DefaultScheme": "Bearer",
|
||||
"IsHttps": false,
|
||||
"Expiration": 30,
|
||||
"ReExpiration": 3000
|
||||
},
|
||||
"RedisConnOptions": {
|
||||
"Host": "[xxxx]",
|
||||
|
||||
Reference in New Issue
Block a user