Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development

This commit is contained in:
cheche
2024-01-08 11:39:21 +08:00
54 changed files with 621 additions and 460 deletions

View File

@@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys", "Src\Dlhis.Sys\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Canteen", "Src\Dlhis.Canteen\Dlhis.Canteen.csproj", "{8317C526-3523-4195-9B19-2F17CFD71927}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.User.Api", "Src\Dlhis.User.Api\Dlhis.User.Api.csproj", "{F294CD7D-0412-48AD-A7E9-E72B9BA0E48E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -65,6 +67,10 @@ Global
{8317C526-3523-4195-9B19-2F17CFD71927}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8317C526-3523-4195-9B19-2F17CFD71927}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8317C526-3523-4195-9B19-2F17CFD71927}.Release|Any CPU.Build.0 = Release|Any CPU
{F294CD7D-0412-48AD-A7E9-E72B9BA0E48E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F294CD7D-0412-48AD-A7E9-E72B9BA0E48E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F294CD7D-0412-48AD-A7E9-E72B9BA0E48E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F294CD7D-0412-48AD-A7E9-E72B9BA0E48E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -77,6 +83,7 @@ Global
{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
{925048C9-5940-4B51-8480-4DC908C754A1} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
{8317C526-3523-4195-9B19-2F17CFD71927} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}
{F294CD7D-0412-48AD-A7E9-E72B9BA0E48E} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0}

View File

@@ -74,6 +74,7 @@ public class BusinessPlacesController : ControllerBase
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[AllowAnonymous]
[HttpGet("shifts")]
public async Task<BusinessPlaceWithShiftResponse> GetShiftsByPlaceCustomCodeHttpGetAsync([FromQuery] BusinessPlaceGetShiftsRequest request)
{

View File

@@ -75,6 +75,7 @@ public class DevicesController : ControllerBase
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[AllowAnonymous]
[HttpPost("resigter")]
public async Task<string> ResigterAsync(DeviceResigterRequest request)
{
@@ -114,4 +115,14 @@ public class DevicesController : ControllerBase
{
await _deviceConnectService.HeartbeatAsync(request);
}
/// <summary>
/// 检查设备是否存在
/// </summary>
/// <returns></returns>
[HttpGet("exists")]
public async Task<bool> CheckExistsAsync(string deviceUniqueNo)
{
return await _deviceService.CheckExistsAsync(deviceUniqueNo);
}
}

View File

@@ -9,4 +9,6 @@ public interface IDeviceService : IScopeDependency
Task<Pagination<DeviceResponse>> GetPageAsync(DevicePageRequest request);
Task SaveAsync(DeviceSaveRequest request);
Task<bool> CheckExistsAsync(string deviceUniqueNo);
}

View File

@@ -35,9 +35,10 @@ public class DeviceConnectService : IDeviceConnectService
RegisterTime = DateTime.Now,
BusinessPlaceCode = businessPlace?.Code,
BusinessPlaceCustomCode = businessPlace?.CustomCode,
TenantId = device.TenantId,
};
await _dbContext.InsertAsync(registry);
await _dbContext.InsertAsync(registry);
return "设备注册成功";
}

View File

@@ -1,9 +1,11 @@
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
using Kurisu.AspNetCore.UnifyResultAndValidation;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
using Kurisu.SqlSugar.Attributes;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
using Mapster;
@@ -34,6 +36,7 @@ public class DeviceService : IDeviceService
return page;
}
[Transactional]
public async Task SaveAsync(DeviceSaveRequest request)
{
await CheckUniqueNoExistsAsync(request);
@@ -46,6 +49,21 @@ public class DeviceService : IDeviceService
entity.Code = Guid.NewGuid();
entity.Brand = template.Brand;
await _dbContext.InsertAsync(entity);
//同时保存注册信息
var registry = await _dbContext.Queryable<DeviceRegistryEntity>().Where(x => x.DeviceUniqueNo == request.UniqueNo).FirstAsync();
if (registry == null)
{
registry = new DeviceRegistryEntity()
{
DeviceUniqueNo = request.UniqueNo,
LastHeartbeatTime = DateTime.Now,
RegisterTime = DateTime.Now,
BusinessPlaceCode = null,
BusinessPlaceCustomCode = null,
};
await _dbContext.InsertAsync(registry);
}
}
else
{
@@ -119,5 +137,13 @@ public class DeviceService : IDeviceService
exists.ThrowIfTrue("唯一号已经存在");
}
[IgnoreTenant]
public async Task<bool> CheckExistsAsync(string deviceUniqueNo)
{
return await _dbContext.Queryable<DeviceEntity>()
.Where(x => x.UniqueNo == deviceUniqueNo && x.Enable)
.AnyAsync();
}
}

View File

@@ -35,7 +35,7 @@ public class MealUserService : IMealUserService
//todo 获取档案信息
var gainfoEntity = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
.Where(x => x.Guestno.ToString() == request.UserId)
.Where(x => x.No.ToString() == request.UserId)
.FirstAsync();
gainfoEntity.ThrowIfNull($"档案[{request.UserId}]不存在");
@@ -44,7 +44,7 @@ public class MealUserService : IMealUserService
{
UserId = request.UserId,
UserType = request.UserType,
UserCode = gainfoEntity.Ename,
UserCode = gainfoEntity.Code,
CarNo = gainfoEntity.CarNo,
Balance = 0,
BalanceOfRecharge = 0,

View File

@@ -31,4 +31,14 @@ public class WerksController : ControllerBase
{
return await _werkService.GetListAsync();
}
/// <summary>
/// 获取当前组织信息
/// </summary>
/// <returns></returns>
[HttpGet("current")]
public async Task<WerkResponse> GetCurrentAsync()
{
return await _werkService.GetCurrentAsync();
}
}

View File

@@ -1,13 +1,19 @@
using Dlhis.Entity.Basic.Enums;
using Dlhis.Entity.Canteen.Enums;
using Kurisu.Core.DataAccess.Dto;
using System.ComponentModel.DataAnnotations;
namespace Dlhis.Basic.Organization.Request
{
namespace Dlhis.Basic.Organization.Request;
public class GainfoPageRequest : PageDto
{
/// <summary>
/// 档案类型
/// </summary>
[EnumDataType(typeof(GainfoStatusEnumType))]
public GainfoStatusEnumType gainfoStatus { get; set; }
}
public GainfoStatusEnumType Status { get; set; } = GainfoStatusEnumType.Working;
/// <summary>
/// 部门号(部门树传入)
/// </summary>
public List<string> DepartmentNos { get; set; }
}

