Skip to content

Commit b5b01bc

Browse files
committed
fix: 角色管理只显示当前用户所在租户的角色(含全局角色)
1 parent 1c0ad92 commit b5b01bc

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

Juggle.Api/Controllers/Api/RoleController.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ public RoleController(JuggleDbContext db, ITenantAccessor tenant)
2727
[HttpPost("page"), Authorize]
2828
public async Task<ApiResult> Page([FromBody] PageRequest req)
2929
{
30-
// 超级管理员看所有角色,其他人员只看本租户角色和全局角色(TenantId=null)
31-
var query = _db.Roles.Where(r => r.Deleted == 0);
32-
if (!_tenant.IsSuperAdmin)
33-
{
34-
// 非超管:显示全局角色(null TenantId)+ 本租户角色
35-
query = query.Where(r => r.TenantId == null || r.TenantId == _tenant.TenantId);
36-
}
30+
// 所有用户只看本租户角色和全局角色(TenantId=null)
31+
var query = _db.Roles.Where(r => r.Deleted == 0)
32+
.Where(r => r.TenantId == null || r.TenantId == _tenant.TenantId);
3733

3834
if (!string.IsNullOrEmpty(req.Keyword))
3935
query = query.Where(r => r.RoleName!.Contains(req.Keyword) || (r.RoleCode != null && r.RoleCode.Contains(req.Keyword)));

JuggleNet6.Frontend/src/views/system/TenantManage.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,14 @@ async function doSubmit() {
197197
if (!form.tenantName) { ElMessage.warning('请输入租户名称'); return }
198198
submitting.value = true
199199
try {
200+
const payload: any = { ...form }
201+
// 空字符串转为 null,避免 DateTime? 反序列化失败
202+
if (!payload.expiredAt) payload.expiredAt = null
203+
200204
if (isEdit.value) {
201-
await request.put('/tenant/update', { id: editId.value, ...form })
205+
await request.put('/tenant/update', { id: editId.value, ...payload })
202206
} else {
203-
await request.post('/tenant/add', form)
207+
await request.post('/tenant/add', payload)
204208
}
205209
ElMessage.success(isEdit.value ? '更新成功' : '新增成功')
206210
dlgVisible.value = false

0 commit comments

Comments
 (0)