From c61812996ad7275e1b2733d555c4824b1c8595c2 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Tue, 30 Apr 2024 01:18:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbpUserDepartmentAppService.cs | 27 +++++++++++-------- .../ItemTypes/ItemTypeAppService.cs | 2 +- .../MyUser/MyUserAppService.cs | 9 +++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Shentun.Peis.Application/AbpUserDepartments/AbpUserDepartmentAppService.cs b/src/Shentun.Peis.Application/AbpUserDepartments/AbpUserDepartmentAppService.cs index fc9f8a5..d4b9942 100644 --- a/src/Shentun.Peis.Application/AbpUserDepartments/AbpUserDepartmentAppService.cs +++ b/src/Shentun.Peis.Application/AbpUserDepartments/AbpUserDepartmentAppService.cs @@ -40,25 +40,30 @@ namespace Shentun.Peis.AbpUserDepartments public async Task CreateManyAsync(Guid UserId, List OrganizationUnitIds) { - if (UserId == Guid.Empty || !OrganizationUnitIds.Any()) + if (UserId == Guid.Empty) { throw new UserFriendlyException($"请求参数有误"); } await _abpUserDepartmentRepository.DeleteAsync(d => d.UserId == UserId, true); - List entlist = new List(); - foreach (var org in OrganizationUnitIds) + + if (OrganizationUnitIds.Any()) { - var ent = new AbpUserDepartment + + List entlist = new List(); + 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 /// /// 用户ID /// - [HttpGet("api/app/abpuserdepartment/getuserdepartment")] + [HttpGet("api/app/abpuserdepartment/getuserdepartment")] public async Task> GetUserDepartmentAsync(Guid UserId) { List guids = new List(); diff --git a/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs b/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs index 08634bd..99ceca5 100644 --- a/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs +++ b/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs @@ -111,7 +111,7 @@ namespace Shentun.Peis.ItemTypes public async Task> 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, diff --git a/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs b/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs index 2e0beff..067ffa0 100644 --- a/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs +++ b/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); From ddd09b07d3cd0fdd8bca31bebb4a651052e47c36 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Tue, 30 Apr 2024 02:34:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=B1=BB=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserItemTypes/UserItemTypeAppService.cs | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs diff --git a/src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs b/src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs new file mode 100644 index 0000000..430ee25 --- /dev/null +++ b/src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs @@ -0,0 +1,84 @@ +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; + +namespace Shentun.Peis.UserItemTypes +{ + /// + /// 用户对应项目类别 + /// + [ApiExplorerSettings(GroupName = "Work")] + [Authorize] + public class UserItemTypeAppService + { + private readonly IRepository _userItemTypeRepository; + + public UserItemTypeAppService( + IRepository userItemTypeRepository + ) + { + _userItemTypeRepository = userItemTypeRepository; + } + /// + /// 设置用户对应的项目类别 先删除,后创建 + /// + /// 用户ID + /// 对应的项目类别ID集合 + /// + /// + [HttpPost("api/app/UserItemType/CreateMany")] + public async Task CreateManyAsync(Guid UserId, List ItemTypeIds) + { + + if (UserId == Guid.Empty) + { + throw new UserFriendlyException($"用户ID不能为空"); + } + + await _userItemTypeRepository.DeleteAsync(d => d.UserId == UserId, true); + + + if (ItemTypeIds.Any()) + { + + List entlist = new List(); + foreach (var itemTypeId in ItemTypeIds) + { + var ent = new UserItemType + { + UserId = UserId, + ItemTypeId = itemTypeId + }; + entlist.Add(ent); + } + + await _userItemTypeRepository.InsertManyAsync(entlist); + } + } + + + /// + /// 获取当前用户对应的项目类别 + /// + /// 用户ID + /// + [HttpPost("api/app/UserItemType/GetUserItemType")] + public async Task> GetUserItemTypeAsync(Guid UserId) + { + List guids = new List(); + var entlist = await _userItemTypeRepository.GetListAsync(m => m.UserId == UserId); + if (entlist.Any()) + { + guids = entlist.Select(s => s.ItemTypeId).ToList(); + } + return guids; + } + } +} From 2c23f29ef7af8257e1ecf461010e726a9791406d Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Tue, 30 Apr 2024 02:42:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserItemTypes/UserItemTypeAppService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs b/src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs index 430ee25..355d272 100644 --- a/src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs +++ b/src/Shentun.Peis.Application/UserItemTypes/UserItemTypeAppService.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; using Volo.Abp; +using Volo.Abp.Application.Services; namespace Shentun.Peis.UserItemTypes { @@ -16,7 +17,7 @@ namespace Shentun.Peis.UserItemTypes /// [ApiExplorerSettings(GroupName = "Work")] [Authorize] - public class UserItemTypeAppService + public class UserItemTypeAppService : ApplicationService { private readonly IRepository _userItemTypeRepository;