View File

@@ -2,45 +2,47 @@
public class GainfoPageResponse
{
/// <summary>
/// 档案号
/// </summary>
public string Guestno { get; set; }
public string No { get; set; }
/// <summary>
/// SAP内部编号
/// </summary>
public string Ano { get; set; }
public string SapNo { get; set; }
/// <summary>
/// 人员类型
/// </summary>
public string Class { get; set; }
public string GType { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Gname { get; set; }
public string Name { get; set; }
/// <summary>
/// 外文名字
/// </summary>
public string NameEn { get; set; }
/// <summary>
/// 工号
/// </summary>
public string Ename { get; set; }
public string Code { get; set; }
/// <summary>
/// 国家代码
/// </summary>
public string Country { get; set; }
public string CountryNo { get; set; }
/// <summary>
/// 证件类型代码
/// </summary>
public string Idcls { get; set; }
public string IdClass { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string IdNO { get; set; }
public string IdNo { get; set; }
/// <summary>
/// 身份证籍贯区域代码
@@ -50,7 +52,7 @@ public class GainfoPageResponse
/// <summary>
/// 性别
/// </summary>
public string Sex { get; set; }
public string Gender { get; set; }
/// <summary>
/// 生日
@@ -65,12 +67,12 @@ public class GainfoPageResponse
/// <summary>
/// 已婚/未婚
/// </summary>
public string Postcode { get; set; }
public string Marital { get; set; }
/// <summary>
/// 部门编码
/// </summary>
public string Appellation { get; set; }
public string DepartmentNo { get; set; }
/// <summary>
/// 民族代码
@@ -82,11 +84,6 @@ public class GainfoPageResponse
/// </summary>
public string Phone { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string Mobile { get; set; }
/// <summary>
/// 学历
/// </summary>
@@ -95,7 +92,12 @@ public class GainfoPageResponse
/// <summary>
/// 岗位
/// </summary>
public string Web { get; set; }
public string Position { get; set; }
/// <summary>
/// 卡号
/// </summary>
public string CarNo { get; set; }
/// <summary>
/// 备注
@@ -103,42 +105,12 @@ public class GainfoPageResponse
public string Remark { get; set; }
/// <summary>
/// 操作账号
/// 人事范围
/// </summary>
public string Log_id { get; set; }
public string Werks { get; set; }
/// <summary>
/// 操作班次
/// 在职状态
/// </summary>
public string Log_shift { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public DateTime Log_date { get; set; }
/// <summary>
/// 操作IP
/// </summary>
public string Log_ip { get; set; }
/// <summary>
/// 是否在职 F 在职 T离职
/// </summary>
public string Isowner { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime Createdate { get; set; }
/// <summary>
/// 外文名字
/// </summary>
public string Gname_en { get; set; }
/// <summary>
/// 卡号
/// </summary>
public string CarNo { get; set; }
public string Employed { get; set; }
}

View File

@@ -5,4 +5,6 @@ namespace Dlhis.Basic.Organization.Services;
public interface IWerkService : IScopeDependency
{
Task<List<WerkResponse>> GetListAsync();
Task<WerkResponse> GetCurrentAsync();
}

View File

@@ -30,7 +30,7 @@ public class GainfoService : IGainfoService
/// <returns></returns>
public Task<Pagination<GainfoPageResponse>> GetPageAsync(GainfoPageRequest request)
{
var page = _gainfoStore.Queryable(request.gainfoStatus)
var page = _gainfoStore.Queryable(request.Status)
.Select<GainfoPageResponse>()
.ToPageListAsync(request);
@@ -47,7 +47,7 @@ public class GainfoService : IGainfoService
var gainfos = new List<GainfoEntity>();
GainfoEntity aginfoEntity = request.Adapt<GainfoEntity>();
aginfoEntity.Guestno = "F" + Guid.NewGuid().ToString();
aginfoEntity.No = "F" + Guid.NewGuid().ToString();
gainfos.Add(aginfoEntity);
await _gainfoStore.InsertAsync(GainfoStatusEnumType.Working, gainfos);
@@ -84,7 +84,7 @@ public class GainfoService : IGainfoService
public async Task DimissionAsync(GainfoDImissionRequest request)
{
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
.Where(x => x.Guestno == request.UserId)
.Where(x => x.No == request.UserId)
.FirstAsync();
gainfo.ThrowIfNull($"该档案不存在");
@@ -109,7 +109,7 @@ public class GainfoService : IGainfoService
public async Task OnboardingAsync(GainfoDImissionRequest request)
{
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.External)
.Where(x => x.Guestno == request.UserId)
.Where(x => x.No == request.UserId)
.FirstAsync();
gainfo.ThrowIfNull($"该档案不存在");

View File

@@ -28,7 +28,7 @@ public class GainfoStore : IGainfoStore
if (gainfoStatus.HasValue && gainfoStatus != GainfoStatusEnumType.Working)
{
var tableName = typeof(GainfoEntity).GetCustomAttribute<SugarTable>().TableName;
return _dbContext.Queryable<GainfoEntity>().AS(tableName + "_" + gainfoStatus);
return _dbContext.Queryable<GainfoEntity>().AS(tableName + gainfoStatus);
}
return _dbContext.Queryable<GainfoEntity>();

View File

@@ -1,5 +1,6 @@
using Dlhis.Basic.Organization.Response;
using Dlhis.Entity.Basic.Entity;
using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Services;
namespace Dlhis.Basic.Organization.Services.Implements;
@@ -7,10 +8,12 @@ namespace Dlhis.Basic.Organization.Services.Implements;
public class WerkService : IWerkService
{
private readonly IDbContext _dbContext;
private readonly ICurrentUser _currentUser;
public WerkService(IDbContext dbContext)
public WerkService(IDbContext dbContext, ICurrentUser currentUser)
{
_dbContext = dbContext;
_currentUser = currentUser;
}
public async Task<List<WerkResponse>> GetListAsync()
@@ -19,4 +22,13 @@ public class WerkService : IWerkService
.Select<WerkResponse>()
.ToListAsync();
}
public async Task<WerkResponse> GetCurrentAsync()
{
var tenant = _currentUser.GetStringTenantId();
return await _dbContext.Queryable<WerkEntity>()
.Where(x => x.Code == tenant)
.Select<WerkResponse>()
.FirstAsync();
}
}

View File

@@ -63,10 +63,10 @@ public class OrderService : IOrderService
.FirstAsync();
var gafinfo = await _dbContext.Queryable<GainfoEntity>()
.Where(x => x.Guestno == canteenUser.UserId)
.Where(x => x.No == canteenUser.UserId)
.FirstAsync();
var settings = await _canteenSettingService.GetUserSettingAsync(gafinfo.Guestno);
var settings = await _canteenSettingService.GetUserSettingAsync(gafinfo.No);
var switchTime = GetSetting<TimeOnly>(settings, CanteenSettingItemEnumType.BusinessSwitchTime);
//金额处理
request.Amount = request.Type == BalanceRecordTypeEnumType.In ? Math.Abs(request.Amount) : -Math.Abs(request.Amount);
@@ -100,7 +100,7 @@ public class OrderService : IOrderService
ThirdNo = request.ThirdNo,
Type = request.Type.Value,
OrderStatus = CanteenOrderStatusEnumType.Wait,
Name = gafinfo.Gname,
Name = gafinfo.Name,
Source = request.Source,
UserId = canteenUser.UserId,
UserCode = canteenUser.UserCode,
@@ -109,7 +109,7 @@ public class OrderService : IOrderService
BusinessShiftCode = shift?.Code,
CostDate = costDate.Date,
CostId = canteenUser.CostId,
DepartmentNo = gafinfo.Appellation,
DepartmentNo = gafinfo.DepartmentNo,
DeviceInfo = device.Code.ToString(),
No = "O" + SnowFlakeHelper.Instance.NextId(),

View File

@@ -79,14 +79,14 @@ public class DeviceEntity : SugarBaseEntity, ITenantId
/// <summary>
/// 最后使用人
/// </summary>
[SugarColumn(ColumnDescription = "最后使用人")]
public DateTime LastLogId { get; set; }
[SugarColumn(IsNullable = true, ColumnDescription = "最后使用人")]
public DateTime? LastLogId { get; set; }
/// <summary>
/// 最后使用日期
/// </summary>
[SugarColumn(ColumnDescription = "最后使用日期")]
public DateTime LastLogDateTime { get; set; }
[SugarColumn(IsNullable = true, ColumnDescription = "最后使用日期")]
public DateTime? LastLogDateTime { get; set; }
/// <summary>

View File

@@ -1,4 +1,6 @@
using SqlSugar;
using Dlhis.Entity.Basic.Enums;
using SqlSugar;
using SqlSugar.DbConvert;
namespace Dlhis.Entity.Basic.Entity;
@@ -12,49 +14,55 @@ public class GainfoEntity : SugarBaseEntity
/// 档案号
/// </summary>
[SugarColumn(ColumnDescription = "档案号")]
public string Guestno { get; set; }
public string No { get; set; }
/// <summary>
/// SAP内部编号
/// </summary>
[SugarColumn(ColumnDescription = "SAP内部编号")]
public string Ano { get; set; }
public string SapNo { get; set; }
/// <summary>
/// 人员类型
/// </summary>
[SugarColumn(ColumnDescription = "人员类型")]
public string Class { get; set; }
public string GType { get; set; }
/// <summary>
/// 姓名
/// </summary>
[SugarColumn(ColumnDescription = "姓名")]
public string Gname { get; set; }
public string Name { get; set; }
/// <summary>
/// 外文名字
/// </summary>
[SugarColumn(ColumnDescription = "外文名字")]
public string NameEn { get; set; }
/// <summary>
/// 工号
/// </summary>
[SugarColumn(ColumnDescription = "工号")]
public string Ename { get; set; }
public string Code { get; set; }
/// <summary>
/// 国家代码
/// </summary>
[SugarColumn(ColumnDescription = "国家代码")]
public string Country { get; set; }
public string CountryNo { get; set; }
/// <summary>
/// 证件类型代码
/// </summary>
[SugarColumn(ColumnDescription = "证件类型代码")]
public string Idcls { get; set; }
public string IdClass { get; set; }
/// <summary>
/// 身份证号
/// </summary>
[SugarColumn(ColumnDescription = "身份证号")]
public string IdNO { get; set; }
public string IdNo { get; set; }
/// <summary>
/// 身份证籍贯区域代码
@@ -65,8 +73,8 @@ public class GainfoEntity : SugarBaseEntity
/// <summary>
/// 性别
/// </summary>
[SugarColumn(ColumnDescription = "性别")]
public string Sex { get; set; }
[SugarColumn(ColumnDescription = "性别", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
public GenderEnumType Gender { get; set; }
/// <summary>
/// 生日
@@ -84,13 +92,13 @@ public class GainfoEntity : SugarBaseEntity
/// 已婚/未婚
/// </summary>
[SugarColumn(ColumnDescription = "已婚/未婚")]
public string Postcode { get; set; }
public string Marital { get; set; }
/// <summary>
/// 部门编码
/// </summary>
[SugarColumn(ColumnDescription = "部门编码")]
public string Appellation { get; set; }
public string DepartmentNo { get; set; }
/// <summary>
/// 民族代码
@@ -104,12 +112,6 @@ public class GainfoEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "手机号码")]
public string Phone { get; set; }
/// <summary>
/// 联系电话
/// </summary>
[SugarColumn(ColumnDescription = "联系电话")]
public string Mobile { get; set; }
/// <summary>
/// 学历
/// </summary>
@@ -120,55 +122,7 @@ public class GainfoEntity : SugarBaseEntity
/// 岗位
/// </summary>
[SugarColumn(ColumnDescription = "岗位")]
public string Web { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnDescription = "备注")]
public string Remark { get; set; }
/// <summary>
/// 操作账号
/// </summary>
[SugarColumn(ColumnDescription = "操作账号")]
public string Log_id { get; set; }
/// <summary>
/// 操作班次
/// </summary>
[SugarColumn(ColumnDescription = "操作班次")]
public string Log_shift { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[SugarColumn(ColumnDescription = "操作时间")]
public DateTime Log_date { get; set; }
/// <summary>
/// 操作IP
/// </summary>
[SugarColumn(ColumnDescription = "操作IP")]
public string Log_ip { get; set; }
/// <summary>
/// 是否在职 F 在职 T离职
/// </summary>
[SugarColumn(ColumnDescription = "是否在职 F 在职 T离职")]
public string Isowner { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDescription = "创建时间")]
public DateTime Createdate { get; set; }
/// <summary>
/// 外文名字
/// </summary>
[SugarColumn(ColumnDescription = "外文名字")]
public string Gname_en { get; set; }
public string Position { get; set; }
/// <summary>
/// 卡号
@@ -176,6 +130,12 @@ public class GainfoEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "卡号")]
public string CarNo { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnDescription = "备注")]
public string Remark { get; set; }
/// <summary>
/// 人事范围
/// </summary>
@@ -183,14 +143,8 @@ public class GainfoEntity : SugarBaseEntity
public string Werks { get; set; }
/// <summary>
/// 人员号
/// 在职状态
/// </summary>
[SugarColumn(ColumnDescription = "人员号")]
public string Pernr { get; set; }
/// <summary>
/// 邮箱
/// </summary>
[SugarColumn(ColumnDescription = "邮箱")]
public string Email { get; set; }
[SugarColumn(ColumnDescription = "在职状态")]
public string Employed { get; set; }
}

View File

@@ -9,7 +9,7 @@ namespace Dlhis.Entity.Basic.Enums;
public enum GainfoStatusEnumType
{
/// <summary>
///
/// 在职
/// </summary>
[Description("在职")]
Working = 1,
@@ -21,7 +21,7 @@ public enum GainfoStatusEnumType
Leave = 2,
/// <summary>
/// 外部人员
/// 外部
/// </summary>
[Description("外部")]
External = 3

View File

@@ -0,0 +1,25 @@
using System.ComponentModel;
namespace Dlhis.Entity.Basic.Enums;
[Description("性别类型")]
public enum GenderEnumType
{
/// <summary>
/// 女性
/// </summary>
[Description("女性")]
Female = 0,
/// <summary>
/// 男性
/// </summary>
[Description("男性")]
Male = 1,
/// <summary>
/// 未知
/// </summary>
[Description("未知")]
Unknown = 99,
}

View File

@@ -12,10 +12,10 @@ namespace Dlhis.Entity.Sys.Entities;
public class MenuPermissionEntity : SugarBaseEntity, ITenantId, ISoftDeleted
{
/// <summary>
/// 权限类型
/// 权限分配类型
/// </summary>
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "权限类型", SqlParameterDbType = typeof(EnumToStringConvert))]
public MenuPermissionTypeEnumType UniqueType { get; set; }
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "权限分配类型", SqlParameterDbType = typeof(EnumToStringConvert))]
public MenuAssignmentTypeEnumType UniqueType { get; set; }
/// <summary>
/// 类型值

