namespace Admin.NET.Core.Service; /// /// 系统用户扩展机构服务 /// public class SysUserExtOrgService : ITransient { private readonly SqlSugarRepository _sysUserExtOrgRep; public SysUserExtOrgService(SqlSugarRepository sysUserExtOrgRep) { _sysUserExtOrgRep = sysUserExtOrgRep; } /// /// 获取用户扩展机构集合 /// /// /// public async Task> GetUserExtOrgList(long userId) { return await _sysUserExtOrgRep.GetListAsync(u => u.UserId == userId); } /// /// 更新用户扩展机构 /// /// /// /// [UnitOfWork] public async Task UpdateUserExtOrg(long userId, List extOrgList) { await _sysUserExtOrgRep.DeleteAsync(u => u.UserId == userId); if (extOrgList == null || extOrgList.Count < 1) return; extOrgList.ForEach(u => { u.UserId = userId; }); await _sysUserExtOrgRep.InsertRangeAsync(extOrgList); } /// /// 根据机构Id集合删除扩展机构 /// /// /// public async Task DeleteUserExtOrgByOrgIdList(List orgIdList) { await _sysUserExtOrgRep.DeleteAsync(u => orgIdList.Contains(u.OrgId)); } /// /// 根据用户Id删除扩展机构 /// /// /// public async Task DeleteUserExtOrgByUserId(long userId) { await _sysUserExtOrgRep.DeleteAsync(u => u.UserId == userId); } /// /// 根据机构Id判断是否有用户 /// /// /// public async Task HasUserOrg(long orgId) { return await _sysUserExtOrgRep.IsAnyAsync(u => u.OrgId == orgId); } /// /// 根据职位Id判断是否有用户 /// /// /// public async Task HasUserPos(long posId) { return await _sysUserExtOrgRep.IsAnyAsync(u => u.PosId == posId); } }