😎1、调整响应头内容 2、调整个人中心可以看到整个组织架构 3、增加行政区划数据转换接口

This commit is contained in:
zuohuaijun 2025-03-13 02:42:45 +08:00
parent 80fbaf1dc1
commit 1d59ca5d56
8 changed files with 203 additions and 17 deletions

View File

@ -27,6 +27,7 @@
<ItemGroup>
<ProjectReference Include="..\Admin.NET.Core\Admin.NET.Core.csproj" />
<ProjectReference Include="..\Plugins\Admin.NET.Plugin.GoView\Admin.NET.Plugin.GoView.csproj" />
<ProjectReference Include="..\Plugins\Admin.NET.Plugin.ReZero\Admin.NET.Plugin.ReZero.csproj" />
</ItemGroup>
</Project>

View File

@ -43,7 +43,7 @@
<PackageReference Include="MiniExcel" Version="1.38.0" />
<PackageReference Include="MiniWord" Version="0.9.2" />
<PackageReference Include="MQTTnet.Server" Version="5.0.1.1416" />
<PackageReference Include="MySqlBackup.NET.MySqlConnector" Version="2.3.8" />
<PackageReference Include="MySqlBackup.NET.MySqlConnector" Version="2.3.9" />
<PackageReference Include="NewLife.Redis" Version="6.1.2025.301" />
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="4.0.0" />
<PackageReference Include="OnceMi.AspNetCore.OSS" Version="1.2.0" />

View File

@ -284,4 +284,194 @@ public class SysCommonService : IDynamicApiController, ITransient
.SetJsonContent(input.JsonContent));
return stressTestHarnessResult;
}
/// <summary>
/// 从 china.sqlite 中获取区划数据
/// </summary>
/// <param name="code">区划编码</param>
/// <param name="level">级数从当前code所在级别往下级数</param>
/// <returns></returns>
public async Task GetRegionTree(string code, int level)
{
level = level > 5 ? 5 : level;
var sqlitePath = "C:\\china.sqlite";
var db = new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = $"Data Source={sqlitePath};Cache=Shared",
DbType = SqlSugar.DbType.Sqlite,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
});
var regionList = new List<SysRegion>();
// 判断编码所属层级
int startLevel = 1; // 省
switch (code.Length)
{
case 4:
startLevel = 2; // 市
break;
case 6:
startLevel = 3; // 区县
break;
case 9:
startLevel = 4; // 街道
break;
case 12:
startLevel = 5; // 社区/村
break;
default:
break;
}
var region1List = GetRegionList(code, startLevel, db);
if (region1List.Count == 0)
return;
region1List.ForEach(u => u.Pid = 0);
regionList.AddRange(region1List);
if (level == 1 || startLevel == 5)
goto result;
startLevel++;
var region2List = new List<SysRegion>();
foreach (var item in region1List)
{
region2List.AddRange(GetRegionList(item.Code, startLevel, db));
}
regionList.AddRange(region2List);
if (level == 2 || startLevel == 5 || region2List.Count == 0)
goto result;
startLevel++;
var region3List = new List<SysRegion>();
foreach (var item in region2List)
{
region3List.AddRange(GetRegionList(item.Code, startLevel, db));
}
regionList.AddRange(region3List);
if (level == 3 || startLevel == 5 || region3List.Count == 0)
goto result;
startLevel++;
var region4List = new List<SysRegion>();
foreach (var item in region3List)
{
region4List.AddRange(GetRegionList(item.Code, startLevel, db));
}
regionList.AddRange(region4List);
if (level == 4 || startLevel == 5 || region4List.Count == 0)
goto result;
startLevel++;
var region5List = new List<SysRegion>();
region5List.AddRange(GetVillageList(region4List.Select(u => u.Code).ToList(), db));
regionList.AddRange(region5List);
result:
// 保存行政区划树
var defaultDbConfig = App.GetOptions<DbConnectionOptions>().ConnectionConfigs[0];
db = new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = defaultDbConfig.ConnectionString,
DbType = defaultDbConfig.DbType,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
});
await db.Deleteable<SysRegion>().ExecuteCommandAsync();
await db.Insertable(regionList).ExecuteCommandAsync();
}
/// <summary>
/// 根据层级及父级编码获取区域集合
/// </summary>
/// <param name="pCode"></param>
/// <param name="level"></param>
/// <param name="db"></param>
/// <returns></returns>
private static List<SysRegion> GetRegionList(string pCode, int level, SqlSugarScope db)
{
string table = "";
switch (level)
{
case 1:
table = "province";
break;
case 2:
table = "city";
break;
case 3:
table = "area";
break;
case 4:
table = "street";
break;
case 5:
table = "village";
break;
default:
break;
}
if (string.IsNullOrWhiteSpace(table))
return [];
var condition = string.IsNullOrWhiteSpace(pCode) || pCode == "0" ? "" : $" and code like '{pCode}%'";
var sql = $"select * from {table} where 1=1 {condition}";
var regions = db.Ado.SqlQuery<SysRegion>(sql);
if (regions.Count == 0)
return [];
foreach (var item in regions)
{
item.Pid = string.IsNullOrWhiteSpace(pCode) || item.Code == pCode || level == 1 ? 0 : Convert.ToInt64(pCode);
item.Level = level;
item.Id = Convert.ToInt64(item.Code);
}
return regions;
}
/// <summary>
/// 获取社区/村集合
/// </summary>
/// <param name="pCodes"></param>
/// <param name="db"></param>
/// <returns></returns>
private static List<SysRegion> GetVillageList(List<string> pCodes, SqlSugarScope db)
{
var condition = pCodes == null || pCodes.Count == 0 ? "" : $" and streetCode in ('{pCodes.Join("','")}')";
var sql = $"select * from village where 1=1 {condition}";
var regions = db.Ado.SqlQuery<dynamic>(sql);
if (regions.Count == 0)
return [];
var regionList = new List<SysRegion>();
foreach (var item in regions)
{
var region = new SysRegion
{
Name = item.name,
Code = item.code,
Pid = Convert.ToInt64(item.streetCode),
Level = 5,
Id = Convert.ToInt64(item.code)
};
regionList.Add(region);
}
return regionList;
}
}