View File

@@ -5,8 +5,8 @@ namespace Dlhis.Entity.Sys.Enums;
/// <summary>
/// 权限类型
/// </summary>
[Description("权限类型")]
public enum MenuPermissionTypeEnumType
[Description("权限分配类型")]
public enum MenuAssignmentTypeEnumType
{
/// <summary>
/// 用户

View File

@@ -3,7 +3,7 @@
namespace Dlhis.ScheduledTask.Configurations
{
//[Configuration]
[Configuration]
public class ServiceSettings
{
public string ServerUrl { get; private set; }

View File

@@ -21,6 +21,7 @@
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />
<PackageReference Include="Kurisu.AspNetCore" Version="0.4.7" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
</ItemGroup>
<ItemGroup>

View File

@@ -7,6 +7,7 @@ EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj", "Src/Dlhis.ScheduledTask/"]
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
RUN dotnet restore "Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj"
COPY . .
WORKDIR "/src/Src/Dlhis.ScheduledTask"

View File

@@ -1,69 +0,0 @@
using Dlhis.ScheduledTask.Configurations;
using Dlhis.ScheduledTask.Job;
using Hangfire;
using Hangfire.Dashboard.BasicAuthorization;
using Hangfire.MySql;
using Kurisu.AspNetCore.Startup;
namespace Dlhis.ScheduledTask
{
public class HangfirePack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<ServiceSettings>(Configuration.GetSection("ServiceSettings"));
services.AddHangfire(configuration =>
{
var options = new MySqlStorageOptions
{
TablesPrefix = "Hangfire"
};
configuration.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseStorage(new MySqlStorage(Configuration.GetConnectionString("HangfireConnection"), options));
});
services.UseHangfireto();
services.AddHangfireServer();
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
AppPath = null,
DashboardTitle = "hangfire",
Authorization = new[]
{
new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
{
RequireSsl = false,
SslRedirect = false,
Users = new []
{
new BasicAuthAuthorizationUser
{
Login ="admin",
PasswordClear = "admin"
}
}
})
}
});
app.UseHangfireDashboard();
BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job."));
RecurringJob.AddOrUpdate<SyncOrgInfoJob>("SyncOrgInfoJob_id", s => s.SyncOrgInfo(), "0 0 0 * * ?");
RecurringJob.AddOrUpdate<SyncPositionJob>("SyncPositionJob_id", s =>s.SyncPositionInfo(), "0 0 1 * * ?");
RecurringJob.AddOrUpdate<SyncPersonJob>("SyncPersonJob_id", s => s.SyncPersonInfo(), "0 0 2 * * ?");
}
}
}

