From 004cb201324695421822ff0b8c6ff4f8388dbccb Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 11 Sep 2022 14:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A7=92=E8=89=B2=E5=85=B3?= =?UTF-8?q?=E8=81=94=E8=8F=9C=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/SwaggerDoc.xml | 7 + .../Controllers/RoleController.cs | 12 + .../yi-sqlsugar-dev.db | Bin 126976 -> 126976 bytes .../Yi.Framework.DTOModel/RoleInfoDto.cs | 16 + .../Yi.Framework.DTOModel/UserInfoDto.cs | 2 +- .../Yi.Framework.Interface/IRoleService.cs | 8 + .../Yi.Framework.Service/RoleService.cs | 17 +- Yi.Vue3.X.RuoYi/src/api/system/role.js | 15 +- .../src/views/system/role/index.vue | 487 ++++++++---------- .../src/views/system/user/index.vue | 8 +- 10 files changed, 275 insertions(+), 297 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.DTOModel/RoleInfoDto.cs diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 889d2c7d..a674189e 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -254,6 +254,13 @@ + + + 添加角色包含菜单 + + + + 测试控制器 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs index b4b38a18..72d28dce 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -60,5 +60,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers { return Result.Success().SetData(await _iRoleService.GetInMenuByRoleId(RoleId)); } + + /// + /// 添加角色包含菜单 + /// + /// + /// + + [HttpPost] + public async Task AddInfo(RoleInfoDto roleDto) + { + return Result.Success().SetData(await _iRoleService.AddInfo(roleDto)); + } } } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index b1bfb457e9e9abc07054574413038b5fe2b473a3..ee4bac059adaaa8f50a41da441e4cb788463801d 100644 GIT binary patch delta 1190 zcmZ{iPe>GD7{fknk7Z0+s2M^sO(321ZT`K5o^zDq=xT`G8^3M1D-uHQ)cV>42 zvpa!jrQ6jil~u_vG6Cq+4ew{QVZ z;k2+Tl!Q6ql28w2cnSmd>G-dZUEkTwiXzW(9O^)I2ubDFgY(vCw|vGkk*ZB;X%nii zz3P@HYOmp{Yb6m$-0<|ZlE_5<8tZrSBB~MYOi1ytjRfdN@CDYuh622RdC0*X$ifi( zf$z{yMYnOeHxYcsn=pnK@B;1k z7YBLsAJ{R}7NUvRQgwd03k_uJm;ILtL1) zNIL($ZY!E*u{THks^rkF+)he@q?4(nsuEo#*4RkFPhGFs^`k|IHtmZzL7fTvZT$B3 zWZRlg<~tVy3Ud|*-vn<4Tlt^7&EMlYsTUugGv&Sbsf0?CcX^R!e_<6Zn4f5Tt#241B*%;W3sN9*oR_7tdbuW;gxdJ5Fw7L^ES0-l12cnTC= Ki4HJ7-u?rW`4{;B delta 650 zcmZp8z~1nHeS$P&{6raN#`uj1YxtS?iZ}BKxN(V^>KYg;7+P8x8(A3`>lv7so0yoH zY|fO*V`AdB+I&-H79&fe3$ys-a=GP`pUBJ9GcYh5V`E@saAsiOU=VGzv}KTHV33pt zafDw;{yZeWAY^1|^ffX6#q$*1F*=&2sJWOSbXv%;=Bgz(87IsL0QRJWL z;nF4n21rO@XypP1GB1Aw1OFHP=lr+$&+;GO-^{;^eV`IA?yss&OpV2lgr{QCuhVj+s=1@ y@go1``}wK|n1#4+O=mY?R0SHnj(htpYep>=W+8s@>Ff?*vDbXt#r+vyE&u==G^}I* diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/RoleInfoDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/RoleInfoDto.cs new file mode 100644 index 00000000..7d972ee3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/RoleInfoDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.DTOModel +{ + public class RoleInfoDto + { + public RoleEntity Role { get; set; } + public List DeptIds { get; set; } + public List MenuIds { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserInfoDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/UserInfoDto.cs index 51616402..983e7135 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserInfoDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/UserInfoDto.cs @@ -11,7 +11,7 @@ namespace Yi.Framework.DTOModel { public UserEntity User { get; set; } public List RoleIds { get; set; } - public List PostId { get; set; } + public List PostIds { get; set; } public long? DeptId { get; set; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs index a59666b3..4414bc1a 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Yi.Framework.Common.Models; +using Yi.Framework.DTOModel; using Yi.Framework.Model.Models; using Yi.Framework.Repository; @@ -36,5 +37,12 @@ namespace Yi.Framework.Interface /// /// Task>> SelctPageList(RoleEntity role, PageParModel page); + + /// + /// 添加角色关联菜单 + /// + /// + /// + Task AddInfo(RoleInfoDto roleDto); } } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs index 0bd24471..bd51a930 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs @@ -1,8 +1,10 @@ using SqlSugar; using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Yi.Framework.Common.Models; +using Yi.Framework.DTOModel; using Yi.Framework.Interface; using Yi.Framework.Model.Models; using Yi.Framework.Repository; @@ -20,13 +22,13 @@ namespace Yi.Framework.Service var _repositoryRoleMenu= _repository.ChangeRepository>(); //多次操作,需要事务确保原子性 return await _repositoryRoleMenu.UseTranAsync(async () => - { + { //删除用户之前所有的用户角色关系(物理删除,没有恢复的必要) + await _repositoryRoleMenu.DeleteAsync(u => roleIds.Contains((long)u.RoleId) ); //遍历用户 foreach (var roleId in roleIds) { - //删除用户之前所有的用户角色关系(物理删除,没有恢复的必要) - await _repositoryRoleMenu.DeleteAsync(u => u.RoleId==roleId); + //添加新的关系 List roleMenuEntity = new(); @@ -64,5 +66,14 @@ namespace Yi.Framework.Service return new PageModel>(data, total); } + + + + public async Task AddInfo(RoleInfoDto roleDto) + { + var res1 = await _repository.InsertReturnSnowflakeIdAsync(roleDto.Role); + var res2 = await GiveRoleSetMenu(new List { res1 }, roleDto.MenuIds); + return !0.Equals(res1) && res2; + } } } diff --git a/Yi.Vue3.X.RuoYi/src/api/system/role.js b/Yi.Vue3.X.RuoYi/src/api/system/role.js index 5f65dfe0..27d4ae14 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/role.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/role.js @@ -9,10 +9,12 @@ export function listRole(query) { }) } + + // 查询角色详细 export function getRole(roleId) { return request({ - url: '/system/role/' + roleId, + url: '/role/getById/' + roleId, method: 'get' }) } @@ -20,7 +22,7 @@ export function getRole(roleId) { // 新增角色 export function addRole(data) { return request({ - url: '/system/role', + url: '/role/addInfo', method: 'post', data: data }) @@ -59,9 +61,14 @@ export function changeRoleStatus(roleId, status) { // 删除角色 export function delRole(roleId) { + if("string"==typeof(roleId)) + { + roleId=[roleId]; + } return request({ - url: '/system/role/' + roleId, - method: 'delete' + url: '/role/delList', + method: 'delete', + data:roleId }) } diff --git a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue index 275dec07..75e3237b 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue @@ -1,269 +1,177 @@