From d001a0de1524e4a9171184592ef8bbe4e6a04678 Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Sun, 11 Sep 2022 02:39:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=BC=96=E8=BE=91=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/SwaggerDoc.xml | 68 +- .../Controllers/AccountController.cs | 4 +- .../BaseSimpleCrudController.cs | 5 +- .../Controllers/RoleController.cs | 2 +- .../Controllers/UserController.cs | 9 +- .../yi-sqlsugar-dev.db | Bin 126976 -> 126976 bytes .../Yi.Framework.Interface/IUserService.cs | 17 +- .../Yi.Framework.Model.csproj | 2 +- .../Yi.Framework.Service/UserService.cs | 24 +- Yi.Vue3.X.RuoYi/src/api/system/role.js | 7 + Yi.Vue3.X.RuoYi/src/api/system/user.js | 2 +- .../src/views/system/user/index.vue | 912 ++++++++---------- 12 files changed, 445 insertions(+), 607 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 60658e32..371d9ddd 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -115,7 +115,7 @@ - + 全部列表查询 @@ -150,40 +150,6 @@ - - - 添加字典表 - - - - - - - 根据字典id获取字典表 - - - - - - - 获取全部字典表 - - - - - - id范围删除 - - - - - - - 更新 - - - - 动态条件分页查询 @@ -192,13 +158,6 @@ - - - 添加字典信息表 - - - - 根据字典类别获取字典信息 @@ -206,27 +165,6 @@ - - - id范围删除 - - - - - - - 更新 - - - - - - - 根据字典id获取字典信息表 - - - - 文件 @@ -416,9 +354,9 @@ - + - 通过用户id得到角色列表 + 通过用户id得到用户信息关联部门、岗位、角色 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index e6eacd32..5a3a3591 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -92,7 +92,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [HttpGet] - [Authorize] + //[Authorize] public async Task GetUserAllInfo() { //通过鉴权jwt获取到用户的id @@ -111,7 +111,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers { var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; var data = await _iUserService.GetUserAllInfo(userId); - + //将后端菜单转换成前端路由,组件级别需要过滤 List routers = _iUserService.RouterBuild(data.Menus.ToList()); return Result.Success().SetData(routers); diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseSimpleCrudController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseSimpleCrudController.cs index a4acd206..2feb5aaf 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseSimpleCrudController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/BaseController/BaseSimpleCrudController.cs @@ -34,8 +34,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [Permission($"{nameof(T)}:get")] + [Route("{id}")] [HttpGet] - public virtual async Task GetById(long id) + public virtual async Task GetById([FromRoute]long id) { return Result.Success().SetData(await _repository.GetByIdAsync(id)); } @@ -45,7 +46,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// /// [Permission($"{nameof(T)}:get")] - [HttpPost] + [HttpGet] public virtual async Task GetList() { return Result.Success().SetData(await _repository.GetListAsync()); diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs index 57b2bc89..b4b38a18 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -21,7 +21,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [ApiController] [Route("api/[controller]/[action]")] - public class RoleController : BaseCrudController + public class RoleController : BaseSimpleCrudController { private IRoleService _iRoleService; public RoleController(ILogger logger, IRoleService iRoleService) : base(logger, iRoleService) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs index 436ccf56..302fc6d9 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -21,7 +21,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [ApiController] [Route("api/[controller]/[action]")] - public class UserController : BaseCrudController + public class UserController : BaseSimpleCrudController { private IUserService _iUserService; public UserController(ILogger logger, IUserService iUserService) : base(logger, iUserService) @@ -85,13 +85,14 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// - /// 通过用户id得到角色列表 + /// 通过用户id得到用户信息关联部门、岗位、角色 /// /// [HttpGet] - public async Task GetRoleListByUserId(long userId) + [Route("{id}")] + public override async Task GetById(long id) { - return Result.Success().SetData(await _iUserService.GetRoleListByUserId(userId)); + return Result.Success().SetData(await _iUserService.GetInfoById(id)); } } } 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 bc2597acdd9b90ed09ea2b331fc1aeb42169b108..6cc32675ecb8e0163f65fe25cb9a94078ce2f0bd 100644 GIT binary patch delta 275 zcmZp8z~1nHeS$P&;6xc`#=ypetqF_^`?>iSF);E+Gw?_AM{ibC@aOk-WfEYMW&i?b z1_llwB`Pg?Q4g26{$@W(I~vW+3S& zJ9Zfv8yf<3#!X)~pD~)7{|nHD=M4PM`JZnVEV#`-`G7vF64Xd0pfVoOBOBgK2AaKYDV(Iam^H8;WC0&)@1QZy%7S{WGX8Ch5w gSy-49rIt^R+0VFQGmFD*eh#Q^=IzhVGfFA|0LU^(X#fBK delta 106 zcmV-w0G0oM;0J)<2ap>9PLUi#0ZxHnwO|3Ej|l((009r801u+G5kQy^1Y7|S2A8Iv z0b8>Hp!g3H#IWp>!Vmxr000024_p8bxDQ;jAs|o>mt4OAs0acN=Kv4%59hNHaN7@) Mz%K>2?9TxdAOdY7#{d8T diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs index 887d398a..37776e4f 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs @@ -10,6 +10,12 @@ namespace Yi.Framework.Interface { public partial interface IUserService { + /// + /// 关联角色测试 + /// + /// + Task> GetListInRole(); + /// /// 测试仓储的上下文对象 /// @@ -34,10 +40,10 @@ namespace Yi.Framework.Interface Task Register(UserEntity userEntity, Action userAction = null); /// - /// 导航属性关联角色 + /// 导航属性关联角色、部门、岗位 /// /// - Task> GetListInRole(); + Task GetInfoById(long userId); /// /// 给用户设置角色,多用户,多角色 @@ -55,13 +61,6 @@ namespace Yi.Framework.Interface /// Task Exist(string userName, Action userAction = null); - /// - /// 通过用户id得到角色列表 - /// - /// - /// - Task> GetRoleListByUserId(long userId); - /// /// 获取当前登录用户的所有信息 /// diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj index 5f6a7ce3..7bc07bb8 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj +++ b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj @@ -6,7 +6,7 @@ - + diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs index cef8cf52..1be9b474 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs @@ -16,6 +16,10 @@ namespace Yi.Framework.Service { public partial class UserService { + public async Task> GetListInRole() + { + return await _repository._DbQueryable.Includes(u => u.Roles).ToListAsync(); + } public async Task> DbTest() { return await _repository._Db.Queryable().ToListAsync(); @@ -64,23 +68,12 @@ namespace Yi.Framework.Service { user.UserName = userEntity.UserName; user.BuildPassword(); - //等待老杰哥更新,杰哥漏了雪花id呀,嘿嘿 - //var entity = await _repository.InsertReturnSnowflakeEntityAsync(user); - //userAction.Invoke(await _repository.GetByIdAsync(entity)); - - //await _repository.InsertReturnSnowflakeEntityAsync(user); - //userAction.Invoke(await _repository.GetByIdAsync(user)); - + userAction.Invoke(await _repository.InsertReturnEntityAsync(user)); return true; } return false; } - public async Task> GetListInRole() - { - return await _repository._DbQueryable.Includes(u => u.Roles).ToListAsync(); - } - public async Task GiveUserSetRole(List userIds, List roleIds) { var _repositoryUserRole = _repository.ChangeRepository>(); @@ -109,9 +102,9 @@ namespace Yi.Framework.Service } - public async Task> GetRoleListByUserId(long userId) + public async Task GetInfoById(long userId) { - return (await _repository._DbQueryable.Includes(u => u.Roles).InSingleAsync(userId)).Roles; + return await _repository._DbQueryable.Includes(u => u.Roles).InSingleAsync(userId); } public async Task GetUserAllInfo(long userId) @@ -179,7 +172,8 @@ namespace Yi.Framework.Service .WhereIF(!string.IsNullOrEmpty(user.Name), u => u.Name.Contains(user.Name)) .WhereIF(!string.IsNullOrEmpty(user.Phone), u => u.Phone.Contains(user.Phone)) .WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime) - .Where(u => u.IsDeleted == false) + .Where(u => u.IsDeleted == user.IsDeleted) + .Includes(u => u.Roles) .OrderBy(u => u.OrderNum, OrderByType.Desc) .ToPageListAsync(page.PageNum, page.PageSize, total); diff --git a/Yi.Vue3.X.RuoYi/src/api/system/role.js b/Yi.Vue3.X.RuoYi/src/api/system/role.js index a772d126..5f65dfe0 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/role.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/role.js @@ -117,3 +117,10 @@ export function deptTreeSelect(roleId) { method: 'get' }) } +// 获取角色选择框列表 +export function roleOptionselect() { + return request({ + url: '/role/getList', + method: 'get' + }) +} \ No newline at end of file diff --git a/Yi.Vue3.X.RuoYi/src/api/system/user.js b/Yi.Vue3.X.RuoYi/src/api/system/user.js index d206052b..c94146bd 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/user.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/user.js @@ -13,7 +13,7 @@ export function listUser(query) { // 查询用户详细 export function getUser(userId) { return request({ - url: '/system/user/' + parseStrEmpty(userId), + url: '/user/getById/' + parseStrEmpty(userId), method: 'get' }) } diff --git a/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue index d80094ff..c4b1a5a5 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue @@ -1,357 +1,245 @@