|
|
|
@ -40,25 +40,30 @@ namespace Shentun.Peis.AbpUserDepartments |
|
|
|
public async Task CreateManyAsync(Guid UserId, List<Guid> OrganizationUnitIds) |
|
|
|
{ |
|
|
|
|
|
|
|
if (UserId == Guid.Empty || !OrganizationUnitIds.Any()) |
|
|
|
if (UserId == Guid.Empty) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"请求参数有误"); |
|
|
|
} |
|
|
|
|
|
|
|
await _abpUserDepartmentRepository.DeleteAsync(d => d.UserId == UserId, true); |
|
|
|
|
|
|
|
List<AbpUserDepartment> entlist = new List<AbpUserDepartment>(); |
|
|
|
foreach (var org in OrganizationUnitIds) |
|
|
|
|
|
|
|
if (OrganizationUnitIds.Any()) |
|
|
|
{ |
|
|
|
var ent = new AbpUserDepartment |
|
|
|
|
|
|
|
List<AbpUserDepartment> entlist = new List<AbpUserDepartment>(); |
|
|
|
foreach (var org in OrganizationUnitIds) |
|
|
|
{ |
|
|
|
UserId = UserId, |
|
|
|
OrganizationUnitId = org |
|
|
|
}; |
|
|
|
entlist.Add(ent); |
|
|
|
} |
|
|
|
var ent = new AbpUserDepartment |
|
|
|
{ |
|
|
|
UserId = UserId, |
|
|
|
OrganizationUnitId = org |
|
|
|
}; |
|
|
|
entlist.Add(ent); |
|
|
|
} |
|
|
|
|
|
|
|
await _abpUserDepartmentRepository.InsertManyAsync(entlist, true); |
|
|
|
await _abpUserDepartmentRepository.InsertManyAsync(entlist, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -67,7 +72,7 @@ namespace Shentun.Peis.AbpUserDepartments |
|
|
|
/// </summary>
|
|
|
|
/// <param name="UserId">用户ID</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("api/app/abpuserdepartment/getuserdepartment")] |
|
|
|
[HttpGet("api/app/abpuserdepartment/getuserdepartment")] |
|
|
|
public async Task<List<Guid>> GetUserDepartmentAsync(Guid UserId) |
|
|
|
{ |
|
|
|
List<Guid> guids = new List<Guid>(); |
|
|
|
|