代码优化

master
xiaochanghai 1 year ago
parent b77f16fa4f
commit b463e16052
  1. 2
      Tiobon.Core.Api/Controllers/BaseController.cs
  2. 2
      Tiobon.Core.Api/Controllers/Ghra_GradeController.cs
  3. 2
      Tiobon.Core.Api/Tiobon.Core.xml
  4. 2
      Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
  5. 4
      Tiobon.Core.Services/BASE/BaseServices.cs

@ -2,7 +2,7 @@
namespace Tiobon.Core.Controllers namespace Tiobon.Core.Controllers
{ {
public class BaseController<IServiceBase> : Controller public class BaseController<IServiceBase, TEntity, TEntityDto, TInsertDto, TEditDto> : Controller
{ {
#region 初始化 #region 初始化
protected IServiceBase _service; protected IServiceBase _service;

@ -6,7 +6,7 @@
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController, GlobalActionFilter] [ApiController, GlobalActionFilter]
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghra)] [Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghra)]
public class Ghra_GradeController : BaseController<IGhra_GradeServices> public class Ghra_GradeController : BaseController<IGhra_GradeServices, Ghra_Grade, Ghra_GradeDto, InsertGhra_GradeInput, EditGhra_GradeInput>
{ {
public Ghra_GradeController(IGhra_GradeServices service) : base(service) public Ghra_GradeController(IGhra_GradeServices service) : base(service)
{ {

@ -4,7 +4,7 @@
<name>Tiobon.Core.Api</name> <name>Tiobon.Core.Api</name>
</assembly> </assembly>
<members> <members>
<member name="M:Tiobon.Core.Controllers.BaseController`1.#ctor(`0)"> <member name="M:Tiobon.Core.Controllers.BaseController`5.#ctor(`0)">
<summary> <summary>
</summary> </summary>

@ -96,7 +96,7 @@ public static class SqlSugarAop
if (App.User?.ID > 0 && dyCreateBy != null && dyCreateBy.GetValue(entityInfo.EntityValue) == null) if (App.User?.ID > 0 && dyCreateBy != null && dyCreateBy.GetValue(entityInfo.EntityValue) == null)
dyCreateBy.SetValue(entityInfo.EntityValue, (int)App.User.ID); dyCreateBy.SetValue(entityInfo.EntityValue, (int)App.User.ID);
if (dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) != null && (DateTime)dyCreateTime.GetValue(entityInfo.EntityValue) == DateTime.MinValue) if ((dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) is null) || (dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) != null && (DateTime)dyCreateTime.GetValue(entityInfo.EntityValue) == DateTime.MinValue))
dyCreateTime.SetValue(entityInfo.EntityValue, DateTime.Now); dyCreateTime.SetValue(entityInfo.EntityValue, DateTime.Now);
break; break;

@ -418,12 +418,12 @@ namespace Tiobon.Core.Services.BASE
var api = request.Path.ObjToString().TrimEnd('/').ToLower(); var api = request.Path.ObjToString().TrimEnd('/').ToLower();
var ip = GetUserIp(UserContext.Context); var ip = GetUserIp(UserContext.Context);
BasePoco ent = entity as BasePoco; var entity1 = Mapper.Map(entity).ToANew<TEntity>();
BasePoco ent = entity1 as BasePoco;
ent.CreateIP = ip; ent.CreateIP = ip;
ent.CreateProg = api; ent.CreateProg = api;
var entity1 = Mapper.Map(entity).ToANew<TEntity>();
return await BaseDal.Add(entity1); return await BaseDal.Add(entity1);
} }

Loading…
Cancel
Save