😎1、修复代码生成字典处理 2、优化菜单添加和更新逻辑 3、升级依赖和更新前端请求文件
This commit is contained in:
parent
c1240eb550
commit
9495569172
@ -6,7 +6,8 @@
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"Microsoft.EntityFrameworkCore": "Information",
|
||||
"AspNetCoreRateLimit": "None"
|
||||
"AspNetCoreRateLimit": "None",
|
||||
"System.Net.Http.HttpClient": "Error"
|
||||
},
|
||||
"File": {
|
||||
"Enabled": false, // 启用文件日志
|
||||
|
||||
@ -40,14 +40,14 @@
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.9" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.116.0" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.6.0" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.9.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
|
||||
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.9" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1133" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1135" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -218,8 +218,16 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
var entityType = provider.DbMaintenance.GetTableInfoList(false).FirstOrDefault(u => u.Name == tableName);
|
||||
if (entityType == null) return null;
|
||||
var entityBasePropertyNames = _codeGenOptions.EntityBaseColumn[nameof(EntityTenant)];
|
||||
var properties = GetEntityInfos().Result.First(u => u.DbTableName == tableName).Type.GetProperties()
|
||||
.Where(e => e.GetCustomAttribute<SugarColumn>()?.IsIgnore == false).Select(u => new
|
||||
{
|
||||
PropertyName = u.Name,
|
||||
ColumnComment = u.GetCustomAttribute<SugarColumn>()?.ColumnDescription,
|
||||
ColumnName = u.GetCustomAttribute<SugarColumn>()?.ColumnName ?? u.Name
|
||||
}).ToList();
|
||||
|
||||
// 按原始类型的顺序获取所有实体类型属性(不包含导航属性,会返回null)
|
||||
return provider.DbMaintenance.GetColumnInfosByTableName(entityType.Name).Select(u => new ColumnOuput
|
||||
var columnList = provider.DbMaintenance.GetColumnInfosByTableName(entityType.Name).Select(u => new ColumnOuput
|
||||
{
|
||||
ColumnName = config.DbSettings.EnableUnderLine ? CodeGenUtil.CamelColumnName(u.DbColumnName, entityBasePropertyNames) : u.DbColumnName,
|
||||
ColumnKey = u.IsPrimarykey.ToString(),
|
||||
@ -227,6 +235,13 @@ public class SysCodeGenService : IDynamicApiController, ITransient
|
||||
NetType = CodeGenUtil.ConvertDataType(u, provider.CurrentConnectionConfig.DbType),
|
||||
ColumnComment = u.ColumnDescription
|
||||
}).ToList();
|
||||
foreach (var column in columnList)
|
||||
{
|
||||
var property = properties.First(u => u.ColumnName == column.ColumnName);
|
||||
column.ColumnComment ??= property?.ColumnComment;
|
||||
column.PropertyName = property?.PropertyName;
|
||||
}
|
||||
return columnList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -116,7 +116,7 @@ public class SysMenuService : IDynamicApiController, ITransient
|
||||
{
|
||||
var isExist = input.Type != MenuTypeEnum.Btn
|
||||
? await _sysMenuRep.IsAnyAsync(u => u.Title == input.Title && u.Pid == input.Pid)
|
||||
: await _sysMenuRep.IsAnyAsync(u => u.Permission == input.Permission && u.Pid == input.Pid);
|
||||
: await _sysMenuRep.IsAnyAsync(u => u.Permission == input.Permission);
|
||||
if (isExist)
|
||||
throw Oops.Oh(ErrorCodeEnum.D4000);
|
||||
|
||||
@ -153,7 +153,7 @@ public class SysMenuService : IDynamicApiController, ITransient
|
||||
|
||||
var isExist = input.Type != MenuTypeEnum.Btn
|
||||
? await _sysMenuRep.IsAnyAsync(u => u.Title == input.Title && u.Type == input.Type && u.Pid == input.Pid && u.Id != input.Id)
|
||||
: await _sysMenuRep.IsAnyAsync(u => u.Permission == input.Permission && u.Type == input.Type && u.Pid == input.Pid && u.Id != input.Id);
|
||||
: await _sysMenuRep.IsAnyAsync(u => u.Permission == input.Permission && u.Id != input.Id);
|
||||
if (isExist)
|
||||
throw Oops.Oh(ErrorCodeEnum.D4000);
|
||||
|
||||
|
||||
@ -327,6 +327,26 @@ public class SysOrgService : IDynamicApiController, ITransient
|
||||
return await GetUserOrgIdList(roleList, userId, userOrgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判定用户是否有某角色权限
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="role">角色代码</param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
public async Task<bool> GetUserHasRole(long userId, SysRole role)
|
||||
{
|
||||
if (_userManager.SuperAdmin) return true;
|
||||
|
||||
var userOrgId = _userManager.OrgId;
|
||||
var roleList = await _sysUserRoleService.GetUserRoleList(userId);
|
||||
if (roleList != null && roleList.Exists(r => r.Code == role.Code)) return true;
|
||||
|
||||
roleList = new List<SysRole> { role };
|
||||
var orgIds = await GetUserOrgIdList(roleList, userId, userOrgId);
|
||||
return orgIds.Contains(userOrgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色Id集合获取机构Id集合
|
||||
/// </summary>
|
||||
|
||||
@ -54,11 +54,14 @@ public class SysRoleService : IDynamicApiController, ITransient
|
||||
[DisplayName("获取角色分页列表")]
|
||||
public async Task<SqlSugarPagedList<PageRoleOutput>> Page(PageRoleInput input)
|
||||
{
|
||||
// 当前用户已拥有的角色集合
|
||||
var roleIdList = _userManager.SuperAdmin ? new List<long>() : await _sysUserRoleService.GetUserRoleIdList(_userManager.UserId);
|
||||
|
||||
return await _sysRoleRep.AsQueryable()
|
||||
.LeftJoin<SysTenant>((u, a) => u.TenantId == a.Id)
|
||||
.LeftJoin<SysOrg>((u, a, b) => a.OrgId == b.Id)
|
||||
.WhereIF(!_userManager.SuperAdmin, u => u.TenantId == _userManager.TenantId) // 若非超管,则只能操作本租户的角色
|
||||
.WhereIF(!_userManager.SuperAdmin && !_userManager.SysAdmin, u => u.CreateUserId == _userManager.UserId) // 若非超管且非系统管理员,则只能操作自己创建的角色
|
||||
.WhereIF(!_userManager.SuperAdmin && !_userManager.SysAdmin, u => u.CreateUserId == _userManager.UserId || roleIdList.Contains(u.Id)) // 若非超管且非系统管理员,则只能操作自己创建的角色
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code.Contains(input.Code))
|
||||
.Select((u, a, b) => new PageRoleOutput
|
||||
|
||||
@ -186,18 +186,12 @@
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { ElMessageBox, ElMessage } from "element-plus";
|
||||
import { auth } from '/@@/utils/authFunction';
|
||||
import { useUserInfo } from '/@/stores/userInfo';
|
||||
import { useUserInfo } from '/@@/stores/userInfo';
|
||||
|
||||
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
|
||||
import { useVxeTable } from '/@@/hooks/useVxeTableOptionsHook';
|
||||
import { Local } from '/@@/utils/storage';
|
||||
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
|
||||
@:import { codeToName, getConstType } from "/@@/utils/constHelper";
|
||||
}
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "DictSelector") || @Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
|
||||
@:import { getDictLabelByCode as dc, getDictLabelByVal as dv, getDictDataList as dl } from '/@@/utils/dict-utils';
|
||||
}
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "DatePicker")){
|
||||
@:import { formatDate } from '/@@/utils/formatTime';
|
||||
}
|
||||
@ -242,6 +236,15 @@ const xGrid = ref<VxeGridInstance>();
|
||||
const editDialogRef = ref<InstanceType<typeof EditDialog>>();
|
||||
const userStore = useUserInfo();
|
||||
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "ConstSelector")){
|
||||
@:const codeToName = userStore.codeToName;
|
||||
}
|
||||
@if(@Model.TableField.Any(x=>x.EffectType == "DictSelector") || @Model.TableField.Any(x=>x.EffectType == "EnumSelector")){
|
||||
@:const dc = userStore.getDictItemByCode;
|
||||
@:const dv = userStore.getDictLabelByVal;
|
||||
@:const dl = userStore.getDictDataByCode;
|
||||
}
|
||||
|
||||
// 变量
|
||||
const state = reactive({
|
||||
showAdvanceQueryUI: false,
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.12.0" />
|
||||
<PackageReference Include="Rezero.Api" Version="1.7.12" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "admin.net.pro",
|
||||
"type": "module",
|
||||
"version": "2.4.33",
|
||||
"lastBuildTime": "2024.12.03",
|
||||
"lastBuildTime": "2024.12.04",
|
||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||
"author": "zuohuaijun",
|
||||
"license": "MIT",
|
||||
@ -29,7 +29,7 @@
|
||||
"@wangeditor/editor-for-vue": "^5.1.12",
|
||||
"animate.css": "^4.1.1",
|
||||
"async-validator": "^4.2.5",
|
||||
"axios": "^1.7.8",
|
||||
"axios": "^1.7.9",
|
||||
"countup.js": "^2.8.0",
|
||||
"cropperjs": "^1.6.2",
|
||||
"crypto-js": "^4.2.0",
|
||||
@ -51,7 +51,7 @@
|
||||
"mqtt": "^5.10.3",
|
||||
"nprogress": "^0.2.0",
|
||||
"ol": "^10.3.0",
|
||||
"pinia": "^2.2.8",
|
||||
"pinia": "^2.3.0",
|
||||
"print-js": "^1.6.0",
|
||||
"push.js": "^1.0.12",
|
||||
"qrcodejs2-fixes": "^0.0.2",
|
||||
@ -74,7 +74,7 @@
|
||||
"vue-router": "^4.5.0",
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vxe-pc-ui": "^4.3.12",
|
||||
"vxe-pc-ui": "^4.3.14",
|
||||
"vxe-table": "^4.8.10",
|
||||
"vxe-table-plugin-element": "^4.0.4",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
||||
@ -88,8 +88,8 @@
|
||||
"@types/node": "^20.17.9",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"@types/sortablejs": "^1.15.8",
|
||||
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
||||
"@typescript-eslint/parser": "^8.16.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
||||
"@typescript-eslint/parser": "^8.17.0",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
||||
"@vue/compiler-sfc": "^3.5.13",
|
||||
@ -98,9 +98,9 @@
|
||||
"eslint-plugin-vue": "^9.32.0",
|
||||
"globals": "^15.13.0",
|
||||
"less": "^4.2.1",
|
||||
"prettier": "^3.4.1",
|
||||
"prettier": "^3.4.2",
|
||||
"rollup-plugin-visualizer": "^5.12.0",
|
||||
"sass": "^1.81.0",
|
||||
"sass": "^1.82.0",
|
||||
"terser": "^5.36.0",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.2",
|
||||
|
||||
@ -135,7 +135,7 @@ export interface AddOrgInput {
|
||||
longitude?: number;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof AddOrgInput
|
||||
|
||||
@ -110,7 +110,7 @@ export interface AddRegionInput {
|
||||
longitude?: number;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof AddRegionInput
|
||||
|
||||
@ -82,6 +82,30 @@ export interface CodeGenInput {
|
||||
*/
|
||||
descStr?: string | null;
|
||||
|
||||
/**
|
||||
* 数据库表名
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
tableName?: string | null;
|
||||
|
||||
/**
|
||||
* 业务名(业务代码包名称)
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
busName?: string | null;
|
||||
|
||||
/**
|
||||
* 命名空间
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
nameSpace?: string | null;
|
||||
|
||||
/**
|
||||
* 作者姓名
|
||||
*
|
||||
@ -90,6 +114,30 @@ export interface CodeGenInput {
|
||||
*/
|
||||
authorName?: string | null;
|
||||
|
||||
/**
|
||||
* 生成方式
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
generateType?: string | null;
|
||||
|
||||
/**
|
||||
* 是否生成菜单
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
generateMenu?: boolean;
|
||||
|
||||
/**
|
||||
* 是否使用 Api Service
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
isApiService?: boolean;
|
||||
|
||||
/**
|
||||
* 类名
|
||||
*
|
||||
@ -138,38 +186,6 @@ export interface CodeGenInput {
|
||||
*/
|
||||
connectionString?: string | null;
|
||||
|
||||
/**
|
||||
* 生成方式
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
generateType?: string | null;
|
||||
|
||||
/**
|
||||
* 数据库表名
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
tableName?: string | null;
|
||||
|
||||
/**
|
||||
* 命名空间
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
nameSpace?: string | null;
|
||||
|
||||
/**
|
||||
* 业务名(业务代码包名称)
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
busName?: string | null;
|
||||
|
||||
/**
|
||||
* 功能名(数据库表名称)
|
||||
*
|
||||
@ -186,14 +202,6 @@ export interface CodeGenInput {
|
||||
*/
|
||||
menuApplication?: string | null;
|
||||
|
||||
/**
|
||||
* 是否生成菜单
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
generateMenu?: boolean;
|
||||
|
||||
/**
|
||||
* 菜单父级
|
||||
*
|
||||
@ -233,12 +241,4 @@ export interface CodeGenInput {
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
printName?: string | null;
|
||||
|
||||
/**
|
||||
* 是否使用 Api Service
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof CodeGenInput
|
||||
*/
|
||||
isApiService?: boolean;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ export interface LogVisOutput {
|
||||
longitude?: number | null;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof LogVisOutput
|
||||
|
||||
@ -150,7 +150,7 @@ export interface SysLogEx {
|
||||
longitude?: number | null;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof SysLogEx
|
||||
|
||||
@ -150,7 +150,7 @@ export interface SysLogOp {
|
||||
longitude?: number | null;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof SysLogOp
|
||||
|
||||
@ -150,7 +150,7 @@ export interface SysLogVis {
|
||||
longitude?: number | null;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof SysLogVis
|
||||
|
||||
@ -151,7 +151,7 @@ export interface SysOrg {
|
||||
longitude?: number;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof SysOrg
|
||||
|
||||
@ -118,7 +118,7 @@ export interface SysRegion {
|
||||
longitude?: number;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof SysRegion
|
||||
|
||||
@ -135,7 +135,7 @@ export interface UpdateOrgInput {
|
||||
longitude?: number;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof UpdateOrgInput
|
||||
|
||||
@ -110,7 +110,7 @@ export interface UpdateRegionInput {
|
||||
longitude?: number;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
* 纬度
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof UpdateRegionInput
|
||||
|
||||
@ -15,10 +15,10 @@ const { t } = i18n.global;
|
||||
*/
|
||||
export const useUserInfo = defineStore('userInfo', {
|
||||
state: (): UserInfosState => ({
|
||||
userInfos: {} as any,
|
||||
constList: [] as any,
|
||||
dictList: {} as any,
|
||||
userTableList: [] as any, // 用户表格字段数据
|
||||
userInfos: {} as any, // 用户信息
|
||||
constList: [] as any, // 常量列表
|
||||
dictList: {} as any, // 字典列表
|
||||
userTableList: [] as any, // 用户表格字段列表
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
@ -135,6 +135,39 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
getDictDataByCode(dictTypeCode: string) {
|
||||
return this.dictList[dictTypeCode] || [];
|
||||
},
|
||||
|
||||
// 根据字典类型和代码取字典项
|
||||
getDictItemByCode(typePCode: string, code: string) {
|
||||
if (code != undefined && code !== '') {
|
||||
const _code = code.toString();
|
||||
const ds = this.getDictDataByCode(typePCode);
|
||||
for (const element of ds) {
|
||||
if (element.code === _code) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
// 根据字典类型和值取描述
|
||||
getDictLabelByVal(typePCode: string, val: string) {
|
||||
if (val != undefined && val !== '') {
|
||||
const _val = val.toString();
|
||||
const ds = this.getDictDataByCode(typePCode);
|
||||
for (const element of ds) {
|
||||
if (element.value === _val) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
// 常量编码和名称转换
|
||||
codeToName(code: any, type: any) {
|
||||
return this.constList.find((x: any) => x.code === type).data.result.find((x: any) => x.code === code)?.name;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user