增加字段dto数据传输对象,对该角色没有关联的属性是否授权赋值为null
This commit is contained in:
parent
764a77456e
commit
b932f6f6a0
@ -1,5 +1,6 @@
|
|||||||
using ZR.Admin.WebApi.Filters;
|
using ZR.Admin.WebApi.Filters;
|
||||||
using ZR.ServiceCore.Model;
|
using ZR.ServiceCore.Model;
|
||||||
|
using ZR.ServiceCore.Model.Dto;
|
||||||
using ZR.ServiceCore.Services.IService;
|
using ZR.ServiceCore.Services.IService;
|
||||||
|
|
||||||
namespace ZR.Admin.WebApi.Controllers.System;
|
namespace ZR.Admin.WebApi.Controllers.System;
|
||||||
@ -9,10 +10,12 @@ namespace ZR.Admin.WebApi.Controllers.System;
|
|||||||
public class SysFieldController : BaseController
|
public class SysFieldController : BaseController
|
||||||
{
|
{
|
||||||
private readonly ISysFieldService _sysFieldService;
|
private readonly ISysFieldService _sysFieldService;
|
||||||
|
private readonly ISysRoleFieldService _sysRoleFieldService;
|
||||||
public SysFieldController(ISysFieldService sysFieldService)
|
|
||||||
|
public SysFieldController(ISysFieldService sysFieldService, ISysRoleFieldService sysRoleFieldService)
|
||||||
{
|
{
|
||||||
_sysFieldService = sysFieldService;
|
_sysFieldService = sysFieldService;
|
||||||
|
_sysRoleFieldService = sysRoleFieldService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("getModelList")]
|
[HttpGet("getModelList")]
|
||||||
@ -33,11 +36,53 @@ public class SysFieldController : BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("getFields")]
|
[HttpGet("getFields")]
|
||||||
public async Task<IActionResult> GetFields([FromQuery] string fullName)
|
public async Task<IActionResult> GetFields([FromQuery] string fullName, long roleId)
|
||||||
{
|
{
|
||||||
var list = await _sysFieldService.Queryable()
|
var fields = await _sysFieldService.Queryable()
|
||||||
.Where(it => it.FullName == fullName)
|
.Where(it => it.FullName == fullName)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
var roleFields = await _sysRoleFieldService
|
||||||
|
.Queryable()
|
||||||
|
.Where(it => it.RoleId == roleId)
|
||||||
|
.Select(it => it.FieldId)
|
||||||
|
.ToListAsync();
|
||||||
|
var list = new List<SysFieldDto>();
|
||||||
|
list = fields.Select(it => new SysFieldDto
|
||||||
|
{
|
||||||
|
FieldName = it.FieldName,
|
||||||
|
FieldType = it.FieldType,
|
||||||
|
FullName = it.FullName,
|
||||||
|
Id = it.Id,
|
||||||
|
IsClass = it.IsClass,
|
||||||
|
IsPermission = roleFields.Contains(it.Id)
|
||||||
|
}).ToList();
|
||||||
|
// fields.ForEach(it =>
|
||||||
|
// {
|
||||||
|
// if (it.Id != 0 && roleFields.Contains(it.Id))
|
||||||
|
// {
|
||||||
|
// list.Add(new SysFieldDto
|
||||||
|
// {
|
||||||
|
// FieldName = it.FieldName,
|
||||||
|
// FieldType = it.FieldType,
|
||||||
|
// FullName = it.FullName,
|
||||||
|
// Id = it.Id,
|
||||||
|
// IsClass = it.IsClass,
|
||||||
|
// IsPermission = true
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// list.Add(new SysFieldDto
|
||||||
|
// {
|
||||||
|
// FieldName = it.FieldName,
|
||||||
|
// FieldType = it.FieldType,
|
||||||
|
// FullName = it.FullName,
|
||||||
|
// Id = it.Id,
|
||||||
|
// IsClass = it.IsClass,
|
||||||
|
// IsPermission = false
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
return SUCCESS(list);
|
return SUCCESS(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,4 +129,6 @@ public class SysFieldController : BaseController
|
|||||||
|
|
||||||
return SUCCESS(serviceCoreModels);
|
return SUCCESS(serviceCoreModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IActionResult> AddOrUpdateSysRoleField([FromBody] List<SysFieldDto> sysFieldDtos){}
|
||||||
}
|
}
|
||||||
17
ZR.ServiceCore/Model/Dto/SysFieldDto.cs
Normal file
17
ZR.ServiceCore/Model/Dto/SysFieldDto.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace ZR.ServiceCore.Model.Dto;
|
||||||
|
|
||||||
|
public class SysFieldDto
|
||||||
|
{
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public string FieldName { get; set; }
|
||||||
|
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
public string FieldType { get; set; }
|
||||||
|
|
||||||
|
public string IsClass { get; set; }
|
||||||
|
|
||||||
|
public bool IsPermission { get; set; }
|
||||||
|
}
|
||||||
11
ZR.ServiceCore/Services/SysRoleFieldService.cs
Normal file
11
ZR.ServiceCore/Services/SysRoleFieldService.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using Infrastructure.Attribute;
|
||||||
|
using ZR.Service;
|
||||||
|
using ZR.ServiceCore.Model;
|
||||||
|
using ZR.ServiceCore.Services.IService;
|
||||||
|
|
||||||
|
namespace ZR.ServiceCore.Services;
|
||||||
|
[AppService(ServiceType = typeof(ISysRoleFieldService), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class SysRoleFieldService : BaseService<SysRoleField>, ISysRoleFieldService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user