DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
fc71364d75
  1. 27
      src/Shentun.Peis.Application/AbpUserDepartments/AbpUserDepartmentAppService.cs
  2. 2
      src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs
  3. 9
      src/Shentun.Peis.Application/MyUser/MyUserAppService.cs
  4. 85
      src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs

27
src/Shentun.Peis.Application/AbpUserDepartments/AbpUserDepartmentAppService.cs

@ -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>();

2
src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs

@ -111,7 +111,7 @@ namespace Shentun.Peis.ItemTypes
public async Task<List<TreeChildViewDto>> GetByCodeAllAsync()
{
var dataList = await Repository.GetListAsync();
var items = from p in dataList
var items = from p in dataList.OrderBy(o => o.DisplayOrder)
select new TreeChildViewDto()
{
Id = p.Id,

9
src/Shentun.Peis.Application/MyUser/MyUserAppService.cs

@ -355,6 +355,15 @@ namespace Shentun.Peis.MyUser
var organizationUnitList = await _organizationUnitRepository.GetListAsync();
var PeisId = await _peisOrganizationUnitManager.GetPeisIdAsync(organizationUnitList, user.Id);
if (user.IsActive == false)
{
throw new UserFriendlyException("账号已被禁用");
}
if (user.LockoutEnabled == true)
{
throw new UserFriendlyException("账号已被锁定");
}
TokenResponse token = await RequestAuthServerLoginByPasswordAsync(input.UserName, input.PassWord);

85
src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs

@ -0,0 +1,85 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp;
using Volo.Abp.Application.Services;
namespace Shentun.Peis.UserItemTypes
{
/// <summary>
/// 用户对应项目类别
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class UserItemTypeAppService : ApplicationService
{
private readonly IRepository<UserItemType> _userItemTypeRepository;
public UserItemTypeAppService(
IRepository<UserItemType> userItemTypeRepository
)
{
_userItemTypeRepository = userItemTypeRepository;
}
/// <summary>
/// 设置用户对应的项目类别 先删除,后创建
/// </summary>
/// <param name="UserId">用户ID</param>
/// <param name="ItemTypeIds">对应的项目类别ID集合</param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/UserItemType/CreateMany")]
public async Task CreateManyAsync(Guid UserId, List<Guid> ItemTypeIds)
{
if (UserId == Guid.Empty)
{
throw new UserFriendlyException($"用户ID不能为空");
}
await _userItemTypeRepository.DeleteAsync(d => d.UserId == UserId, true);
if (ItemTypeIds.Any())
{
List<UserItemType> entlist = new List<UserItemType>();
foreach (var itemTypeId in ItemTypeIds)
{
var ent = new UserItemType
{
UserId = UserId,
ItemTypeId = itemTypeId
};
entlist.Add(ent);
}
await _userItemTypeRepository.InsertManyAsync(entlist);
}
}
/// <summary>
/// 获取当前用户对应的项目类别
/// </summary>
/// <param name="UserId">用户ID</param>
/// <returns></returns>
[HttpPost("api/app/UserItemType/GetUserItemType")]
public async Task<List<Guid>> GetUserItemTypeAsync(Guid UserId)
{
List<Guid> guids = new List<Guid>();
var entlist = await _userItemTypeRepository.GetListAsync(m => m.UserId == UserId);
if (entlist.Any())
{
guids = entlist.Select(s => s.ItemTypeId).ToList();
}
return guids;
}
}
}
Loading…
Cancel
Save