You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.6 KiB
38 lines
1.6 KiB
1 year ago
|
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;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取指定用户的议价组信息
|
||
|
/// </summary>
|
||
|
/// <param name="userId"></param>
|
||
|
/// <param name="throwExWhenUserNotBelongYJ">当用户不属于议价组团队是否抛出错误</param>
|
||
|
/// <returns></returns>
|
||
|
/// <exception cref="BusinessException"></exception>
|
||
|
public (User user, Userdepartment department, bool isBargainTeam) GetisBargainTeamByUserId(string userId, bool throwExWhenUserNotBelongYJ = false)
|
||
|
{
|
||
|
var user = fsqlManager.MDSfsql.Select<User>(userId).ToOne();
|
||
|
if (user == null)
|
||
|
throw new BusinessException("用户不存在");
|
||
|
if (string.IsNullOrEmpty(user.DepartmentId))
|
||
|
throw new BusinessException("该用户没有归属部门");
|
||
|
var department = fsqlManager.MDSfsql.Select<Userdepartment>(user.DepartmentId).ToOne();
|
||
|
if (department == null)
|
||
|
throw new BusinessException("部门不存在");
|
||
|
if (throwExWhenUserNotBelongYJ && department.ParentDepartmentId != "1760971468360912896")
|
||
|
throw new BusinessException("该用户所在部门不属于议价组");
|
||
|
return (user, department, department.ParentDepartmentId == "1760971468360912896");
|
||
|
}
|
||
|
}
|
||
|
}
|