功能完善

This commit is contained in:
路 范
2022-03-31 09:07:38 +08:00
parent 8a57806a29
commit dd71325ea8
17 changed files with 1644 additions and 11 deletions

View File

@@ -82,7 +82,7 @@ namespace Ewide.Core.Service
/// <param name="input"></param>
/// <remarks>默认用户名/密码admin/admin</remarks>
/// <returns></returns>
[HttpPost("/login")]
[HttpPost("/gb/yjb/login")]
[AllowAnonymous]
[Op(LogOpType.GRANT)]
public async Task<LoginOutput> LoginAsync([Required] LoginInput input)

View File

@@ -0,0 +1,58 @@
using Furion;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.LinqBuilder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Core.Util
{
public static class DEntityExtensions
{
public async static Task<TEntity> InsertOrUpdate<TEntity>(this TEntity entity) where TEntity : DEntityBase, IPrivateEntity, new()
{
if (entity.Id.IsNullOrEmpty())
await entity.SetInsertDefaultValue().InsertAsync();
else
await entity.SetUpdateDefaultValue().UpdateExcludeAsync(new[] { nameof(entity.CreatedTime), nameof(entity.CreatedUserId), nameof(entity.CreatedUserName) });
return entity;
}
public async static Task<TEntity> InsertOrUpdate<TEntity>(this TEntity entity, bool isInsert) where TEntity : DEntityBase, IPrivateEntity, new()
{
if (isInsert)
await entity.SetInsertDefaultValue().InsertAsync();
else
await entity.SetUpdateDefaultValue().UpdateAsync();
return entity;
}
public static TEntity SetInsertDefaultValue<TEntity>(this TEntity entity) where TEntity : DEntityBase
{
if (string.IsNullOrEmpty(entity.Id))
entity.Id = Guid.NewGuid().ToString();
if (!entity.CreatedTime.HasValue)
entity.CreatedTime = DateTime.Now;
//if (string.IsNullOrEmpty(entity.CreatedUserId))
entity.CreatedUserId = GetUserId();
if (string.IsNullOrEmpty(entity.CreatedUserName))
entity.CreatedUserName = App.GetService<UserManager>().Name;
return entity;
}
public static TEntity SetUpdateDefaultValue<TEntity>(this TEntity entity) where TEntity : DEntityBase
{
entity.UpdatedTime = DateTime.Now;
entity.UpdatedUserId = GetUserId();
entity.UpdatedUserName = App.GetService<UserManager>().Name;
return entity;
}
private static string GetUserId()
{
var userid = App.GetService<UserManager>().UserId;
//if (string.IsNullOrWhiteSpace(userid))
// userid = App.GetService<UserManager>().WorkUSERID;
return userid;
}
}
}