通用修改业务函数代码提交
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -15,8 +20,36 @@ namespace Tnb.WarehouseMgr
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
private static Dictionary<string, BaseWareHouseService> _serviceMap = new Dictionary<string, BaseWareHouseService>();
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
|
||||
static BaseWareHouseService()
|
||||
{
|
||||
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && u.IsSubclassOf(typeof(BaseWareHouseService))).ToList();
|
||||
foreach (var serviceType in serviceTypes)
|
||||
{
|
||||
var bizTypeId = serviceType.GetCustomAttribute<ServiceModuleAttribute>()?.BizTypeId;
|
||||
if (!bizTypeId.IsNullOrEmpty())
|
||||
{
|
||||
_serviceMap[bizTypeId!] = (BaseWareHouseService)Activator.CreateInstance(serviceType)!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Task this[WareHouseUpInput input]
|
||||
{
|
||||
set
|
||||
{
|
||||
if (_serviceMap.ContainsKey(input.bizTypeId))
|
||||
{
|
||||
_serviceMap[input.bizTypeId].ModifyAsync(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user