View File

@@ -32,8 +32,7 @@ namespace Dlhis.ScheduledTask.Job
var headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", headerValue);
string apiUrl =
"http://sappidap.jinkosolar.cn:51000/RESTAdapter/Rest/EHR_ORGANIZATION/";
string apiUrl = "http://sappidap.jinkosolar.cn:51000/RESTAdapter/Rest/EHR_ORGANIZATION/";
string requestBody = "{\"I_DATE\":\"2021-01-01\",\"I_DATE_TO\":\"2022-05-29\",\"I_LANGU\":\"1\",\"T_ID\":{\"item\":[{\"OBJID\":\"50007967\"},{\"OBJID\":\"50008308\"}]}}";
@@ -76,8 +75,6 @@ namespace Dlhis.ScheduledTask.Job
foreach (ZHRS_ORG item in modifiedOrgList)
{
var existingOrgs = await _dbContext.Queryable<ZHRF_SYN_01Entity>().Where(x => x.OBJID == item.OBJID).FirstAsync();
if (existingOrgs != null)

View File

@@ -82,8 +82,8 @@ namespace Dlhis.ScheduledTask.Job
//var existsWorkCodes = conn.Query<string>($"select ename from gainfo_sap where ename in ( {string.Join(",", searchCodes.Select(x => $"'{x}'"))} )")
// .ToList();
var existsWorkCodes = _dbContext.Queryable<GainfoEntity>()
.Where(x => searchCodes.Contains(x.Ename))
.Select(x => x.Ename)
.Where(x => searchCodes.Contains(x.Code))
.Select(x => x.Code)
.ToList();
var originUpdates = persons.Where(x => existsWorkCodes.Contains(x.ZWORKCODE)).ToList();
@@ -142,19 +142,18 @@ namespace Dlhis.ScheduledTask.Job
private async Task SavePerson(GainfoSap item)
{
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNO == item.idno).FirstAsync();
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.idno).FirstAsync();
if (gainfo != null)
{
gainfo.Pernr = item.PERNR;
gainfo.Gname = item.gname;
gainfo.Ename = item.ename;
gainfo.Web = item.web;
gainfo.SapNo = item.PERNR;
gainfo.Name = item.gname;
gainfo.Code = item.ename;
gainfo.Position = item.web;
gainfo.Phone = item.phone;
gainfo.Appellation = item.appellation;
gainfo.Isowner = item.isowner;
gainfo.DepartmentNo = item.appellation;
gainfo.Employed = item.isowner;
gainfo.Remark = item.remark;
gainfo.Email = item.email;
gainfo.Createdate = (DateTime)item.createdate;
gainfo.Degree = item.email;
gainfo.Werks = item.WERKS;
await _dbContext.UpdateAsync(gainfo);
}
@@ -162,30 +161,29 @@ namespace Dlhis.ScheduledTask.Job
{
var info = new GainfoEntity()
{
Ano = item.ano,
Guestno = item.guestno,
Class = item.@class,
Gname = item.gname,
Ename = item.ename,
Country = item.country,
Idcls = item.idcls,
SapNo = item.ano,
No = item.guestno,
GType = item.@class,
Name = item.gname,
Code = item.ename,
CountryNo = item.country,
IdClass = item.idcls,
Native = item.native,
Sex = item.sex,
Gender = item.sex,
Birthday = (DateTime)item.birthday,
Address = item.address,
//Occupation = item.occupation,
Appellation = item.appellation,
DepartmentNo = item.appellation,
Nation = item.nation,
Phone = item.phone,
Web = item.web,
Log_id = item.log_id,
Log_shift = item.log_shift,
Log_date = (DateTime)item.log_date,
Log_ip = item.log_ip,
Isowner = item.isowner,
Position = item.web,
//Log_id = item.log_id,
//Log_shift = item.log_shift,
//Log_date = (DateTime)item.log_date,
//Log_ip = item.log_ip,
Employed = item.isowner,
Remark = item.remark,
Email = item.email,
Createdate = (DateTime)item.createdate,
Degree = item.email,
Werks = item.WERKS,
};
await _dbContext.InsertAsync(info);
@@ -193,46 +191,44 @@ namespace Dlhis.ScheduledTask.Job
}
private async Task UpdatePerson(GainfoSap item)
{
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNO == item.idno).FirstAsync();
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.idno).FirstAsync();
if (gainfo != null)
{
_dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
{
Pernr = item.PERNR,
Gname = item.gname,
Ename = item.ename,
Web = item.web,
SapNo = item.PERNR,
Name = item.gname,
Code = item.ename,
Position = item.web,
Phone = item.phone,
Appellation = item.appellation,
Isowner = item.isowner,
DepartmentNo = item.appellation,
Employed = item.isowner,
Remark = item.remark,
Email = item.email,
Createdate = (DateTime)item.createdate,
Degree = item.email,
Werks = item.WERKS
})
.Where(g => g.IdNO == item.idno
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNO == item.idno && g.Pernr != item.PERNR && g.Isowner == "T")
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNO == item.idno && int.Parse(g.Pernr) > int.Parse(item.PERNR) && g.Isowner == item.isowner));
.Where(g => g.IdNo == item.idno
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNo == item.idno && g.SapNo != item.PERNR && g.Employed == "T")
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNo == item.idno && int.Parse(g.SapNo) > int.Parse(item.PERNR) && g.Employed == item.isowner));
}
else
{
_dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
{
Pernr = item.PERNR,
Gname = item.gname,
Ename = item.ename,
Web = item.web,
SapNo = item.PERNR,
Name = item.gname,
Code = item.ename,
Position = item.web,
Phone = item.phone,
Appellation = item.appellation,
Isowner = item.isowner,
DepartmentNo = item.appellation,
Employed = item.isowner,
Remark = item.remark,
Email = item.email,
Createdate = (DateTime)item.createdate,
Degree = item.email,
Werks = item.WERKS
})
.Where(g => g.Ano == item.PERNR
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.Ename == item.ename && g.Isowner == "T")
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNO == item.idno && int.Parse(g.Pernr) > int.Parse(item.PERNR) && g.Isowner == item.isowner));
.Where(g => g.SapNo == item.PERNR
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.Code == item.ename && g.Employed == "T")
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNo == item.idno && int.Parse(g.SapNo) > int.Parse(item.PERNR) && g.Employed == item.isowner));
}
}

