😎1、获取用户信息返回角色详细集合 2、完善角色相关翻译文件 3、更新前端请求文件

This commit is contained in:
zuohuaijun 2025-07-17 12:02:43 +08:00
parent f7d298df36
commit 699063658b
10 changed files with 86 additions and 9 deletions

View File

@ -212,7 +212,10 @@ public class AppAuthService : IDynamicApiController, ITransient
// 职位
var pos = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysPos>>().GetByIdAsync(user.PosId);
// 角色集合
var roleIds = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable().Where(u => u.UserId == user.Id).Select(u => u.RoleId).ToListAsync();
var roles = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable()
.LeftJoin<SysRole>((u, a) => u.RoleId == a.Id)
.Where(u => u.UserId == user.Id)
.Select((u, a) => new RoleDto { Id = a.Id, Name = a.Name, Code = a.Code }).ToListAsync();
// 接口集合
var apis = (await _sysRoleService.GetUserApiList())[0];
@ -233,7 +236,7 @@ public class AppAuthService : IDynamicApiController, ITransient
OrgType = org?.Type,
PosName = pos?.Name,
Apis = apis,
RoleIds = roleIds
Roles = roles
};
}

View File

@ -99,7 +99,7 @@ public class LoginUserOutput
/// <summary>
/// 角色集合
/// </summary>
public List<long> RoleIds { get; set; }
public List<RoleDto> Roles { get; set; }
/// <summary>
/// 水印文字
@ -110,4 +110,25 @@ public class LoginUserOutput
/// 最新密码修改时间
/// </summary>
public DateTime? LastChangePasswordTime;
}
/// <summary>
/// 角色
/// </summary>
public class RoleDto
{
/// <summary>
/// 角色Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 编码
/// </summary>
public string Code { get; set; }
}

View File

@ -293,7 +293,10 @@ public class SysAuthService : IDynamicApiController, ITransient
// 职位
var pos = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysPos>>().GetByIdAsync(user.PosId);
// 角色集合
var roleIds = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable().Where(u => u.UserId == user.Id).Select(u => u.RoleId).ToListAsync();
var roles = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable()
.LeftJoin<SysRole>((u, a) => u.RoleId == a.Id)
.Where(u => u.UserId == user.Id)
.Select((u, a) => new RoleDto { Id = a.Id, Name=a.Name, Code = a.Code }).ToListAsync();
// 接口集合
var apis = (await App.GetRequiredService<SysRoleService>().GetUserApiList())[0];
// 个性化水印文字(若系统水印为空则不显示)
@ -319,7 +322,7 @@ public class SysAuthService : IDynamicApiController, ITransient
OrgType = org?.Type,
PosName = pos?.Name,
Apis = apis,
RoleIds = roleIds,
Roles = roles,
WatermarkText = watermarkText,
LastChangePasswordTime = user.LastChangePasswordTime
};

View File

@ -397,6 +397,7 @@ export * from './report-data-source-output';
export * from './reset-column-custom-input';
export * from './reset-pwd-user-input';
export * from './role-api-input';
export * from './role-dto';
export * from './role-input';
export * from './role-menu-input';
export * from './role-org-input';

View File

@ -13,6 +13,7 @@
*/
import { AccountTypeEnum } from './account-type-enum';
import { RoleDto } from './role-dto';
/**
*
*
@ -158,10 +159,10 @@ export interface LoginUserOutput {
/**
*
*
* @type {Array<number>}
* @type {Array<RoleDto>}
* @memberof LoginUserOutput
*/
roleIds?: Array<number> | null;
roles?: Array<RoleDto> | null;
/**
*

View File

@ -0,0 +1,46 @@
/* 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 RoleDto
*/
export interface RoleDto {
/**
* Id
*
* @type {number}
* @memberof RoleDto
*/
id?: number;
/**
*
*
* @type {string}
* @memberof RoleDto
*/
name?: string | null;
/**
*
*
* @type {string}
* @memberof RoleDto
*/
code?: string | null;
}

View File

@ -221,6 +221,7 @@ export default {
editRole: 'Edit Role',
confirmDeleteRole: 'Are you sure to delete role: [{roleName}]?',
dataScope: 'Data Scope',
sysFlag: 'System Flag',
tenantName: 'Tenant Name',
roleCodeRequired: 'Role code is required',
roleNameRequired: 'Role name is required',

View File

@ -223,6 +223,7 @@ export default {
editRole: '编辑角色',
confirmDeleteRole: '确定删除角色:【{roleName}】?',
dataScope: '数据范围',
sysFlag: '是否内置',
tenantName: '租户名称',
role: '角色',
apiRoute: 'API路由',

View File

@ -87,7 +87,7 @@ export const useUserInfo = defineStore('userInfo', {
orgName: d.orgName,
posName: d.posName,
posId: d.posId,
roles: d.roleIds,
roles: d.roles,
authApiList: d.apis,
lastChangePasswordTime: d.lastChangePasswordTime,
time: new Date().getTime(),

View File

@ -139,7 +139,7 @@ const options = useVxeTable<PageRoleOutput>(
{ field: 'name', title: i18n.t('message.list.roleName'), minWidth: 150, showOverflow: 'tooltip' },
{ field: 'code', title: i18n.t('message.list.roleCode'), minWidth: 150, showOverflow: 'tooltip' },
{ field: 'dataScope', title: i18n.t('message.list.dataScope'), minWidth: 150, showOverflow: 'tooltip', slots: { default: 'row_dataScope' } },
{ field: 'sysFlag', title: '是否内置', width: 80, showOverflow: 'tooltip', slots: { default: 'row_sysFlag' } },
{ field: 'sysFlag', title: i18n.t('message.list.sysFlag'), width: 80, showOverflow: 'tooltip', slots: { default: 'row_sysFlag' } },
{ field: 'tenantName', title: i18n.t('message.list.tenantName'), minWidth: 180, showOverflow: 'tooltip' },
{ field: 'orderNo', title: i18n.t('message.list.orderNo'), width: 80, showOverflow: 'tooltip' },
{ field: 'status', title: i18n.t('message.list.status'), width: 80, showOverflow: 'tooltip', slots: { default: 'row_status' } },