using ce.autofac.extension; using learun.iapplication; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace learun.application { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2019.09.25 /// 描 述:用户关联对象 /// public class UserRelationBLL : UserRelationIBLL, BLL { private readonly UserRelationService userRelationService = new UserRelationService(); #region 获取数据 /// /// 获取对象主键列表信息 /// /// 用户主键 /// 分类:1-角色2-岗位 /// public Task> GetObjectIdList(string userId, int category) { return userRelationService.GetObjectIdList(userId, category); } /// /// 获取对象主键列表信息 /// /// 用户主键 /// 分类:1-角色2-岗位 /// public async Task GetObjectIds(string userId, int category) { string res = ""; var list = await GetObjectIdList(userId, category); foreach (UserRelationEntity item in list) { if (res != "") { res += ","; } res += item.F_ObjectId; } return res; } /// /// 获取用户主键列表信息 /// /// 关联或角色主键集合 /// public Task> GetUserIdList(string objectId) { return userRelationService.GetUserIdList(objectId); } /// /// 获取用户主键列表信息 /// /// 关联或角色主键集合 /// public Task> GetUserIdList(IEnumerable objectIdList) { return userRelationService.GetUserIdList(objectIdList); } #endregion 获取数据 #region 提交数据 /// /// 保存用户对应对象数据 /// /// 对应对象主键 /// 分类:1-角色2-岗位 /// 对用户主键列表 public async Task SaveEntityList(string objectId, int category, string userIds) { List list = new List(); if (!string.IsNullOrEmpty(userIds)) { string[] userIdList = userIds.Split(','); foreach (string userId in userIdList) { UserRelationEntity userRelationEntity = new UserRelationEntity(); userRelationEntity.F_UserRelationId = Guid.NewGuid().ToString(); userRelationEntity.F_CreateDate = DateTime.Now; userRelationEntity.F_UserId = userId; userRelationEntity.F_Category = category; userRelationEntity.F_ObjectId = objectId; list.Add(userRelationEntity); } } await userRelationService.SaveEntityList(objectId, list); } #endregion 提交数据 } }