View File

@@ -0,0 +1,67 @@
using Dlhis.ScheduledTask.Configurations;
using Dlhis.ScheduledTask.Job;
using Hangfire;
using Hangfire.Dashboard.BasicAuthorization;
using Hangfire.MySql;
using Kurisu.AspNetCore.Startup;
namespace Dlhis.ScheduledTask.Packs;
public class HangfirePack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<ServiceSettings>(Configuration.GetSection("ServiceSettings"));
services.AddHangfire(configuration =>
{
var options = new MySqlStorageOptions
{
TablesPrefix = "Hangfire"
};
configuration.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseStorage(new MySqlStorage(Configuration.GetConnectionString("HangfireConnection"), options));
});
services.UseHangfireto();
services.AddHangfireServer();
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
AppPath = null,
DashboardTitle = "hangfire",
Authorization = new[]
{
new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
{
RequireSsl = false,
SslRedirect = false,
Users = new []
{
new BasicAuthAuthorizationUser
{
Login ="admin",
PasswordClear = "admin"
}
}
})
}
});
app.UseHangfireDashboard();
BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job."));
RecurringJob.AddOrUpdate<SyncOrgInfoJob>("SyncOrgInfoJob_id", s => s.SyncOrgInfo(), "0 0 0 * * ?");
RecurringJob.AddOrUpdate<SyncPositionJob>("SyncPositionJob_id", s => s.SyncPositionInfo(), "0 0 1 * * ?");
RecurringJob.AddOrUpdate<SyncPersonJob>("SyncPersonJob_id", s => s.SyncPersonInfo(), "0 0 2 * * ?");
}
}

