😎1、增加国家地名库同步 2、增加行政区域转组织架构 3、文件管理增加租户管理

This commit is contained in:
zuohuaijun 2024-08-15 02:25:00 +08:00
parent 882350c21f
commit b808d352c4
21 changed files with 502 additions and 122 deletions

View File

@ -12,7 +12,7 @@ namespace Admin.NET.Core;
[SugarTable(null, "系统文件表")]
[SysTable]
[SugarIndex("index_{table}_F", nameof(FileName), OrderByType.Asc)]
public partial class SysFile : EntityBaseData
public partial class SysFile : EntityTenantBaseData
{
/// <summary>
/// 提供者

View File

@ -69,6 +69,13 @@ public partial class SysRegion : EntityBaseId
[SugarColumn(ColumnDescription = "层级")]
public int Level { get; set; }
/// <summary>
/// 类型
/// </summary>
[SugarColumn(ColumnDescription = "类型", Length = 32)]
[MaxLength(32)]
public string? Type { get; set; }
/// <summary>
/// 拼音
/// </summary>

View File

@ -138,7 +138,8 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
new SysMenu{ Id=1310000000383, Pid=1310000000381, Title="编辑", Permission="sysRegion/update", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
new SysMenu{ Id=1310000000384, Pid=1310000000381, Title="增加", Permission="sysRegion/add", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
new SysMenu{ Id=1310000000385, Pid=1310000000381, Title="删除", Permission="sysRegion/delete", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
new SysMenu{ Id=1310000000386, Pid=1310000000381, Title="同步", Permission="sysRegion/sync", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
new SysMenu{ Id=1310000000386, Pid=1310000000381, Title="同步国家统计局", Permission="sysRegion/syncRegionStats", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
new SysMenu{ Id=1310000000387, Pid=1310000000381, Title="同步国家地名信息库", Permission="sysRegion/syncRegionMca", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
new SysMenu{ Id=1310000000391, Pid=1310000000301, Title="文件管理", Path="/platform/file", Name="sysFile", Component="/system/file/index", Icon="ele-Document", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=180 },
new SysMenu{ Id=1310000000392, Pid=1310000000391, Title="查询", Permission="sysFile/page", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },

View File

@ -125,6 +125,7 @@ public class SysRoleMenuSeedData : ISqlSugarEntitySeedData<SysRoleMenu>
new SysRoleMenu{ Id=1300000000284, RoleId=1300000000101, MenuId=1310000000384 },
new SysRoleMenu{ Id=1300000000285, RoleId=1300000000101, MenuId=1310000000385 },
new SysRoleMenu{ Id=1300000000286, RoleId=1300000000101, MenuId=1310000000386 },
new SysRoleMenu{ Id=1300000000287, RoleId=1300000000101, MenuId=1310000000387 },
// 文件管理
new SysRoleMenu{ Id=1300000000291, RoleId=1300000000101, MenuId=1310000000391 },
new SysRoleMenu{ Id=1300000000292, RoleId=1300000000101, MenuId=1310000000392 },

View File

@ -204,7 +204,7 @@ public class SysCacheService : IDynamicApiController, ISingleton
/// </summary>
/// <returns></returns>
[DisplayName("清空所有缓存")]
[ApiDescriptionSettings(Name = "Clear")]
[ApiDescriptionSettings(Name = "Clear"), HttpPost]
public void Clear()
{
_cacheProvider.Cache.Clear();

View File

@ -43,4 +43,17 @@ public class UpdateRegionInput : AddRegionInput
public class DeleteRegionInput : BaseIdInput
{
}
public class SyncInput
{
/// <summary>
/// 指定省
/// </summary>
public string Province { get; set; }
/// <summary>
/// 指定市
/// </summary>
public string City { get; set; }
}

View File

@ -6,6 +6,7 @@
using AngleSharp;
using AngleSharp.Html.Dom;
using NewLife.Remoting;
namespace Admin.NET.Core.Service;
@ -146,15 +147,16 @@ public class SysRegionService : IDynamicApiController, ITransient
}
/// <summary>
/// 同步行政区域 🔖
/// 同步行政区域(国家统计局) 🔖
/// </summary>
/// <returns></returns>
[DisplayName("同步行政区域")]
public async Task Sync()
[DisplayName("同步行政区域(国家统计局)")]
public async Task SyncRegionStats(SyncInput input)
{
var syncLevel = await _sysConfigService.GetConfigValue<int>(ConfigConst.SysRegionSyncLevel);
if (syncLevel < 1 || syncLevel > 5)
syncLevel = 3;//默认区县级
var context = BrowsingContext.New(AngleSharp.Configuration.Default.WithDefaultLoader());
var dom = await context.OpenAsync(_url);
@ -167,11 +169,12 @@ public class SysRegionService : IDynamicApiController, ITransient
foreach (IHtmlAnchorElement item in itemList)
{
if (!string.IsNullOrWhiteSpace(input.Province) && item.TextContent != input.Province) continue;
var list = new List<SysRegion>();
var region = new SysRegion
{
Id = YitIdHelper.NextId(),
//Id = YitIdHelper.NextId(),
Pid = 0,
Name = item.TextContent,
Remark = item.Href,
@ -179,90 +182,89 @@ public class SysRegionService : IDynamicApiController, ITransient
};
list.Add(region);
// 市级
if (!string.IsNullOrEmpty(item.Href))
////// 市级
if (string.IsNullOrEmpty(item.Href)) continue;
var dom1 = await context.OpenAsync(item.Href);
var itemList1 = dom1.QuerySelectorAll("table.citytable tr.citytr td a");
for (var i1 = 0; i1 < itemList1.Length; i1 += 2)
{
var dom1 = await context.OpenAsync(item.Href);
var itemList1 = dom1.QuerySelectorAll("table.citytable tr.citytr td a");
for (var i1 = 0; i1 < itemList1.Length; i1 += 2)
var item1 = (IHtmlAnchorElement)itemList1[i1 + 1];
if (!string.IsNullOrWhiteSpace(input.City) && item1.TextContent != input.City) continue;
string cityCode = itemList1[i1].TextContent;
// 若URL中查询的一级行政区域缺少Code则通过二级区域填充
if (list.Count == 1 && !string.IsNullOrEmpty(cityCode))
{
var item1 = (IHtmlAnchorElement)itemList1[i1 + 1];
var region1 = new SysRegion
region.Code = cityCode.Substring(0, 2).PadRight(cityCode.Length, '0');
region.Id = long.Parse(region.Code);
}
// 同步层级为“1-省级”退出
if (syncLevel < 2)
break;
var region1 = new SysRegion
{
Id = long.Parse(cityCode),
Pid = region.Id,
Name = item1.TextContent,
Code = itemList1[i1].TextContent,
Remark = item1.Href,
Level = 2,
};
list.Add(region1);
////// 区县级
if (string.IsNullOrEmpty(item1.Href) || syncLevel <= 2) continue;
var dom2 = await context.OpenAsync(item1.Href);
var itemList2 = dom2.QuerySelectorAll("table.countytable tr.countytr td a");
for (var i2 = 0; i2 < itemList2.Length; i2 += 2)
{
var item2 = (IHtmlAnchorElement)itemList2[i2 + 1];
var region2 = new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region.Id,
Name = item1.TextContent,
Code = itemList1[i1].TextContent,
Remark = item1.Href,
Level = 2,
Id = long.Parse(itemList2[i2].TextContent),
Pid = region1.Id,
Name = item2.TextContent,
Code = itemList2[i2].TextContent,
Remark = item2.Href,
Level = 3,
};
// 若URL中查询的一级行政区域缺少Code则通过二级区域填充
if (list.Count == 1 && !string.IsNullOrEmpty(region1.Code))
region.Code = region1.Code.Substring(0, 2).PadRight(region1.Code.Length, '0');
// 同步层级为“1-省级”退出
if (syncLevel < 2)
break;
list.Add(region2);
list.Add(region1);
// 区县级
if (!string.IsNullOrEmpty(item1.Href) && syncLevel > 2)
////// 街道级
if (string.IsNullOrEmpty(item2.Href) || syncLevel <= 3) continue;
var dom3 = await context.OpenAsync(item2.Href);
var itemList3 = dom3.QuerySelectorAll("table.towntable tr.towntr td a");
for (var i3 = 0; i3 < itemList3.Length; i3 += 2)
{
var dom2 = await context.OpenAsync(item1.Href);
var itemList2 = dom2.QuerySelectorAll("table.countytable tr.countytr td a");
for (var i2 = 0; i2 < itemList2.Length; i2 += 2)
var item3 = (IHtmlAnchorElement)itemList3[i3 + 1];
var region3 = new SysRegion
{
var item2 = (IHtmlAnchorElement)itemList2[i2 + 1];
var region2 = new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region1.Id,
Name = item2.TextContent,
Code = itemList2[i2].TextContent,
Remark = item2.Href,
Level = 3,
};
list.Add(region2);
Id = long.Parse(itemList3[i3].TextContent),
Pid = region2.Id,
Name = item3.TextContent,
Code = itemList3[i3].TextContent,
Remark = item3.Href,
Level = 4,
};
list.Add(region3);
// 街道级
if (!string.IsNullOrEmpty(item2.Href) && syncLevel > 3)
////// 村级
if (string.IsNullOrEmpty(item3.Href) || syncLevel <= 4) continue;
var dom4 = await context.OpenAsync(item3.Href);
var itemList4 = dom4.QuerySelectorAll("table.villagetable tr.villagetr td");
for (var i4 = 0; i4 < itemList4.Length; i4 += 3)
{
list.Add(new SysRegion
{
var dom3 = await context.OpenAsync(item2.Href);
var itemList3 = dom3.QuerySelectorAll("table.towntable tr.towntr td a");
for (var i3 = 0; i3 < itemList3.Length; i3 += 2)
{
var item3 = (IHtmlAnchorElement)itemList3[i3 + 1];
var region3 = new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region2.Id,
Name = item3.TextContent,
Code = itemList3[i3].TextContent,
Remark = item3.Href,
Level = 4,
};
list.Add(region3);
// 村级
if (!string.IsNullOrEmpty(item3.Href) && syncLevel > 4)
{
var dom4 = await context.OpenAsync(item3.Href);
var itemList4 = dom4.QuerySelectorAll("table.villagetable tr.villagetr td");
for (var i4 = 0; i4 < itemList4.Length; i4 += 3)
{
list.Add(new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region3.Id,
Name = itemList4[i4 + 2].TextContent,
Code = itemList4[i4].TextContent,
CityCode = itemList4[i4 + 1].TextContent,
Level = 5,
});
}
}
}
}
Id = long.Parse(itemList4[i4].TextContent),
Pid = region3.Id,
Name = itemList4[i4 + 2].TextContent,
Code = itemList4[i4].TextContent,
CityCode = itemList4[i4 + 1].TextContent,
Level = 5,
});
}
}
}
@ -272,4 +274,72 @@ public class SysRegionService : IDynamicApiController, ITransient
_sysRegionRep.Context.Fastest<SysRegion>().BulkCopy(list);
}
}
/// <summary>
/// 同步行政区划数据国家地名信息库最多支持2级深度
/// </summary>
/// <returns></returns>
[DisplayName("同步行政区划数据(国家地名信息库)")]
public async Task<int> SyncRegionMca(long code)
{
var url = $"https://dmfw.mca.gov.cn/9095/xzqh/getList?code={code}&maxLevel=2";
var httpClient = new HttpClient();
var res = await httpClient.GetAsync<SysRegion>(url);
if (res == null) return 0;
var areaList = new List<SysRegion>()
{
new SysRegion
{
Id = Convert.ToInt64(res.Code),
Pid = 0,
Code = res.Code,
Name = res.Name,
Type = res.Type,
Level = res.Level,
}
};
foreach (var item in res.Children)
{
var region = new SysRegion
{
Id = Convert.ToInt64(item.Code),
Pid = Convert.ToInt64(res.Code),
Code = item.Code,
Name = item.Name,
Type = item.Type,
Level = item.Level,
};
areaList.Add(region);
foreach (var child in item.Children)
{
areaList.Add(new SysRegion
{
Id = Convert.ToInt64(child.Code),
Pid = region.Id,
Code = child.Code,
Name = child.Name,
Type = child.Type,
Level = child.Level,
});
}
}
await _sysRegionRep.AsDeleteable().ExecuteCommandAsync();
return await _sysRegionRep.AsInsertable(areaList).ExecuteCommandAsync();
}
/// <summary>
/// 生成组织架构
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[DisplayName("生成组织架构")]
public async Task GenOrg(long Id)
{
await Task.CompletedTask;
}
}

View File

@ -2,7 +2,7 @@
"name": "admin.net.pro",
"type": "module",
"version": "2.4.33",
"lastBuildTime": "2024.08.14",
"lastBuildTime": "2024.08.15",
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
"author": "zuohuaijun",
"license": "MIT",
@ -70,7 +70,7 @@
"vue-router": "^4.4.3",
"vue-signature-pad": "^3.0.2",
"vue3-tree-org": "^4.2.2",
"vxe-pc-ui": "^4.0.94",
"vxe-pc-ui": "^4.0.95",
"vxe-table": "^4.7.59",
"vxe-table-plugin-element": "^4.0.4",
"vxe-table-plugin-export-xlsx": "^4.0.5",
@ -84,13 +84,13 @@
"@types/node": "^20.14.14",
"@types/nprogress": "^0.2.3",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"@vitejs/plugin-vue": "^5.1.2",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"@vue/compiler-sfc": "^3.4.37",
"code-inspector-plugin": "^0.15.2",
"eslint": "^9.8.0",
"eslint": "^9.9.0",
"eslint-plugin-vue": "^9.27.0",
"globals": "^15.8.0",
"less": "^4.2.0",
@ -101,7 +101,7 @@
"typescript": "^5.5.4",
"vite": "^5.4.0",
"vite-plugin-cdn-import": "^1.0.1",
"vite-plugin-compression2": "^1.1.3",
"vite-plugin-compression2": "^1.1.4",
"vite-plugin-vue-setup-extend": "^0.4.0",
"vue-eslint-parser": "^9.4.3"
},

View File

@ -100,7 +100,7 @@ export const SysCacheApiAxiosParamCreator = function (configuration?: Configurat
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysCacheClearDelete: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
apiSysCacheClearPost: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysCache/clear`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
@ -108,7 +108,7 @@ export const SysCacheApiAxiosParamCreator = function (configuration?: Configurat
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'DELETE', ...baseOptions, ...options};
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
@ -408,8 +408,8 @@ export const SysCacheApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysCacheClearDelete(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
const localVarAxiosArgs = await SysCacheApiAxiosParamCreator(configuration).apiSysCacheClearDelete(options);
async apiSysCacheClearPost(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
const localVarAxiosArgs = await SysCacheApiAxiosParamCreator(configuration).apiSysCacheClearPost(options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
@ -512,8 +512,8 @@ export const SysCacheApiFactory = function (configuration?: Configuration, baseP
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysCacheClearDelete(options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysCacheApiFp(configuration).apiSysCacheClearDelete(options).then((request) => request(axios, basePath));
async apiSysCacheClearPost(options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysCacheApiFp(configuration).apiSysCacheClearPost(options).then((request) => request(axios, basePath));
},
/**
*
@ -595,8 +595,8 @@ export class SysCacheApi extends BaseAPI {
* @throws {RequiredError}
* @memberof SysCacheApi
*/
public async apiSysCacheClearDelete(options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysCacheApiFp(this.configuration).apiSysCacheClearDelete(options).then((request) => request(this.axios, this.basePath));
public async apiSysCacheClearPost(options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysCacheApiFp(this.configuration).apiSysCacheClearPost(options).then((request) => request(this.axios, this.basePath));
}
/**
*

View File

@ -18,11 +18,13 @@ import { Configuration } from '../configuration';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
import { AddRegionInput } from '../models';
import { AdminResultInt32 } from '../models';
import { AdminResultInt64 } from '../models';
import { AdminResultListSysRegion } from '../models';
import { AdminResultSqlSugarPagedListSysRegion } from '../models';
import { DeleteRegionInput } from '../models';
import { PageRegionInput } from '../models';
import { SyncInput } from '../models';
import { UpdateRegionInput } from '../models';
/**
* SysRegionApi - axios parameter creator
@ -126,6 +128,55 @@ export const SysRegionApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysRegionGenOrgIdPost: async (id: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError('id','Required parameter id was null or undefined when calling apiSysRegionGenOrgIdPost.');
}
const localVarPath = `/api/sysRegion/genOrg/{id}`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication Bearer required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
*
* @summary 🔖
@ -228,12 +279,18 @@ export const SysRegionApiAxiosParamCreator = function (configuration?: Configura
},
/**
*
* @summary 🔖
* @summary 2
* @param {number} code
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysRegionSyncPost: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysRegion/sync`;
apiSysRegionSyncRegionMcaCodePost: async (code: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'code' is not null or undefined
if (code === null || code === undefined) {
throw new RequiredError('code','Required parameter code was null or undefined when calling apiSysRegionSyncRegionMcaCodePost.');
}
const localVarPath = `/api/sysRegion/syncRegionMca/{code}`
.replace(`{${"code"}}`, encodeURIComponent(String(code)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
@ -269,6 +326,54 @@ export const SysRegionApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
*
* @summary 🔖
* @param {SyncInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysRegionSyncRegionStatsPost: async (body?: SyncInput, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysRegion/syncRegionStats`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication Bearer required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
localVarHeaderParameter['Content-Type'] = 'application/json-patch+json';
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
*
* @summary 🔖
@ -354,6 +459,20 @@ export const SysRegionApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysRegionGenOrgIdPost(id: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
const localVarAxiosArgs = await SysRegionApiAxiosParamCreator(configuration).apiSysRegionGenOrgIdPost(id, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary 🔖
@ -384,12 +503,27 @@ export const SysRegionApiFp = function(configuration?: Configuration) {
},
/**
*
* @summary 🔖
* @summary 2
* @param {number} code
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysRegionSyncPost(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
const localVarAxiosArgs = await SysRegionApiAxiosParamCreator(configuration).apiSysRegionSyncPost(options);
async apiSysRegionSyncRegionMcaCodePost(code: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultInt32>>> {
const localVarAxiosArgs = await SysRegionApiAxiosParamCreator(configuration).apiSysRegionSyncRegionMcaCodePost(code, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary 🔖
* @param {SyncInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysRegionSyncRegionStatsPost(body?: SyncInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
const localVarAxiosArgs = await SysRegionApiAxiosParamCreator(configuration).apiSysRegionSyncRegionStatsPost(body, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
@ -438,6 +572,16 @@ export const SysRegionApiFactory = function (configuration?: Configuration, base
async apiSysRegionDeletePost(body?: DeleteRegionInput, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysRegionApiFp(configuration).apiSysRegionDeletePost(body, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysRegionGenOrgIdPost(id: number, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysRegionApiFp(configuration).apiSysRegionGenOrgIdPost(id, options).then((request) => request(axios, basePath));
},
/**
*
* @summary 🔖
@ -460,12 +604,23 @@ export const SysRegionApiFactory = function (configuration?: Configuration, base
},
/**
*
* @summary 🔖
* @summary 2
* @param {number} code
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysRegionSyncPost(options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysRegionApiFp(configuration).apiSysRegionSyncPost(options).then((request) => request(axios, basePath));
async apiSysRegionSyncRegionMcaCodePost(code: number, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultInt32>> {
return SysRegionApiFp(configuration).apiSysRegionSyncRegionMcaCodePost(code, options).then((request) => request(axios, basePath));
},
/**
*
* @summary 🔖
* @param {SyncInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysRegionSyncRegionStatsPost(body?: SyncInput, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
return SysRegionApiFp(configuration).apiSysRegionSyncRegionStatsPost(body, options).then((request) => request(axios, basePath));
},
/**
*
@ -509,6 +664,17 @@ export class SysRegionApi extends BaseAPI {
public async apiSysRegionDeletePost(body?: DeleteRegionInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysRegionApiFp(this.configuration).apiSysRegionDeletePost(body, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {number} id
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysRegionApi
*/
public async apiSysRegionGenOrgIdPost(id: number, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysRegionApiFp(this.configuration).apiSysRegionGenOrgIdPost(id, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary 🔖
@ -533,13 +699,25 @@ export class SysRegionApi extends BaseAPI {
}
/**
*
* @summary 🔖
* @summary 2
* @param {number} code
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysRegionApi
*/
public async apiSysRegionSyncPost(options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysRegionApiFp(this.configuration).apiSysRegionSyncPost(options).then((request) => request(this.axios, this.basePath));
public async apiSysRegionSyncRegionMcaCodePost(code: number, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultInt32>> {
return SysRegionApiFp(this.configuration).apiSysRegionSyncRegionMcaCodePost(code, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary 🔖
* @param {SyncInput} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysRegionApi
*/
public async apiSysRegionSyncRegionStatsPost(body?: SyncInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
return SysRegionApiFp(this.configuration).apiSysRegionSyncRegionStatsPost(body, options).then((request) => request(this.axios, this.basePath));
}
/**
*

View File

@ -85,6 +85,14 @@ export interface AddRegionInput {
*/
level?: number;
/**
*
*
* @type {string}
* @memberof AddRegionInput
*/
type?: string | null;
/**
*
*

View File

@ -77,7 +77,7 @@ export interface FileOutput {
fileType?: string | null;
/**
* true
* true则所有人都可以查
*
* @type {boolean}
* @memberof FileOutput

View File

@ -330,6 +330,7 @@ export * from './sql-sugar-paged-list-user-output';
export * from './status-enum';
export * from './struct-layout-attribute';
export * from './swagger-submit-url-body';
export * from './sync-input';
export * from './sync-sys-ldap-input';
export * from './sys-code-gen';
export * from './sys-code-gen-config';

View File

@ -0,0 +1,38 @@
/* tslint:disable */
/* eslint-disable */
/**
* Admin.NET
* .NET <br/><u><b><font color='FF0000'> 👮</font></b></u>
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/**
*
*
* @export
* @interface SyncInput
*/
export interface SyncInput {
/**
*
*
* @type {string}
* @memberof SyncInput
*/
province?: string | null;
/**
*
*
* @type {string}
* @memberof SyncInput
*/
city?: string | null;
}

View File

@ -37,7 +37,7 @@ export interface SysFileUploadFileBody {
fileType?: string;
/**
* true
* true则所有人都可以查
*
* @type {boolean}
* @memberof SysFileUploadFileBody

View File

@ -100,6 +100,14 @@ export interface SysFile {
*/
createOrgName?: string | null;
/**
* Id
*
* @type {number}
* @memberof SysFile
*/
tenantId?: number | null;
/**
*
*

View File

@ -93,6 +93,14 @@ export interface SysRegion {
*/
level?: number;
/**
*
*
* @type {string}
* @memberof SysRegion
*/
type?: string | null;
/**
*
*

View File

@ -85,6 +85,14 @@ export interface UpdateRegionInput {
*/
level?: number;
/**
*
*
* @type {string}
* @memberof UpdateRegionInput
*/
type?: string | null;
/**
*
*

View File

@ -61,7 +61,7 @@ export interface UploadFileFromBase64Input {
fileType?: string | null;
/**
* true
* true则所有人都可以查
*
* @type {boolean}
* @memberof UploadFileFromBase64Input

View File

@ -134,7 +134,7 @@ const clearCache = () => {
type: 'warning',
})
.then(async () => {
await getAPI(SysCacheApi).apiSysCacheClearDelete();
await getAPI(SysCacheApi).apiSysCacheClearPost();
await handleQuery();
state.cacheValue = undefined;
state.cacheKey = undefined;

View File

@ -37,11 +37,13 @@
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents" :tree-config="{ transform: true, parentField: 'pid' }">
<template #toolbar_buttons>
<el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'sysRegion/add'"> 新增 </el-button>
<el-button type="danger" icon="ele-Lightning" @click="handlSync" v-auth="'sysRegion/add'"> 同步统计局 </el-button>
<el-button-group style="padding-left: 12px">
<el-button-group style="padding: 0 12px 0 12px">
<el-button type="primary" icon="ele-Expand" @click="handleExpand"> 全部展开 </el-button>
<el-button type="primary" icon="ele-Fold" @click="handleFold"> 全部折叠 </el-button>
</el-button-group>
<el-button type="danger" icon="ele-Lightning" @click="syncRegionStats" v-auth="'sysRegion/add'"> 同步国家统计局 </el-button>
<el-button type="danger" icon="ele-Lightning" @click="syncRegionMca" v-auth="'sysRegion/add'"> 同步国家地名信息库 </el-button>
</template>
<template #toolbar_tools> </template>
<template #empty>
@ -54,6 +56,7 @@
<el-tooltip content="删除" placement="top">
<el-button icon="ele-Delete" text type="danger" v-auth="'sysRegion/delete'" @click="handleDelete(row)"> </el-button>
</el-tooltip>
<el-button icon="ele-OfficeBuilding" text type="primary" v-auth="'sysOrg/add'" @click="genOrg(row)"> 生成组织架构 </el-button>
</template>
</vxe-grid>
</el-card>
@ -67,7 +70,6 @@
<script lang="ts" setup name="sysRegion">
import { nextTick, onMounted, reactive, ref } from 'vue';
import { ElMessageBox, ElMessage, ElNotification } from 'element-plus';
import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
@ -111,11 +113,12 @@ const options = useVxeTable<SysRegion>(
{ type: 'seq', title: '序号', width: 100, fixed: 'left' },
{ field: 'name', title: '行政名称', minWidth: 280, showOverflow: 'tooltip', treeNode: true },
{ field: 'code', title: '行政代码', minWidth: 120, showOverflow: 'tooltip' },
{ field: 'cityCode', title: '区号', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'type', title: '类型', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'orderNo', title: '排序', minWidth: 80, showOverflow: 'tooltip' },
{ field: 'createTime', title: '修改时间', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'cityCode', title: '区号', minWidth: 100, showOverflow: 'tooltip' },
// { field: 'createTime', title: '', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'remark', title: '备注', minWidth: 300, showOverflow: 'tooltip' },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
{ title: '操作', fixed: 'right', width: 200, showOverflow: true, slots: { default: 'row_buttons' } },
],
},
// vxeGrid()vxe-table
@ -218,8 +221,8 @@ const handleNodeChange = async (node: any) => {
await handleQuery();
};
//
const handlSync = async () => {
//
const syncRegionStats = async () => {
ElMessageBox.confirm('确认同步国家统计局行政区域数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -228,11 +231,47 @@ const handlSync = async () => {
.then(async () => {
ElNotification({
title: '提示',
message: '后台努力同步中...',
message: '努力同步中...',
type: 'success',
position: 'bottom-right',
});
await getAPI(SysRegionApi).apiSysRegionSyncPost({ timeout: 1000 * 60 * 30 });
await getAPI(SysRegionApi).apiSysRegionSyncRegionStatsPost(); // { timeout: 1000 * 60 * 30 }
await handleQuery();
ElMessage.success('同步成功');
})
.catch(() => {});
};
//
const syncRegionMca = async () => {
ElMessageBox.confirm('确认同步国家地名信息库行政区域数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
ElNotification({
title: '提示',
message: '努力同步中...',
type: 'success',
position: 'bottom-right',
});
await getAPI(SysRegionApi).apiSysRegionSyncRegionMcaCodePost(110100000000);
await handleQuery();
ElMessage.success('同步成功');
})
.catch(() => {});
};
//
const genOrg = (row: any) => {
ElMessageBox.confirm('确认生成/更新系统组织架构?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
await getAPI(SysRegionApi).apiSysRegionGenOrgIdPost(row.id);
})
.catch(() => {});
};