😎1、性别枚举调整 2、调整字典服务 3、其他优化
This commit is contained in:
parent
2e3149a028
commit
a588c38369
@ -26,7 +26,7 @@
|
||||
<PackageReference Include="Magicodes.IE.Excel" Version="2.7.5.1" />
|
||||
<PackageReference Include="Magicodes.IE.Pdf" Version="2.7.5.1" />
|
||||
<PackageReference Include="Magicodes.IE.Word" Version="2.7.5.1" />
|
||||
<PackageReference Include="MailKit" Version="4.7.0" />
|
||||
<PackageReference Include="MailKit" Version="4.7.1" />
|
||||
<PackageReference Include="NewLife.Redis" Version="5.7.2024.709" />
|
||||
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
|
||||
@ -7,26 +7,32 @@
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 性别枚举
|
||||
/// 性别枚举(GB/T 2261.1-2003)
|
||||
/// </summary>
|
||||
[Description("性别枚举")]
|
||||
public enum GenderEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 男
|
||||
/// 未知的性别
|
||||
/// </summary>
|
||||
[Description("男")]
|
||||
[Description("未知的性别")]
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 男性
|
||||
/// </summary>
|
||||
[Description("男性")]
|
||||
Male = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 女
|
||||
/// 女性
|
||||
/// </summary>
|
||||
[Description("女")]
|
||||
[Description("女性")]
|
||||
Female = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 其他
|
||||
/// 未说明的性别
|
||||
/// </summary>
|
||||
[Description("其他")]
|
||||
Other = 3
|
||||
[Description("未说明的性别")]
|
||||
Unspecified = 9
|
||||
}
|
||||
@ -11,6 +11,7 @@ public class DictDataInput : BaseIdInput
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
[Dict("StatusEnum")]
|
||||
public StatusEnum Status { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ public class DictTypeInput : BaseIdInput
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
[Dict("StatusEnum")]
|
||||
public StatusEnum Status { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
//
|
||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||
//
|
||||
@ -16,8 +16,8 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
private readonly SysCacheService _sysCacheService;
|
||||
private readonly SqlSugarRepository<SysDictData> _sysDictDataRep;
|
||||
|
||||
public SysDictDataService(SqlSugarRepository<SysDictData> sysDictDataRep,
|
||||
SysCacheService sysCacheService)
|
||||
public SysDictDataService(SqlSugarRepository<SysDictData> sysDictDataRep
|
||||
, SysCacheService sysCacheService)
|
||||
{
|
||||
_sysDictDataRep = sysDictDataRep;
|
||||
_sysCacheService = sysCacheService;
|
||||
@ -60,8 +60,7 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
public async Task AddDictData(AddDictDataInput input)
|
||||
{
|
||||
var isExist = await _sysDictDataRep.IsAnyAsync(u => u.Code == input.Code && u.DictTypeId == input.DictTypeId);
|
||||
if (isExist)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3003);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D3003);
|
||||
|
||||
await _sysDictDataRep.InsertAsync(input.Adapt<SysDictData>());
|
||||
}
|
||||
@ -98,9 +97,7 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
[DisplayName("删除字典值")]
|
||||
public async Task DeleteDictData(DeleteDictDataInput input)
|
||||
{
|
||||
var dictData = await _sysDictDataRep.GetFirstAsync(u => u.Id == input.Id);
|
||||
if (dictData == null)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3004);
|
||||
var dictData = await _sysDictDataRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D3004);
|
||||
|
||||
var dictTypeCode = await _sysDictDataRep.AsQueryable().Where(u => u.DictTypeId == dictData.Id).Select(u => u.DictType.Code).FirstAsync();
|
||||
_sysCacheService.Remove($"{CacheConst.KeyDict}{dictTypeCode}");
|
||||
@ -128,18 +125,13 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
[DisplayName("修改字典值状态")]
|
||||
public async Task SetStatus(DictDataInput input)
|
||||
{
|
||||
var dictData = await _sysDictDataRep.GetFirstAsync(u => u.Id == input.Id);
|
||||
if (dictData == null)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3004);
|
||||
|
||||
if (!Enum.IsDefined(typeof(StatusEnum), input.Status))
|
||||
throw Oops.Oh(ErrorCodeEnum.D3005);
|
||||
var dictData = await _sysDictDataRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D3004);
|
||||
|
||||
var dictTypeCode = await _sysDictDataRep.AsQueryable().Where(u => u.DictTypeId == dictData.Id).Select(u => u.DictType.Code).FirstAsync();
|
||||
_sysCacheService.Remove($"{CacheConst.KeyDict}{dictTypeCode}");
|
||||
|
||||
dictData.Status = input.Status;
|
||||
await _sysDictDataRep.UpdateAsync(dictData);
|
||||
await _sysDictDataRep.AsUpdateable(dictData).UpdateColumns(u => new { u.Status }, true).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -156,13 +148,9 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
if (dictDataList == null)
|
||||
{
|
||||
dictDataList = await _sysDictDataRep.AsQueryable()
|
||||
.Where(u => u.DictTypeId == dictTypeId)
|
||||
.OrderBy(u => new { u.OrderNo, u.Code })
|
||||
.ToListAsync();
|
||||
|
||||
.Where(u => u.DictTypeId == dictTypeId).OrderBy(u => new { u.OrderNo, u.Code }).ToListAsync();
|
||||
_sysCacheService.Set($"{CacheConst.KeyDict}{dictType.Code}", dictDataList);
|
||||
}
|
||||
|
||||
return dictDataList;
|
||||
}
|
||||
|
||||
|
||||
@ -60,10 +60,7 @@ public class SysDictTypeService : IDynamicApiController, ITransient
|
||||
[DisplayName("获取字典类型-值列表")]
|
||||
public async Task<List<SysDictData>> GetDataList([FromQuery] GetDataDictTypeInput input)
|
||||
{
|
||||
var dictType = await _sysDictTypeRep.GetFirstAsync(u => u.Code == input.Code);
|
||||
if (dictType == null)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
|
||||
var dictType = await _sysDictTypeRep.GetFirstAsync(u => u.Code == input.Code) ?? throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
return await _sysDictDataService.GetDictDataListByDictTypeId(dictType.Id);
|
||||
}
|
||||
|
||||
@ -77,8 +74,7 @@ public class SysDictTypeService : IDynamicApiController, ITransient
|
||||
public async Task AddDictType(AddDictTypeInput input)
|
||||
{
|
||||
var isExist = await _sysDictTypeRep.IsAnyAsync(u => u.Code == input.Code);
|
||||
if (isExist)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3001);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D3001);
|
||||
|
||||
await _sysDictTypeRep.InsertAsync(input.Adapt<SysDictType>());
|
||||
}
|
||||
@ -94,12 +90,10 @@ public class SysDictTypeService : IDynamicApiController, ITransient
|
||||
public async Task UpdateDictType(UpdateDictTypeInput input)
|
||||
{
|
||||
var isExist = await _sysDictTypeRep.IsAnyAsync(u => u.Id == input.Id);
|
||||
if (!isExist)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
if (!isExist) throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
|
||||
isExist = await _sysDictTypeRep.IsAnyAsync(u => u.Code == input.Code && u.Id != input.Id);
|
||||
if (isExist)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3001);
|
||||
if (isExist) throw Oops.Oh(ErrorCodeEnum.D3001);
|
||||
|
||||
_sysCacheService.Remove($"{CacheConst.KeyDict}{input.Code}");
|
||||
await _sysDictTypeRep.UpdateAsync(input.Adapt<SysDictType>());
|
||||
@ -115,9 +109,7 @@ public class SysDictTypeService : IDynamicApiController, ITransient
|
||||
[DisplayName("删除字典类型")]
|
||||
public async Task DeleteDictType(DeleteDictTypeInput input)
|
||||
{
|
||||
var dictType = await _sysDictTypeRep.GetFirstAsync(u => u.Id == input.Id);
|
||||
if (dictType == null)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
var dictType = await _sysDictTypeRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
|
||||
// 删除字典值
|
||||
await _sysDictTypeRep.DeleteAsync(dictType);
|
||||
@ -144,17 +136,12 @@ public class SysDictTypeService : IDynamicApiController, ITransient
|
||||
[DisplayName("修改字典类型状态")]
|
||||
public async Task SetStatus(DictTypeInput input)
|
||||
{
|
||||
var dictType = await _sysDictTypeRep.GetFirstAsync(u => u.Id == input.Id);
|
||||
if (dictType == null)
|
||||
throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
|
||||
if (!Enum.IsDefined(typeof(StatusEnum), input.Status))
|
||||
throw Oops.Oh(ErrorCodeEnum.D3005);
|
||||
var dictType = await _sysDictTypeRep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D3000);
|
||||
|
||||
_sysCacheService.Remove($"{CacheConst.KeyDict}{dictType.Code}");
|
||||
|
||||
dictType.Status = input.Status;
|
||||
await _sysDictTypeRep.UpdateAsync(dictType);
|
||||
await _sysDictTypeRep.AsUpdateable(dictType).UpdateColumns(u => new { u.Status }, true).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -49,7 +49,7 @@ public class SysEnumService : IDynamicApiController, ITransient
|
||||
{
|
||||
string description = type.Name;
|
||||
var attrs = type.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
if (attrs.Any())
|
||||
if (attrs.Length != 0)
|
||||
{
|
||||
var att = ((DescriptionAttribute[])attrs)[0];
|
||||
description = att.Description;
|
||||
|
||||
@ -49,12 +49,12 @@ public static class CommonUtil
|
||||
// 代理模式:获取真正的本机地址
|
||||
// X-Original-Host=原始请求
|
||||
// X-Forwarded-Server=从哪里转发过来
|
||||
if (App.HttpContext.Request.Headers.ContainsKey("Origin")) // 配置成完整的路径如(结尾不要带"/"),比如 https://www.abc.com
|
||||
result = $"{App.HttpContext.Request.Headers["Origin"]}";
|
||||
else if (App.HttpContext.Request.Headers.ContainsKey("X-Original")) // 配置成完整的路径如(结尾不要带"/"),比如 https://www.abc.com
|
||||
result = $"{App.HttpContext.Request.Headers["X-Original"]}";
|
||||
else if (App.HttpContext.Request.Headers.ContainsKey("X-Original-Host"))
|
||||
result = $"{App.HttpContext.Request.Scheme}://{App.HttpContext.Request.Headers["X-Original-Host"]}";
|
||||
if (App.HttpContext.Request.Headers.TryGetValue("Origin", out Microsoft.Extensions.Primitives.StringValues value1)) // 配置成完整的路径如(结尾不要带"/"),比如 https://www.abc.com
|
||||
result = $"{value1}";
|
||||
else if (App.HttpContext.Request.Headers.TryGetValue("X-Original", out Microsoft.Extensions.Primitives.StringValues value2)) // 配置成完整的路径如(结尾不要带"/"),比如 https://www.abc.com
|
||||
result = $"{value2}";
|
||||
else if (App.HttpContext.Request.Headers.TryGetValue("X-Original-Host", out Microsoft.Extensions.Primitives.StringValues value3))
|
||||
result = $"{App.HttpContext.Request.Scheme}://{value3}";
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public static class CommonUtil
|
||||
/// <returns></returns>
|
||||
public static async Task<IActionResult> ExportExcelTemplate<T>(string fileName = null) where T : class, new()
|
||||
{
|
||||
IImporter importer = new ExcelImporter();
|
||||
var importer = new ExcelImporter();
|
||||
var res = await importer.GenerateTemplateBytes<T>();
|
||||
|
||||
return new FileContentResult(res, "application/octet-stream") { FileDownloadName = $"{(string.IsNullOrEmpty(fileName) ? typeof(T).Name : fileName)}.xlsx" };
|
||||
@ -152,9 +152,9 @@ public static class CommonUtil
|
||||
}
|
||||
|
||||
var map = dict.Value.Item1;
|
||||
if (map != null && map.ContainsKey(sourceVal))
|
||||
if (map != null && map.TryGetValue(sourceVal, out string value))
|
||||
{
|
||||
var newVal = map[sourceVal];
|
||||
var newVal = value;
|
||||
targeProp.SetValue(newData, newVal);
|
||||
}
|
||||
else
|
||||
@ -190,7 +190,7 @@ public static class CommonUtil
|
||||
/// <returns></returns>
|
||||
public static async Task<ICollection<T>> ImportExcelData<T>([Required] IFormFile file) where T : class, new()
|
||||
{
|
||||
IImporter importer = new ExcelImporter();
|
||||
var importer = new ExcelImporter();
|
||||
var res = await importer.Import<T>(file.OpenReadStream());
|
||||
var message = string.Empty;
|
||||
if (res.HasError)
|
||||
@ -212,11 +212,13 @@ public static class CommonUtil
|
||||
/// <summary>
|
||||
/// 导入Excel数据并错误标记
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="importResultCallback"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<ICollection<T>> ImportExcelData<T>([Required] IFormFile file, Func<ImportResult<T>, ImportResult<T>> importResultCallback = null) where T : class, new()
|
||||
{
|
||||
IImporter importer = new ExcelImporter();
|
||||
var importer = new ExcelImporter();
|
||||
var resultStream = new MemoryStream();
|
||||
var res = await importer.Import<T>(file.OpenReadStream(), resultStream, importResultCallback);
|
||||
resultStream.Seek(0, SeekOrigin.Begin);
|
||||
@ -240,7 +242,7 @@ public static class CommonUtil
|
||||
message += "\r\n字段缺失:" + string.Join(",", res.TemplateErrors.Select(m => m.RequireColumnName).ToList());
|
||||
|
||||
if (message.Length > 200)
|
||||
message = message.Substring(0, 200) + "...\r\n异常过多,建议下载错误标记文件查看详细错误信息并重新导入。";
|
||||
message = string.Concat(message.AsSpan(0, 200), "...\r\n异常过多,建议下载错误标记文件查看详细错误信息并重新导入。");
|
||||
throw Oops.Oh("导入异常:" + message);
|
||||
}
|
||||
return res.Data;
|
||||
@ -337,7 +339,7 @@ public static class CommonUtil
|
||||
else
|
||||
{
|
||||
propMappings.Add(propertyInfo.Name, new Tuple<Dictionary<string, object>, PropertyInfo, PropertyInfo>(
|
||||
null, propertyInfo, tTargetProps.ContainsKey(propertyInfo.Name) ? tTargetProps[propertyInfo.Name] : null));
|
||||
null, propertyInfo, tTargetProps.TryGetValue(propertyInfo.Name, out PropertyInfo value) ? value : null));
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,34 +381,34 @@ public static class CommonUtil
|
||||
else
|
||||
{
|
||||
propMappings.Add(propertyInfo.Name, new Tuple<Dictionary<object, string>, PropertyInfo, PropertyInfo>(
|
||||
null, sourceProps.ContainsKey(propertyInfo.Name) ? sourceProps[propertyInfo.Name] : null, propertyInfo));
|
||||
null, sourceProps.TryGetValue(propertyInfo.Name, out PropertyInfo value) ? value : null, propertyInfo));
|
||||
}
|
||||
}
|
||||
|
||||
return propMappings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取属性映射
|
||||
/// </summary>
|
||||
/// <typeparam name="TTarget"></typeparam>
|
||||
/// <returns>整理导入对象的 属性名称, 字典数据,原属性信息,目标属性信息 </returns>
|
||||
private static Dictionary<string, Tuple<string, string>> GetExportDicttMap<TTarget>() where TTarget : new()
|
||||
{
|
||||
// 整理导入对象的属性名称,目标属性名,字典Code
|
||||
var propMappings = new Dictionary<string, Tuple<string, string>>();
|
||||
var tTargetProps = typeof(TTarget).GetProperties();
|
||||
foreach (var propertyInfo in tTargetProps)
|
||||
{
|
||||
var attrs = propertyInfo.GetCustomAttribute<ImportDictAttribute>();
|
||||
if (attrs != null && !string.IsNullOrWhiteSpace(attrs.TypeCode))
|
||||
{
|
||||
propMappings.Add(propertyInfo.Name, new Tuple<string, string>(attrs.TargetPropName, attrs.TypeCode));
|
||||
}
|
||||
}
|
||||
///// <summary>
|
||||
///// 获取属性映射
|
||||
///// </summary>
|
||||
///// <typeparam name="TTarget"></typeparam>
|
||||
///// <returns>整理导入对象的 属性名称, 字典数据,原属性信息,目标属性信息 </returns>
|
||||
//private static Dictionary<string, Tuple<string, string>> GetExportDicttMap<TTarget>() where TTarget : new()
|
||||
//{
|
||||
// // 整理导入对象的属性名称,目标属性名,字典Code
|
||||
// var propMappings = new Dictionary<string, Tuple<string, string>>();
|
||||
// var tTargetProps = typeof(TTarget).GetProperties();
|
||||
// foreach (var propertyInfo in tTargetProps)
|
||||
// {
|
||||
// var attrs = propertyInfo.GetCustomAttribute<ImportDictAttribute>();
|
||||
// if (attrs != null && !string.IsNullOrWhiteSpace(attrs.TypeCode))
|
||||
// {
|
||||
// propMappings.Add(propertyInfo.Name, new Tuple<string, string>(attrs.TargetPropName, attrs.TypeCode));
|
||||
// }
|
||||
// }
|
||||
|
||||
return propMappings;
|
||||
}
|
||||
// return propMappings;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 解析IP地址
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "admin.net.pro",
|
||||
"type": "module",
|
||||
"version": "2.4.33",
|
||||
"lastBuildTime": "2024.07.12",
|
||||
"lastBuildTime": "2024.07.14",
|
||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||
"author": "zuohuaijun",
|
||||
"license": "MIT",
|
||||
@ -68,8 +68,8 @@
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vuedraggable": "4.0.3",
|
||||
"vxe-pc-ui": "^4.0.64",
|
||||
"vxe-table": "^4.7.49",
|
||||
"vxe-pc-ui": "^4.0.67",
|
||||
"vxe-table": "^4.7.50",
|
||||
"vxe-table-plugin-element": "^4.0.4",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.5",
|
||||
"xe-utils": "^3.5.28",
|
||||
@ -88,10 +88,10 @@
|
||||
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
||||
"@vue/compiler-sfc": "^3.4.31",
|
||||
"code-inspector-plugin": "^0.14.2",
|
||||
"eslint": "^9.6.0",
|
||||
"eslint": "^9.7.0",
|
||||
"eslint-plugin-vue": "^9.27.0",
|
||||
"less": "^4.2.0",
|
||||
"prettier": "^3.3.2",
|
||||
"prettier": "^3.3.3",
|
||||
"rollup-plugin-visualizer": "^5.12.0",
|
||||
"sass": "^1.77.8",
|
||||
"terser": "^5.31.2",
|
||||
|
||||
@ -54,7 +54,8 @@
|
||||
<template #row_sex="{ row }">
|
||||
<el-tag v-if="row.sex === 1" type="success">男</el-tag>
|
||||
<el-tag v-else-if="row.sex === 2" type="danger">女</el-tag>
|
||||
<el-tag v-else type="info">其他</el-tag>
|
||||
<el-tag v-else-if="row.sex === 0" type="info">未知的性别</el-tag>
|
||||
<el-tag v-else-if="row.sex === 9" type="info">未说明的性别</el-tag>
|
||||
</template>
|
||||
<template #row_accountType="{ row }">
|
||||
<el-tag v-if="row.accountType === 888">系统管理员</el-tag>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user