View File

@@ -0,0 +1,15 @@
using Kurisu.AspNetCore.Startup;
using Kurisu.SqlSugar.Extensions;
namespace Dlhis.ScheduledTask.Packs;
public class SqlSugarPack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddSqlSugar();
}
}

View File

@@ -14,6 +14,5 @@ public class Startup : DefaultStartup
{
public Startup(IConfiguration configuration) : base(configuration)
{
}
}

View File

@@ -1,34 +0,0 @@
using System.Linq;
using Dlhis.ScheduledTask.Entities;
namespace Dlhis
{
public class SqlGeneration
{
private static string _insertSql;
private static string _updateSql;
static SqlGeneration()
{
//""
var properties = typeof(GainfoSap).GetProperties();
var insertFields = properties
.Where(x => !x.IsDefined(typeof(IgnoreColumnAttribute), false))
.Where(x => !x.IsDefined(typeof(PkColumnAttribute), false))
.Select(x => x.Name);
_insertSql = $" insert into gainfo_sap({string.Join(",", insertFields)}) \r\n values \r\n ({string.Join(",", insertFields.Select(x => $"@{x}"))})";
var updateFields = properties
.Where(x => !x.IsDefined(typeof(IgnoreColumnAttribute), false))
.Where(x => !x.IsDefined(typeof(PkColumnAttribute), false))
.Where(x => !x.IsDefined(typeof(UpdateColumnAttribute), false))
.Select(x => x.Name);
_updateSql = $" update gainfo_sap set {string.Join(",", updateFields.Select(x => $"{x}=@{x}"))} \t\n where ename=@ename";
}
public static string InsertSql => _insertSql;
public static string UpdateSql => _updateSql;
}
}

View File

@@ -1,29 +0,0 @@
using Kurisu.AspNetCore.Startup;
using Kurisu.AspNetCore;
using Kurisu.SqlSugar.Extensions;
using SqlSugar;
namespace Dlhis.ScheduledTask
{
public class SqlSugarPack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddSqlSugar();
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
#if DEBUG
using var scope = app.ApplicationServices.CreateScope();
var db = scope.ServiceProvider.GetService<ISqlSugarClient>();
var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false)).ToArray();
db.DbMaintenance.CreateDatabase();
db.CodeFirst.InitTables(tables);
#endif
}
}
}

View File

@@ -18,10 +18,12 @@
<ItemGroup>
<PackageReference Include="Kurisu.AspNetCore" Version="0.4.7" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
<ProjectReference Include="..\Dlhis.User.Api\Dlhis.User.Api.csproj" />
</ItemGroup>
</Project>

View File

@@ -6,17 +6,18 @@ EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Src/Dlhis.Permission/Dlhis.Permission.csproj", "Src/Dlhis.Permission/"]
COPY ["Src/Dlhis.Sys/Dlhis.Sys.csproj", "Src/Dlhis.Sys/"]
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
RUN dotnet restore "Src/Dlhis.Permission/Dlhis.Permission.csproj"
COPY ["Src/Dlhis.User.Api/Dlhis.User.Api.csproj", "Src/Dlhis.User.Api/"]
RUN dotnet restore "Src/Dlhis.Sys/Dlhis.Sys.csproj"
COPY . .
WORKDIR "/src/Src/Dlhis.Permission"
RUN dotnet build "Dlhis.Permission.csproj" -c Release -o /app/build
WORKDIR "/src/Src/Dlhis.Sys"
RUN dotnet build "Dlhis.Sys.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Dlhis.Permission.csproj" -c Release -o /app/publish /p:UseAppHost=false
RUN dotnet publish "Dlhis.Sys.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Dlhis.Permission.dll"]
ENTRYPOINT ["dotnet", "Dlhis.Sys.dll"]

View File

@@ -8,6 +8,9 @@ using Dlhis.Entity.Sys.Enums;
namespace Dlhis.Sys.Menu.Controllers;
/// <summary>
/// 菜单
/// </summary>
[Authorize]
[Route("api/[controller]")]
[ApiController]
@@ -23,14 +26,11 @@ public class MenusController : ControllerBase
/// <summary>
/// 菜单列表
/// </summary>
/// <param name="platform">菜单平台类型 PlatformEnumType</param>
/// <returns></returns>
[HttpGet("list")]
public async Task<List<MenuResponse>> GetListAsync([EnumDataType(typeof(PlatformEnumType))] PlatformEnumType? platform)
public async Task<List<MenuResponse>> GetListAsync([EnumDataType(typeof(PlatformEnumType))] PlatformEnumType? platform = PlatformEnumType.PCAdmin)
{
if (!platform.HasValue)
{
platform = PlatformEnumType.UserMobile;
}
return await _menuService.GetListAsync(platform.Value);
}
@@ -59,17 +59,19 @@ public class MenusController : ControllerBase
/// <summary>
/// 当前类型的权限分配
/// </summary>
/// <param name="permissionType">权限类型</param>
/// <param name="uniqueType">权限分配类型 MenuAssignmentTypeEnumType</param>
/// <param name="uniqueValue">类型对应的唯一值</param>
/// <returns></returns>
[HttpGet("assignments")]
public async Task<List<string>> GetAssignmentsAsync([EnumDataType(typeof(MenuPermissionTypeEnumType))] MenuPermissionTypeEnumType permissionType, [Required] string uniqueValue)
public async Task<List<string>> GetAssignmentsAsync(
[EnumDataType(typeof(MenuAssignmentTypeEnumType))] MenuAssignmentTypeEnumType uniqueType,
[Required] string uniqueValue)
{
return await _menuService.GetAssignmentCodesAsync(permissionType, uniqueValue);
return await _menuService.GetAssignmentCodesAsync(uniqueType, uniqueValue);
}
/// <summary>
/// 获取所有权限分配
/// 获取我的所有权限
/// </summary>
/// <returns></returns>
[HttpGet("assignments/all")]
@@ -79,7 +81,7 @@ public class MenusController : ControllerBase
}
/// <summary>
/// 我的菜单
/// 获取我的菜单
/// </summary>
/// <returns></returns>
[HttpGet("my")]
@@ -89,7 +91,7 @@ public class MenusController : ControllerBase
}
/// <summary>
/// 重置
/// 重置所有路由
/// </summary>
/// <param name="request"></param>
/// <returns></returns>

View File

