using System; using ce.autofac.extension; using learun.iapplication; using learun.util; using System.Threading.Tasks; namespace learun.application { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2019.09.19 /// 描 述:业务基类 /// public class BLLBase { #region 基础信息 private UserEntity userInfo; private string roleIds; private string postIds; /// /// 获取当前用户信息 /// /// 用户id /// public async Task CurrentUser(string userId = null) { var userBLL = IocManager.Instance.GetService(); if (string.IsNullOrEmpty(userId)) { if (userInfo == null) { userInfo = await userBLL.GetEntity(); } return userInfo; } else { return await userBLL.GetEntity(userId); } } /// /// 获取当前登录者的角色id集合 /// /// public async Task CurrentUserRoleIds() { if (roleIds == null) { var _userInfo = await CurrentUser(); var userRelationIBLL = IocManager.Instance.GetService(); roleIds = await userRelationIBLL.GetObjectIds(_userInfo.F_UserId, 1); } return roleIds; } /// /// 获取当前登录者的角色id集合 /// /// 用户主键 /// public Task CurrentUserRoleIds(string userId) { var userRelationIBLL = IocManager.Instance.GetService(); return userRelationIBLL.GetObjectIds(userId, 1); } /// /// 获取当前登录者的岗位id集合 /// /// public async Task CurrentUserPostIds() { if (postIds == null) { var _userInfo = await CurrentUser(); var userRelationIBLL = IocManager.Instance.GetService(); postIds = await userRelationIBLL.GetObjectIds(_userInfo.F_UserId, 2); } return postIds; } /// /// 获取当前登录者的岗位id集合 /// /// 用户主键 /// public Task CurrentUserPostIds(string userId) { var userRelationIBLL = IocManager.Instance.GetService(); return userRelationIBLL.GetObjectIds(userId, 2); } /// /// 获取登录者用户名称 /// /// public string GetUserName() { return ContextHelper.GetItem("userName") as string; } /// /// 获取登录者用户Id /// /// public string GetUserId() { return ContextHelper.GetItem("userId") as string; } /// /// 获取登录者用户账号 /// /// public string GetUserAccount() { return ContextHelper.GetItem("account") as string; } #endregion 基础信息 #region 数据权限 /// /// 获取数据权限设置sql查询语句 /// /// 数据权限编码 /// public async Task GetDataAuthoritySql(string code) { var dataAuthorizeIBLL = IocManager.Instance.GetService(); return await dataAuthorizeIBLL.GetWhereSql(code); } #endregion 数据权限 #region 单据编码 /// /// 获取编码 /// /// 编码规则编码 /// public Task GetRuleCode(string code) { var codeRuleIBLL = IocManager.Instance.GetService(); return codeRuleIBLL.GetBillCode(code); } /// /// 占用编码 /// /// 编码规则编码 /// public async Task UseRuleSeed(string code) { var codeRuleIBLL = IocManager.Instance.GetService(); await codeRuleIBLL.UseRuleSeed(code); } #endregion 单据编码 } }