Browse Source

完善和修复用户角色

master
wanggang 1 year ago
parent
commit
540def15c3
  1. 17
      code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs
  2. 11
      code/src/Modules/BaseService/BaseService.Application/UserManagement/UserAppService.cs
  3. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js
  4. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  5. 5
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/role.js
  6. 5
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/user.js

17
code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs

@ -23,6 +23,14 @@ namespace BaseService.UserManagement
_repository = roleRepository;
}
[HttpGet]
public async Task<ListResultDto<IdentityRoleDto>> GetAllAsync()
{
var items = await _repository.GetListAsync().ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(items);
return new ListResultDto<IdentityRoleDto>(dtos);
}
[HttpGet]
public async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input)
{
@ -33,6 +41,15 @@ namespace BaseService.UserManagement
return new PagedResultDto<IdentityRoleDto>(totalCount, dtos);
}
[HttpGet("{id}")]
[Authorize(IdentityPermissions.Roles.Delete)]
public async Task<IdentityRoleDto> Details(Guid id)
{
var role = await _roleManager.GetByIdAsync(id).ConfigureAwait(false);
var dto = ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
return dto;
}
[HttpPost]
[Authorize(IdentityPermissions.Roles.Create)]
public async Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input)

11
code/src/Modules/BaseService/BaseService.Application/UserManagement/UserAppService.cs

@ -1,4 +1,4 @@
using BaseService.BaseData;
using BaseService.BaseData;
using BaseService.BaseData.Permissions.Dto;
using BaseService.RelationBaseData;
using BaseService.RelationData.Dto;
@ -408,5 +408,14 @@ namespace BaseService.Systems.UserManagement
return dto;
}
[HttpDelete("{id}")]
[Authorize(IdentityPermissions.Roles.Delete)]
public async Task<IActionResult> Delete(Guid id)
{
var entity = await UserManager.GetByIdAsync(id).ConfigureAwait(false);
await UserManager.DeleteAsync(entity).ConfigureAwait(false);
return new OkResult();
}
}
}

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js

@ -122,7 +122,7 @@ export default {
} else if (props.schema.url) {
try {
const url = `${props.schema.url}`;
const result = await request(url, null, { method: "POST" });
const result = await request(url, null, { method: props.schema.method ?? "POST" });
options.value = result.data?.items.map((o) => ({
value: o[props.schema.value],
label: o[props.schema.label],

3
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

@ -656,9 +656,10 @@ export default {
}
const method = editFormMode.value === "create" ? config.edit.createMethod : config.edit.updateMethod;
const response = await request(url, editFormModel.value, { method });
if (!response.errors) {
if (response.errors) {
ElMessageBox.alert(`错误:${response.errors?.error?.message}`, `代码:${response.errors?.error?.code}`);
//model.errors = response.errors; //??
} else {
await load();
editFormMode.value = null;
dialogVisible.value = false;

5
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/role.js

@ -20,10 +20,12 @@ const schema = {
};
const queryUrl = "role/get-list";
const detailsUrl = "role/details/%s";
const deleteUrl = "role/delete/%s";
const updateUrl = "role/update/%s";
const createUrl = "role/create";
const queryMethod = "GET";
const detailsMethod = "GET";
const deleteMethod = "DELETE";
const updateMethod = "PUT";
const createMethod = "POST";
@ -56,10 +58,11 @@ export default function () {
schema: schema,
},
edit: {
detailsUrl,
deleteUrl,
updateUrl,
createUrl,
detailsMethod,
deleteMethod,
updateMethod,
createMethod,

5
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/user.js

@ -69,7 +69,8 @@ const schema = {
type: "array",
input: "select",
multiple: true,
url: "identity/roles/all",
url: "role/get-all",
method: "get",
value: "name",
label: "name",
items: {
@ -84,7 +85,7 @@ const queryUrl = `${baseUrl}`;
const detailsUrl = `${baseUrl}/%s`;
const createUrl = `${baseUrl}`;
const updateUrl = `${baseUrl}/%s`;
const deleteUrl = "identity/users/%s";
const deleteUrl = `${baseUrl}/%s`;
const queryMethod = "GET";
const detailsMethod = "GET";
const createMethod = "POST";

Loading…
Cancel
Save