diff --git a/Dlis.Jinko.Yikatong.sln b/Dlis.Jinko.Yikatong.sln
index 5e8e65cf..8818e9f3 100644
--- a/Dlis.Jinko.Yikatong.sln
+++ b/Dlis.Jinko.Yikatong.sln
@@ -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}
diff --git a/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs b/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs
index 9649c414..33b6db3e 100644
--- a/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs
+++ b/Src/Dlhis.Basic/BusinessPlace/Controllers/BusinessPlacesController.cs
@@ -74,6 +74,7 @@ public class BusinessPlacesController : ControllerBase
///
///
///
+ [AllowAnonymous]
[HttpGet("shifts")]
public async Task GetShiftsByPlaceCustomCodeHttpGetAsync([FromQuery] BusinessPlaceGetShiftsRequest request)
{
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
index 6de59649..9ad46959 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
@@ -75,6 +75,7 @@ public class DevicesController : ControllerBase
///
///
///
+ [AllowAnonymous]
[HttpPost("resigter")]
public async Task ResigterAsync(DeviceResigterRequest request)
{
@@ -114,4 +115,14 @@ public class DevicesController : ControllerBase
{
await _deviceConnectService.HeartbeatAsync(request);
}
+
+ ///
+ /// 检查设备是否存在
+ ///
+ ///
+ [HttpGet("exists")]
+ public async Task CheckExistsAsync(string deviceUniqueNo)
+ {
+ return await _deviceService.CheckExistsAsync(deviceUniqueNo);
+ }
}
diff --git a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
index a9a84773..708b947a 100644
--- a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
@@ -9,4 +9,6 @@ public interface IDeviceService : IScopeDependency
Task> GetPageAsync(DevicePageRequest request);
Task SaveAsync(DeviceSaveRequest request);
+
+ Task CheckExistsAsync(string deviceUniqueNo);
}
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs
index 96ffedbd..6a531783 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceConnectService.cs
@@ -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 "设备注册成功";
}
@@ -93,8 +94,8 @@ public class DeviceConnectService : IDeviceConnectService
private async Task GetEnableDeviceAsync(string uniqueNo)
{
var device = await _dbContext.Queryable()
- .Where(x => x.UniqueNo == uniqueNo)
- .FirstAsync();
+ .Where(x => x.UniqueNo == uniqueNo)
+ .FirstAsync();
device.ThrowIfNull($"未知的设备唯一编码{uniqueNo}");
device.Enable.ThrowIfFalse("设备尚未启用");
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index 27496c9f..73d60440 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -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().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 CheckExistsAsync(string deviceUniqueNo)
+ {
+ return await _dbContext.Queryable()
+ .Where(x => x.UniqueNo == deviceUniqueNo && x.Enable)
+ .AnyAsync();
+ }
}
diff --git a/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs b/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs
index 22f0f6ce..56bc97b1 100644
--- a/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs
+++ b/Src/Dlhis.Basic/MealUser/Services/Implements/MealUserService.cs
@@ -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,
diff --git a/Src/Dlhis.Basic/Organization/Controllers/WerksController.cs b/Src/Dlhis.Basic/Organization/Controllers/WerksController.cs
index 8156ff56..bf6b57ca 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/WerksController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/WerksController.cs
@@ -31,4 +31,14 @@ public class WerksController : ControllerBase
{
return await _werkService.GetListAsync();
}
+
+ ///
+ /// 获取当前组织信息
+ ///
+ ///
+ [HttpGet("current")]
+ public async Task GetCurrentAsync()
+ {
+ return await _werkService.GetCurrentAsync();
+ }
}
diff --git a/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs b/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs
index a738acc4..0bfb339b 100644
--- a/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs
+++ b/Src/Dlhis.Basic/Organization/Request/GainfoPageRequest.cs
@@ -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
{
- public class GainfoPageRequest : PageDto
- {
- [EnumDataType(typeof(GainfoStatusEnumType))]
- public GainfoStatusEnumType gainfoStatus { get; set; }
- }
+ ///
+ /// 档案类型
+ ///
+ [EnumDataType(typeof(GainfoStatusEnumType))]
+ public GainfoStatusEnumType Status { get; set; } = GainfoStatusEnumType.Working;
+
+ ///
+ /// 部门号(部门树传入)
+ ///
+ public List DepartmentNos { get; set; }
}
diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
index 6873bb3c..6c2a976b 100644
--- a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
+++ b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
@@ -2,45 +2,47 @@
public class GainfoPageResponse
{
- ///
- /// 档案号
- ///
- public string Guestno { get; set; }
+ public string No { get; set; }
///
/// SAP内部编号
///
- public string Ano { get; set; }
+ public string SapNo { get; set; }
///
/// 人员类型
///
- public string Class { get; set; }
+ public string GType { get; set; }
///
/// 姓名
///
- public string Gname { get; set; }
+ public string Name { get; set; }
+
+ ///
+ /// 外文名字
+ ///
+ public string NameEn { get; set; }
///
/// 工号
///
- public string Ename { get; set; }
+ public string Code { get; set; }
///
/// 国家代码
///
- public string Country { get; set; }
+ public string CountryNo { get; set; }
///
/// 证件类型代码
///
- public string Idcls { get; set; }
+ public string IdClass { get; set; }
///
/// 身份证号
///
- public string IdNO { get; set; }
+ public string IdNo { get; set; }
///
/// 身份证籍贯区域代码
@@ -50,7 +52,7 @@ public class GainfoPageResponse
///
/// 性别
///
- public string Sex { get; set; }
+ public string Gender { get; set; }
///
/// 生日
@@ -65,12 +67,12 @@ public class GainfoPageResponse
///
/// 已婚/未婚
///
- public string Postcode { get; set; }
+ public string Marital { get; set; }
///
/// 部门编码
///
- public string Appellation { get; set; }
+ public string DepartmentNo { get; set; }
///
/// 民族代码
@@ -82,11 +84,6 @@ public class GainfoPageResponse
///
public string Phone { get; set; }
- ///
- /// 联系电话
- ///
- public string Mobile { get; set; }
-
///
/// 学历
///
@@ -95,7 +92,12 @@ public class GainfoPageResponse
///
/// 岗位
///
- public string Web { get; set; }
+ public string Position { get; set; }
+
+ ///
+ /// 卡号
+ ///
+ public string CarNo { get; set; }
///
/// 备注
@@ -103,42 +105,12 @@ public class GainfoPageResponse
public string Remark { get; set; }
///
- /// 操作账号
+ /// 人事范围
///
- public string Log_id { get; set; }
+ public string Werks { get; set; }
///
- /// 操作班次
+ /// 在职状态
///
- public string Log_shift { get; set; }
-
- ///
- /// 操作时间
- ///
- public DateTime Log_date { get; set; }
-
- ///
- /// 操作IP
- ///
- public string Log_ip { get; set; }
-
- ///
- /// 是否在职 F 在职 T离职
- ///
- public string Isowner { get; set; }
-
- ///
- /// 创建时间
- ///
- public DateTime Createdate { get; set; }
-
- ///
- /// 外文名字
- ///
- public string Gname_en { get; set; }
-
- ///
- /// 卡号
- ///
- public string CarNo { get; set; }
+ public string Employed { get; set; }
}
diff --git a/Src/Dlhis.Basic/Organization/Services/IWerkService.cs b/Src/Dlhis.Basic/Organization/Services/IWerkService.cs
index d4207c78..0114d2e7 100644
--- a/Src/Dlhis.Basic/Organization/Services/IWerkService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/IWerkService.cs
@@ -5,4 +5,6 @@ namespace Dlhis.Basic.Organization.Services;
public interface IWerkService : IScopeDependency
{
Task> GetListAsync();
+
+ Task GetCurrentAsync();
}
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index b0d3f707..4ca1306a 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -30,7 +30,7 @@ public class GainfoService : IGainfoService
///
public Task> GetPageAsync(GainfoPageRequest request)
{
- var page = _gainfoStore.Queryable(request.gainfoStatus)
+ var page = _gainfoStore.Queryable(request.Status)
.Select()
.ToPageListAsync(request);
@@ -47,7 +47,7 @@ public class GainfoService : IGainfoService
var gainfos = new List();
GainfoEntity aginfoEntity = request.Adapt();
- 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($"该档案不存在");
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs
index f3bcc871..6bfed005 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoStore.cs
@@ -28,7 +28,7 @@ public class GainfoStore : IGainfoStore
if (gainfoStatus.HasValue && gainfoStatus != GainfoStatusEnumType.Working)
{
var tableName = typeof(GainfoEntity).GetCustomAttribute().TableName;
- return _dbContext.Queryable().AS(tableName + "_" + gainfoStatus);
+ return _dbContext.Queryable().AS(tableName + gainfoStatus);
}
return _dbContext.Queryable();
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/WerkService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/WerkService.cs
index cf7ff67a..e9982a88 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/WerkService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/WerkService.cs
@@ -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> GetListAsync()
@@ -19,4 +22,13 @@ public class WerkService : IWerkService
.Select()
.ToListAsync();
}
+
+ public async Task GetCurrentAsync()
+ {
+ var tenant = _currentUser.GetStringTenantId();
+ return await _dbContext.Queryable()
+ .Where(x => x.Code == tenant)
+ .Select()
+ .FirstAsync();
+ }
}
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
index 4cf8f473..9d8bd945 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
@@ -63,10 +63,10 @@ public class OrderService : IOrderService
.FirstAsync();
var gafinfo = await _dbContext.Queryable()
- .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(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(),
diff --git a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
index 354d9368..79281c0c 100644
--- a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
@@ -79,14 +79,14 @@ public class DeviceEntity : SugarBaseEntity, ITenantId
///
/// 最后使用人
///
- [SugarColumn(ColumnDescription = "最后使用人")]
- public DateTime LastLogId { get; set; }
+ [SugarColumn(IsNullable = true, ColumnDescription = "最后使用人")]
+ public DateTime? LastLogId { get; set; }
///
/// 最后使用日期
///
- [SugarColumn(ColumnDescription = "最后使用日期")]
- public DateTime LastLogDateTime { get; set; }
+ [SugarColumn(IsNullable = true, ColumnDescription = "最后使用日期")]
+ public DateTime? LastLogDateTime { get; set; }
///
diff --git a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs
index 0aa10c72..9c56815a 100644
--- a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs
@@ -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
/// 档案号
///
[SugarColumn(ColumnDescription = "档案号")]
- public string Guestno { get; set; }
+ public string No { get; set; }
///
/// SAP内部编号
///
[SugarColumn(ColumnDescription = "SAP内部编号")]
- public string Ano { get; set; }
+ public string SapNo { get; set; }
///
/// 人员类型
///
[SugarColumn(ColumnDescription = "人员类型")]
- public string Class { get; set; }
+ public string GType { get; set; }
///
/// 姓名
///
[SugarColumn(ColumnDescription = "姓名")]
- public string Gname { get; set; }
+ public string Name { get; set; }
+
+ ///
+ /// 外文名字
+ ///
+ [SugarColumn(ColumnDescription = "外文名字")]
+ public string NameEn { get; set; }
///
/// 工号
///
[SugarColumn(ColumnDescription = "工号")]
- public string Ename { get; set; }
+ public string Code { get; set; }
///
/// 国家代码
///
[SugarColumn(ColumnDescription = "国家代码")]
- public string Country { get; set; }
+ public string CountryNo { get; set; }
///
/// 证件类型代码
///
[SugarColumn(ColumnDescription = "证件类型代码")]
- public string Idcls { get; set; }
+ public string IdClass { get; set; }
///
/// 身份证号
///
[SugarColumn(ColumnDescription = "身份证号")]
- public string IdNO { get; set; }
+ public string IdNo { get; set; }
///
/// 身份证籍贯区域代码
@@ -65,8 +73,8 @@ public class GainfoEntity : SugarBaseEntity
///
/// 性别
///
- [SugarColumn(ColumnDescription = "性别")]
- public string Sex { get; set; }
+ [SugarColumn(ColumnDescription = "性别", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
+ public GenderEnumType Gender { get; set; }
///
/// 生日
@@ -84,13 +92,13 @@ public class GainfoEntity : SugarBaseEntity
/// 已婚/未婚
///
[SugarColumn(ColumnDescription = "已婚/未婚")]
- public string Postcode { get; set; }
+ public string Marital { get; set; }
///
/// 部门编码
///
[SugarColumn(ColumnDescription = "部门编码")]
- public string Appellation { get; set; }
+ public string DepartmentNo { get; set; }
///
/// 民族代码
@@ -104,12 +112,6 @@ public class GainfoEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "手机号码")]
public string Phone { get; set; }
- ///
- /// 联系电话
- ///
- [SugarColumn(ColumnDescription = "联系电话")]
- public string Mobile { get; set; }
-
///
/// 学历
///
@@ -120,55 +122,7 @@ public class GainfoEntity : SugarBaseEntity
/// 岗位
///
[SugarColumn(ColumnDescription = "岗位")]
- public string Web { get; set; }
-
- ///
- /// 备注
- ///
- [SugarColumn(ColumnDescription = "备注")]
- public string Remark { get; set; }
-
- ///
- /// 操作账号
- ///
- [SugarColumn(ColumnDescription = "操作账号")]
- public string Log_id { get; set; }
-
- ///
- /// 操作班次
- ///
- [SugarColumn(ColumnDescription = "操作班次")]
- public string Log_shift { get; set; }
-
- ///
- /// 操作时间
- ///
- [SugarColumn(ColumnDescription = "操作时间")]
- public DateTime Log_date { get; set; }
-
- ///
- /// 操作IP
- ///
- [SugarColumn(ColumnDescription = "操作IP")]
- public string Log_ip { get; set; }
-
- ///
- /// 是否在职 F 在职 T离职
- ///
- [SugarColumn(ColumnDescription = "是否在职 F 在职 T离职")]
- public string Isowner { get; set; }
-
- ///
- /// 创建时间
- ///
- [SugarColumn(ColumnDescription = "创建时间")]
- public DateTime Createdate { get; set; }
-
- ///
- /// 外文名字
- ///
- [SugarColumn(ColumnDescription = "外文名字")]
- public string Gname_en { get; set; }
+ public string Position { get; set; }
///
/// 卡号
@@ -176,6 +130,12 @@ public class GainfoEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "卡号")]
public string CarNo { get; set; }
+ ///
+ /// 备注
+ ///
+ [SugarColumn(ColumnDescription = "备注")]
+ public string Remark { get; set; }
+
///
/// 人事范围
///
@@ -183,14 +143,8 @@ public class GainfoEntity : SugarBaseEntity
public string Werks { get; set; }
///
- /// 人员号
+ /// 在职状态
///
- [SugarColumn(ColumnDescription = "人员号")]
- public string Pernr { get; set; }
-
- ///
- /// 邮箱
- ///
- [SugarColumn(ColumnDescription = "邮箱")]
- public string Email { get; set; }
+ [SugarColumn(ColumnDescription = "在职状态")]
+ public string Employed { get; set; }
}
diff --git a/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs b/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs
index dd5e9c00..517140ea 100644
--- a/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs
+++ b/Src/Dlhis.Entity/Basic/Enums/GainfoStatusEnumType.cs
@@ -9,7 +9,7 @@ namespace Dlhis.Entity.Basic.Enums;
public enum GainfoStatusEnumType
{
///
- ///
+ /// 在职
///
[Description("在职")]
Working = 1,
@@ -21,7 +21,7 @@ public enum GainfoStatusEnumType
Leave = 2,
///
- /// 外部人员
+ /// 外部
///
[Description("外部")]
External = 3
diff --git a/Src/Dlhis.Entity/Basic/Enums/GenderEnumType.cs b/Src/Dlhis.Entity/Basic/Enums/GenderEnumType.cs
new file mode 100644
index 00000000..51b3e6fc
--- /dev/null
+++ b/Src/Dlhis.Entity/Basic/Enums/GenderEnumType.cs
@@ -0,0 +1,25 @@
+using System.ComponentModel;
+
+namespace Dlhis.Entity.Basic.Enums;
+
+[Description("性别类型")]
+public enum GenderEnumType
+{
+ ///
+ /// 女性
+ ///
+ [Description("女性")]
+ Female = 0,
+
+ ///
+ /// 男性
+ ///
+ [Description("男性")]
+ Male = 1,
+
+ ///
+ /// 未知
+ ///
+ [Description("未知")]
+ Unknown = 99,
+}
diff --git a/Src/Dlhis.Entity/Sys/Entities/MenuPermissionEntity.cs b/Src/Dlhis.Entity/Sys/Entities/MenuPermissionEntity.cs
index beb83bb2..e177ad52 100644
--- a/Src/Dlhis.Entity/Sys/Entities/MenuPermissionEntity.cs
+++ b/Src/Dlhis.Entity/Sys/Entities/MenuPermissionEntity.cs
@@ -12,10 +12,10 @@ namespace Dlhis.Entity.Sys.Entities;
public class MenuPermissionEntity : SugarBaseEntity, ITenantId, ISoftDeleted
{
///
- /// 权限类型
+ /// 权限分配类型
///
- [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; }
///
/// 类型值
diff --git a/Src/Dlhis.Entity/Sys/Enums/MenuPermissionTypeEnumType.cs b/Src/Dlhis.Entity/Sys/Enums/MenuAssignmentTypeEnumType.cs
similarity index 87%
rename from Src/Dlhis.Entity/Sys/Enums/MenuPermissionTypeEnumType.cs
rename to Src/Dlhis.Entity/Sys/Enums/MenuAssignmentTypeEnumType.cs
index 6413fb12..0d70d4b4 100644
--- a/Src/Dlhis.Entity/Sys/Enums/MenuPermissionTypeEnumType.cs
+++ b/Src/Dlhis.Entity/Sys/Enums/MenuAssignmentTypeEnumType.cs
@@ -5,8 +5,8 @@ namespace Dlhis.Entity.Sys.Enums;
///
/// 权限类型
///
-[Description("权限类型")]
-public enum MenuPermissionTypeEnumType
+[Description("权限分配类型")]
+public enum MenuAssignmentTypeEnumType
{
///
/// 用户
diff --git a/Src/Dlhis.ScheduledTask/Configurations/ServiceSettings.cs b/Src/Dlhis.ScheduledTask/Configurations/ServiceSettings.cs
index 1c381ff1..6e904403 100644
--- a/Src/Dlhis.ScheduledTask/Configurations/ServiceSettings.cs
+++ b/Src/Dlhis.ScheduledTask/Configurations/ServiceSettings.cs
@@ -3,7 +3,7 @@
namespace Dlhis.ScheduledTask.Configurations
{
- //[Configuration]
+ [Configuration]
public class ServiceSettings
{
public string ServerUrl { get; private set; }
diff --git a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj
index 024b57a4..7893c27b 100644
--- a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj
+++ b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj
@@ -21,6 +21,7 @@
+
diff --git a/Src/Dlhis.ScheduledTask/Dockerfile b/Src/Dlhis.ScheduledTask/Dockerfile
index 2c70e70a..01d8ae26 100644
--- a/Src/Dlhis.ScheduledTask/Dockerfile
+++ b/Src/Dlhis.ScheduledTask/Dockerfile
@@ -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"
diff --git a/Src/Dlhis.ScheduledTask/HangfirePack.cs b/Src/Dlhis.ScheduledTask/HangfirePack.cs
deleted file mode 100644
index 941cd109..00000000
--- a/Src/Dlhis.ScheduledTask/HangfirePack.cs
+++ /dev/null
@@ -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(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_id", s => s.SyncOrgInfo(), "0 0 0 * * ?");
- RecurringJob.AddOrUpdate("SyncPositionJob_id", s =>s.SyncPositionInfo(), "0 0 1 * * ?");
- RecurringJob.AddOrUpdate("SyncPersonJob_id", s => s.SyncPersonInfo(), "0 0 2 * * ?");
-
- }
-
-
- }
-}
diff --git a/Src/Dlhis.ScheduledTask/Job/SyncOrgInfoJob.cs b/Src/Dlhis.ScheduledTask/Job/SyncOrgInfoJob.cs
index 3381dae1..49b6c85b 100644
--- a/Src/Dlhis.ScheduledTask/Job/SyncOrgInfoJob.cs
+++ b/Src/Dlhis.ScheduledTask/Job/SyncOrgInfoJob.cs
@@ -22,9 +22,9 @@ namespace Dlhis.ScheduledTask.Job
_dbContext = dbContext;
}
-
- public async Task SyncOrgInfo()
+
+ public async Task SyncOrgInfo()
{
HttpClient httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMinutes(10);
@@ -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\"}]}}";
@@ -43,7 +42,7 @@ namespace Dlhis.ScheduledTask.Job
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
- ZHRS_ORGResult orgResult = JsonSerializer.Deserialize(responseData);
+ ZHRS_ORGResult orgResult = JsonSerializer.Deserialize(responseData);
if (orgResult.T_ORG != null && orgResult.T_ORG.item.Count > 0)
{
@@ -52,10 +51,10 @@ namespace Dlhis.ScheduledTask.Job
// 使用 SQLSugar 将新数据同步到数据库
await SaveOrg(modifiedOrgList);
}
- //}
- //else
- //{
- // Console.WriteLine($"HTTP请求失败,状态码:{response.StatusCode}");
+ //}
+ //else
+ //{
+ // Console.WriteLine($"HTTP请求失败,状态码:{response.StatusCode}");
}
}
@@ -70,19 +69,17 @@ namespace Dlhis.ScheduledTask.Job
return sapList.Except(needRemove, new ZHRS_ORGComparer()).ToList();
}
- private async Task SaveOrg(List modifiedOrgList)
+ private async Task SaveOrg(List modifiedOrgList)
{
if (modifiedOrgList == null || modifiedOrgList.Count == 0) return;
foreach (ZHRS_ORG item in modifiedOrgList)
{
-
-
var existingOrgs = await _dbContext.Queryable().Where(x => x.OBJID == item.OBJID).FirstAsync();
if (existingOrgs != null)
{
- var org = item.Adapt(existingOrgs);
+ var org = item.Adapt(existingOrgs);
await _dbContext.UpdateAsync(org);
}
else
@@ -90,7 +87,7 @@ namespace Dlhis.ScheduledTask.Job
var org = item.Adapt();
await _dbContext.InsertAsync(org);
}
- }
+ }
}
}
}
diff --git a/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs b/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs
index 33c7793b..833e07b5 100644
--- a/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs
+++ b/Src/Dlhis.ScheduledTask/Job/SyncPersonJob.cs
@@ -82,8 +82,8 @@ namespace Dlhis.ScheduledTask.Job
//var existsWorkCodes = conn.Query($"select ename from gainfo_sap where ename in ( {string.Join(",", searchCodes.Select(x => $"'{x}'"))} )")
// .ToList();
var existsWorkCodes = _dbContext.Queryable()
- .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();
@@ -120,7 +120,7 @@ namespace Dlhis.ScheduledTask.Job
i++;
try
{
- await UpdatePerson(item);
+ await UpdatePerson(item);
//conn.Execute(SqlGeneration.UpdateSql, item);
//log.Debug($"执行更新{i}/{currentTotal} name:{item.gname},ename:{item.ename}");
}
@@ -142,19 +142,18 @@ namespace Dlhis.ScheduledTask.Job
private async Task SavePerson(GainfoSap item)
{
- var gainfo = await _dbContext.Queryable().Where(x => x.IdNO == item.idno).FirstAsync();
+ var gainfo = await _dbContext.Queryable().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().Where(x => x.IdNO == item.idno).FirstAsync();
+ var gainfo = await _dbContext.Queryable().Where(x => x.IdNo == item.idno).FirstAsync();
if (gainfo != null)
{
_dbContext.Updateable().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().Any(g => g.IdNO == item.idno && g.Pernr != item.PERNR && g.Isowner == "T")
- && !_dbContext.Queryable().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().Any(g => g.IdNo == item.idno && g.SapNo != item.PERNR && g.Employed == "T")
+ && !_dbContext.Queryable().Any(g => g.IdNo == item.idno && int.Parse(g.SapNo) > int.Parse(item.PERNR) && g.Employed == item.isowner));
}
else
{
_dbContext.Updateable().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().Any(g => g.Ename == item.ename && g.Isowner == "T")
- && !_dbContext.Queryable().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().Any(g => g.Code == item.ename && g.Employed == "T")
+ && !_dbContext.Queryable().Any(g => g.IdNo == item.idno && int.Parse(g.SapNo) > int.Parse(item.PERNR) && g.Employed == item.isowner));
}
}
diff --git a/Src/Dlhis.ScheduledTask/Packs/HangfirePack.cs b/Src/Dlhis.ScheduledTask/Packs/HangfirePack.cs
new file mode 100644
index 00000000..5453da57
--- /dev/null
+++ b/Src/Dlhis.ScheduledTask/Packs/HangfirePack.cs
@@ -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(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_id", s => s.SyncOrgInfo(), "0 0 0 * * ?");
+ RecurringJob.AddOrUpdate("SyncPositionJob_id", s => s.SyncPositionInfo(), "0 0 1 * * ?");
+ RecurringJob.AddOrUpdate("SyncPersonJob_id", s => s.SyncPersonInfo(), "0 0 2 * * ?");
+ }
+}
diff --git a/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs b/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs
new file mode 100644
index 00000000..ede7092f
--- /dev/null
+++ b/Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs
@@ -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();
+ }
+}
diff --git a/Src/Dlhis.ScheduledTask/Program.cs b/Src/Dlhis.ScheduledTask/Program.cs
index 66b0e63e..281db99e 100644
--- a/Src/Dlhis.ScheduledTask/Program.cs
+++ b/Src/Dlhis.ScheduledTask/Program.cs
@@ -14,6 +14,5 @@ public class Startup : DefaultStartup
{
public Startup(IConfiguration configuration) : base(configuration)
{
-
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/SqlGeneration.cs b/Src/Dlhis.ScheduledTask/SqlGeneration.cs
deleted file mode 100644
index da1e0068..00000000
--- a/Src/Dlhis.ScheduledTask/SqlGeneration.cs
+++ /dev/null
@@ -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;
- }
-}
-
diff --git a/Src/Dlhis.ScheduledTask/SqlSugarPack.cs b/Src/Dlhis.ScheduledTask/SqlSugarPack.cs
deleted file mode 100644
index dec5a3de..00000000
--- a/Src/Dlhis.ScheduledTask/SqlSugarPack.cs
+++ /dev/null
@@ -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();
- var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false)).ToArray();
- db.DbMaintenance.CreateDatabase();
- db.CodeFirst.InitTables(tables);
-#endif
- }
- }
-}
diff --git a/Src/Dlhis.Sys/Dlhis.Sys.csproj b/Src/Dlhis.Sys/Dlhis.Sys.csproj
index 8a6887a8..763d284c 100644
--- a/Src/Dlhis.Sys/Dlhis.Sys.csproj
+++ b/Src/Dlhis.Sys/Dlhis.Sys.csproj
@@ -18,10 +18,12 @@
+
+
diff --git a/Src/Dlhis.Sys/Dockerfile b/Src/Dlhis.Sys/Dockerfile
index d0ee9cec..44238aec 100644
--- a/Src/Dlhis.Sys/Dockerfile
+++ b/Src/Dlhis.Sys/Dockerfile
@@ -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"]
\ No newline at end of file
+ENTRYPOINT ["dotnet", "Dlhis.Sys.dll"]
\ No newline at end of file
diff --git a/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs b/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
index bc162d0b..d301c770 100644
--- a/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
+++ b/Src/Dlhis.Sys/Menu/Controllers/MenusController.cs
@@ -8,6 +8,9 @@ using Dlhis.Entity.Sys.Enums;
namespace Dlhis.Sys.Menu.Controllers;
+///
+/// 菜单
+///
[Authorize]
[Route("api/[controller]")]
[ApiController]
@@ -23,14 +26,11 @@ public class MenusController : ControllerBase
///
/// 菜单列表
///
+ /// 菜单平台类型 PlatformEnumType
///
[HttpGet("list")]
- public async Task> GetListAsync([EnumDataType(typeof(PlatformEnumType))] PlatformEnumType? platform)
+ public async Task> 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
///
/// 当前类型的权限分配
///
- /// 权限类型
+ /// 权限分配类型 MenuAssignmentTypeEnumType
/// 类型对应的唯一值
///
[HttpGet("assignments")]
- public async Task> GetAssignmentsAsync([EnumDataType(typeof(MenuPermissionTypeEnumType))] MenuPermissionTypeEnumType permissionType, [Required] string uniqueValue)
+ public async Task> GetAssignmentsAsync(
+ [EnumDataType(typeof(MenuAssignmentTypeEnumType))] MenuAssignmentTypeEnumType uniqueType,
+ [Required] string uniqueValue)
{
- return await _menuService.GetAssignmentCodesAsync(permissionType, uniqueValue);
+ return await _menuService.GetAssignmentCodesAsync(uniqueType, uniqueValue);
}
///
- /// 获取所有权限分配
+ /// 获取我的所有权限
///
///
[HttpGet("assignments/all")]
@@ -79,7 +81,7 @@ public class MenusController : ControllerBase
}
///
- /// 我的菜单
+ /// 获取我的菜单
///
///
[HttpGet("my")]
@@ -89,7 +91,7 @@ public class MenusController : ControllerBase
}
///
- /// 重置
+ /// 重置所有路由
///
///
///
diff --git a/Src/Dlhis.Sys/Menu/Request/MenuPermissionAssignmentRequest.cs b/Src/Dlhis.Sys/Menu/Request/MenuPermissionAssignmentRequest.cs
index d7945625..09860fb1 100644
--- a/Src/Dlhis.Sys/Menu/Request/MenuPermissionAssignmentRequest.cs
+++ b/Src/Dlhis.Sys/Menu/Request/MenuPermissionAssignmentRequest.cs
@@ -6,10 +6,10 @@ namespace Dlhis.Sys.Menu.Request;
public class MenuPermissionAssignmentRequest
{
///
- /// 权限类型
+ /// 权限类型 MenuAssignmentTypeEnumType
///
- [EnumDataType(typeof(MenuPermissionTypeEnumType))]
- public MenuPermissionTypeEnumType UniqueType { get; set; }
+ [EnumDataType(typeof(MenuAssignmentTypeEnumType))]
+ public MenuAssignmentTypeEnumType UniqueType { get; set; }
///
/// 唯一值
diff --git a/Src/Dlhis.Sys/Menu/Request/SaveMenuRequest.cs b/Src/Dlhis.Sys/Menu/Request/SaveMenuRequest.cs
index 4e72baab..a7f6ae81 100644
--- a/Src/Dlhis.Sys/Menu/Request/SaveMenuRequest.cs
+++ b/Src/Dlhis.Sys/Menu/Request/SaveMenuRequest.cs
@@ -60,13 +60,13 @@ public class SaveMenuRequest : IValidatableObject
public int Sequence { get; set; }
///
- /// 菜单类型
+ /// 菜单类型 MenuEnumType
///
[EnumDataType(typeof(MenuEnumType))]
public MenuEnumType MenuType { get; set; }
///
- /// 平台
+ /// 平台 PlatformEnumType
///
[EnumDataType(typeof(PlatformEnumType))]
public PlatformEnumType Platform { get; set; }
diff --git a/Src/Dlhis.Sys/Menu/Response/MenuResponse.cs b/Src/Dlhis.Sys/Menu/Response/MenuResponse.cs
index cc1400ab..0f84c250 100644
--- a/Src/Dlhis.Sys/Menu/Response/MenuResponse.cs
+++ b/Src/Dlhis.Sys/Menu/Response/MenuResponse.cs
@@ -68,12 +68,6 @@ public class MenuResponse
///
public PlatformEnumType Platform { get; set; }
-
- ///
- /// 手机端才会有
- ///
- public List HotelIds { get; set; } = new List();
-
///
/// 子菜单
///
diff --git a/Src/Dlhis.Sys/Menu/Services/IMenuService.cs b/Src/Dlhis.Sys/Menu/Services/IMenuService.cs
index 5e19b56c..8a1646ba 100644
--- a/Src/Dlhis.Sys/Menu/Services/IMenuService.cs
+++ b/Src/Dlhis.Sys/Menu/Services/IMenuService.cs
@@ -5,7 +5,7 @@ using Dlhis.Sys.Menu.Response;
namespace Dlhis.Sys.Menu.Services;
-public interface IMenuService
+public interface IMenuService : IScopeDependency
{
Task> GetListAsync(PlatformEnumType platform);
@@ -13,7 +13,7 @@ public interface IMenuService
Task AssignmentAsync(MenuPermissionAssignmentRequest request);
- Task> GetAssignmentCodesAsync(MenuPermissionTypeEnumType permissionType, string uniqueData);
+ Task> GetAssignmentCodesAsync(MenuAssignmentTypeEnumType permissionType, string uniqueData);
Task> GetAllAssignmentPermissionsAsync();
diff --git a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
index 5606c08b..10cffed3 100644
--- a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
+++ b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
@@ -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> 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().Where(x => x.PCode == beforeCode).ToListAsync();
- menus.ForEach(x => { x.PCode = pcode; });
-
- //修改权限code为当前的code,避免权限丢失
- var permissions = await _dbContext.Queryable().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()
@@ -98,15 +85,57 @@ public class MenuService : IMenuService
await _dbContext.InsertAsync(permissions);
}
- public Task> GetAssignmentCodesAsync(MenuPermissionTypeEnumType permissionType, string uniqueData)
+ public async Task> GetAssignmentCodesAsync(MenuAssignmentTypeEnumType uniqueType, string uniqueData)
{
- throw new NotImplementedException();
+ var permissionCodes = await _dbContext.Queryable()
+ .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 RecursionHandler(List menus, List innerPermissions)
+ {
+ var codes = new HashSet();
+ 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> GetAllAssignmentPermissionsAsync()
{
var all = await GetAllAssignmentCodesAsync();
-
return await _dbContext.Queryable().Where(x => all.Contains(x.Code)).Select(x => x.Permission).ToListAsync();
}
@@ -238,20 +267,34 @@ public class MenuService : IMenuService
private async Task> GetAllAssignmentCodesAsync()
{
- var user = await _dbContext.Queryable().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)
+ {
+ if (beforeCode != pcode)
{
- return new List();
+ //修改下级的PCode为当前的code
+ var menus = await _dbContext.Queryable().Where(x => x.PCode == beforeCode).ToListAsync();
+ menus.ForEach(x => { x.PCode = pcode; });
+
+ //修改权限code为当前的code,避免权限丢失
+ var permissions = await _dbContext.Queryable().Where(x => x.Code == beforeCode).ToListAsync();
+ permissions.ForEach(x => { x.Code = pcode; });
+
+ await _dbContext.UpdateAsync(menus);
+ await _dbContext.UpdateAsync(permissions);
}
-
- // 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();
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Sys/Program.cs b/Src/Dlhis.Sys/Program.cs
index 2f2202fc..2539a772 100644
--- a/Src/Dlhis.Sys/Program.cs
+++ b/Src/Dlhis.Sys/Program.cs
@@ -1,21 +1,20 @@
using Kurisu.AspNetCore.Startup;
using Kurisu.Startup;
-namespace Dlhis.Sys
+namespace Dlhis.Sys;
+
+class Program
{
- class Program
+ static void Main(string[] args)
{
- static void Main(string[] args)
- {
- KurisuHost.Run(true, args);
- }
+ KurisuHost.Run(true, args);
}
+}
- public class Startup : DefaultStartup
+public class Startup : DefaultStartup
+{
+ public Startup(IConfiguration configuration) : base(configuration)
{
- public Startup(IConfiguration configuration) : base(configuration)
- {
- }
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Sys/Properties/launchSettings.json b/Src/Dlhis.Sys/Properties/launchSettings.json
index b5d66c45..f52c9c8c 100644
--- a/Src/Dlhis.Sys/Properties/launchSettings.json
+++ b/Src/Dlhis.Sys/Properties/launchSettings.json
@@ -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
}
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Sys/SqlSugarPack.cs b/Src/Dlhis.Sys/SqlSugarPack.cs
new file mode 100644
index 00000000..26d783d6
--- /dev/null
+++ b/Src/Dlhis.Sys/SqlSugarPack.cs
@@ -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();
+ }
+}
diff --git a/Src/Dlhis.Sys/appsettings.Development.json b/Src/Dlhis.Sys/appsettings.Development.json
index 0c208ae9..18251b98 100644
--- a/Src/Dlhis.Sys/appsettings.Development.json
+++ b/Src/Dlhis.Sys/appsettings.Development.json
@@ -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"
+ }
}
}
diff --git a/Src/Dlhis.Sys/appsettings.json b/Src/Dlhis.Sys/appsettings.json
index 369aba6b..1b5c78f0 100644
--- a/Src/Dlhis.Sys/appsettings.json
+++ b/Src/Dlhis.Sys/appsettings.json
@@ -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": {
diff --git a/Src/Dlhis.User.Api/Dlhis.User.Api.csproj b/Src/Dlhis.User.Api/Dlhis.User.Api.csproj
new file mode 100644
index 00000000..71b4a337
--- /dev/null
+++ b/Src/Dlhis.User.Api/Dlhis.User.Api.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ disable
+
+
+
+
+
+
+
diff --git a/Src/Dlhis.User.Api/IUserApi.cs b/Src/Dlhis.User.Api/IUserApi.cs
new file mode 100644
index 00000000..1e52028b
--- /dev/null
+++ b/Src/Dlhis.User.Api/IUserApi.cs
@@ -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> GetUserByIdAsync(int id);
+}
\ No newline at end of file
diff --git a/Src/Dlhis.User.Api/Response/UserResponse.cs b/Src/Dlhis.User.Api/Response/UserResponse.cs
new file mode 100644
index 00000000..391341d2
--- /dev/null
+++ b/Src/Dlhis.User.Api/Response/UserResponse.cs
@@ -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; }
+}
diff --git a/Src/Dlhis.User/Dlhis.User.csproj b/Src/Dlhis.User/Dlhis.User.csproj
index 6ac4aa28..b15a865e 100644
--- a/Src/Dlhis.User/Dlhis.User.csproj
+++ b/Src/Dlhis.User/Dlhis.User.csproj
@@ -4,6 +4,8 @@
net6.0
disable
enable
+ Linux
+ ..\..
diff --git a/Src/Dlhis.User/Identity/Controllers/RolesController.cs b/Src/Dlhis.User/Identity/Controllers/RolesController.cs
index 0f8e0f99..be7468ac 100644
--- a/Src/Dlhis.User/Identity/Controllers/RolesController.cs
+++ b/Src/Dlhis.User/Identity/Controllers/RolesController.cs
@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
namespace Dlhis.User.Identity.Controllers;
+///
+/// 角色
+///
[Authorize(Roles = "admin")]
[Route("api/[controller]")]
[ApiController]
@@ -19,6 +22,11 @@ public class RolesController : ControllerBase
_roleService = roleService;
}
+ ///
+ /// 获取角色分页
+ ///
+ ///
+ ///
[HttpGet]
public async Task> GetPageAsync(RolePageRequest request)
{
diff --git a/Src/Dlhis.User/Identity/Controllers/UsersController.cs b/Src/Dlhis.User/Identity/Controllers/UsersController.cs
index 0700500c..e0d5d519 100644
--- a/Src/Dlhis.User/Identity/Controllers/UsersController.cs
+++ b/Src/Dlhis.User/Identity/Controllers/UsersController.cs
@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
namespace Dlhis.User.Identity.Controllers;
+///
+/// 用户
+///
[Authorize(Roles = "admin")]
[Route("api/[controller]")]
[ApiController]
@@ -29,4 +32,21 @@ public class UsersController : ControllerBase
{
return await _userService.GetPageAsync(request);
}
+
+ ///
+ /// 获取用户列表
+ ///
+ ///
+ [HttpGet("list")]
+ public async Task> GetUsersAsync()
+ {
+ return await _userService.GetUsersAsync();
+ }
+
+ [Authorize]
+ [HttpGet]
+ public async Task GetUserByIdAsync(int id)
+ {
+ return await _userService.GetUserByIdAsync(id);
+ }
}
diff --git a/Src/Dlhis.User/Identity/Services/IUserService.cs b/Src/Dlhis.User/Identity/Services/IUserService.cs
index 227bdf6e..e07ac0d6 100644
--- a/Src/Dlhis.User/Identity/Services/IUserService.cs
+++ b/Src/Dlhis.User/Identity/Services/IUserService.cs
@@ -9,4 +9,8 @@ public interface IUserService : IScopeDependency
Task> GetPageAsync(UserPageRequest request);
Task ResetAccessFailedCountAsync(int id);
+
+ Task> GetUsersAsync();
+
+ Task GetUserByIdAsync(int id);
}
diff --git a/Src/Dlhis.User/Identity/Services/Implements/UserService.cs b/Src/Dlhis.User/Identity/Services/Implements/UserService.cs
index b4c0844a..e7ebc36a 100644
--- a/Src/Dlhis.User/Identity/Services/Implements/UserService.cs
+++ b/Src/Dlhis.User/Identity/Services/Implements/UserService.cs
@@ -38,4 +38,17 @@ public class UserService : IUserService
user.AccessFailedCount = 0;
await _dbContext.UpdateAsync(user);
}
+
+ public async Task> GetUsersAsync()
+ {
+ //todo tenant
+ var users = await _dbContext.Queryable().Select().ToListAsync();
+ return users;
+ }
+
+ public async Task GetUserByIdAsync(int id)
+ {
+ var user = await _dbContext.Queryable().Where(x => x.Id == id).Select().FirstAsync();
+ return user;
+ }
}
diff --git a/Src/Dlhis.User/Properties/launchSettings.json b/Src/Dlhis.User/Properties/launchSettings.json
index ebd6db88..67846e57 100644
--- a/Src/Dlhis.User/Properties/launchSettings.json
+++ b/Src/Dlhis.User/Properties/launchSettings.json
@@ -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"
+}
\ No newline at end of file