添加项目文件。
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://gitee.com/dotnetmoyu/MoYu/raw/v4/schemas/v4/MoYu-schema.json",
|
||||
//swagger分组设置
|
||||
"[openapi:Application]": {
|
||||
"Order": 90, //分组排序,int 类型,数字越大排前面,默认 0
|
||||
"Title": "业务模块" //配置分组标题,string 类型
|
||||
},
|
||||
//系统层设置
|
||||
"ApplicationSettings": {
|
||||
"InitTable": false, //是否初始化表结构
|
||||
"InitSeedData": false //是否初始化种子数据
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://gitee.com/dotnetmoyu/MoYu/raw/v4/schemas/v4/MoYu-schema.json",
|
||||
//swagger分组设置
|
||||
"[openapi:Application]": {
|
||||
"Order": 90, //分组排序,int 类型,数字越大排前面,默认 0
|
||||
"Title": "业务模块" //配置分组标题,string 类型
|
||||
},
|
||||
//系统层设置
|
||||
"ApplicationSettings": {
|
||||
"InitTable": false, //是否初始化表结构
|
||||
"InitSeedData": false, //是否初始化种子数据0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
public class ApplicationConst
|
||||
{
|
||||
#region 别称
|
||||
|
||||
/// <summary>
|
||||
/// 机构
|
||||
/// </summary>
|
||||
public const string BIZ_ORG = "机构";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 岗位
|
||||
/// </summary>
|
||||
public const string BIZ_POS = "岗位";
|
||||
|
||||
#endregion 别称
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 代码生成基础
|
||||
///</summary>
|
||||
[SugarTable("gen_test", TableDescription = "代码生成测试")]
|
||||
[Tenant(SqlSugarConst.DB_DEFAULT)]
|
||||
[CodeGen]
|
||||
public class GenTest : DataEntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 姓名
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
public string Sex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 民族
|
||||
/// </summary>
|
||||
public string Nation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年龄
|
||||
/// </summary>
|
||||
|
||||
public int Age { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生日
|
||||
/// </summary>
|
||||
public DateTime Bir { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存款
|
||||
/// </summary>
|
||||
public decimal Money { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序码
|
||||
///</summary>
|
||||
public int SortCode { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Entity
|
||||
{
|
||||
[SugarTable("WeiBingJu_Medicinal", TableDescription = "药材管理")]
|
||||
[Tenant(SqlSugarConst.DB_DEFAULT)]
|
||||
[CodeGen]
|
||||
public class Medicinal : DataEntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 药材
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "药材")]
|
||||
public string MedicinalName { get; set; }
|
||||
/// <summary>
|
||||
/// 数量(g)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "数量(g)")]
|
||||
public decimal Number { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Entity
|
||||
{
|
||||
[SugarTable("WeiBingJu_MedicinalAddLog", TableDescription = "药材添加记录")]
|
||||
[Tenant(SqlSugarConst.DB_DEFAULT)]
|
||||
[CodeGen]
|
||||
public class MedicinalAddLog : DataEntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 药材关联id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "药材关联id")]
|
||||
public long MedicinalId { get; set; }
|
||||
/// <summary>
|
||||
/// 添加重量(g)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "添加重量(g)")]
|
||||
public decimal AddWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 药材单价
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "药材单价")]
|
||||
public decimal UnitPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总价
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "总价")]
|
||||
public decimal TotalPrice { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Entity
|
||||
{
|
||||
[SugarTable("WeiBingJu_Person", TableDescription = "人员表(员工和员工亲戚)")]
|
||||
[Tenant(SqlSugarConst.DB_DEFAULT)]
|
||||
[CodeGen]
|
||||
public class Person : DataEntityBase
|
||||
{
|
||||
[SugarColumn(Length = 128, ColumnDescription = "姓名")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 若非空,表示此 person 是某员工的家属
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "关联员工Id", IsNullable = true)]
|
||||
public long? EmployeeId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDescription = "关系配置id", IsNullable = true)]
|
||||
public long? RelationShip { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDescription = "出生日期", IsNullable = true)]
|
||||
public string Birthday { get; set; }
|
||||
|
||||
/// <summary>单位 cm,保留两位小数</summary>
|
||||
[SugarColumn(ColumnDescription = "身高(cm)", IsNullable = true)]
|
||||
public decimal? Height { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Entity
|
||||
{
|
||||
[SugarTable("WeiBingJu_Prescription", TableDescription = "处方管理")]
|
||||
[Tenant(SqlSugarConst.DB_DEFAULT)]
|
||||
[CodeGen]
|
||||
public class Prescription : DataEntityBase
|
||||
{
|
||||
[SugarColumn(ColumnDescription = "处方对象 PersonId")]
|
||||
public long PersonId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDescription = "诊断结果", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string DiagnosisResult { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDescription = "用药建议", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string UserMedicinaAdvice { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDescription = "就诊时间")]
|
||||
public DateTime? VisitDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>单位 kg,保留两位小数</summary>
|
||||
[SugarColumn(ColumnDescription = "体重(kg)", IsNullable = true)]
|
||||
public decimal? Weight { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Entity
|
||||
{
|
||||
[SugarTable("WeiBingJu_PrescriptionHerb", TableDescription = "处方消耗药材表")]
|
||||
[Tenant(SqlSugarConst.DB_DEFAULT)]
|
||||
[CodeGen]
|
||||
public class PrescriptionHerb : DataEntityBase
|
||||
{
|
||||
[SugarColumn(ColumnDescription = "处方Id")]
|
||||
public long PrescriptionId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDescription = "药材Id")]
|
||||
public long MedicinalId { get; set; }
|
||||
|
||||
/// <summary>消耗克数,单位 g</summary>
|
||||
[SugarColumn(ColumnDescription = "消耗(g)")]
|
||||
public decimal AmountG { get; set; }
|
||||
|
||||
[SugarColumn(Length = 500, IsNullable = true, ColumnDescription = "用量说明/备注")]
|
||||
public string Note { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
global using MoYu;
|
||||
global using MoYu.DependencyInjection;
|
||||
global using MoYu.FriendlyException;
|
||||
global using Mapster;
|
||||
global using Microsoft.AspNetCore.Builder;
|
||||
global using Microsoft.AspNetCore.Hosting;
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
global using Microsoft.Extensions.DependencyInjection;
|
||||
global using SimpleAdmin.Cache;
|
||||
global using SimpleAdmin.Core;
|
||||
global using SimpleAdmin.Core.Extension;
|
||||
global using SimpleAdmin.SqlSugar;
|
||||
global using SimpleAdmin.System;
|
||||
global using SqlSugar;
|
||||
global using System.Reflection;
|
||||
global using SimpleAdmin.Application.Services.Medicinal;
|
||||
global using SimpleAdmin.Application.Services.Medicinal.Dto;
|
||||
global using SimpleAdmin.Application.Services.Prescription;
|
||||
global using SimpleAdmin.Application.Services.Prescription.Dto;
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using MoYu.ConfigurableOptions;
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 系统配置
|
||||
/// </summary>
|
||||
public class ApplicationSettingsOptions : BaseOptions, IConfigurableOptions
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Services.Medicinal.Dto
|
||||
{
|
||||
// 药材列表DTO
|
||||
public class MedicinalDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string MedicinalName { get; set; }
|
||||
public decimal Stock { get; set; }
|
||||
public decimal UsedCost { get; set; }
|
||||
public decimal RemainingValue { get; set; }
|
||||
public decimal TotalUsedWeight { get; set; }
|
||||
}
|
||||
|
||||
// 药材消耗记录DTO
|
||||
public class MedicinalConsumptionRecordDto
|
||||
{
|
||||
public decimal AmountG { get; set; }
|
||||
public string PersonName { get; set; }
|
||||
public bool IsRelative { get; set; }
|
||||
public string EmployeeName { get; set; }
|
||||
public DateTime? UseTime { get; set; }
|
||||
}
|
||||
|
||||
// 药材添加记录DTO
|
||||
public class MedicinalAddLogDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public decimal AddWeight { get; set; }
|
||||
public decimal UnitPrice { get; set; }
|
||||
public DateTime AddTime { get; set; }
|
||||
public string AddUserName { get; set; }
|
||||
public decimal TotalPrice { get; set; }
|
||||
|
||||
public bool CanEdit { get; set; }
|
||||
}
|
||||
|
||||
// 添加药材输入DTO
|
||||
public class AddMedicinalInput
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public decimal AddWeight { get; set; }
|
||||
public decimal TotalPrice { get; set; }
|
||||
/// <summary>
|
||||
/// 未找到下拉框的时候传这个值代表添加新的药材
|
||||
/// </summary>
|
||||
public string MedicinalName { get; set; }
|
||||
}
|
||||
|
||||
// 修改药材添加记录输入DTO
|
||||
public class UpdateMedicinalAddLogInput
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public decimal AddWeight { get; set; }
|
||||
public decimal TotalPrice { get; set; }
|
||||
}
|
||||
|
||||
// 药材类型DTO
|
||||
public class MedicinalTypeDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
// 添加药材类型输入DTO
|
||||
public class AddMedicinalTypeInput
|
||||
{
|
||||
[Required(ErrorMessage = "药材名称不能为空")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class DeleteMedicinalLog
|
||||
{
|
||||
public long Id { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Services.Medicinal
|
||||
{
|
||||
public interface IMedicinalService : ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取药材列表,带筛选
|
||||
/// </summary>
|
||||
/// <param name="name">药材名称筛选</param>
|
||||
/// <param name="page">页码</param>
|
||||
/// <param name="size">页大小</param>
|
||||
/// <returns></returns>
|
||||
Task<SqlSugarPagedList<MedicinalDto>> GetMedicinalList(string medicinalName, int page, int size);
|
||||
|
||||
/// <summary>
|
||||
/// 获取药材消耗记录
|
||||
/// </summary>
|
||||
/// <param name="medicinalId">药材ID</param>
|
||||
/// <returns></returns>
|
||||
Task<SqlSugarPagedList<MedicinalConsumptionRecordDto>> GetConsumptionRecords(long medicinalId, int page, int size);
|
||||
/// <summary>
|
||||
/// 获取药材下拉
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<MedicinalDto>> GetMedicinalDictList();
|
||||
|
||||
/// <summary>
|
||||
/// 获取药材添加记录
|
||||
/// </summary>
|
||||
/// <param name="medicinalId">药材ID</param>
|
||||
/// <returns></returns>
|
||||
Task<SqlSugarPagedList<MedicinalAddLogDto>> GetAdditionRecords(long medicinalId, int page, int size);
|
||||
|
||||
/// <summary>
|
||||
/// 添加药材
|
||||
/// </summary>
|
||||
/// <param name="input">添加信息</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddMedicinal(AddMedicinalInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 修改药材添加记录(仅当天可修改)
|
||||
/// </summary>
|
||||
/// <param name="id">记录ID</param>
|
||||
/// <param name="input">修改信息</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateAdditionRecord(UpdateMedicinalAddLogInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 删除药材添加记录(仅当天可删除)
|
||||
/// </summary>
|
||||
/// <param name="id">记录ID</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteAdditionRecord(long id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System.Linq.Dynamic.Core;
|
||||
using SimpleAdmin.Application.Entity;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
public class MedicinalService : DbRepository<Medicinal>, IMedicinalService
|
||||
{
|
||||
private readonly ISysUserService _sysUserService;
|
||||
private readonly IDictService _dictService;
|
||||
public MedicinalService(ISysUserService sysUserService, IDictService dictService)
|
||||
{
|
||||
_sysUserService = sysUserService;
|
||||
_dictService = dictService;
|
||||
}
|
||||
public async Task<SqlSugarPagedList<MedicinalDto>> GetMedicinalList(string medicinalName, int page, int size)
|
||||
{
|
||||
// 1. 获取数据范围(原有逻辑不变)
|
||||
//var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
//dataScope?.Remove(UserManager.OrgId);
|
||||
|
||||
// 2. 分页查询药材基本信息(1次查询,原有逻辑不变)
|
||||
var query = this.AsQueryable()
|
||||
//.WhereIF(dataScope.Any(), m => dataScope.Contains(m.Id))
|
||||
.WhereIF(!string.IsNullOrEmpty(medicinalName), m => m.MedicinalName.Contains(medicinalName))
|
||||
.OrderBy(p => p.Number)
|
||||
.Select(m => new MedicinalDto
|
||||
{
|
||||
Id = m.Id,
|
||||
MedicinalName = m.MedicinalName,
|
||||
Stock = m.Number, // 当前库存
|
||||
});
|
||||
|
||||
var pageInfo = await query.ToPagedListAsync(page, size);
|
||||
if (!pageInfo.List.Any()) return pageInfo;
|
||||
|
||||
// 3. 批量计算:成本、剩余价值、总使用量(仅2次查询,无循环查询)
|
||||
var medicinalIds = pageInfo.List.Select(dto => dto.Id).ToList();
|
||||
var costAndUsageDict = await BatchCalculateCostAndValue(medicinalIds);
|
||||
|
||||
// 4. 内存中赋值所有指标(无数据库查询)
|
||||
foreach (var item in pageInfo.List)
|
||||
{
|
||||
if (costAndUsageDict.TryGetValue(item.Id, out var metrics))
|
||||
{
|
||||
item.UsedCost = metrics.usedCost; // 使用成本
|
||||
item.RemainingValue = metrics.remainingValue; // 剩余价值
|
||||
item.TotalUsedWeight = metrics.totalUsedWeight; // 新增:总使用量
|
||||
}
|
||||
else
|
||||
{
|
||||
// 无数据时默认值
|
||||
item.UsedCost = 0;
|
||||
item.RemainingValue = 0;
|
||||
item.TotalUsedWeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取药材下拉
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MedicinalDto>> GetMedicinalDictList()
|
||||
{
|
||||
////获取数据范围
|
||||
//var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
//dataScope?.Remove(UserManager.OrgId);
|
||||
//药材查询
|
||||
return await this.AsQueryable()
|
||||
//.WhereIF(dataScope.Any(), m => dataScope.Contains(m.Id)) //机构ID查询
|
||||
.OrderBy(p => p.Number)
|
||||
.Select(m => new MedicinalDto
|
||||
{
|
||||
Id = m.Id,
|
||||
MedicinalName = m.MedicinalName,
|
||||
Stock = m.Number,
|
||||
}).ToListAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取药材消耗记录
|
||||
/// </summary>
|
||||
/// <param name="medicinalId"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
public async Task<SqlSugarPagedList<MedicinalConsumptionRecordDto>> GetConsumptionRecords(long medicinalId, int page, int size)
|
||||
{
|
||||
return await Context.Queryable<PrescriptionHerb>()
|
||||
// 先关联处方
|
||||
.LeftJoin<Prescription>((ph, p) => ph.PrescriptionId == p.Id)
|
||||
// 再关联就诊人
|
||||
.LeftJoin<Person>((ph, p, pe) => p.PersonId == pe.Id)
|
||||
// 再关联员工
|
||||
.LeftJoin<Person>((ph, p, pe, emp) => pe.EmployeeId != null && pe.EmployeeId == emp.Id)
|
||||
// 条件也使用多参数
|
||||
.Where((ph, p, pe, emp) => ph.MedicinalId == medicinalId)
|
||||
.OrderByDescending((ph, p, pe, emp) => p.VisitDate)
|
||||
// 投影使用所有表别名
|
||||
.Select((ph, p, pe, emp) => new MedicinalConsumptionRecordDto
|
||||
{
|
||||
AmountG = ph.AmountG,
|
||||
PersonName = pe.Name,
|
||||
IsRelative = pe.EmployeeId != null,
|
||||
EmployeeName = emp == null ? null : emp.Name,
|
||||
UseTime = p.VisitDate
|
||||
})
|
||||
// 分页
|
||||
.ToPagedListAsync(page, size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取药材添加记录
|
||||
/// </summary>
|
||||
/// <param name="medicinalId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SqlSugarPagedList<MedicinalAddLogDto>> GetAdditionRecords(long medicinalId, int page, int size)
|
||||
{
|
||||
var returnList = await Context.Queryable<MedicinalAddLog>()
|
||||
.Where(log => log.MedicinalId == medicinalId)
|
||||
.OrderByDescending(dto => dto.CreateTime)
|
||||
.Select(log => new MedicinalAddLogDto
|
||||
{
|
||||
Id = log.Id,
|
||||
AddWeight = log.AddWeight,
|
||||
UnitPrice = log.UnitPrice,
|
||||
AddTime = log.CreateTime.Value,
|
||||
AddUserName = log.CreateUser,
|
||||
TotalPrice = log.TotalPrice,
|
||||
CanEdit = false
|
||||
})
|
||||
.ToPagedListAsync(page, size);
|
||||
|
||||
foreach (var item in returnList.List)
|
||||
{
|
||||
if (item.AddTime.Date == DateTime.Now.Date)
|
||||
{
|
||||
item.CanEdit = true;
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加药材
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddMedicinal(AddMedicinalInput input)
|
||||
{
|
||||
if (input.TotalPrice <= 0 || input.AddWeight <= 0) throw Oops.Bah("请填写正确的金额或者重量!");
|
||||
// 开启事务
|
||||
await Context.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
// 检查药材是否已存在
|
||||
var existing = await Context.Queryable<Medicinal>()
|
||||
.Where(m => m.Id == input.Id)
|
||||
.FirstAsync();
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
// 更新库存
|
||||
existing.Number += input.AddWeight;
|
||||
await Context.Updateable(existing).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var medicinalModel = await Context.Queryable<Medicinal>()
|
||||
.Where(m => m.MedicinalName == input.MedicinalName)
|
||||
.FirstAsync();
|
||||
if (medicinalModel != null) throw Oops.Bah("已存在该药材,请在下拉框选择!");
|
||||
input.Id = YitIdHelper.NextId();
|
||||
// 新增药材记录
|
||||
await Context.Insertable(new Medicinal
|
||||
{
|
||||
Id = input.Id.Value,
|
||||
Number = input.AddWeight,
|
||||
MedicinalName = input.MedicinalName,
|
||||
}).ExecuteCommandAsync();
|
||||
}
|
||||
decimal unitPrice = 0m;
|
||||
if (input.AddWeight > 0)
|
||||
{
|
||||
unitPrice = Decimal.Round(input.TotalPrice / input.AddWeight, 2, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
// 添加记录
|
||||
await Context.Insertable(new MedicinalAddLog
|
||||
{
|
||||
MedicinalId = input.Id.Value,
|
||||
AddWeight = input.AddWeight,
|
||||
UnitPrice = unitPrice,
|
||||
TotalPrice = input.TotalPrice
|
||||
}).ExecuteCommandAsync();
|
||||
|
||||
await Context.Ado.CommitTranAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await Context.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改药材添加记录
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<bool> UpdateAdditionRecord(UpdateMedicinalAddLogInput input)
|
||||
{
|
||||
if(input.TotalPrice<=0 || input.AddWeight<=0) throw Oops.Bah("请填写正确的金额或者重量!");
|
||||
var log = await Context.Queryable<MedicinalAddLog>().Where(l => l.Id == input.Id).FirstAsync();
|
||||
if (log == null)
|
||||
{
|
||||
throw Oops.Bah("记录不存在!");
|
||||
}
|
||||
|
||||
// 检查是否是当天记录
|
||||
if (log.CreateTime.Value.Date != DateTime.Now.Date)
|
||||
{
|
||||
throw Oops.Bah("只能修改当天的记录!");
|
||||
}
|
||||
|
||||
// 计算重量变化
|
||||
var weightDiff = input.AddWeight - log.AddWeight;
|
||||
|
||||
// 开启事务
|
||||
await Context.Ado.BeginTranAsync();
|
||||
|
||||
try
|
||||
{
|
||||
// 更新记录
|
||||
log.AddWeight = input.AddWeight;
|
||||
log.TotalPrice = input.TotalPrice;
|
||||
log.UnitPrice = Decimal.Round(input.TotalPrice / input.AddWeight, 2, MidpointRounding.AwayFromZero);
|
||||
await Context.Updateable(log).ExecuteCommandAsync();
|
||||
|
||||
// 更新药材库存
|
||||
var medicinal = await Context.Queryable<Medicinal>()
|
||||
.Where(m => m.Id == log.MedicinalId)
|
||||
.FirstAsync();
|
||||
|
||||
if (medicinal != null)
|
||||
{
|
||||
medicinal.Number += weightDiff;
|
||||
if(medicinal.Number<0) throw Oops.Bah("无法修改,库存不足!");
|
||||
await Context.Updateable(medicinal).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await Context.Ado.CommitTranAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await Context.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除药材添加记录
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<bool> DeleteAdditionRecord(long id)
|
||||
{
|
||||
var log = await Context.Queryable<MedicinalAddLog>().Where(l => l.Id == id).FirstAsync();
|
||||
if (log == null)
|
||||
{
|
||||
throw Oops.Bah("记录不存在!");
|
||||
}
|
||||
|
||||
// 检查是否是当天记录
|
||||
if (log.CreateTime.Value.Date != DateTime.Now.Date)
|
||||
{
|
||||
throw Oops.Bah("只能删除当天的记录!");
|
||||
}
|
||||
|
||||
// 开启事务
|
||||
await Context.Ado.BeginTranAsync();
|
||||
|
||||
try
|
||||
{
|
||||
// 删除记录
|
||||
log.IsDelete = true;
|
||||
await Context.Updateable(log).ExecuteCommandAsync();
|
||||
|
||||
|
||||
// 更新药材库存
|
||||
var medicinal = await Context.Queryable<Medicinal>()
|
||||
.Where(m => m.Id == log.MedicinalId)
|
||||
.FirstAsync();
|
||||
|
||||
if (medicinal != null)
|
||||
{
|
||||
medicinal.Number -= log.AddWeight;
|
||||
if(medicinal.Number<0) throw Oops.Bah("无法删除,库存不足!");
|
||||
await Context.Updateable(medicinal).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await Context.Ado.CommitTranAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await Context.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量计算:使用成本、剩余价值、总使用量(先进先出法)
|
||||
/// </summary>
|
||||
/// <param name="medicinalIds">需要计算的药材ID列表</param>
|
||||
private async Task<Dictionary<long, (
|
||||
decimal usedCost,//预估花费
|
||||
decimal remainingValue,//预估剩余价值
|
||||
decimal totalUsedWeight//使用总量
|
||||
)>> BatchCalculateCostAndValue(List<long> medicinalIds)
|
||||
{
|
||||
var result = new Dictionary<long, (decimal, decimal, decimal)>();
|
||||
if (!medicinalIds.Any()) return result;
|
||||
|
||||
// 1. 批量查询所有药材的【当前库存】(1次查询)
|
||||
var medicinals = await Context.Queryable<Medicinal>()
|
||||
.Where(m => medicinalIds.Contains(m.Id))
|
||||
.Select(m => new { m.Id, m.Number }) // Number = 当前库存
|
||||
.ToListAsync();
|
||||
|
||||
// 2. 批量查询所有药材的【入库记录】(1次查询,仅查需要的字段)
|
||||
var allAddLogs = await Context.Queryable<MedicinalAddLog>()
|
||||
.Where(l => medicinalIds.Contains(l.MedicinalId))
|
||||
.OrderBy(l => l.CreateTime) // 先进先出:按入库时间排序
|
||||
.Select(l => new {
|
||||
l.MedicinalId,
|
||||
l.AddWeight, // 入库量
|
||||
l.UnitPrice, // 单价(用于计算成本)
|
||||
l.TotalPrice // 总成本(用于计算成本)
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// 3. 按【药材ID】分组入库记录(内存处理,无数据库查询)
|
||||
var groupedLogs = allAddLogs
|
||||
.GroupBy(l => l.MedicinalId)
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
|
||||
// 4. 遍历每个药材,内存中计算所有指标
|
||||
foreach (var med in medicinals)
|
||||
{
|
||||
// 初始化默认值(无入库记录时)
|
||||
decimal totalIn = 0; // 总入库量(AddWeight 总和)
|
||||
decimal totalCost = 0; // 总入库成本
|
||||
decimal totalUsedWeight = 0; // 总使用量
|
||||
decimal usedCost = 0; // 使用成本
|
||||
decimal remainingValue = 0;// 剩余价值
|
||||
|
||||
// 若有入库记录,计算总入库量、总成本
|
||||
if (groupedLogs.TryGetValue(med.Id, out var addLogs) && addLogs.Any())
|
||||
{
|
||||
totalIn = addLogs.Sum(l => l.AddWeight); // 总入库量 = 所有 AddWeight 求和
|
||||
totalCost = addLogs.Sum(l => l.TotalPrice); // 总入库成本
|
||||
}
|
||||
|
||||
// 计算总使用量:总入库量 - 当前库存(若结果为负,说明数据异常,按0处理)
|
||||
totalUsedWeight = Math.Max(0, totalIn - med.Number);
|
||||
|
||||
// 若有使用量,继续用先进先出法计算使用成本
|
||||
if (totalUsedWeight > 0 && groupedLogs.TryGetValue(med.Id, out var validLogs))
|
||||
{
|
||||
decimal remainingToCalculate = totalUsedWeight;
|
||||
foreach (var log in validLogs)
|
||||
{
|
||||
if (remainingToCalculate <= 0) break;
|
||||
|
||||
// 当前入库记录的量 <= 剩余未计算的使用量:全部计入成本
|
||||
if (log.AddWeight <= remainingToCalculate)
|
||||
{
|
||||
usedCost += log.AddWeight * log.UnitPrice;
|
||||
remainingToCalculate -= log.AddWeight;
|
||||
}
|
||||
// 当前入库记录的量 > 剩余未计算的使用量:仅计算剩余部分
|
||||
else
|
||||
{
|
||||
usedCost += remainingToCalculate * log.UnitPrice;
|
||||
remainingToCalculate = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 剩余价值 = 总入库成本 - 使用成本(若为负,按0处理)
|
||||
remainingValue = Math.Max(0, totalCost - usedCost);
|
||||
|
||||
// 存入结果字典
|
||||
result[med.Id] = (usedCost, remainingValue, totalUsedWeight);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 机构服务
|
||||
/// </summary>
|
||||
public interface IOrgService : ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加机构
|
||||
/// </summary>
|
||||
/// <param name="input">添加参数</param>
|
||||
/// <returns></returns>
|
||||
Task Add(SysOrgAddInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 复制机构
|
||||
/// </summary>
|
||||
/// <param name="input">机构复制参数</param>
|
||||
/// <returns></returns>
|
||||
Task Copy(SysOrgCopyInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 删除机构
|
||||
/// </summary>
|
||||
/// <param name="input">删除参数</param>
|
||||
/// <returns></returns>
|
||||
Task Delete(BaseIdListInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 编辑机构
|
||||
/// </summary>
|
||||
/// <param name="input">编辑参数</param>
|
||||
/// <returns></returns>
|
||||
Task Edit(SysOrgEditInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 机构分页查询
|
||||
/// </summary>
|
||||
/// <param name="input">查询参数</param>
|
||||
/// <returns>分页信息</returns>
|
||||
Task<SqlSugarPagedList<SysOrg>> Page(SysOrgPageInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 机构树结构
|
||||
/// </summary>
|
||||
/// <param name="input">机构选择器</param>
|
||||
/// <returns></returns>
|
||||
Task<List<SysOrg>> Tree(SysOrgTreeInput input = null);
|
||||
|
||||
/// <summary>
|
||||
/// 机构详情
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<SysOrg> Detail(BaseIdInput input);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <inheritdoc cref="IOrgService"/>
|
||||
public class OrgService : DbRepository<SysOrg>, IOrgService
|
||||
{
|
||||
private readonly ISysOrgService _sysOrgService;
|
||||
private readonly ISysUserService _sysUserService;
|
||||
|
||||
public OrgService(ISysOrgService sysOrgService, ISysUserService sysUserService)
|
||||
{
|
||||
_sysOrgService = sysOrgService;
|
||||
_sysUserService = sysUserService;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<SqlSugarPagedList<SysOrg>> Page(SysOrgPageInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
dataScope?.Remove(UserManager.OrgId);
|
||||
//构建查询
|
||||
var query = Context.Queryable<SysOrg>()
|
||||
.WhereIF(dataScope != null, it => dataScope.Contains(it.Id))//机构ID查询
|
||||
.WhereIF(input.ParentId > 0,
|
||||
it => it.ParentId == input.ParentId || SqlFunc.JsonLike(it.ParentIdList, input.ParentId.ToString()))//父级
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Name), it => it.Name.Contains(input.Name))//根据名称查询
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Code), it => it.Code.Contains(input.Code))//根据编码查询
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Status), it => it.Status == input.Status)//根据状态查询
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.SortField), $"{input.SortField} {input.SortOrder}").OrderBy(it => it.SortCode)
|
||||
.OrderBy(it => it.CreateTime);//排序
|
||||
var pageInfo = await query.ToPagedListAsync(input.PageNum, input.PageSize);//分页
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<SysOrg>> Tree(SysOrgTreeInput input = null)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
//构建机构树
|
||||
var result = await _sysOrgService.Tree(dataScope, input);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Add(SysOrgAddInput input)
|
||||
{
|
||||
await CheckInput(input, SystemConst.ADD);//检查参数
|
||||
await _sysOrgService.Add(input, ApplicationConst.BIZ_ORG);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Edit(SysOrgEditInput input)
|
||||
{
|
||||
await CheckInput(input, SystemConst.EDIT);//检查参数
|
||||
await _sysOrgService.Edit(input, ApplicationConst.BIZ_ORG);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Copy(SysOrgCopyInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
if (dataScope == null || dataScope.Count > 0)//如果有机构
|
||||
{
|
||||
if (dataScope is { Count: > 0 } && (!dataScope.ContainsAll(input.Ids) || !dataScope.Contains(input.TargetId)))//判断目标机构和需要复制的机构是否都在数据范围里面
|
||||
throw Oops.Bah("您没有权限复制这些机构");
|
||||
await _sysOrgService.Copy(input);//复制操作
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Delete(BaseIdListInput input)
|
||||
{
|
||||
//获取所有ID
|
||||
var ids = input.Ids;
|
||||
//获取要删除的机构列表
|
||||
var orgList = (await _sysOrgService.GetListAsync()).Where(it => ids.Contains(it.Id)).ToList();
|
||||
if (orgList.Any(it => it.Category == CateGoryConst.ORG_COMPANY))//如果有公司{
|
||||
throw Oops.Bah("不能删除根机构");
|
||||
//检查数据范围
|
||||
var orgIds = orgList.Select(it => it.Id).ToList();
|
||||
var createUserIds = orgList.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
|
||||
await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除这些机构");
|
||||
await _sysOrgService.Delete(input, ApplicationConst.BIZ_ORG);//删除操作
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<SysOrg> Detail(BaseIdInput input)
|
||||
{
|
||||
var org = await _sysOrgService.GetSysOrgById(input.Id);//获取机构
|
||||
var errorMessage = "您没有权限查看该机构";
|
||||
//判断数据范围
|
||||
await _sysUserService.CheckApiDataScope(org.Id, org.CreateUserId.GetValueOrDefault(), errorMessage);
|
||||
return org;
|
||||
}
|
||||
|
||||
#region 方法
|
||||
|
||||
/// <summary>
|
||||
/// 检查输入参数
|
||||
/// </summary>
|
||||
/// <param name="sysOrg">参数</param>
|
||||
/// <param name="operate">操作名称</param>
|
||||
private async Task CheckInput(SysOrg sysOrg, string operate)
|
||||
{
|
||||
sysOrg.Category = CateGoryConst.ORG_DEPT;//设置分类为部门,业务只能操作部门
|
||||
if (sysOrg.ParentId == SimpleAdminConst.ZERO)
|
||||
{
|
||||
throw Oops.Bah($"不能{operate}根机构");
|
||||
}
|
||||
var errorMessage = $"您没有权限{operate}该机构";
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
if (dataScope is { Count: > 0 })//如果有机构
|
||||
{
|
||||
if (sysOrg.Id > 0 && !dataScope.Contains(sysOrg.Id))//如果id不为0判断是否在数据范围
|
||||
throw Oops.Bah(errorMessage);
|
||||
if (!dataScope.Contains(sysOrg.ParentId))//判断父ID是否在数据范围
|
||||
throw Oops.Bah($"{errorMessage}下的机构");
|
||||
}
|
||||
else if (dataScope is { Count: 0 })
|
||||
{
|
||||
//如果id大于0表示编辑
|
||||
if (sysOrg.Id > 0)
|
||||
{
|
||||
var org = await _sysOrgService.GetSysOrgById(sysOrg.Id);//获取机构
|
||||
if (org.CreateUserId != UserManager.UserId)
|
||||
throw Oops.Bah(errorMessage);//机构的创建人不是自己则报错
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Oops.Bah(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 方法
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 岗位管理
|
||||
/// </summary>
|
||||
public interface IPositionService : ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加岗位
|
||||
/// </summary>
|
||||
/// <param name="input">添加参数</param>
|
||||
/// <returns></returns>
|
||||
Task Add(PositionAddInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 删除岗位
|
||||
/// </summary>
|
||||
/// <param name="input">id列表</param>
|
||||
/// <returns></returns>
|
||||
Task Delete(BaseIdListInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 编辑岗位
|
||||
/// </summary>
|
||||
/// <param name="input">编辑参数</param>
|
||||
/// <returns></returns>
|
||||
Task Edit(PositionEditInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 岗位分页查询
|
||||
/// </summary>
|
||||
/// <param name="input">查询参数</param>
|
||||
/// <returns>分页列表</returns>
|
||||
Task<SqlSugarPagedList<SysPosition>> Page(PositionPageInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 岗位选择器
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PositionSelectorOutput>> Selector(PositionSelectorInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 岗位详情
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<SysPosition> Detail(BaseIdInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 岗位树形结构
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PositionTreeOutput>> Tree(PositionTreeInput input);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="IPositionService"/>
|
||||
/// </summary>
|
||||
public class PositionService : DbRepository<SysPosition>, IPositionService
|
||||
{
|
||||
private readonly ISysUserService _sysUserService;
|
||||
private readonly ISysPositionService _sysPositionService;
|
||||
|
||||
public PositionService(ISysUserService sysUserService, ISysPositionService sysPositionService)
|
||||
{
|
||||
_sysUserService = sysUserService;
|
||||
_sysPositionService = sysPositionService;
|
||||
}
|
||||
|
||||
#region 查询
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<SqlSugarPagedList<SysPosition>> Page(PositionPageInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
input.OrgIds = dataScope;
|
||||
//分页查询
|
||||
var pageInfo = await _sysPositionService.Page(input);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<PositionTreeOutput>> Tree(PositionTreeInput input)
|
||||
{
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
input.OrgIds = dataScope;
|
||||
var result = await _sysPositionService.Tree(input);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新增
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Add(PositionAddInput input)
|
||||
{
|
||||
await CheckInput(input, SystemConst.ADD);//检查参数
|
||||
await _sysPositionService.Add(input, ApplicationConst.BIZ_POS);//添加岗位
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<PositionSelectorOutput>> Selector(PositionSelectorInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
input.OrgIds = dataScope;//赋值机构列表
|
||||
var result = await _sysPositionService.Selector(input);//查询
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<SysPosition> Detail(BaseIdInput input)
|
||||
{
|
||||
var position = await _sysPositionService.GetSysPositionById(input.Id);
|
||||
//判断数据范围
|
||||
await _sysUserService.CheckApiDataScope(position.OrgId, position.CreateUserId.GetValueOrDefault(), "您没有权限查看该机构");
|
||||
return position;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 编辑
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Edit(PositionEditInput input)
|
||||
{
|
||||
await CheckInput(input, SystemConst.EDIT);//检查参数
|
||||
await _sysPositionService.Edit(input, ApplicationConst.BIZ_POS);//编辑
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 删除
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task Delete(BaseIdListInput input)
|
||||
{
|
||||
//获取所有ID
|
||||
var ids = input.Ids;
|
||||
//获取要删除的岗位列表
|
||||
var positions = (await _sysPositionService.GetListAsync()).Where(it => ids.Contains(it.Id)).ToList();
|
||||
//检查数据范围
|
||||
var orgIds = positions.Select(it => it.OrgId).ToList();
|
||||
var createUserIds = positions.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
|
||||
await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除该机构");
|
||||
await _sysPositionService.Delete(input, ApplicationConst.BIZ_ORG);//删除岗位
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 方法
|
||||
|
||||
/// <summary>
|
||||
/// 检查输入参数
|
||||
/// </summary>
|
||||
/// <param name="sysPosition">参数</param>
|
||||
/// <param name="operate">操作名称</param>
|
||||
private async Task CheckInput(SysPosition sysPosition, string operate)
|
||||
{
|
||||
var errorMessage = $"您没有权限在该机构下{operate}岗位";
|
||||
//如果id大于0表示编辑
|
||||
if (sysPosition.Id > 0)
|
||||
{
|
||||
var position = await _sysPositionService.GetSysPositionById(sysPosition.Id);//获取机构
|
||||
sysPosition.CreateUserId = position.CreateUserId;
|
||||
}
|
||||
await _sysUserService.CheckApiDataScope(sysPosition.OrgId, sysPosition.CreateUserId.GetValueOrDefault(), errorMessage);
|
||||
}
|
||||
|
||||
#endregion 方法
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
public interface IRoleService : ITransient
|
||||
{
|
||||
#region 查询
|
||||
|
||||
/// <summary>
|
||||
/// 角色拥有资源
|
||||
/// </summary>
|
||||
/// <param name="input">角色id</param>
|
||||
/// <param name="category">资源类型</param>
|
||||
/// <returns>角色拥有资源信息</returns>
|
||||
Task<RoleOwnResourceOutput> OwnResource(BaseIdInput input, string category);
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色下的用户
|
||||
/// </summary>
|
||||
/// <param name="input">角色ID</param>
|
||||
/// <returns></returns>
|
||||
Task<List<UserSelectorOutPut>> OwnUser(BaseIdInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询角色
|
||||
/// </summary>
|
||||
/// <param name="input">查询参数</param>
|
||||
/// <returns></returns>
|
||||
Task<SqlSugarPagedList<SysRole>> Page(RolePageInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 角色选择器
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<SqlSugarPagedList<RoleSelectorOutPut>> RoleSelector(RoleSelectorInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色树
|
||||
/// </summary>
|
||||
/// <param name="input">角色树</param>
|
||||
/// <returns></returns>
|
||||
Task<List<RoleTreeOutput>> Tree(RoleTreeInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 角色详情
|
||||
/// </summary>
|
||||
/// <param name="input">角色Id</param>
|
||||
/// <returns></returns>
|
||||
Task<SysRole> Detail(BaseIdInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 资源树选择器
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<ResTreeSelector>> ResourceTreeSelector();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新增
|
||||
|
||||
/// <summary>
|
||||
/// 添加角色
|
||||
/// </summary>
|
||||
/// <param name="input">添加参数</param>
|
||||
/// <returns></returns>
|
||||
Task Add(RoleAddInput input);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 编辑
|
||||
|
||||
/// <summary>
|
||||
/// 编辑角色
|
||||
/// </summary>
|
||||
/// <param name="input">编辑参数</param>
|
||||
/// <returns></returns>
|
||||
Task Edit(RoleEditInput input);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 给角色授权
|
||||
/// </summary>
|
||||
/// <param name="input">授权参数</param>
|
||||
/// <returns></returns>
|
||||
Task GrantResource(GrantResourceInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 给角色授权用户
|
||||
/// </summary>
|
||||
/// <param name="input">授权信息</param>
|
||||
/// <returns></returns>
|
||||
Task GrantUser(GrantUserInput input);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色
|
||||
/// </summary>
|
||||
/// <param name="input">删除参数</param>
|
||||
/// <returns></returns>
|
||||
Task Delete(BaseIdListInput input);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NewLife.Serialization;
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <inheritdoc cref="IRoleService"/>
|
||||
public class RoleService : IRoleService
|
||||
{
|
||||
private readonly ILogger<RoleService> _logger;
|
||||
private readonly ISysUserService _sysUserService;
|
||||
private readonly ISysRoleService _sysRoleService;
|
||||
private readonly IResourceService _resourceService;
|
||||
private readonly IRelationService _relationService;
|
||||
|
||||
public RoleService(ILogger<RoleService> logger, ISysUserService sysUserService, ISysRoleService sysRoleService,
|
||||
IResourceService resourceService, IRelationService relationService)
|
||||
{
|
||||
_logger = logger;
|
||||
_sysUserService = sysUserService;
|
||||
_sysRoleService = sysRoleService;
|
||||
_resourceService = resourceService;
|
||||
_relationService = relationService;
|
||||
}
|
||||
|
||||
#region 查询
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<RoleOwnResourceOutput> OwnResource(BaseIdInput input, string category)
|
||||
{
|
||||
return await _sysRoleService.OwnResource(input, category);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<UserSelectorOutPut>> OwnUser(BaseIdInput input)
|
||||
{
|
||||
return await _sysRoleService.OwnUser(input);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<SqlSugarPagedList<SysRole>> Page(RolePageInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
input.OrgIds = dataScope;
|
||||
input.Category = CateGoryConst.ROLE_ORG;//只查询机构角色
|
||||
//分页查询
|
||||
var pageInfo = await _sysRoleService.Page(input);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<SqlSugarPagedList<RoleSelectorOutPut>> RoleSelector(RoleSelectorInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
input.OrgIds = dataScope;
|
||||
return await _sysRoleService.RoleSelector(input);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<RoleTreeOutput>> Tree(RoleTreeInput input)
|
||||
{
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
input.OrgIds = dataScope;
|
||||
return await _sysRoleService.Tree(input);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<SysRole> Detail(BaseIdInput input)
|
||||
{
|
||||
var role = await _sysRoleService.Detail(input);
|
||||
var errorMessage = "您没有权限查看该角色";
|
||||
await _sysUserService.CheckApiDataScope(role.OrgId, role.CreateUserId, errorMessage);
|
||||
return role;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<ResTreeSelector>> ResourceTreeSelector()
|
||||
{
|
||||
var resourceTreeSelectors = new List<ResTreeSelector>();//定义结果
|
||||
var user = await _sysUserService.GetUserById(UserManager.UserId);//获取用户
|
||||
//获取角色资源关系
|
||||
var relations =
|
||||
await _relationService.GetRelationListByObjectIdListAndCategory(user.RoleIdList, CateGoryConst.RELATION_SYS_ROLE_HAS_RESOURCE);
|
||||
var menuIds = new HashSet<long>();//菜单ID集合
|
||||
var buttonIds = new HashSet<long>();//按钮ID集合
|
||||
relations.ForEach(it =>
|
||||
{
|
||||
var resources = it.ExtJson.ToJsonEntity<RelationRoleResource>();//转换为对象获取资源
|
||||
menuIds.Add(resources.MenuId);//添加菜单ID
|
||||
resources.ButtonInfo.ForEach(b => buttonIds.Add(b));//添加按钮ID
|
||||
});
|
||||
var menuList = await _resourceService.GetListByCategory(CateGoryConst.RESOURCE_MENU);//获取所有菜单
|
||||
var buttonList = await _resourceService.GetListByCategory(CateGoryConst.RESOURCE_BUTTON);//获取所有按钮
|
||||
var moduleList = await _resourceService.GetListByCategory(CateGoryConst.RESOURCE_MODULE);//获取所有模块
|
||||
var ownMenuList = menuList.Where(it => menuIds.Contains(it.Id)).ToList();//已拥有的菜单
|
||||
var parentMenuList = menuList.Where(it => ownMenuList.Select(m => m.ParentId).Contains(it.Id)).ToList();//获取所有父级菜单
|
||||
ownMenuList.AddRange(parentMenuList);//将父级菜单加入到拥有菜单列表
|
||||
var ownButtonList = buttonList.Where(it => buttonIds.Contains(it.Id)).ToList();//已拥有的按钮
|
||||
var moduleIds = ownMenuList.Select(it => it.Module.GetValueOrDefault()).Distinct().ToList();//模块ID集合
|
||||
var ownModuleList = moduleList.Where(it => moduleIds.Contains(it.Id)).ToList();//已拥有的模块
|
||||
//遍历模块
|
||||
foreach (var module in ownModuleList)
|
||||
{
|
||||
//将实体转换为ResourceTreeSelectorOutPut获取基本信息
|
||||
var resourceTreeSelector = module.Adapt<ResTreeSelector>();
|
||||
resourceTreeSelector.Menu = await GetRoleGrantResourceMenus(module.Id, ownMenuList, ownButtonList);//获取授权菜单
|
||||
resourceTreeSelectors.Add(resourceTreeSelector);
|
||||
}
|
||||
return resourceTreeSelectors;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 增加
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task Add(RoleAddInput input)
|
||||
{
|
||||
await CheckInput(input);//检查参数
|
||||
await _sysRoleService.Add(input);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 编辑
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task Edit(RoleEditInput input)
|
||||
{
|
||||
await CheckInput(input);//检查参数
|
||||
await _sysRoleService.Edit(input);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task GrantResource(GrantResourceInput input)
|
||||
{
|
||||
await _sysRoleService.GrantResource(input);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task GrantUser(GrantUserInput input)
|
||||
{
|
||||
await _sysRoleService.GrantUser(input);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 删除
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task Delete(BaseIdListInput input)
|
||||
{
|
||||
//获取所有ID
|
||||
var ids = input.Ids;
|
||||
//获取要删除的机构列表
|
||||
var roleList = (await _sysRoleService.GetListAsync()).Where(it => ids.Contains(it.Id)).ToList();
|
||||
if (roleList.Any(it => it.Category == CateGoryConst.ROLE_GLOBAL))//如果有全局角色
|
||||
throw Oops.Bah("不能删除全局角色");
|
||||
//检查数据范围
|
||||
var orgIds = roleList.Select(it => it.OrgId.GetValueOrDefault()).ToList();
|
||||
var createUserIds = roleList.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
|
||||
await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除这些角色");
|
||||
await _sysRoleService.Delete(input);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 方法
|
||||
|
||||
/// <summary>
|
||||
/// 检查输入参数
|
||||
/// </summary>
|
||||
/// <param name="sysRole"></param>
|
||||
private async Task CheckInput(SysRole sysRole)
|
||||
{
|
||||
sysRole.Category = CateGoryConst.ROLE_ORG;
|
||||
if (sysRole.DefaultDataScope.ScopeCategory == CateGoryConst.SCOPE_ALL)
|
||||
throw Oops.Bah("不能添加全局数据范围的角色");
|
||||
await _sysUserService.CheckApiDataScope(sysRole.OrgId, sysRole.CreateUserId.GetValueOrDefault(), "您没有权限添加该角色");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取授权菜单
|
||||
/// </summary>
|
||||
/// <param name="moduleId">模块Id</param>
|
||||
/// <param name="ownMenuList">拥有菜单列表</param>
|
||||
/// <param name="ownButtonList">拥有权限按钮列表</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ResTreeSelector.RoleGrantResourceMenu>> GetRoleGrantResourceMenus(long moduleId, List<SysResource> ownMenuList,
|
||||
List<SysResource> ownButtonList)
|
||||
{
|
||||
var roleGrantResourceMenus = new List<ResTreeSelector.RoleGrantResourceMenu>();//定义结果
|
||||
var parentMenuList = ownMenuList.Where(it => it.ParentId == SimpleAdminConst.ZERO).ToList();//获取一级目录
|
||||
//遍历一级目录
|
||||
foreach (var parent in parentMenuList)
|
||||
{
|
||||
//如果是目录则去遍历下级
|
||||
if (parent.MenuType == SysResourceConst.CATALOG)
|
||||
{
|
||||
//获取所有下级菜单
|
||||
var menuList = _resourceService.GetChildListById(ownMenuList, parent.Id, false);
|
||||
if (menuList.Count > 0)//如果有菜单
|
||||
{
|
||||
//遍历下级菜单
|
||||
foreach (var menu in menuList)
|
||||
{
|
||||
//如果菜单类型是菜单
|
||||
if (menu.MenuType is SysResourceConst.MENU or SysResourceConst.SUBSET)
|
||||
{
|
||||
//获取菜单下按钮集合并转换成对应实体
|
||||
var buttonList = ownButtonList.Where(it => it.ParentId == menu.Id).ToList();
|
||||
var buttons = buttonList.Adapt<List<ResTreeSelector.RoleGrantResourceButton>>();
|
||||
roleGrantResourceMenus.Add(new ResTreeSelector.RoleGrantResourceMenu
|
||||
{
|
||||
Id = menu.Id,
|
||||
ParentId = parent.Id,
|
||||
ParentName = parent.Title,
|
||||
Module = moduleId,
|
||||
Title = _resourceService.GetRoleGrantResourceMenuTitle(menuList, menu),//菜单名称需要特殊处理因为有二级菜单
|
||||
Button = buttons
|
||||
});
|
||||
}
|
||||
else if (menu.MenuType == SysResourceConst.LINK || menu.MenuType == SysResourceConst.IFRAME)//如果是内链或者外链
|
||||
{
|
||||
//直接加到资源列表
|
||||
roleGrantResourceMenus.Add(new ResTreeSelector.RoleGrantResourceMenu
|
||||
{
|
||||
Id = menu.Id,
|
||||
ParentId = parent.Id,
|
||||
ParentName = parent.Title,
|
||||
Module = moduleId,
|
||||
Title = menu.Title
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//否则就将自己加到一级目录里面
|
||||
roleGrantResourceMenus.Add(new ResTreeSelector.RoleGrantResourceMenu
|
||||
{
|
||||
Id = parent.Id,
|
||||
ParentId = parent.Id,
|
||||
ParentName = parent.Title,
|
||||
Module = moduleId
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//就将自己加到一级目录里面
|
||||
var roleGrantResourcesButtons = new ResTreeSelector.RoleGrantResourceMenu
|
||||
{
|
||||
Id = parent.Id,
|
||||
ParentId = parent.Id,
|
||||
ParentName = parent.Title,
|
||||
Module = moduleId,
|
||||
Title = parent.Title
|
||||
};
|
||||
//如果菜单类型是菜单
|
||||
if (parent.MenuType == SysResourceConst.MENU)
|
||||
{
|
||||
//获取菜单下按钮集合并转换成对应实体
|
||||
var buttonList = ownButtonList.Where(it => it.ParentId == parent.Id).ToList();
|
||||
roleGrantResourcesButtons.Button = buttonList.Adapt<List<ResTreeSelector.RoleGrantResourceButton>>();
|
||||
}
|
||||
roleGrantResourceMenus.Add(roleGrantResourcesButtons);
|
||||
}
|
||||
}
|
||||
return roleGrantResourceMenus;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 业务用户导入
|
||||
/// </summary>
|
||||
public class BizUserImportInput : SysUserImportInput
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 业务用户导出
|
||||
/// </summary>
|
||||
public class BizUserExportOutput : SysUserExportOutput
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// 人员管理服务
|
||||
/// </summary>
|
||||
public interface IUserService : ITransient
|
||||
{
|
||||
#region 查询
|
||||
|
||||
/// <summary>
|
||||
/// 人员选择器
|
||||
/// </summary>
|
||||
/// <param name="input">查询参数</param>
|
||||
/// <returns>人员列表</returns>
|
||||
Task<SqlSugarPagedList<UserSelectorOutPut>> Selector(UserSelectorInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 用户分页查询
|
||||
/// </summary>
|
||||
/// <param name="input">查询参数</param>
|
||||
/// <returns>用户分页列表</returns>
|
||||
Task<SqlSugarPagedList<SysUser>> Page(UserPageInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户拥有角色
|
||||
/// </summary>
|
||||
/// <param name="input">用户ID</param>
|
||||
/// <returns></returns>
|
||||
Task<List<RoleSelectorOutPut>> OwnRole(BaseIdInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 角色选择器
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<SqlSugarPagedList<RoleSelectorOutPut>> RoleSelector(RoleSelectorInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 人员详情
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task<SysUser> Detail(BaseIdInput input);
|
||||
|
||||
#endregion 查询
|
||||
|
||||
#region 添加
|
||||
|
||||
/// <summary>
|
||||
/// 添加用户
|
||||
/// </summary>
|
||||
/// <param name="input">添加参数</param>
|
||||
/// <returns></returns>
|
||||
Task Add(UserAddInput input);
|
||||
|
||||
#endregion 添加
|
||||
|
||||
#region 编辑
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="input">编辑参数</param>
|
||||
/// <returns></returns>
|
||||
Task Edit(UserEditInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 禁用用户
|
||||
/// </summary>
|
||||
/// <param name="input">用户Id</param>
|
||||
/// <returns></returns>
|
||||
Task DisableUser(BaseIdInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 启用用户
|
||||
/// </summary>
|
||||
/// <param name="input">用户Id</param>
|
||||
/// <returns></returns>
|
||||
Task EnableUser(BaseIdInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 重置密码
|
||||
/// </summary>
|
||||
/// <param name="input">用户Id</param>
|
||||
/// <returns></returns>
|
||||
Task ResetPassword(BaseIdInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 给用户授权角色
|
||||
/// </summary>
|
||||
/// <param name="input">授权参数</param>
|
||||
/// <returns></returns>
|
||||
Task GrantRole(UserGrantRoleInput input);
|
||||
|
||||
#endregion 编辑
|
||||
|
||||
#region 删除
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
/// </summary>
|
||||
/// <param name="input">Id列表</param>
|
||||
/// <returns></returns>
|
||||
Task Delete(BaseIdListInput input);
|
||||
|
||||
#endregion 删除
|
||||
|
||||
#region 导入导出
|
||||
|
||||
/// <summary>
|
||||
/// 导入预览
|
||||
/// </summary>
|
||||
/// <param name="input">导入参数</param>
|
||||
/// <returns></returns>
|
||||
Task<dynamic> Preview(ImportPreviewInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取导入模板
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<FileStreamResult> Template();
|
||||
|
||||
/// <summary>
|
||||
/// 导出
|
||||
/// </summary>
|
||||
/// <param name="input">查询参数</param>
|
||||
/// <returns></returns>
|
||||
Task<dynamic> Export(UserPageInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据
|
||||
/// </summary>
|
||||
/// <param name="input">数据</param>
|
||||
/// <returns>导入结果</returns>
|
||||
Task<ImportResultOutPut<BizUserImportInput>> Import(ImportResultInput<BizUserImportInput> input);
|
||||
|
||||
/// <summary>
|
||||
/// 批量编辑
|
||||
/// </summary>
|
||||
/// <param name="input">编辑字段信息</param>
|
||||
/// <returns></returns>
|
||||
Task Edits(BatchEditInput input);
|
||||
|
||||
#endregion 导入导出
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="IUserService"/>
|
||||
/// </summary>
|
||||
public class UserService : DbRepository<SysUser>, IUserService
|
||||
{
|
||||
private readonly ISysUserService _sysUserService;
|
||||
private readonly ISysRoleService _sysRoleService;
|
||||
private readonly IImportExportService _importExportService;
|
||||
|
||||
public UserService(ISysUserService sysUserService, ISysRoleService sysRoleService, IImportExportService importExportService)
|
||||
{
|
||||
_sysUserService = sysUserService;
|
||||
_sysRoleService = sysRoleService;
|
||||
_importExportService = importExportService;
|
||||
}
|
||||
|
||||
#region 查询
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<SqlSugarPagedList<SysUser>> Page(UserPageInput input)
|
||||
{
|
||||
var query = await GetQuery(input);
|
||||
//分页查询
|
||||
var pageInfo = await _sysUserService.Page(query);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<RoleSelectorOutPut>> OwnRole(BaseIdInput input)
|
||||
{
|
||||
return await _sysUserService.OwnRole(input);//获取角色
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<SqlSugarPagedList<UserSelectorOutPut>> Selector(UserSelectorInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
if (dataScope == null)
|
||||
return await _sysUserService.Selector(input);//查询
|
||||
if (dataScope.Count > 0)
|
||||
{
|
||||
input.OrgIds = dataScope;//赋值机构列表
|
||||
return await _sysUserService.Selector(input);//查询
|
||||
}
|
||||
//返回自己
|
||||
return new SqlSugarPagedList<UserSelectorOutPut>
|
||||
{
|
||||
Total = 1,
|
||||
Pages = 1,
|
||||
HasPrevPages = false,
|
||||
HasNextPages = false,
|
||||
List = new[]
|
||||
{
|
||||
new UserSelectorOutPut
|
||||
{
|
||||
Account = UserManager.UserAccount, Id = UserManager.UserId,
|
||||
Name = UserManager.Name, OrgId = UserManager.OrgId
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<SqlSugarPagedList<RoleSelectorOutPut>> RoleSelector(RoleSelectorInput input)
|
||||
{
|
||||
var sysRoles = new SqlSugarPagedList<RoleSelectorOutPut>
|
||||
{
|
||||
Total = 1,
|
||||
Pages = 1,
|
||||
HasPrevPages = false,
|
||||
HasNextPages = false,
|
||||
List = new List<RoleSelectorOutPut>()
|
||||
};
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
if (dataScope == null)
|
||||
sysRoles = await _sysRoleService.RoleSelector(input);//获取角色选择器列表
|
||||
else if (dataScope.Count > 0)//如果有机构
|
||||
{
|
||||
input.OrgIds = dataScope;//将数据范传进去
|
||||
sysRoles = await _sysRoleService.RoleSelector(input);//获取角色选择器列表
|
||||
}
|
||||
return sysRoles;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<SysUser> Detail(BaseIdInput input)
|
||||
{
|
||||
var user = await _sysUserService.Detail(input);
|
||||
var errorMessage = "您没有权限查看该人员";
|
||||
//判断数据范围
|
||||
await _sysUserService.CheckApiDataScope(user.OrgId, user.CreateUserId, errorMessage);
|
||||
return user;
|
||||
}
|
||||
|
||||
#endregion 查询
|
||||
|
||||
#region 新增
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task Add(UserAddInput input)
|
||||
{
|
||||
await CheckInput(input, SystemConst.ADD);//检查参数
|
||||
await _sysUserService.Add(input);//添加
|
||||
}
|
||||
|
||||
#endregion 新增
|
||||
|
||||
#region 编辑
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task Edit(UserEditInput input)
|
||||
{
|
||||
await CheckInput(input, SystemConst.EDIT);//检查参数
|
||||
await _sysUserService.Edit(input);//编辑
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task Edits(BatchEditInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
var ids = input.Ids;
|
||||
var sysUsers = await GetListAsync(it => ids.Contains(it.Id),
|
||||
it => new SysUser { OrgId = it.OrgId, CreateUserId = it.CreateUserId });//根据用户ID获取机构id、
|
||||
sysUsers.ForEach(it =>
|
||||
{
|
||||
if (dataScope != null && !dataScope.Contains(it.OrgId) && it.CreateUserId != UserManager.UserId)
|
||||
throw Oops.Bah(ErrorCodeEnum.A0004);//如果不包含机构id并且不是自己创建的
|
||||
});
|
||||
await _sysUserService.Edits(input);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task DisableUser(BaseIdInput input)
|
||||
{
|
||||
await CheckInput(input.Id, SystemConst.DISABLE);//检查权限
|
||||
await _sysUserService.DisableUser(input);//禁用
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task EnableUser(BaseIdInput input)
|
||||
{
|
||||
await CheckInput(input.Id, SystemConst.ENABLE);//检查权限
|
||||
await _sysUserService.EnableUser(input);//启用
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task GrantRole(UserGrantRoleInput input)
|
||||
{
|
||||
await CheckInput(input.Id, SystemConst.DISABLE);//检查权限
|
||||
await _sysUserService.GrantRole(input);//授权
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task ResetPassword(BaseIdInput input)
|
||||
{
|
||||
await CheckInput(input.Id, SystemConst.RESET_PWD);//检查权限
|
||||
await _sysUserService.ResetPassword(input);//重置密码
|
||||
}
|
||||
|
||||
#endregion 编辑
|
||||
|
||||
#region 删除
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task Delete(BaseIdListInput input)
|
||||
{
|
||||
//获取所有ID
|
||||
var ids = input.Ids;
|
||||
|
||||
//获取用户下信息
|
||||
var users = await GetListAsync(it => ids.Contains(it.Id), it => new SysUser { OrgId = it.OrgId, Id = it.Id });
|
||||
//检查数据范围
|
||||
var orgIds = users.Select(it => it.OrgId).ToList();
|
||||
var createUserIds = users.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
|
||||
await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除这些人员");
|
||||
await _sysUserService.Delete(input);//删除
|
||||
}
|
||||
|
||||
#endregion 删除
|
||||
|
||||
#region 导入导出
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<FileStreamResult> Template()
|
||||
{
|
||||
var templateName = "人员信息.xlsx";
|
||||
//var result = _importExportService.GenerateLocalTemplate(templateName);
|
||||
var result = await _importExportService.GenerateTemplate<BizUserImportInput>(templateName);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<dynamic> Preview(ImportPreviewInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
if (dataScope == null || dataScope.Count > 0)
|
||||
{
|
||||
var importPreview = await _importExportService.GetImportPreview<BizUserImportInput>(input.File);
|
||||
importPreview.Data = await CheckImport(importPreview.Data, dataScope);//检查导入数据
|
||||
return importPreview;
|
||||
}
|
||||
throw Oops.Bah("您无权导入用户");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<dynamic> Export(UserPageInput input)
|
||||
{
|
||||
var query = await GetQuery(input);
|
||||
var users = await _sysUserService.List(query);
|
||||
var data = users.Adapt<List<SysUserExportOutput>>();//转为Dto
|
||||
var result = await _importExportService.Export(data, "人员信息");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<ImportResultOutPut<BizUserImportInput>> Import(ImportResultInput<BizUserImportInput> input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
if (dataScope.Count > 0)
|
||||
{
|
||||
var data = await CheckImport(input.Data, dataScope, true);//检查数据格式
|
||||
var result = _importExportService.GetImportResultPreview(data, out var importData);
|
||||
var sysUsers = importData.Adapt<List<SysUser>>();//转实体
|
||||
await _sysUserService.SetUserDefault(sysUsers);//设置用户默认值
|
||||
await InsertOrBulkCopy(sysUsers);// 数据导入
|
||||
return result;
|
||||
}
|
||||
throw Oops.Bah("您无权导入用户");
|
||||
}
|
||||
|
||||
#endregion 导入导出
|
||||
|
||||
#region 方法
|
||||
|
||||
/// <summary>
|
||||
/// 检查输入参数
|
||||
/// </summary>
|
||||
/// <param name="sysUser"></param>
|
||||
/// <param name="operate">操作类型</param>
|
||||
private async Task CheckInput(SysUser sysUser, string operate)
|
||||
{
|
||||
var errorMessage = $"您没有权限{operate}该机构下的人员";
|
||||
if (sysUser.Id != SimpleAdminConst.ZERO)
|
||||
{
|
||||
var user = await _sysUserService.GetUserById(sysUser.Id);
|
||||
sysUser.CreateUserId = user.CreateUserId;
|
||||
}
|
||||
//检查数据范围
|
||||
await _sysUserService.CheckApiDataScope(sysUser.OrgId, sysUser.CreateUserId.GetValueOrDefault(), errorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查输入参数
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <param name="operate">操作</param>
|
||||
private async Task CheckInput(long userId, string operate)
|
||||
{
|
||||
var errorMessage = $"您没有权限{operate}该机构下的人员";
|
||||
var sysUser = await _sysUserService.GetUserById(userId);
|
||||
//检查数据范围
|
||||
await _sysUserService.CheckApiDataScope(sysUser.OrgId, sysUser.CreateUserId.GetValueOrDefault(), errorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查导入数据
|
||||
/// </summary>
|
||||
/// <param name="data">数据</param>
|
||||
/// <param name="dataScope">数据范围ID数组</param>
|
||||
/// <param name="clearError">是否初始化错误</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<BizUserImportInput>> CheckImport(List<BizUserImportInput> data, List<long> dataScope, bool clearError = false)
|
||||
{
|
||||
var errorMessage = "没有权限";
|
||||
//先经过系统用户检查
|
||||
var bizUsers = await _sysUserService.CheckImport(data, clearError);
|
||||
bizUsers.ForEach(it =>
|
||||
{
|
||||
//如果机构没有错误
|
||||
if (!it.ErrorInfo.ContainsKey(nameof(it.OrgName)))
|
||||
{
|
||||
//判断是否包含数据范围,如果不包含
|
||||
if (dataScope != null && !dataScope.Contains(it.OrgId))
|
||||
{
|
||||
it.ErrorInfo.Add(nameof(it.OrgName), errorMessage);
|
||||
if (!it.ErrorInfo.ContainsKey(nameof(it.PositionName)))//如果机构没错
|
||||
it.ErrorInfo.Add(nameof(it.PositionName), errorMessage);
|
||||
}
|
||||
}
|
||||
if (it.ErrorInfo.Count > 0) it.HasError = true;//如果错误信息数量大于0则表示有错误
|
||||
});
|
||||
bizUsers = bizUsers.OrderByDescending(it => it.HasError).ToList();//排序
|
||||
return bizUsers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取查询条件
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<UserPageInput> GetQuery(UserPageInput input)
|
||||
{
|
||||
//获取数据范围
|
||||
var dataScope = await _sysUserService.GetLoginUserApiDataScope();
|
||||
//动态查询条件
|
||||
var exp = Expressionable.Create<SysUser>();
|
||||
exp.And(u => u.Account != SysRoleConst.SUPER_ADMIN);
|
||||
exp.AndIF(dataScope is { Count: > 0 }, u => dataScope.Contains(u.OrgId));//用户机构在数据范围内
|
||||
exp.AndIF(dataScope is { Count: 0 }, u => u.Id == UserManager.UserId);//用户ID等于自己
|
||||
input.Expression = exp;
|
||||
return input;
|
||||
}
|
||||
|
||||
#endregion 方法
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Services.Prescription.Dto
|
||||
{
|
||||
// 人员类型枚举
|
||||
public enum PersonType
|
||||
{
|
||||
[Description("员工")]
|
||||
Employee = 1,
|
||||
[Description("家属")]
|
||||
Relative = 2
|
||||
}
|
||||
|
||||
// 处方列表DTO
|
||||
public class PrescriptionDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long PersonId { get; set; }
|
||||
public string PersonName { get; set; }
|
||||
public PersonType PersonType { get; set; }
|
||||
/// <summary>
|
||||
/// 关联的员工名称
|
||||
/// </summary>
|
||||
public string EmployeeName { get; set; }
|
||||
public DateTime? VisitDate { get; set; }
|
||||
public bool CanEdit { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public decimal TotalMedicineCost { get; set; }
|
||||
|
||||
}
|
||||
// 辅助类:存储FIFO计算所需的入库记录信息
|
||||
public class MedicinalFifoRecord
|
||||
{
|
||||
public long MedicinalId { get; set; }
|
||||
public decimal AddWeight { get; set; }
|
||||
public decimal UnitPrice { get; set; }
|
||||
}
|
||||
// 处方查询输入DTO
|
||||
public class PrescriptionQueryInput: BasePageInput
|
||||
{
|
||||
public DateTime? VisitDate { get; set; }
|
||||
public long? MedicinalId { get; set; }
|
||||
public PersonType? PersonType { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
|
||||
public string PersonName { get; set; }
|
||||
}
|
||||
|
||||
// 处方详情DTO
|
||||
public class PrescriptionDetailDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public PersonDetailDto Person { get; set; }
|
||||
public string DiagnosisResult { get; set; }
|
||||
public string UserMedicinaAdvice { get; set; }
|
||||
public DateTime? VisitDate { get; set; }
|
||||
public List<PrescriptionHerbDto> Herbs { get; set; }
|
||||
public bool CanEdit { get; set; }
|
||||
}
|
||||
|
||||
// 人员详情DTO
|
||||
public class PersonDetailDto
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Birthday { get; set; }
|
||||
public decimal? Weight { get; set; }
|
||||
public decimal? Height { get; set; }
|
||||
public bool IsEmployee { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
public string EmployeeName { get; set; }
|
||||
public long? RelationShip { get; set; }
|
||||
public string RelationShipName { get; set; }
|
||||
}
|
||||
|
||||
// 处方药材DTO
|
||||
public class PrescriptionHerbDto
|
||||
{
|
||||
public long MedicinalId { get; set; }
|
||||
public string MedicinalName { get; set; }
|
||||
public decimal AmountG { get; set; }
|
||||
public string Note { get; set; }
|
||||
}
|
||||
|
||||
// DTOs(替换/合并到你的 DTO 定义处)
|
||||
public class SavePrescriptionInput
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public PersonInputDto Person { get; set; }
|
||||
public string DiagnosisResult { get; set; }
|
||||
public string UserMedicinaAdvice { get; set; }
|
||||
public DateTime? VisitDate { get; set; }
|
||||
public List<PrescriptionHerbInputDto> Herbs { get; set; }
|
||||
}
|
||||
|
||||
// 人员输入 DTO(新增字段以支持前端发送临时员工信息)
|
||||
public class PersonInputDto
|
||||
{
|
||||
public long? Id { get; set; } // 可能的已存在人员ID
|
||||
public string TempId { get; set; } // 可选:前端临时 id(兼容旧流程)
|
||||
public string Name { get; set; }
|
||||
public string Birthday { get; set; }
|
||||
public decimal? Weight { get; set; }
|
||||
public decimal? Height { get; set; }
|
||||
public bool IsEmployee { get; set; }
|
||||
public long? RelationShip { get; set; } // 亲属关系 id(若为家属)
|
||||
public long? EmployeeId { get; set; } // 关联员工 id(如果是家属)
|
||||
/// <summary>
|
||||
/// 当前关联的员工是否是前端临时新增(需要后端创建)
|
||||
/// </summary>
|
||||
public bool EmployeeIsTemp { get; set; }
|
||||
/// <summary>
|
||||
/// 当 EmployeeIsTemp 为 true 或者前端直接传了员工名字时,后端可用此字段创建员工
|
||||
/// </summary>
|
||||
public string EmployeeName { get; set; }
|
||||
}
|
||||
// 处方药材输入DTO
|
||||
public class PrescriptionHerbInputDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public decimal AmountG { get; set; }
|
||||
public string Note { get; set; }
|
||||
}
|
||||
|
||||
// 人员DTO
|
||||
public class PersonDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Birthday { get; set; }
|
||||
|
||||
public decimal? Height { get; set; }
|
||||
|
||||
public long? RelationShip { get; set; }
|
||||
}
|
||||
|
||||
// 关系类型DTO
|
||||
public class RelationTypeDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SimpleAdmin.Application.Services.Prescription
|
||||
{
|
||||
public interface IPrescriptionService : ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取处方列表,带筛选
|
||||
/// </summary>
|
||||
/// <param name="input">筛选条件</param>
|
||||
/// <returns></returns>
|
||||
Task<SqlSugarPagedList<PrescriptionDto>> GetPrescriptionList(PrescriptionQueryInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取处方详情
|
||||
/// </summary>
|
||||
/// <param name="id">处方ID</param>
|
||||
/// <returns></returns>
|
||||
Task<PrescriptionDetailDto> GetPrescriptionDetail(long id);
|
||||
|
||||
/// <summary>
|
||||
/// 保存处方(新增或编辑)
|
||||
/// </summary>
|
||||
/// <param name="input">处方信息</param>
|
||||
/// <returns></returns>
|
||||
Task<long> SavePrescription(SavePrescriptionInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取人员列表(员工和家属)
|
||||
/// </summary>
|
||||
/// <param name="type">人员类型</param>
|
||||
/// <param name="employeeId">员工ID(用于获取家属)</param>
|
||||
/// <returns></returns>
|
||||
Task<List<PersonDto>> GetPersonList(PersonType? type, long? employeeId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有关系类型(写死在代码中)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<RelationTypeDto>> GetRelationTypes();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,551 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using SimpleAdmin.Application.Entity;
|
||||
using SimpleAdmin.Application.Services.Prescription;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
public class PrescriptionService : DbRepository<Prescription>, IPrescriptionService
|
||||
{
|
||||
public async Task<SqlSugarPagedList<PrescriptionDto>> GetPrescriptionList(PrescriptionQueryInput input)
|
||||
{
|
||||
// 原有查询逻辑保持不变
|
||||
var query = Context.Queryable<Prescription>()
|
||||
.LeftJoin<Person>((p, pe) => p.PersonId == pe.Id)
|
||||
.LeftJoin<Person>((p, pe, emp) => pe.EmployeeId != null && pe.EmployeeId == emp.Id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.PersonName), (p, pe, emp) =>
|
||||
input.PersonName.Contains(pe.Name) || pe.Name.Contains(input.PersonName) ||
|
||||
input.PersonName.Contains(emp.Name) || emp.Name.Contains(input.PersonName))
|
||||
.WhereIF(input.PersonType.HasValue && input.PersonType == PersonType.Employee, (p, pe) =>
|
||||
pe.EmployeeId == null)
|
||||
.WhereIF(input.PersonType.HasValue && input.PersonType != PersonType.Employee, (p, pe) =>
|
||||
pe.EmployeeId != null);
|
||||
|
||||
try
|
||||
{
|
||||
// 获取处方基础信息(添加总成本属性)
|
||||
var prescriptionPage = await query.OrderByDescending((p, pe, emp) => p.CreateTime)
|
||||
.Select((p, pe, emp) => new PrescriptionDto
|
||||
{
|
||||
Id = p.Id,
|
||||
PersonId = p.PersonId,
|
||||
PersonName = pe.Name,
|
||||
PersonType = pe.EmployeeId != null ? PersonType.Relative : PersonType.Employee,
|
||||
VisitDate = p.VisitDate,
|
||||
CreateTime = p.CreateTime.Value,
|
||||
EmployeeName = emp.Name,
|
||||
CanEdit = false,
|
||||
TotalMedicineCost = 0 // 初始化总成本
|
||||
}).ToPagedListAsync(input.PageNum, input.PageSize);
|
||||
|
||||
// 设置可编辑状态
|
||||
foreach (var item in prescriptionPage.List)
|
||||
{
|
||||
item.CanEdit = item.CreateTime.Date == DateTime.Now.Date;
|
||||
}
|
||||
|
||||
// 获取当前页所有处方的药材明细
|
||||
var pidList = prescriptionPage.List.Select(a => a.Id).ToList();
|
||||
var prescriptionHerbList = await Context.Queryable<PrescriptionHerb>()
|
||||
.Where(a => pidList.Contains(a.PrescriptionId))
|
||||
.ToListAsync();
|
||||
|
||||
if (prescriptionHerbList.Any())
|
||||
{
|
||||
// 1. 按【处方ID+药材ID】分组,统计每个处方中每种药材的总使用量
|
||||
var prescriptionMedicinalUsage = prescriptionHerbList
|
||||
.GroupBy(h => new { h.PrescriptionId, h.MedicinalId })
|
||||
.Select(g => new
|
||||
{
|
||||
PrescriptionId = g.Key.PrescriptionId,
|
||||
MedicinalId = g.Key.MedicinalId,
|
||||
TotalUsedWeight = g.Sum(h => h.AmountG) // 同一处方中同一药材的总用量
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// 2. 收集所有涉及的药材ID,批量获取FIFO计算所需数据
|
||||
var medicinalIds = prescriptionMedicinalUsage.Select(u => u.MedicinalId).Distinct().ToList();
|
||||
var fifoData = await GetMedicinalFifoData(medicinalIds);
|
||||
|
||||
// 3. 按处方ID分组,计算每个处方的总成本
|
||||
var groupedByPrescription = prescriptionMedicinalUsage
|
||||
.GroupBy(u => u.PrescriptionId)
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
|
||||
// 4. 遍历处方,计算总成本
|
||||
foreach (var prescription in prescriptionPage.List)
|
||||
{
|
||||
if (groupedByPrescription.TryGetValue(prescription.Id, out var usages))
|
||||
{
|
||||
foreach (var usage in usages)
|
||||
{
|
||||
// 基于FIFO计算当前药材的使用成本
|
||||
var herbCost = CalculateHerbCostByFifo(
|
||||
fifoData,
|
||||
usage.MedicinalId,
|
||||
usage.TotalUsedWeight
|
||||
);
|
||||
|
||||
// 累加到处方总成本
|
||||
prescription.TotalMedicineCost += herbCost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prescriptionPage;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"错误: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取药材FIFO计算所需的基础数据(入库记录)
|
||||
/// </summary>
|
||||
private async Task<Dictionary<long, List<MedicinalFifoRecord>>> GetMedicinalFifoData(List<long> medicinalIds)
|
||||
{
|
||||
if (!medicinalIds.Any())
|
||||
return new Dictionary<long, List<MedicinalFifoRecord>>();
|
||||
|
||||
// 批量查询所有涉及药材的入库记录(按时间排序)
|
||||
var addLogs = await Context.Queryable<MedicinalAddLog>()
|
||||
.Where(l => medicinalIds.Contains(l.MedicinalId))
|
||||
.OrderBy(l => l.CreateTime) // FIFO核心:按入库时间排序
|
||||
.Select(l => new MedicinalFifoRecord
|
||||
{
|
||||
MedicinalId = l.MedicinalId,
|
||||
AddWeight = l.AddWeight,
|
||||
UnitPrice = l.UnitPrice
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// 按药材ID分组
|
||||
return addLogs.GroupBy(l => l.MedicinalId)
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按FIFO规则计算单种药材的使用成本
|
||||
/// </summary>
|
||||
private decimal CalculateHerbCostByFifo(
|
||||
Dictionary<long, List<MedicinalFifoRecord>> fifoData,
|
||||
long medicinalId,
|
||||
decimal usedWeight)
|
||||
{
|
||||
if (usedWeight <= 0 || !fifoData.TryGetValue(medicinalId, out var records) || !records.Any())
|
||||
return 0;
|
||||
|
||||
decimal remainingToCalculate = usedWeight;
|
||||
decimal totalCost = 0;
|
||||
|
||||
// 按入库顺序依次消耗
|
||||
foreach (var record in records)
|
||||
{
|
||||
if (remainingToCalculate <= 0)
|
||||
break;
|
||||
|
||||
if (record.AddWeight <= remainingToCalculate)
|
||||
{
|
||||
// 当前批次全部消耗
|
||||
totalCost += record.AddWeight * record.UnitPrice;
|
||||
remainingToCalculate -= record.AddWeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 消耗当前批次的部分量
|
||||
totalCost += remainingToCalculate * record.UnitPrice;
|
||||
remainingToCalculate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return totalCost;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取处方详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<PrescriptionDetailDto> GetPrescriptionDetail(long id)
|
||||
{
|
||||
var prescription = await Context.Queryable<Prescription>()
|
||||
.Where(p => p.Id == id)
|
||||
.FirstAsync();
|
||||
|
||||
if (prescription == null)
|
||||
{
|
||||
throw Oops.Bah("处方不存在");
|
||||
}
|
||||
|
||||
var person = await Context.Queryable<Person>()
|
||||
.Where(pe => pe.Id == prescription.PersonId)
|
||||
.FirstAsync();
|
||||
|
||||
var herbs = await Context.Queryable<PrescriptionHerb, Medicinal>((ph, mt) => ph.MedicinalId == mt.Id)
|
||||
.Where(ph => ph.PrescriptionId == id)
|
||||
.Select((ph, mt) => new PrescriptionHerbDto
|
||||
{
|
||||
MedicinalId = mt.Id,
|
||||
MedicinalName = mt.MedicinalName,
|
||||
AmountG = ph.AmountG,
|
||||
Note = ph.Note
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
// 判断是否是员工还是家属
|
||||
PersonDto employee = null;
|
||||
if (person.EmployeeId.HasValue)
|
||||
{
|
||||
var empPerson = await Context.Queryable<Person>()
|
||||
.Where(pe => pe.Id == person.EmployeeId)
|
||||
.Select(pe => new PersonDto
|
||||
{
|
||||
Id = pe.Id,
|
||||
Name = pe.Name
|
||||
})
|
||||
.FirstAsync();
|
||||
|
||||
employee = empPerson;
|
||||
}
|
||||
var RelationShipName = await GetRelationTypes();
|
||||
return new PrescriptionDetailDto
|
||||
{
|
||||
Id = prescription.Id,
|
||||
Person = new PersonDetailDto
|
||||
{
|
||||
Id = person.Id,
|
||||
Name = person.Name,
|
||||
Birthday = person.Birthday,
|
||||
Weight = prescription.Weight,
|
||||
Height = person.Height,
|
||||
IsEmployee = !person.EmployeeId.HasValue,
|
||||
EmployeeId = person.EmployeeId,
|
||||
EmployeeName = employee?.Name,
|
||||
RelationShip = person.RelationShip,
|
||||
RelationShipName = RelationShipName.FirstOrDefault(t => t.Id == person.RelationShip)?.Name
|
||||
},
|
||||
DiagnosisResult = prescription.DiagnosisResult,
|
||||
UserMedicinaAdvice = prescription.UserMedicinaAdvice,
|
||||
VisitDate = prescription.VisitDate,
|
||||
Herbs = herbs,
|
||||
CanEdit = prescription.CreateTime.Value.Date == DateTime.Now.Date
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加编辑处方记录
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<long> SavePrescription(SavePrescriptionInput input)
|
||||
{
|
||||
// 基础参数验证
|
||||
if (input == null)
|
||||
throw Oops.Bah("输入参数不能为空");
|
||||
|
||||
if (input.Herbs == null || !input.Herbs.Any())
|
||||
throw Oops.Bah("处方药材不能为空");
|
||||
|
||||
await Context.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
// 用于在方法内记录新创建的员工 id(如果需要)
|
||||
long? createdEmployeeId = null;
|
||||
|
||||
// ---------- 1. 处理前端在 person 中携带的“临时员工”(如果存在) ----------
|
||||
if (input.Person == null)
|
||||
throw Oops.Bah("人员信息不能为空");
|
||||
|
||||
// 场景 A: 病人是家属(IsEmployee == false),但关联的员工是前端临时新增
|
||||
if (!input.Person.IsEmployee)
|
||||
{
|
||||
// 如果前端明确标记关联员工为临时新增(EmployeeIsTemp),需要先创建员工
|
||||
if (input.Person.EmployeeIsTemp)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input.Person.EmployeeName))
|
||||
throw Oops.Bah("标记了临时关联员工,但未提供员工姓名");
|
||||
|
||||
// 创建新员工记录(作为 Person 表的一条记录,RelationShip=null, EmployeeId=null)
|
||||
var newEmp = new Person
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Name = input.Person.EmployeeName?.Trim(),
|
||||
};
|
||||
await Context.Insertable(newEmp).ExecuteCommandAsync();
|
||||
createdEmployeeId = newEmp.Id;
|
||||
}
|
||||
else if (input.Person.EmployeeId.HasValue && input.Person.EmployeeId.Value > 0)
|
||||
{
|
||||
// 如果前端传的是已有员工 ID,校验该员工是否存在
|
||||
var exists = await Context.Queryable<Person>()
|
||||
.AnyAsync(p => p.Id == input.Person.EmployeeId.Value);
|
||||
if (!exists)
|
||||
throw Oops.Bah($"关联的员工 ID={input.Person.EmployeeId.Value} 不存在");
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(input.Person.EmployeeName))
|
||||
{
|
||||
// 兼容:即便没有显式 EmployeeIsTemp,前端传了 EmployeeName,我们也可以选择创建员工
|
||||
var newEmp = new Person
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Name = input.Person.EmployeeName.Trim(),
|
||||
};
|
||||
await Context.Insertable(newEmp).ExecuteCommandAsync();
|
||||
createdEmployeeId = newEmp.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有绑定员工信息(既不是 temp,也没有 employeeId),则无法继续
|
||||
if (input.Person.Id == null || input.Person.Id <= 0)
|
||||
throw Oops.Bah("家属未关联员工,请选择或新增关联员工");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 病人是公司员工(IsEmployee == true)
|
||||
// 如果没有 Id,但前端同时将该员工标记为临时新增,或者传了 Name 而无 Id,则创建员工
|
||||
if ((!input.Person.Id.HasValue || input.Person.Id.Value <= 0) &&
|
||||
(!string.IsNullOrWhiteSpace(input.Person.Name) || input.Person.EmployeeIsTemp))
|
||||
{
|
||||
// 如果前端对员工也标记了 EmployeeIsTemp 且提供了 EmployeeName,则优先使用 EmployeeName(兼容性)
|
||||
string empNameForCreate = !string.IsNullOrWhiteSpace(input.Person.Name) ? input.Person.Name.Trim() : input.Person.EmployeeName?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(empNameForCreate))
|
||||
throw Oops.Bah("新增员工时姓名不能为空");
|
||||
|
||||
var newEmp = new Person
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Name = empNameForCreate,
|
||||
Birthday = input.Person.Birthday,
|
||||
Height = input.Person.Height,
|
||||
};
|
||||
await Context.Insertable(newEmp).ExecuteCommandAsync();
|
||||
// 将新创建的员工 id 作为主 person id(病人本身)
|
||||
input.Person.Id = newEmp.Id;
|
||||
}
|
||||
else if (input.Person.Id.HasValue && input.Person.Id.Value > 0)
|
||||
{
|
||||
// 校验存在性
|
||||
var exists = await Context.Queryable<Person>().AnyAsync(p => p.Id == input.Person.Id.Value);
|
||||
if (!exists)
|
||||
throw Oops.Bah($"指定的人员 ID={input.Person.Id.Value} 不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 2. 确定主 personId(如果是临时创建的员工, input.Person.Id 已在上一步设置) ----------
|
||||
long personId;
|
||||
if (input.Person.Id.HasValue && input.Person.Id.Value > 0)
|
||||
{
|
||||
personId = input.Person.Id.Value;
|
||||
// 已存在的人员(或上一步创建的员工),我们仍然可以继续使用 Storageable 更新信息
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有 Id,需新建主人员(可能是家属或员工)
|
||||
if (string.IsNullOrWhiteSpace(input.Person.Name))
|
||||
throw Oops.Bah("新增人员信息不完整,姓名为必填项");
|
||||
|
||||
personId = YitIdHelper.NextId();
|
||||
}
|
||||
|
||||
// ---------- 3. 保存/更新主人员信息(使用 Storageable,兼容插入或更新) ----------
|
||||
var mappedEmployeeId = input.Person.EmployeeId;
|
||||
|
||||
// 如果之前创建了员工(createdEmployeeId),优先使用该 id 作为家属的 EmployeeId
|
||||
if (createdEmployeeId.HasValue)
|
||||
mappedEmployeeId = createdEmployeeId.Value;
|
||||
|
||||
// 如果 person.IsEmployee == true,则 person.EmployeeId 应为 null(员工不需要关联员工)
|
||||
if (input.Person.IsEmployee)
|
||||
mappedEmployeeId = null;
|
||||
|
||||
var person = new Person
|
||||
{
|
||||
Id = personId,
|
||||
Name = input.Person?.Name,
|
||||
Birthday = input.Person?.Birthday,
|
||||
Height = input.Person?.Height,
|
||||
RelationShip = input.Person?.RelationShip,
|
||||
EmployeeId = mappedEmployeeId
|
||||
};
|
||||
await Context.Storageable(person).ExecuteCommandAsync();
|
||||
|
||||
// ---------- 4. 处方保存/编辑逻辑(沿用原逻辑) ----------
|
||||
Prescription prescription;
|
||||
if (input.Id.HasValue) // 编辑
|
||||
{
|
||||
prescription = await Context.Queryable<Prescription>()
|
||||
.FirstAsync(p => p.Id == input.Id.Value);
|
||||
|
||||
if (prescription == null)
|
||||
throw Oops.Bah("处方不存在");
|
||||
|
||||
if (prescription.CreateTime.Value.Date != DateTime.Now.Date)
|
||||
throw Oops.Bah("只能编辑当天的处方");
|
||||
|
||||
// 查询原有消耗记录并恢复库存
|
||||
var oldHerbs = await Context.Queryable<PrescriptionHerb>()
|
||||
.Where(ph => ph.PrescriptionId == input.Id.Value)
|
||||
.ToListAsync();
|
||||
|
||||
if (oldHerbs.Count > 0)
|
||||
{
|
||||
foreach (var g in oldHerbs.GroupBy(x => x.MedicinalId))
|
||||
{
|
||||
// 恢复库存(加回已消耗)
|
||||
// 注意:使用 Updateable 批量操作替换为 SetColumns 表达式累加数值
|
||||
await Context.Updateable<Medicinal>()
|
||||
.SetColumns(m => new Medicinal { Number = m.Number + g.Sum(x => x.AmountG) })
|
||||
.Where(m => m.Id == g.Key)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除原有处方药材(物理删除或软删按你系统策略)
|
||||
await Context.Deleteable<PrescriptionHerb>()
|
||||
.Where(ph => ph.PrescriptionId == input.Id.Value)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
// 更新处方
|
||||
prescription.PersonId = personId;
|
||||
prescription.Weight = input.Person.Weight;
|
||||
prescription.DiagnosisResult = input.DiagnosisResult;
|
||||
prescription.UserMedicinaAdvice = input.UserMedicinaAdvice;
|
||||
prescription.VisitDate = input.VisitDate ?? DateTime.Now;
|
||||
await Context.Updateable(prescription).ExecuteCommandAsync();
|
||||
}
|
||||
else // 新增
|
||||
{
|
||||
var prescripId = YitIdHelper.NextId();
|
||||
prescription = new Prescription
|
||||
{
|
||||
Id = prescripId,
|
||||
Weight = input.Person.Weight,
|
||||
PersonId = personId,
|
||||
DiagnosisResult = input.DiagnosisResult,
|
||||
UserMedicinaAdvice = input.UserMedicinaAdvice,
|
||||
VisitDate = input.VisitDate ?? DateTime.Now,
|
||||
CreateTime = DateTime.Now // 新增时设置创建时间
|
||||
};
|
||||
await Context.Insertable(prescription).ExecuteCommandAsync();
|
||||
input.Id = prescripId;
|
||||
}
|
||||
|
||||
// ---------- 5. 校验库存 & 扣减 & 插入消耗记录 ----------
|
||||
var herbIds = input.Herbs.Select(h => h.Id).ToList();
|
||||
var medicinalList = await Context.Queryable<Medicinal>()
|
||||
.Where(m => herbIds.Contains(m.Id))
|
||||
.ToListAsync();
|
||||
List<long> HerbsId = new List<long>();
|
||||
foreach (var herb in input.Herbs)
|
||||
{
|
||||
var medicinal = medicinalList.FirstOrDefault(m => m.Id == herb.Id);
|
||||
if (medicinal == null)
|
||||
throw Oops.Bah($"药材[{herb.Id}]不存在");
|
||||
if (herb.AmountG<=0)
|
||||
throw Oops.Bah($"请填写正确的消耗量,药材[{medicinal.MedicinalName}]");
|
||||
if (medicinal.Number < herb.AmountG)
|
||||
throw Oops.Bah($"药材[{medicinal.MedicinalName}]库存不足,当前库存: {medicinal.Number}g,需要: {herb.AmountG}g");
|
||||
if(HerbsId.Contains(herb.Id)) throw Oops.Bah($"请勿重复添加同一个药材【{medicinal.MedicinalName}】");
|
||||
HerbsId.Add(herb.Id);
|
||||
medicinal.Number -= herb.AmountG;
|
||||
}
|
||||
|
||||
// 批量更新药材库存
|
||||
await Context.Updateable(medicinalList).ExecuteCommandAsync();
|
||||
|
||||
// 批量插入处方药材
|
||||
var prescriptionHerbs = input.Herbs.Select(h => new PrescriptionHerb
|
||||
{
|
||||
PrescriptionId = input.Id.Value,
|
||||
MedicinalId = h.Id,
|
||||
AmountG = h.AmountG,
|
||||
Note = h.Note
|
||||
}).ToList();
|
||||
await Context.Insertable(prescriptionHerbs).ExecuteCommandAsync();
|
||||
|
||||
await Context.Ado.CommitTranAsync();
|
||||
return input.Id.Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
await Context.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 人员下拉
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PersonDto>> GetPersonList(PersonType? type, long? employeeId)
|
||||
{
|
||||
var query = Context.Queryable<Person>();
|
||||
|
||||
// 筛选员工或家属
|
||||
if (type.HasValue)
|
||||
{
|
||||
if (type == PersonType.Employee)
|
||||
{
|
||||
query = query.Where(pe => pe.EmployeeId == null);
|
||||
}
|
||||
else if (type == PersonType.Relative && employeeId.HasValue)
|
||||
{
|
||||
query = query.Where(pe => pe.EmployeeId == employeeId);
|
||||
}
|
||||
}
|
||||
|
||||
return await query.Select(pe => new PersonDto
|
||||
{
|
||||
Id = pe.Id,
|
||||
Name = pe.Name,
|
||||
Birthday = pe.Birthday,
|
||||
Height = pe.Height,
|
||||
RelationShip = pe.RelationShip
|
||||
}).ToListAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取关系下拉
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<RelationTypeDto>> GetRelationTypes()
|
||||
{
|
||||
var sysmodel = await Context.Queryable<SysDict>().FirstAsync(a => a.DictValue == "Relation");
|
||||
if (sysmodel != null)
|
||||
{
|
||||
return await Context.Queryable<SysDict>().Where(a => a.ParentId == sysmodel.Id).Select(pe => new RelationTypeDto
|
||||
{
|
||||
Id = int.Parse(pe.DictValue),
|
||||
Name = pe.DictLabel,
|
||||
}).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<RelationTypeDto>
|
||||
{
|
||||
new RelationTypeDto { Id = 1, Name = "配偶" },
|
||||
new RelationTypeDto { Id = 2, Name = "子女" },
|
||||
new RelationTypeDto { Id = 3, Name = "父母" },
|
||||
new RelationTypeDto { Id = 4, Name = "兄弟姐妹" },
|
||||
new RelationTypeDto { Id = 5, Name = "其他" }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="applicationsettings.Development.json" />
|
||||
<None Remove="applicationsettings.Production.json" />
|
||||
<None Remove="SimpleAdmin.Application.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SimpleAdmin.System\SimpleAdmin.System.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Application.Development.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Application.Production.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,838 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>SimpleAdmin.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="F:SimpleAdmin.Application.ApplicationConst.BIZ_ORG">
|
||||
<summary>
|
||||
机构
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:SimpleAdmin.Application.ApplicationConst.BIZ_POS">
|
||||
<summary>
|
||||
岗位
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.GenTest">
|
||||
<summary>
|
||||
代码生成基础
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.GenTest.Name">
|
||||
<summary>
|
||||
姓名
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.GenTest.Sex">
|
||||
<summary>
|
||||
性别
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.GenTest.Nation">
|
||||
<summary>
|
||||
民族
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.GenTest.Age">
|
||||
<summary>
|
||||
年龄
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.GenTest.Bir">
|
||||
<summary>
|
||||
生日
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.GenTest.Money">
|
||||
<summary>
|
||||
存款
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.GenTest.SortCode">
|
||||
<summary>
|
||||
排序码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.Medicinal.MedicinalName">
|
||||
<summary>
|
||||
药材
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.Medicinal.Number">
|
||||
<summary>
|
||||
数量(g)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.MedicinalAddLog.MedicinalId">
|
||||
<summary>
|
||||
药材关联id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.MedicinalAddLog.AddWeight">
|
||||
<summary>
|
||||
添加重量(g)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.MedicinalAddLog.UnitPrice">
|
||||
<summary>
|
||||
药材单价
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.MedicinalAddLog.TotalPrice">
|
||||
<summary>
|
||||
总价
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.Person.EmployeeId">
|
||||
<summary>
|
||||
若非空,表示此 person 是某员工的家属
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.Person.Height">
|
||||
<summary>单位 cm,保留两位小数</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.Prescription.Weight">
|
||||
<summary>单位 kg,保留两位小数</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Entity.PrescriptionHerb.AmountG">
|
||||
<summary>消耗克数,单位 g</summary>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.ApplicationSettingsOptions">
|
||||
<summary>
|
||||
系统配置
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Services.Medicinal.Dto.AddMedicinalInput.MedicinalName">
|
||||
<summary>
|
||||
未找到下拉框的时候传这个值代表添加新的药材
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Medicinal.IMedicinalService.GetMedicinalList(System.String,System.Int32,System.Int32)">
|
||||
<summary>
|
||||
获取药材列表,带筛选
|
||||
</summary>
|
||||
<param name="name">药材名称筛选</param>
|
||||
<param name="page">页码</param>
|
||||
<param name="size">页大小</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Medicinal.IMedicinalService.GetConsumptionRecords(System.Int64,System.Int32,System.Int32)">
|
||||
<summary>
|
||||
获取药材消耗记录
|
||||
</summary>
|
||||
<param name="medicinalId">药材ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Medicinal.IMedicinalService.GetMedicinalDictList">
|
||||
<summary>
|
||||
获取药材下拉
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Medicinal.IMedicinalService.GetAdditionRecords(System.Int64,System.Int32,System.Int32)">
|
||||
<summary>
|
||||
获取药材添加记录
|
||||
</summary>
|
||||
<param name="medicinalId">药材ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Medicinal.IMedicinalService.AddMedicinal(SimpleAdmin.Application.Services.Medicinal.Dto.AddMedicinalInput)">
|
||||
<summary>
|
||||
添加药材
|
||||
</summary>
|
||||
<param name="input">添加信息</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Medicinal.IMedicinalService.UpdateAdditionRecord(SimpleAdmin.Application.Services.Medicinal.Dto.UpdateMedicinalAddLogInput)">
|
||||
<summary>
|
||||
修改药材添加记录(仅当天可修改)
|
||||
</summary>
|
||||
<param name="id">记录ID</param>
|
||||
<param name="input">修改信息</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Medicinal.IMedicinalService.DeleteAdditionRecord(System.Int64)">
|
||||
<summary>
|
||||
删除药材添加记录(仅当天可删除)
|
||||
</summary>
|
||||
<param name="id">记录ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Services.Prescription.Dto.PrescriptionDto.EmployeeName">
|
||||
<summary>
|
||||
关联的员工名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Services.Prescription.Dto.PersonInputDto.EmployeeIsTemp">
|
||||
<summary>
|
||||
当前关联的员工是否是前端临时新增(需要后端创建)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:SimpleAdmin.Application.Services.Prescription.Dto.PersonInputDto.EmployeeName">
|
||||
<summary>
|
||||
当 EmployeeIsTemp 为 true 或者前端直接传了员工名字时,后端可用此字段创建员工
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Prescription.IPrescriptionService.GetPrescriptionList(SimpleAdmin.Application.Services.Prescription.Dto.PrescriptionQueryInput)">
|
||||
<summary>
|
||||
获取处方列表,带筛选
|
||||
</summary>
|
||||
<param name="input">筛选条件</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Prescription.IPrescriptionService.GetPrescriptionDetail(System.Int64)">
|
||||
<summary>
|
||||
获取处方详情
|
||||
</summary>
|
||||
<param name="id">处方ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Prescription.IPrescriptionService.SavePrescription(SimpleAdmin.Application.Services.Prescription.Dto.SavePrescriptionInput)">
|
||||
<summary>
|
||||
保存处方(新增或编辑)
|
||||
</summary>
|
||||
<param name="input">处方信息</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Prescription.IPrescriptionService.GetPersonList(System.Nullable{SimpleAdmin.Application.Services.Prescription.Dto.PersonType},System.Nullable{System.Int64})">
|
||||
<summary>
|
||||
获取人员列表(员工和家属)
|
||||
</summary>
|
||||
<param name="type">人员类型</param>
|
||||
<param name="employeeId">员工ID(用于获取家属)</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Services.Prescription.IPrescriptionService.GetRelationTypes">
|
||||
<summary>
|
||||
获取所有关系类型(写死在代码中)
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.IOrgService">
|
||||
<summary>
|
||||
机构服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IOrgService.Add(SimpleAdmin.System.SysOrgAddInput)">
|
||||
<summary>
|
||||
添加机构
|
||||
</summary>
|
||||
<param name="input">添加参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IOrgService.Copy(SimpleAdmin.System.SysOrgCopyInput)">
|
||||
<summary>
|
||||
复制机构
|
||||
</summary>
|
||||
<param name="input">机构复制参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IOrgService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<summary>
|
||||
删除机构
|
||||
</summary>
|
||||
<param name="input">删除参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IOrgService.Edit(SimpleAdmin.System.SysOrgEditInput)">
|
||||
<summary>
|
||||
编辑机构
|
||||
</summary>
|
||||
<param name="input">编辑参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IOrgService.Page(SimpleAdmin.System.SysOrgPageInput)">
|
||||
<summary>
|
||||
机构分页查询
|
||||
</summary>
|
||||
<param name="input">查询参数</param>
|
||||
<returns>分页信息</returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IOrgService.Tree(SimpleAdmin.System.SysOrgTreeInput)">
|
||||
<summary>
|
||||
机构树结构
|
||||
</summary>
|
||||
<param name="input">机构选择器</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IOrgService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
机构详情
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.OrgService">
|
||||
<inheritdoc cref="T:SimpleAdmin.Application.IOrgService"/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.Page(SimpleAdmin.System.SysOrgPageInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.Tree(SimpleAdmin.System.SysOrgTreeInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.Add(SimpleAdmin.System.SysOrgAddInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.Edit(SimpleAdmin.System.SysOrgEditInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.Copy(SimpleAdmin.System.SysOrgCopyInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.OrgService.CheckInput(SimpleAdmin.System.SysOrg,System.String)">
|
||||
<summary>
|
||||
检查输入参数
|
||||
</summary>
|
||||
<param name="sysOrg">参数</param>
|
||||
<param name="operate">操作名称</param>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.IPositionService">
|
||||
<summary>
|
||||
岗位管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IPositionService.Add(SimpleAdmin.System.PositionAddInput)">
|
||||
<summary>
|
||||
添加岗位
|
||||
</summary>
|
||||
<param name="input">添加参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IPositionService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<summary>
|
||||
删除岗位
|
||||
</summary>
|
||||
<param name="input">id列表</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IPositionService.Edit(SimpleAdmin.System.PositionEditInput)">
|
||||
<summary>
|
||||
编辑岗位
|
||||
</summary>
|
||||
<param name="input">编辑参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IPositionService.Page(SimpleAdmin.System.PositionPageInput)">
|
||||
<summary>
|
||||
岗位分页查询
|
||||
</summary>
|
||||
<param name="input">查询参数</param>
|
||||
<returns>分页列表</returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IPositionService.Selector(SimpleAdmin.System.PositionSelectorInput)">
|
||||
<summary>
|
||||
岗位选择器
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IPositionService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
岗位详情
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IPositionService.Tree(SimpleAdmin.System.PositionTreeInput)">
|
||||
<summary>
|
||||
岗位树形结构
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.PositionService">
|
||||
<summary>
|
||||
<inheritdoc cref="T:SimpleAdmin.Application.IPositionService"/>
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.Page(SimpleAdmin.System.PositionPageInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.Tree(SimpleAdmin.System.PositionTreeInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.Add(SimpleAdmin.System.PositionAddInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.Selector(SimpleAdmin.System.PositionSelectorInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.Edit(SimpleAdmin.System.PositionEditInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.PositionService.CheckInput(SimpleAdmin.System.SysPosition,System.String)">
|
||||
<summary>
|
||||
检查输入参数
|
||||
</summary>
|
||||
<param name="sysPosition">参数</param>
|
||||
<param name="operate">操作名称</param>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.OwnResource(SimpleAdmin.Core.BaseIdInput,System.String)">
|
||||
<summary>
|
||||
角色拥有资源
|
||||
</summary>
|
||||
<param name="input">角色id</param>
|
||||
<param name="category">资源类型</param>
|
||||
<returns>角色拥有资源信息</returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.OwnUser(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
获取角色下的用户
|
||||
</summary>
|
||||
<param name="input">角色ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.Page(SimpleAdmin.System.RolePageInput)">
|
||||
<summary>
|
||||
分页查询角色
|
||||
</summary>
|
||||
<param name="input">查询参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.RoleSelector(SimpleAdmin.System.RoleSelectorInput)">
|
||||
<summary>
|
||||
角色选择器
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.Tree(SimpleAdmin.System.RoleTreeInput)">
|
||||
<summary>
|
||||
获取角色树
|
||||
</summary>
|
||||
<param name="input">角色树</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
角色详情
|
||||
</summary>
|
||||
<param name="input">角色Id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.ResourceTreeSelector">
|
||||
<summary>
|
||||
资源树选择器
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.Add(SimpleAdmin.System.RoleAddInput)">
|
||||
<summary>
|
||||
添加角色
|
||||
</summary>
|
||||
<param name="input">添加参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.Edit(SimpleAdmin.System.RoleEditInput)">
|
||||
<summary>
|
||||
编辑角色
|
||||
</summary>
|
||||
<param name="input">编辑参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.GrantResource(SimpleAdmin.System.GrantResourceInput)">
|
||||
<summary>
|
||||
给角色授权
|
||||
</summary>
|
||||
<param name="input">授权参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.GrantUser(SimpleAdmin.System.GrantUserInput)">
|
||||
<summary>
|
||||
给角色授权用户
|
||||
</summary>
|
||||
<param name="input">授权信息</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IRoleService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<summary>
|
||||
删除角色
|
||||
</summary>
|
||||
<param name="input">删除参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.RoleService">
|
||||
<inheritdoc cref="T:SimpleAdmin.Application.IRoleService"/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.OwnResource(SimpleAdmin.Core.BaseIdInput,System.String)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.OwnUser(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.Page(SimpleAdmin.System.RolePageInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.RoleSelector(SimpleAdmin.System.RoleSelectorInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.Tree(SimpleAdmin.System.RoleTreeInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.ResourceTreeSelector">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.Add(SimpleAdmin.System.RoleAddInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.Edit(SimpleAdmin.System.RoleEditInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.GrantResource(SimpleAdmin.System.GrantResourceInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.GrantUser(SimpleAdmin.System.GrantUserInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.CheckInput(SimpleAdmin.System.SysRole)">
|
||||
<summary>
|
||||
检查输入参数
|
||||
</summary>
|
||||
<param name="sysRole"></param>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.RoleService.GetRoleGrantResourceMenus(System.Int64,System.Collections.Generic.List{SimpleAdmin.System.SysResource},System.Collections.Generic.List{SimpleAdmin.System.SysResource})">
|
||||
<summary>
|
||||
获取授权菜单
|
||||
</summary>
|
||||
<param name="moduleId">模块Id</param>
|
||||
<param name="ownMenuList">拥有菜单列表</param>
|
||||
<param name="ownButtonList">拥有权限按钮列表</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.BizUserImportInput">
|
||||
<summary>
|
||||
业务用户导入
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.BizUserExportOutput">
|
||||
<summary>
|
||||
业务用户导出
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.IUserService">
|
||||
<summary>
|
||||
人员管理服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Selector(SimpleAdmin.System.UserSelectorInput)">
|
||||
<summary>
|
||||
人员选择器
|
||||
</summary>
|
||||
<param name="input">查询参数</param>
|
||||
<returns>人员列表</returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Page(SimpleAdmin.System.UserPageInput)">
|
||||
<summary>
|
||||
用户分页查询
|
||||
</summary>
|
||||
<param name="input">查询参数</param>
|
||||
<returns>用户分页列表</returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.OwnRole(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
获取用户拥有角色
|
||||
</summary>
|
||||
<param name="input">用户ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.RoleSelector(SimpleAdmin.System.RoleSelectorInput)">
|
||||
<summary>
|
||||
角色选择器
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
人员详情
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Add(SimpleAdmin.System.UserAddInput)">
|
||||
<summary>
|
||||
添加用户
|
||||
</summary>
|
||||
<param name="input">添加参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Edit(SimpleAdmin.System.UserEditInput)">
|
||||
<summary>
|
||||
编辑
|
||||
</summary>
|
||||
<param name="input">编辑参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.DisableUser(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
禁用用户
|
||||
</summary>
|
||||
<param name="input">用户Id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.EnableUser(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
启用用户
|
||||
</summary>
|
||||
<param name="input">用户Id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.ResetPassword(SimpleAdmin.Core.BaseIdInput)">
|
||||
<summary>
|
||||
重置密码
|
||||
</summary>
|
||||
<param name="input">用户Id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.GrantRole(SimpleAdmin.System.UserGrantRoleInput)">
|
||||
<summary>
|
||||
给用户授权角色
|
||||
</summary>
|
||||
<param name="input">授权参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<summary>
|
||||
删除用户
|
||||
</summary>
|
||||
<param name="input">Id列表</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Preview(SimpleAdmin.System.ImportPreviewInput)">
|
||||
<summary>
|
||||
导入预览
|
||||
</summary>
|
||||
<param name="input">导入参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Template">
|
||||
<summary>
|
||||
获取导入模板
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Export(SimpleAdmin.System.UserPageInput)">
|
||||
<summary>
|
||||
导出
|
||||
</summary>
|
||||
<param name="input">查询参数</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Import(SimpleAdmin.System.ImportResultInput{SimpleAdmin.Application.BizUserImportInput})">
|
||||
<summary>
|
||||
导入数据
|
||||
</summary>
|
||||
<param name="input">数据</param>
|
||||
<returns>导入结果</returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.IUserService.Edits(SimpleAdmin.System.BatchEditInput)">
|
||||
<summary>
|
||||
批量编辑
|
||||
</summary>
|
||||
<param name="input">编辑字段信息</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.UserService">
|
||||
<summary>
|
||||
<inheritdoc cref="T:SimpleAdmin.Application.IUserService"/>
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Page(SimpleAdmin.System.UserPageInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.OwnRole(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Selector(SimpleAdmin.System.UserSelectorInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.RoleSelector(SimpleAdmin.System.RoleSelectorInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Detail(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Add(SimpleAdmin.System.UserAddInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Edit(SimpleAdmin.System.UserEditInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Edits(SimpleAdmin.System.BatchEditInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.DisableUser(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.EnableUser(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.GrantRole(SimpleAdmin.System.UserGrantRoleInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.ResetPassword(SimpleAdmin.Core.BaseIdInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Delete(SimpleAdmin.Core.BaseIdListInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Template">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Preview(SimpleAdmin.System.ImportPreviewInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Export(SimpleAdmin.System.UserPageInput)">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.Import(SimpleAdmin.System.ImportResultInput{SimpleAdmin.Application.BizUserImportInput})">
|
||||
<inheritdoc/>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.CheckInput(SimpleAdmin.System.SysUser,System.String)">
|
||||
<summary>
|
||||
检查输入参数
|
||||
</summary>
|
||||
<param name="sysUser"></param>
|
||||
<param name="operate">操作类型</param>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.CheckInput(System.Int64,System.String)">
|
||||
<summary>
|
||||
检查输入参数
|
||||
</summary>
|
||||
<param name="userId">用户ID</param>
|
||||
<param name="operate">操作</param>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.CheckImport(System.Collections.Generic.List{SimpleAdmin.Application.BizUserImportInput},System.Collections.Generic.List{System.Int64},System.Boolean)">
|
||||
<summary>
|
||||
检查导入数据
|
||||
</summary>
|
||||
<param name="data">数据</param>
|
||||
<param name="dataScope">数据范围ID数组</param>
|
||||
<param name="clearError">是否初始化错误</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.UserService.GetQuery(SimpleAdmin.System.UserPageInput)">
|
||||
<summary>
|
||||
获取查询条件
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:SimpleAdmin.Application.Startup">
|
||||
<summary>
|
||||
AppStartup启动类
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:SimpleAdmin.Application.Startup.ConfigureServices(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
||||
<summary>
|
||||
ConfigureServices中不能解析服务,比如App.GetService(),尤其是不能在ConfigureServices中获取诸如缓存等数据进行初始化,应该在Configure中进行
|
||||
服务都还没初始化完成,会导致内存中存在多份 IOC 容器!!
|
||||
正确应该在 Configure 中,这个时候服务(IServiceCollection 已经完成 BuildServiceProvider() 操作了
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
</member>
|
||||
<member name="M:MedicinalService.GetMedicinalDictList">
|
||||
<summary>
|
||||
获取药材下拉
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<!-- Badly formed XML comment ignored for member "M:MedicinalService.GetConsumptionRecords(System.Int64,System.Int32,System.Int32)" -->
|
||||
<member name="M:MedicinalService.GetAdditionRecords(System.Int64,System.Int32,System.Int32)">
|
||||
<summary>
|
||||
获取药材添加记录
|
||||
</summary>
|
||||
<param name="medicinalId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:MedicinalService.AddMedicinal(SimpleAdmin.Application.Services.Medicinal.Dto.AddMedicinalInput)">
|
||||
<summary>
|
||||
添加药材
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:MedicinalService.UpdateAdditionRecord(SimpleAdmin.Application.Services.Medicinal.Dto.UpdateMedicinalAddLogInput)">
|
||||
<summary>
|
||||
修改药材添加记录
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:System.Exception"></exception>
|
||||
</member>
|
||||
<member name="M:MedicinalService.DeleteAdditionRecord(System.Int64)">
|
||||
<summary>
|
||||
删除药材添加记录
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:System.Exception"></exception>
|
||||
</member>
|
||||
<member name="M:MedicinalService.BatchCalculateCostAndValue(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
批量计算:使用成本、剩余价值、总使用量(先进先出法)
|
||||
</summary>
|
||||
<param name="medicinalIds">需要计算的药材ID列表</param>
|
||||
</member>
|
||||
<member name="M:PrescriptionService.GetMedicinalFifoData(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
获取药材FIFO计算所需的基础数据(入库记录)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:PrescriptionService.CalculateHerbCostByFifo(System.Collections.Generic.Dictionary{System.Int64,System.Collections.Generic.List{SimpleAdmin.Application.Services.Prescription.Dto.MedicinalFifoRecord}},System.Int64,System.Decimal)">
|
||||
<summary>
|
||||
按FIFO规则计算单种药材的使用成本
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:PrescriptionService.GetPrescriptionDetail(System.Int64)">
|
||||
<summary>
|
||||
获取处方详情
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:System.Exception"></exception>
|
||||
</member>
|
||||
<member name="M:PrescriptionService.SavePrescription(SimpleAdmin.Application.Services.Prescription.Dto.SavePrescriptionInput)">
|
||||
<summary>
|
||||
添加编辑处方记录
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:PrescriptionService.GetPersonList(System.Nullable{SimpleAdmin.Application.Services.Prescription.Dto.PersonType},System.Nullable{System.Int64})">
|
||||
<summary>
|
||||
获取 人员下拉
|
||||
</summary>
|
||||
<param name="type"></param>
|
||||
<param name="employeeId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:PrescriptionService.GetRelationTypes">
|
||||
<summary>
|
||||
获取关系下拉
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
|
||||
//
|
||||
// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
|
||||
// 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
|
||||
// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
|
||||
// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
|
||||
// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
|
||||
// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
|
||||
|
||||
namespace SimpleAdmin.Application;
|
||||
|
||||
/// <summary>
|
||||
/// AppStartup启动类
|
||||
/// </summary>
|
||||
public class Startup : AppStartup
|
||||
{
|
||||
/// <summary>
|
||||
/// ConfigureServices中不能解析服务,比如App.GetService(),尤其是不能在ConfigureServices中获取诸如缓存等数据进行初始化,应该在Configure中进行
|
||||
/// 服务都还没初始化完成,会导致内存中存在多份 IOC 容器!!
|
||||
/// 正确应该在 Configure 中,这个时候服务(IServiceCollection 已经完成 BuildServiceProvider() 操作了
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
//业务配置转实体
|
||||
services.AddConfigurableOptions<ApplicationSettingsOptions>();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
var fullName = Assembly.GetExecutingAssembly().FullName;//获取程序集全名
|
||||
//通过 App.GetOptions<TOptions> 获取选项
|
||||
var settings = App.GetOptions<ApplicationSettingsOptions>();
|
||||
CodeFirstUtils.CodeFirst(settings, fullName);//CodeFirst
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user