feat: 添加用户、角色状态修改

This commit is contained in:
橙子
2023-02-19 22:18:04 +08:00
parent dffdaa8d68
commit 380f728de2
8 changed files with 64 additions and 6 deletions

View File

@@ -128,6 +128,14 @@
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.RBAC.Application.Identity.RoleService.UpdateStateAsync(System.Int64,System.Boolean)">
<summary>
更新状态
</summary>
<param name="id"></param>
<param name="state"></param>
<returns></returns>
</member>
<member name="T:Yi.RBAC.Application.Identity.UserService"> <member name="T:Yi.RBAC.Application.Identity.UserService">
<summary> <summary>
User服务实现 User服务实现
@@ -163,6 +171,14 @@
<param name="input"></param> <param name="input"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.RBAC.Application.Identity.UserService.UpdateStateAsync(System.Int64,System.Boolean)">
<summary>
更新状态
</summary>
<param name="id"></param>
<param name="state"></param>
<returns></returns>
</member>
<member name="T:Yi.RBAC.Application.Setting.ConfigService"> <member name="T:Yi.RBAC.Application.Setting.ConfigService">
<summary> <summary>
Config服务实现 Config服务实现

View File

@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Identity;
using Yi.Framework.Uow; using Yi.Framework.Uow;
using Yi.Framework.Ddd.Dtos; using Yi.Framework.Ddd.Dtos;
using SqlSugar; using SqlSugar;
using Microsoft.AspNetCore.Mvc;
namespace Yi.RBAC.Application.Identity namespace Yi.RBAC.Application.Identity
{ {
@@ -80,5 +81,25 @@ namespace Yi.RBAC.Application.Identity
} }
return dto; return dto;
} }
/// <summary>
/// 更新状态
/// </summary>
/// <param name="id"></param>
/// <param name="state"></param>
/// <returns></returns>
[Route("/api/role/{id}/{state}")]
public async Task<RoleGetOutputDto> UpdateStateAsync([FromRoute] long id, [FromRoute] bool state)
{
var entity = await _repository.GetByIdAsync(id);
if (entity is null)
{
throw new ApplicationException("角色未存在");
}
entity.State = state;
return await MapToGetOutputDtoAsync(entity);
}
} }
} }

View File

@@ -10,6 +10,7 @@ using Yi.Framework.Ddd.Dtos;
using Yi.RBAC.Domain.Identity.Repositories; using Yi.RBAC.Domain.Identity.Repositories;
using SqlSugar; using SqlSugar;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc;
namespace Yi.RBAC.Application.Identity namespace Yi.RBAC.Application.Identity
{ {
@@ -132,5 +133,24 @@ namespace Yi.RBAC.Application.Identity
} }
return await MapToGetOutputDtoAsync(entity); return await MapToGetOutputDtoAsync(entity);
} }
/// <summary>
/// 更新状态
/// </summary>
/// <param name="id"></param>
/// <param name="state"></param>
/// <returns></returns>
[Route("/api/user/{id}/{state}")]
public async Task<UserGetOutputDto> UpdateStateAsync([FromRoute] long id,[FromRoute] bool state)
{
var entity = await _repository.GetByIdAsync(id);
if (entity is null)
{
throw new ApplicationException("用户未存在");
}
entity.State = state;
return await MapToGetOutputDtoAsync(entity);
}
} }
} }

View File

@@ -49,7 +49,7 @@ export function dataScope(data) {
// 角色状态修改 // 角色状态修改
export function changeRoleStatus(roleId, isDel) { export function changeRoleStatus(roleId, isDel) {
return request({ return request({
url: `/role/updateStatus?roleId=${roleId}&isDel=${isDel}`, url: `/role/${roleId}/${isDel}`,
method: 'put' method: 'put'
}) })
} }

View File

@@ -61,7 +61,7 @@ export function resetUserPwd(id, password) {
// 用户状态修改 // 用户状态修改
export function changeUserStatus(userId, isDel) { export function changeUserStatus(userId, isDel) {
return request({ return request({
url: `/user/updateStatus?userId=${userId}&isDel=${isDel}`, url: `/user/${userId}/${isDel}`,
method: 'put' method: 'put'
}) })
} }

View File

@@ -51,7 +51,7 @@
<el-table-column label="显示顺序" prop="orderNum" /> <el-table-column label="显示顺序" prop="orderNum" />
<el-table-column label="状态" align="center"> <el-table-column label="状态" align="center">
<template #default="scope"> <template #default="scope">
<el-switch v-model="scope.row.state" :active-value="true" :inactive-value="true" <el-switch v-model="scope.row.state" :active-value="true" :inactive-value="false"
@change="handleStatusChange(scope.row)"></el-switch> @change="handleStatusChange(scope.row)"></el-switch>
</template> </template>
</el-table-column> </el-table-column>
@@ -296,7 +296,7 @@ function handleSelectionChange(selection) {
} }
/** 角色状态修改 */ /** 角色状态修改 */
function handleStatusChange(row) { function handleStatusChange(row) {
let text = row.state === false ? "启用" : "停用"; let text = row.state === true ? "启用" : "停用";
proxy.$modal proxy.$modal
.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?') .confirm('确认要"' + text + '""' + row.roleName + '"角色吗?')
.then(function () { .then(function () {
@@ -306,7 +306,7 @@ function handleStatusChange(row) {
proxy.$modal.msgSuccess(text + "成功"); proxy.$modal.msgSuccess(text + "成功");
}) })
.catch(function () { .catch(function () {
row.state = row.state === "0" ? "1" : "0"; row.state = row.state === true ? false : true;
}); });
} }
/** 更多操作 */ /** 更多操作 */

View File

@@ -375,7 +375,8 @@ function handleExport() {
}; };
/** 用户状态修改 */ /** 用户状态修改 */
function handleStatusChange(row) { function handleStatusChange(row) {
let text = row.state === false ? "启用" : "停用"; console.log(row.state);
let text = row.state === true ? "启用" : "停用";
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () { proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
return changeUserStatus(row.id, row.state); return changeUserStatus(row.id, row.state);
}).then(() => { }).then(() => {