54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
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;
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
{
|
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
public class BaseWareHouseService : IOverideVisualDevService, IDynamicApiController, ITransient
|
|
{
|
|
private static Dictionary<string, IWHStorageService> _stroageMap = new Dictionary<string, IWHStorageService>(StringComparer.OrdinalIgnoreCase);
|
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
|
|
|
static BaseWareHouseService()
|
|
{
|
|
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
|
|
foreach (var serviceType in serviceTypes)
|
|
{
|
|
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name;
|
|
if (!callerName.IsNullOrEmpty())
|
|
{
|
|
_stroageMap[callerName!] = (IWHStorageService)Activator.CreateInstance(serviceType)!;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected async Task DoUpdate(WareHouseUpInput input)
|
|
{
|
|
if (_stroageMap.ContainsKey(input.loginType))
|
|
{
|
|
await _stroageMap[input.loginType].Do(input);
|
|
}
|
|
}
|
|
|
|
public virtual Task ModifyAsync(WareHouseUpInput input)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|