using BBWYB.Common.Models; using BBWYB.Server.Model.Db; namespace BBWYB.Server.Business { public class UserBusiness : IDenpendency { private FreeSqlMultiDBManager fsqlManager; public UserBusiness(FreeSqlMultiDBManager fsqlManager) { this.fsqlManager = fsqlManager; } /// /// 获取指定用户的议价组信息 /// /// /// 当用户不属于议价组团队是否抛出错误 /// /// public (User user, Userdepartment department, bool isBargainTeam) GetisBargainTeamByUserId(string userId, bool throwExWhenUserNotBelongYJ = false) { var user = fsqlManager.MDSfsql.Select(userId).ToOne(); if (user == null) throw new BusinessException("用户不存在"); if (string.IsNullOrEmpty(user.DepartmentId)) throw new BusinessException("该用户没有归属部门"); var department = fsqlManager.MDSfsql.Select(user.DepartmentId).ToOne(); if (department == null) throw new BusinessException("部门不存在"); if (throwExWhenUserNotBelongYJ && department.ParentDepartmentId != "1760971468360912896") throw new BusinessException("该用户所在部门不属于议价组"); return (user, department, department.ParentDepartmentId == "1760971468360912896"); } } }