View File

@ -157,15 +157,7 @@ public class SysFileService : IDynamicApiController, ITransient
[DisplayName("下载指定文件Base64格式")]
public async Task<string> DownloadFileBase64([FromBody] string url)
{
var db = _sysFileRep.CopyNew();
db.Context.QueryFilter.Clear();
var sysFile = await db.GetFirstAsync(u => u.Url == url);
if (sysFile==null)
{
$"文件{url}不存在,数据库记录中".LogError();
throw Oops.Oh($"文件不存在");
}
var sysFile = await _sysFileRep.AsQueryable().ClearFilter().FirstAsync(u => u.Url == url) ?? throw Oops.Oh($"文件不存在");
return await _customFileProvider.DownloadFileBase64Async(sysFile);
}

View File

@ -278,12 +278,12 @@ public class Startup : AppStartup
// 隐藏服务器信息
context.Response.Headers.Append("Server", "none");
// 防止浏览器 MIME 类型嗅探,确保内容按照声明的类型处理
context.Response.Headers.Append("X-Content-Type-Options", "nosniff");
//context.Response.Headers.Append("X-Content-Type-Options", "nosniff");
// 防止点击劫持,确保页面内容不被其他页面覆盖
// DENY表示该页面不允许在 frame 中展示,即便是在相同域名的页面中嵌套也不允许
// SAMEORIGIN表示该页面可以在相同域名页面的 frame 中展示
// ALLOW-FROM uri表示该页面可以在指定来源的 frame 中展示
context.Response.Headers.Append("X-Frame-Options", "ALLOW-FROM " + App.GetConfig<string>("Urls", true));
//context.Response.Headers.Append("X-Frame-Options", "ALLOW-FROM " + App.GetConfig<string>("Urls", true));
// 启用 XSS 保护,防止跨站脚本注入
context.Response.Headers.Append("X-XSS-Protection", "1; mode=block");
// 控制在请求中发送的来源信息,减少潜在的隐私泄露

View File

@ -29,7 +29,7 @@
"@wangeditor/editor-for-vue": "^5.1.12",
"animate.css": "^4.1.1",
"async-validator": "^4.2.5",
"axios": "^1.8.2",
"axios": "^1.8.3",
"countup.js": "^2.8.0",
"cropperjs": "^1.6.2",
"crypto-js": "^4.2.0",
@ -76,7 +76,7 @@
"vue-signature-pad": "^3.0.2",
"vue3-flag-icons": "^0.0.3",
"vue3-tree-org": "^4.2.2",
"vxe-pc-ui": "^4.4.9",
"vxe-pc-ui": "^4.4.10",
"vxe-table": "^4.11.21",
"vxe-table-plugin-element": "^4.0.4",
"vxe-table-plugin-export-xlsx": "^4.0.7",
@ -95,7 +95,7 @@
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue-jsx": "^4.1.1",
"@vue/compiler-sfc": "^3.5.13",
"code-inspector-plugin": "^0.20.3",
"code-inspector-plugin": "^0.20.4",
"eslint": "^9.22.0",
"eslint-plugin-vue": "^10.0.0",
"globals": "^16.0.0",

View File

@ -54,11 +54,14 @@ const state = reactive({
color: '#FFFFFF',
},
});
const props = defineProps({
isAllOrg: Boolean,
});
//
onMounted(async () => {
state.loading = true;
var res = await getAPI(SysOrgApi).apiSysOrgListGet(0);
var res = props.isAllOrg ? await getAPI(SysOrgApi).apiSysOrgChildTreePidLevelGet(0, 100) : await getAPI(SysOrgApi).apiSysOrgListGet(0);
var d = res.data.result ?? [];
state.orgData = d[0] ?? []; //
if (state.orgData.id == userInfos.value.orgId) state.orgData.style = currentNodeStyle;

View File

@ -112,7 +112,7 @@
</el-form>
</el-tab-pane>
<el-tab-pane :label="t('message.list.organizationStructure')">
<OrgTree ref="orgTreeRef" />
<OrgTree ref="orgTreeRef" :isAllOrg="true" />
</el-tab-pane>
<el-tab-pane :label="t('message.list.changePassword')">
<div style="color: red; padding: 10px 10px; background: #faecd8; margin-bottom: 15px">