@@ -6,10 +6,10 @@ namespace Dlhis.Sys.Menu.Request;
public class MenuPermissionAssignmentRequest
{
/// <summary>
/// 权限类型
/// 权限类型 MenuAssignmentTypeEnumType
/// </summary>
[EnumDataType(typeof(MenuPermissionTypeEnumType))]
public MenuPermissionTypeEnumType UniqueType { get; set; }
[EnumDataType(typeof(MenuAssignmentTypeEnumType))]
public MenuAssignmentTypeEnumType UniqueType { get; set; }
/// <summary>
/// 唯一值

View File

@@ -60,13 +60,13 @@ public class SaveMenuRequest : IValidatableObject
public int Sequence { get; set; }
/// <summary>
/// 菜单类型
/// 菜单类型 MenuEnumType
/// </summary>
[EnumDataType(typeof(MenuEnumType))]
public MenuEnumType MenuType { get; set; }
/// <summary>
/// 平台
/// 平台 PlatformEnumType
/// </summary>
[EnumDataType(typeof(PlatformEnumType))]
public PlatformEnumType Platform { get; set; }

View File

@@ -68,12 +68,6 @@ public class MenuResponse
/// </summary>
public PlatformEnumType Platform { get; set; }
/// <summary>
/// 手机端才会有
/// </summary>
public List<string> HotelIds { get; set; } = new List<string>();
/// <summary>
/// 子菜单
/// </summary>

View File

@@ -5,7 +5,7 @@ using Dlhis.Sys.Menu.Response;
namespace Dlhis.Sys.Menu.Services;
public interface IMenuService
public interface IMenuService : IScopeDependency
{
Task<List<MenuResponse>> GetListAsync(PlatformEnumType platform);
@@ -13,7 +13,7 @@ public interface IMenuService
Task AssignmentAsync(MenuPermissionAssignmentRequest request);
Task<List<string>> GetAssignmentCodesAsync(MenuPermissionTypeEnumType permissionType, string uniqueData);
Task<List<string>> GetAssignmentCodesAsync(MenuAssignmentTypeEnumType permissionType, string uniqueData);
Task<List<string>> GetAllAssignmentPermissionsAsync();

View File

@@ -2,8 +2,10 @@
using Dlhis.Entity.Sys.Enums;
using Dlhis.Sys.Menu.Request;
using Dlhis.Sys.Menu.Response;
using Dlhis.User.Api;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Attributes;
using Kurisu.SqlSugar.Services;
using Mapster;
@@ -13,11 +15,13 @@ public class MenuService : IMenuService
{
private readonly IDbContext _dbContext;
private readonly ICurrentUser _currentUser;
private readonly IUserApi _userApi;
public MenuService(IDbContext dbContext, ICurrentUser currentUser)
public MenuService(IDbContext dbContext, ICurrentUser currentUser, IUserApi userApi)
{
_dbContext = dbContext;
_currentUser = currentUser;
_userApi = userApi;
}
public async Task<List<MenuResponse>> GetListAsync(PlatformEnumType platform)
@@ -37,6 +41,7 @@ public class MenuService : IMenuService
return top;
}
[Transactional]
public async Task SaveMenuAsync(SaveMenuRequest request)
{
await CheckAsync(request);
@@ -57,27 +62,9 @@ public class MenuService : IMenuService
}
}
private async Task ChangeIfCodeEditAsync(string beforeCode, string pcode)
{
if (beforeCode != pcode)
{
//修改下级的PCode为当前的code
var menus = await _dbContext.Queryable<MenuEntity>().Where(x => x.PCode == beforeCode).ToListAsync();
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; });
await _dbContext.UpdateAsync(menus);
await _dbContext.UpdateAsync(permissions);
}
}
public async Task AssignmentAsync(MenuPermissionAssignmentRequest request)
{
(request.UniqueType == MenuPermissionTypeEnumType.Role).ThrowIfTrue("暂不支持角色分配");
(request.UniqueType == MenuAssignmentTypeEnumType.Role).ThrowIfTrue("暂不支持角色分配");
//清空覆盖
var permissionsToDelete = await _dbContext.Queryable<MenuPermissionEntity>()
@@ -98,15 +85,57 @@ public class MenuService : IMenuService
await _dbContext.InsertAsync(permissions);
}
public Task<List<string>> GetAssignmentCodesAsync(MenuPermissionTypeEnumType permissionType, string uniqueData)
public async Task<List<string>> GetAssignmentCodesAsync(MenuAssignmentTypeEnumType uniqueType, string uniqueData)
{
throw new NotImplementedException();
var permissionCodes = await _dbContext.Queryable<MenuPermissionEntity>()
.Where(x => x.UniqueType == uniqueType)
.Where(x => x.UniqueValue == uniqueData)
.Select(x => x.Code)
.ToListAsync();
var menus = await GetListAsync(PlatformEnumType.PCAdmin);
foreach (var menu in menus)
{
if (menu.Items.Any())
{
var codes = RecursionHandler(menu.Items, permissionCodes);
permissionCodes.RemoveAll(x => codes.Contains(x));
}
}
return permissionCodes;
static List<string> RecursionHandler(List<MenuResponse> menus, List<string> innerPermissions)
{
var codes = new HashSet<string>();
foreach (var menu in menus)
{
if (menu.Items.Any())
{
var innerPermissionCodes = RecursionHandler(menu.Items, innerPermissions);
foreach (var item in innerPermissionCodes)
{
codes.Add(item);
}
}
if (!innerPermissions.Contains(menu.Code))
{
foreach (var item in menu.Items.Select(x => x.Code))
{
codes.Add(item);
}
}
}
return codes.ToList();
}
}
public async Task<List<string>> GetAllAssignmentPermissionsAsync()
{
var all = await GetAllAssignmentCodesAsync();
return await _dbContext.Queryable<MenuEntity>().Where(x => all.Contains(x.Code)).Select(x => x.Permission).ToListAsync();
}
@@ -238,20 +267,34 @@ 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)
var userApiResult = await _userApi.GetUserByIdAsync(_currentUser.GetIntSubjectId());
(userApiResult.Code == Kurisu.Core.Result.ApiStateCode.Success).ThrowIfFalse(userApiResult.Msg);
var user = userApiResult.Data;
// var groupCodes = await GetAssignmentCodesAsync(MenuPermissionTypeEnumType.Group, manager.usergrp);
//user
var userCodes = await GetAssignmentCodesAsync(MenuAssignmentTypeEnumType.User, user.Id.ToString());
var all = userCodes;// gP.Concat(uP).Distinct().ToList();
return all;
}
private async Task ChangeIfCodeEditAsync(string beforeCode, string pcode)
{
return new List<string>();
}
if (beforeCode != pcode)
{
//修改下级的PCode为当前的code
var menus = await _dbContext.Queryable<MenuEntity>().Where(x => x.PCode == beforeCode).ToListAsync();
menus.ForEach(x => { x.PCode = pcode; });
// var gP = await GetAssignmentCodesAsync(MenuPermissionTypeEnumType.Group, manager.usergrp);
//
// //user
// var uP = await GetAssignmentCodesAsync(MenuPermissionTypeEnumType.User, manager.account);
// var all = gP.Concat(uP).Distinct().ToList();
//修改权限code为当前的code,避免权限丢失
var permissions = await _dbContext.Queryable<MenuPermissionEntity>().Where(x => x.Code == beforeCode).ToListAsync();
permissions.ForEach(x => { x.Code = pcode; });
//return all;
return new List<string>();
await _dbContext.UpdateAsync(menus);
await _dbContext.UpdateAsync(permissions);
}
}
}

