fix sys模块代码迁移
This commit is contained in:
@@ -25,6 +25,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scheduled", "Scheduled", "{
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Basic", "Src\Dlhis.Basic\Dlhis.Basic.csproj", "{D1F81CB7-F3EF-4196-A751-468248368020}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.User", "Src\Dlhis.User\Dlhis.User.csproj", "{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -59,6 +61,10 @@ Global
|
||||
{D1F81CB7-F3EF-4196-A751-468248368020}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D1F81CB7-F3EF-4196-A751-468248368020}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D1F81CB7-F3EF-4196-A751-468248368020}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -70,6 +76,7 @@ Global
|
||||
{4C1FADD9-8AFB-4087-9E52-EE6D6523ED38} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
|
||||
{FD8D38C5-0827-49D1-A0BA-7707FBFDA2EC} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
|
||||
{D1F81CB7-F3EF-4196-A751-468248368020} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
|
||||
{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class BusinessPlaceService : IBusinessPlaceService
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
[IgnoreTenant]
|
||||
|
||||
public async Task<Pagination<BusinessPlaceResponse>> GetPageAsync(BusinessPlacePageRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<CanteenBusinessPlaceEntity>()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Entity.Permission.Entities;
|
||||
namespace Dlhis.Entity.Sys.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备权限
|
||||
@@ -1,8 +1,8 @@
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace Dlhis.Entity.Permission.Entities;
|
||||
namespace Dlhis.Entity.Sys.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单
|
||||
@@ -1,9 +1,9 @@
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace Dlhis.Entity.Permission.Entities;
|
||||
namespace Dlhis.Entity.Sys.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单权限
|
||||
16
Src/Dlhis.Entity/Sys/Entities/RoleEntity.cs
Normal file
16
Src/Dlhis.Entity/Sys/Entities/RoleEntity.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Entity.Sys.Entities;
|
||||
|
||||
[SugarTable(TableName = "Roles")]
|
||||
public class RoleEntity
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string NormalizedName { get; set; }
|
||||
|
||||
public string ConcurrencyStamp { get; set; }
|
||||
}
|
||||
38
Src/Dlhis.Entity/Sys/Entities/UserEntity.cs
Normal file
38
Src/Dlhis.Entity/Sys/Entities/UserEntity.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Entity.Sys.Entities;
|
||||
|
||||
[SugarTable("Users")]
|
||||
public class UserEntity
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
public string NormalizedUserName { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
|
||||
public string NormalizedEmail { get; set; }
|
||||
|
||||
public bool EmailConfirmed { get; set; }
|
||||
|
||||
public string PasswordHash { get; set; }
|
||||
|
||||
public string SecurityStamp { get; set; }
|
||||
|
||||
public string ConcurrencyStamp { get; set; }
|
||||
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
public string PhoneNumberConfirmed { get; set; }
|
||||
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
|
||||
public bool LockoutEnd { get; set; }
|
||||
|
||||
public bool LockoutEnabled { get; set; }
|
||||
|
||||
public int AccessFailedCount { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Permission.Enums;
|
||||
namespace Dlhis.Entity.Sys.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 设备权限类型
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Permission.Enums;
|
||||
namespace Dlhis.Entity.Sys.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单类型
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Permission.Enums;
|
||||
namespace Dlhis.Entity.Sys.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 权限类型
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Permission.Enums;
|
||||
namespace Dlhis.Entity.Sys.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 平台类型
|
||||
@@ -1,11 +1,10 @@
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Kurisu.SqlSugar.Attributes;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Dlhis.Sys.Menu.Services;
|
||||
using Dlhis.Sys.Menu.Response;
|
||||
using Dlhis.Sys.Menu.Request;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Controllers;
|
||||
|
||||
@@ -40,7 +39,6 @@ public class MenusController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Transactional]
|
||||
[HttpPost]
|
||||
public async Task Save(SaveMenuRequest request)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Request;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Request;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
|
||||
namespace Dlhis.Sys.Menu.Response;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Dlhis.Sys.Menu.Request;
|
||||
using Dlhis.Sys.Menu.Response;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Dlhis.Entity.Permission.Entities;
|
||||
using Dlhis.Entity.Permission.Enums;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Dlhis.Sys.Menu.Request;
|
||||
using Dlhis.Sys.Menu.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
@@ -64,17 +64,11 @@ public class MenuService : IMenuService
|
||||
{
|
||||
//修改下级的PCode为当前的code
|
||||
var menus = await _dbContext.Queryable<MenuEntity>().Where(x => x.PCode == beforeCode).ToListAsync();
|
||||
menus.ForEach(x =>
|
||||
{
|
||||
x.PCode = pcode;
|
||||
});
|
||||
menus.ForEach(x => { x.PCode = pcode; });
|
||||
|
||||
//修改权限code为当前的code,避免权限丢失
|
||||
var permissions = await _dbContext.Queryable<MenuPermissionEntity>().Where(x => x.Code == beforeCode).ToListAsync();
|
||||
permissions.ForEach(x =>
|
||||
{
|
||||
x.Code = pcode;
|
||||
});
|
||||
permissions.ForEach(x => { x.Code = pcode; });
|
||||
|
||||
await _dbContext.UpdateAsync(menus);
|
||||
await _dbContext.UpdateAsync(permissions);
|
||||
@@ -98,7 +92,6 @@ public class MenuService : IMenuService
|
||||
Code = x,
|
||||
UniqueType = request.UniqueType,
|
||||
UniqueValue = request.UniqueValue
|
||||
|
||||
}).ToList();
|
||||
|
||||
|
||||
@@ -110,24 +103,78 @@ public class MenuService : IMenuService
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<List<string>> GetAllAssignmentPermissionsAsync()
|
||||
public async Task<List<string>> GetAllAssignmentPermissionsAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var all = await GetAllAssignmentCodesAsync();
|
||||
|
||||
return await _dbContext.Queryable<MenuEntity>().Where(x => all.Contains(x.Code)).Select(x => x.Permission).ToListAsync();
|
||||
}
|
||||
|
||||
public Task<List<MenuResponse>> GetCurrentMenusAsync()
|
||||
public async Task<List<MenuResponse>> GetCurrentMenusAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//我能看到的权限code,非permissions
|
||||
var allCodes = await GetAllAssignmentCodesAsync();
|
||||
if (!allCodes.Any())
|
||||
{
|
||||
return await GetListAsync(PlatformEnumType.PCAdmin);
|
||||
}
|
||||
|
||||
public Task<bool> IsPass(IEnumerable<string> p)
|
||||
var allMenus = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Platform == PlatformEnumType.PCAdmin)
|
||||
.Where(x => x.Visible)
|
||||
.Where(x => allCodes.Contains(x.Code))
|
||||
.Select<MenuResponse>()
|
||||
.ToListAsync();
|
||||
|
||||
//获取顶级数据
|
||||
var menus = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Platform == PlatformEnumType.PCAdmin)
|
||||
.Where(x => x.Visible)
|
||||
.Where(x => string.IsNullOrEmpty(x.PCode))
|
||||
.Select<MenuResponse>()
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var menu in menus)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
RecursionGetNext(menu, allMenus);
|
||||
}
|
||||
|
||||
public Task ResetAsync(List<SaveMenuRequest> request)
|
||||
menus.RemoveAll(x => !x.Items.Any());
|
||||
return menus;
|
||||
}
|
||||
|
||||
public async Task<bool> IsPass(IEnumerable<string> p)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var permissions = await GetAllAssignmentPermissionsAsync();
|
||||
return permissions.Count == 0 || permissions.All(x => p.Contains(x));
|
||||
}
|
||||
|
||||
public async Task ResetAsync(List<SaveMenuRequest> request)
|
||||
{
|
||||
var menus = await _dbContext.Queryable<MenuEntity>().Where(x => x.Platform == PlatformEnumType.PCAdmin).ToListAsync();
|
||||
await _dbContext.Client.Deleteable(menus).ExecuteCommandAsync();
|
||||
|
||||
foreach (var item in request)
|
||||
{
|
||||
await SaveMenuAsync(item);
|
||||
if (item.Items?.Any() == true)
|
||||
{
|
||||
await RecursionSaveNextAsync(item.Items);
|
||||
}
|
||||
}
|
||||
|
||||
//递归处理下一级
|
||||
async Task RecursionSaveNextAsync(List<SaveMenuRequest> menus)
|
||||
{
|
||||
foreach (var item in menus)
|
||||
{
|
||||
await SaveMenuAsync(item);
|
||||
if (item.Items?.Any() == true)
|
||||
{
|
||||
await RecursionSaveNextAsync(item.Items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,4 +235,23 @@ public class MenuService : IMenuService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetAllAssignmentCodesAsync()
|
||||
{
|
||||
var user = await _dbContext.Queryable<UserEntity>().Where(x => x.Id == _currentUser.GetIntSubjectId()).FirstAsync();
|
||||
if (user == null)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
// var gP = await GetAssignmentCodesAsync(MenuPermissionTypeEnumType.Group, manager.usergrp);
|
||||
//
|
||||
// //user
|
||||
// var uP = await GetAssignmentCodesAsync(MenuPermissionTypeEnumType.User, manager.account);
|
||||
// var all = gP.Concat(uP).Distinct().ToList();
|
||||
|
||||
//return all;
|
||||
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Startup;
|
||||
|
||||
class Program
|
||||
namespace Dlhis.Sys
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
KurisuHost.Run<Startup>(true, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Startup : DefaultStartup
|
||||
{
|
||||
public class Startup : DefaultStartup
|
||||
{
|
||||
public Startup(IConfiguration configuration) : base(configuration)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Src/Dlhis.User/Dlhis.User.csproj
Normal file
23
Src/Dlhis.User/Dlhis.User.csproj
Normal file
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="log\**" />
|
||||
<Content Remove="log\**" />
|
||||
<EmbeddedResource Remove="log\**" />
|
||||
<None Remove="log\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.4.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
27
Src/Dlhis.User/Identity/Controllers/RolesController.cs
Normal file
27
Src/Dlhis.User/Identity/Controllers/RolesController.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Dlhis.User.Identity.Request;
|
||||
using Dlhis.User.Identity.Response;
|
||||
using Dlhis.User.Identity.Services;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.User.Identity.Controllers;
|
||||
|
||||
[Authorize(Roles = "admin")]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class RolesController : ControllerBase
|
||||
{
|
||||
private readonly IRoleService _roleService;
|
||||
|
||||
public RolesController(IRoleService roleService)
|
||||
{
|
||||
_roleService = roleService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<Pagination<RoleRespone>> GetPageAsync(RolePageRequest request)
|
||||
{
|
||||
return await _roleService.GetPageAsync(request);
|
||||
}
|
||||
}
|
||||
32
Src/Dlhis.User/Identity/Controllers/UsersController.cs
Normal file
32
Src/Dlhis.User/Identity/Controllers/UsersController.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Dlhis.User.Identity.Request;
|
||||
using Dlhis.User.Identity.Response;
|
||||
using Dlhis.User.Identity.Services;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.User.Identity.Controllers;
|
||||
|
||||
[Authorize(Roles = "admin")]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public UsersController(IUserService userService)
|
||||
{
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("page")]
|
||||
public async Task<Pagination<UserResponse>> GetPageAsync([FromQuery] UserPageRequest request)
|
||||
{
|
||||
return await _userService.GetPageAsync(request);
|
||||
}
|
||||
}
|
||||
7
Src/Dlhis.User/Identity/Request/RolePageRequest.cs
Normal file
7
Src/Dlhis.User/Identity/Request/RolePageRequest.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.User.Identity.Request;
|
||||
|
||||
public class RolePageRequest : PageDto
|
||||
{
|
||||
}
|
||||
7
Src/Dlhis.User/Identity/Request/UserPageRequest.cs
Normal file
7
Src/Dlhis.User/Identity/Request/UserPageRequest.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.User.Identity.Request;
|
||||
|
||||
public class UserPageRequest : PageDto
|
||||
{
|
||||
}
|
||||
10
Src/Dlhis.User/Identity/Response/RoleRespone.cs
Normal file
10
Src/Dlhis.User/Identity/Response/RoleRespone.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Dlhis.User.Identity.Response;
|
||||
|
||||
public class RoleRespone
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string NormalizedName { get; set; }
|
||||
}
|
||||
28
Src/Dlhis.User/Identity/Response/UserResponse.cs
Normal file
28
Src/Dlhis.User/Identity/Response/UserResponse.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace Dlhis.User.Identity.Response;
|
||||
|
||||
public class UserResponse
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
public string NormalizedUserName { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
|
||||
public string NormalizedEmail { get; set; }
|
||||
|
||||
public bool EmailConfirmed { get; set; }
|
||||
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
public string PhoneNumberConfirmed { get; set; }
|
||||
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
|
||||
public bool LockoutEnd { get; set; }
|
||||
|
||||
public bool LockoutEnabled { get; set; }
|
||||
|
||||
public int AccessFailedCount { get; set; }
|
||||
}
|
||||
10
Src/Dlhis.User/Identity/Services/IRoleService.cs
Normal file
10
Src/Dlhis.User/Identity/Services/IRoleService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Dlhis.User.Identity.Request;
|
||||
using Dlhis.User.Identity.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.User.Identity.Services;
|
||||
|
||||
public interface IRoleService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<RoleRespone>> GetPageAsync(RolePageRequest request);
|
||||
}
|
||||
12
Src/Dlhis.User/Identity/Services/IUserService.cs
Normal file
12
Src/Dlhis.User/Identity/Services/IUserService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Dlhis.User.Identity.Request;
|
||||
using Dlhis.User.Identity.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.User.Identity.Services;
|
||||
|
||||
public interface IUserService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<UserResponse>> GetPageAsync(UserPageRequest request);
|
||||
|
||||
Task ResetAccessFailedCountAsync(int id);
|
||||
}
|
||||
41
Src/Dlhis.User/Identity/Services/Implements/UserService.cs
Normal file
41
Src/Dlhis.User/Identity/Services/Implements/UserService.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.User.Identity.Request;
|
||||
using Dlhis.User.Identity.Response;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.User.Identity.Services.Implements;
|
||||
|
||||
public class UserService : IUserService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public UserService(IDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<Pagination<UserResponse>> GetPageAsync(UserPageRequest request)
|
||||
{
|
||||
return await _dbContext.Queryable<UserEntity>()
|
||||
.WhereIF(request.Search.IsPresent(), x => x.UserName.Contains(request.Search)
|
||||
|| x.NormalizedUserName.Contains(request.Search)
|
||||
|| x.Email.Contains(request.Search)
|
||||
|| x.NormalizedEmail.Contains(request.Search)
|
||||
|| x.PhoneNumber.Contains(request.Search)
|
||||
)
|
||||
.Select<UserResponse>()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
public async Task ResetAccessFailedCountAsync(int id)
|
||||
{
|
||||
var user = await _dbContext.Queryable<UserEntity>().Where(x => x.Id == id).FirstAsync();
|
||||
user.ThrowIfNull("用户不存在,无法重置");
|
||||
|
||||
user.AccessFailedCount = 0;
|
||||
await _dbContext.UpdateAsync(user);
|
||||
}
|
||||
}
|
||||
21
Src/Dlhis.User/Program.cs
Normal file
21
Src/Dlhis.User/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Startup;
|
||||
|
||||
namespace Dlhis.User
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
KurisuHost.Run<Startup>(true, args);
|
||||
}
|
||||
}
|
||||
|
||||
public class Startup : DefaultStartup
|
||||
{
|
||||
public Startup(IConfiguration configuration) : base(configuration)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Src/Dlhis.User/Properties/launchSettings.json
Normal file
13
Src/Dlhis.User/Properties/launchSettings.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Dlhis.User": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5010",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Src/Dlhis.User/SqlSugarPack.cs
Normal file
14
Src/Dlhis.User/SqlSugarPack.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
|
||||
namespace Dlhis.User;
|
||||
|
||||
public class SqlSugarPack : BaseAppPack
|
||||
{
|
||||
public override bool IsBeforeUseRouting { get; }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSqlSugar();
|
||||
}
|
||||
}
|
||||
35
Src/Dlhis.User/appsettings.Development.json
Normal file
35
Src/Dlhis.User/appsettings.Development.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"InternalRequest": {
|
||||
"CommonRequestUrl": "http://localhost:5001"
|
||||
},
|
||||
"SwaggerOptions": {
|
||||
"Enable": true,
|
||||
"Authority": "https://yikatong.isawesome.cn/oauth2",
|
||||
"ClientId": "4fb184324eac4180",
|
||||
"ClientSecret": "8ac8f235152f1524",
|
||||
"Scopes": {
|
||||
"openid": "openid",
|
||||
"profile": "profile",
|
||||
"role": "role",
|
||||
"yikatong": "yikatong"
|
||||
}
|
||||
},
|
||||
"IdentityServerOptions": {
|
||||
"Authority": "https://yikatong.isawesome.cn/oauth2",
|
||||
"RequireHttpsMetadata": true,
|
||||
"Issuer": "identity.isawesome.cn",
|
||||
"Audience": "",
|
||||
"Pat": {
|
||||
"Enable": false,
|
||||
"Scheme": "token",
|
||||
"ClientId": "reference",
|
||||
"ClientSecret": "123456"
|
||||
}
|
||||
}
|
||||
}
|
||||
73
Src/Dlhis.User/appsettings.json
Normal file
73
Src/Dlhis.User/appsettings.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"SqlSugarOptions": {
|
||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=identity;charset=utf8mb4;",
|
||||
"SlaveConnectionString": [],
|
||||
"Timeout": 30,
|
||||
"SlowSqlTime": 1,
|
||||
"EnableSqlLog": true
|
||||
},
|
||||
"SwaggerOptions": {
|
||||
"Enable": true,
|
||||
"Authority": "http://identity.oauth.svc.cluster.local",
|
||||
"ClientId": "4fb184324eac4180",
|
||||
"ClientSecret": "8ac8f235152f1524",
|
||||
"Scopes": {
|
||||
"openid": "openid",
|
||||
"profile": "profile",
|
||||
"role": "role",
|
||||
"yikatong": "yikatong"
|
||||
}
|
||||
},
|
||||
"IdentityServerOptions": {
|
||||
"Authority": "http://identity.oauth.svc.cluster.local",
|
||||
"RequireHttpsMetadata": false,
|
||||
"Issuer": "identity.isawesome.cn",
|
||||
"Audience": "",
|
||||
"Pat": {
|
||||
"Enable": false,
|
||||
"Scheme": "token",
|
||||
"ClientId": "reference",
|
||||
"ClientSecret": "123456"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"System": "Warning",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Async",
|
||||
"Args": {
|
||||
"configure": [
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "log/log.txt",
|
||||
"rollingInterval": "Hour"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user