From 540def15c3dbd047b1a97d363b420373d6ce5b93 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Sat, 22 Jul 2023 12:00:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=92=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserManagement/RoleAppService.cs | 17 +++++++++++++++++ .../UserManagement/UserAppService.cs | 13 +++++++++++-- .../wwwroot/components/form/form-input.js | 2 +- .../wwwroot/components/list/index.js | 3 ++- .../wwwroot/models/role.js | 5 ++++- .../wwwroot/models/user.js | 5 +++-- 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs b/code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs index 1b9822fb..7259ac48 100644 --- a/code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs +++ b/code/src/Modules/BaseService/BaseService.Application/UserManagement/RoleAppService.cs @@ -23,6 +23,14 @@ namespace BaseService.UserManagement _repository = roleRepository; } + [HttpGet] + public async Task> GetAllAsync() + { + var items = await _repository.GetListAsync().ConfigureAwait(false); + var dtos = ObjectMapper.Map, List>(items); + return new ListResultDto(dtos); + } + [HttpGet] public async Task> GetListAsync(GetIdentityRolesInput input) { @@ -33,6 +41,15 @@ namespace BaseService.UserManagement return new PagedResultDto(totalCount, dtos); } + [HttpGet("{id}")] + [Authorize(IdentityPermissions.Roles.Delete)] + public async Task Details(Guid id) + { + var role = await _roleManager.GetByIdAsync(id).ConfigureAwait(false); + var dto = ObjectMapper.Map(role); + return dto; + } + [HttpPost] [Authorize(IdentityPermissions.Roles.Create)] public async Task CreateAsync(IdentityRoleCreateDto input) diff --git a/code/src/Modules/BaseService/BaseService.Application/UserManagement/UserAppService.cs b/code/src/Modules/BaseService/BaseService.Application/UserManagement/UserAppService.cs index 609fc6ad..80cae7fb 100644 --- a/code/src/Modules/BaseService/BaseService.Application/UserManagement/UserAppService.cs +++ b/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 Delete(Guid id) + { + var entity = await UserManager.GetByIdAsync(id).ConfigureAwait(false); + await UserManager.DeleteAsync(entity).ConfigureAwait(false); + return new OkResult(); + } } -} \ No newline at end of file +} diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js index 6ea4e459..a7c27f10 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js +++ b/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], diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js index 075b776e..3e61c4df 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js +++ b/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; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/role.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/role.js index 6a4d3b5d..be94b800 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/role.js +++ b/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, diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/user.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/user.js index 600b21cf..07f136d8 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/user.js +++ b/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";