View File

@@ -1,8 +1,8 @@
using Kurisu.AspNetCore.Startup;
using Kurisu.Startup;
namespace Dlhis.Sys
{
namespace Dlhis.Sys;
class Program
{
static void Main(string[] args)
@@ -18,4 +18,3 @@ namespace Dlhis.Sys
}
}
}

View File

@@ -1,20 +1,12 @@
{
"profiles": {
"Dlhis.Permission": {
"Dlhis.Sys": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5003"
},
"Docker": {
"commandName": "Docker",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_URLS": "http://+:80"
},
"publishAllPorts": true
}
}
}

View File

@@ -0,0 +1,14 @@
using Kurisu.AspNetCore.Startup;
using Kurisu.SqlSugar.Extensions;
namespace Dlhis.Sys;
public class SqlSugarPack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddSqlSugar();
}
}

View File

@@ -4,5 +4,32 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"InternalRequest": {
"CommonRequestUrl": "http://common",
"UserRequestUrl": "http://localhost:5010"
},
"SwaggerOptions": {
"Enable": true,
"Authority": "https://yikatong.isawesome.cn/oauth2",
"ClientId": "4fb184324eac4180",
"ClientSecret": "8ac8f235152f1524",
"Scopes": {
"openid": "openid",
"profile": "profile",
"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"
}
}
}

View File

@@ -6,18 +6,31 @@
}
},
"AllowedHosts": "*",
"InternalRequest": {
"CommonRequestUrl": "http://common",
"UserRequestUrl": "http://user"
},
"SqlSugarOptions": {
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
"SlaveConnectionString": [],
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": true
},
"SwaggerOptions": {
"Enable": true,
"Authority": "https://yikatong.isawesome.cn/oauth2",
"Authority": "http://identity.oauth.svc.cluster.local",
"ClientId": "4fb184324eac4180",
"ClientSecret": "8ac8f235152f1524",
"Scopes": {
"openid": "openid"
"openid": "openid",
"profile": "profile",
"yikatong": "yikatong"
}
},
"IdentityServerOptions": {
"Authority": "https://yikatong.isawesome.cn/oauth2",
"RequireHttpsMetadata": true,
"Authority": "http://identity.oauth.svc.cluster.local",
"RequireHttpsMetadata": false,
"Issuer": "identity.isawesome.cn",
"Audience": "",
"Pat": {

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Kurisu.RemoteCall" Version="0.0.2" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
using Dlhis.User.Api.Response;
using Kurisu.Core.Result;
using Kurisu.RemoteCall.Attributes;
namespace Dlhis.User.Api;
[EnableRemoteClient(Name = "user-service", BaseUrl = "${InternalRequest:UserRequestUrl}")]
public interface IUserApi
{
[Auth]
[Get("/api/users")]
Task<DefaultApiResult<UserResponse>> GetUserByIdAsync(int id);
}

View File

@@ -0,0 +1,28 @@
namespace Dlhis.User.Api.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; }
}

View File

@@ -4,6 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>

View File

@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
namespace Dlhis.User.Identity.Controllers;
/// <summary>
/// 角色
/// </summary>
[Authorize(Roles = "admin")]
[Route("api/[controller]")]
[ApiController]
@@ -19,6 +22,11 @@ public class RolesController : ControllerBase
_roleService = roleService;
}
/// <summary>
/// 获取角色分页
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpGet]
public async Task<Pagination<RoleRespone>> GetPageAsync(RolePageRequest request)
{

View File

@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
namespace Dlhis.User.Identity.Controllers;
/// <summary>
/// 用户
/// </summary>
[Authorize(Roles = "admin")]
[Route("api/[controller]")]
[ApiController]
@@ -29,4 +32,21 @@ public class UsersController : ControllerBase
{
return await _userService.GetPageAsync(request);
}
/// <summary>
/// 获取用户列表
/// </summary>
/// <returns></returns>
[HttpGet("list")]
public async Task<List<UserResponse>> GetUsersAsync()
{
return await _userService.GetUsersAsync();
}
[Authorize]
[HttpGet]
public async Task<UserResponse> GetUserByIdAsync(int id)
{
return await _userService.GetUserByIdAsync(id);
}
}

View File

@@ -9,4 +9,8 @@ public interface IUserService : IScopeDependency
Task<Pagination<UserResponse>> GetPageAsync(UserPageRequest request);
Task ResetAccessFailedCountAsync(int id);
Task<List<UserResponse>> GetUsersAsync();
Task<UserResponse> GetUserByIdAsync(int id);
}

View File

@@ -38,4 +38,17 @@ public class UserService : IUserService
user.AccessFailedCount = 0;
await _dbContext.UpdateAsync(user);
}
public async Task<List<UserResponse>> GetUsersAsync()
{
//todo tenant
var users = await _dbContext.Queryable<UserEntity>().Select<UserResponse>().ToListAsync();
return users;
}
public async Task<UserResponse> GetUserByIdAsync(int id)
{
var user = await _dbContext.Queryable<UserEntity>().Where(x => x.Id == id).Select<UserResponse>().FirstAsync();
return user;
}
}

View File

@@ -1,13 +1,13 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
{
"profiles": {
"Dlhis.User": {
"commandName": "Project",
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5010"
}
}
}
},
"$schema": "https://json.schemastore.org/launchsettings.json"
}