68 lines
2.5 KiB
C#
68 lines
2.5 KiB
C#
/*
|
||
*所有关于HR_DeptShip类的业务代码应在此处编写
|
||
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
||
*如果需要事务请使用repository.DbContextBeginTransaction
|
||
*也可使用DBServerProvider.手动获取数据库相关信息
|
||
*用户信息、权限、角色等使用UserContext.Current操作
|
||
*HR_DeptShipService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
||
*/
|
||
using Microsoft.AspNetCore.Http;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
using Newtonsoft.Json;
|
||
using VOL.DingTalk.Models.Biz;
|
||
using VOL.DingTalk.Services.Biz;
|
||
using VOL.HR.IRepositories;
|
||
using VOL.YSErp.Models.Biz;
|
||
using VOL.YSErp.Services.Biz;
|
||
|
||
namespace VOL.HR.Services
|
||
{
|
||
public partial class HR_DeptShipService
|
||
{
|
||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||
private readonly IHR_DeptShipRepository _repository;//访问数据库
|
||
|
||
private readonly DingTalkService _dingTalkService;
|
||
private readonly YSERPService _ysService;
|
||
[ActivatorUtilitiesConstructor]
|
||
private readonly Core.CacheManager.ICacheService _cacheService;
|
||
|
||
[ActivatorUtilitiesConstructor]
|
||
public HR_DeptShipService(
|
||
IHR_DeptShipRepository dbRepository,
|
||
IHttpContextAccessor httpContextAccessor,
|
||
Core.CacheManager.ICacheService cacheService
|
||
)
|
||
: base(dbRepository)
|
||
{
|
||
_httpContextAccessor = httpContextAccessor;
|
||
_repository = dbRepository;
|
||
//多租户会用到这init代码,其他情况可以不用
|
||
//base.Init(dbRepository);
|
||
_cacheService = cacheService;
|
||
|
||
_dingTalkService = new DingTalkService(new DingTalk.Models.SystemToken(), new DingTalk.Models.DingTalkConfig());
|
||
_ysService = new YSERPService(new YSErp.Models.SystemToken(), new YSErp.Models.YSConfig());
|
||
}
|
||
|
||
|
||
public Task<List<YSERPDepartment>> GetYSERPDepartments()
|
||
{
|
||
|
||
if (_cacheService.Exists("YS_DEPT_CACHE"))
|
||
{
|
||
return Task.FromResult(_cacheService.Get<List<YSERPDepartment>>("YS_DEPT_CACHE"));
|
||
}
|
||
else
|
||
{
|
||
var depts = _ysService.GetAllDepartmentsAsync();
|
||
if (depts != null)
|
||
{
|
||
_cacheService.Add("YS_DEPT_CACHE", JsonConvert.SerializeObject(depts.Result), 600);
|
||
}
|
||
return depts;
|
||
}
|
||
}
|
||
}
|
||
}
|