| | |
| | | using System.Security.Cryptography; |
| | | using System.Data; |
| | | using Model.ModelDto.LogDto; |
| | | using Utility; |
| | | using Model.ModelVm.LogVm; |
| | | |
| | | namespace Wms.Controllers |
| | | { |
| | |
| | | private readonly IFunSettingServer _setting; //功能设定 |
| | | private readonly IInterfaceServer _interface;//接口管理 |
| | | private readonly IOperationSysServer _operation; //操作日志 |
| | | private readonly UserManager _userManager; |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | |
| | | /// <param name="department">部门</param> |
| | | /// <param name="setting">功能设定</param> |
| | | /// <param name="operation">操作日志</param> |
| | | public BasisController(ICustomerServer customerSvc, ILogisticsInfoServer logisticsSvc, IUserInforServer userInforServer, IRolesServer rolesServer, IRoleRightServer roleRightServer, IRBACServer rBACServer, IUnitServer unitSvc, IPackagServer packagServer, IMaterialsServer mate, IDepartmentServer department, IFunSettingServer setting, IInterfaceServer interfaceS, IOperationSysServer operation) |
| | | public BasisController(ICustomerServer customerSvc, ILogisticsInfoServer logisticsSvc, IUserInforServer userInforServer, IRolesServer rolesServer, IRoleRightServer roleRightServer, IRBACServer rBACServer, IUnitServer unitSvc, IPackagServer packagServer, IMaterialsServer mate, IDepartmentServer department, IFunSettingServer setting, IInterfaceServer interfaceS, IOperationSysServer operation, UserManager userManager) |
| | | { |
| | | _customerSvc = customerSvc;//客户Svc |
| | | _logisticsSvc = logisticsSvc;//物流Svc |
| | |
| | | _setting = setting; //功能设定 |
| | | _interface = interfaceS;//接口管理 |
| | | _operation = operation; //操作日志 |
| | | _userManager = userManager; |
| | | } |
| | | //基本信息管理 |
| | | |
| | |
| | | /// <param name="Status">状态</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetUserRoleList(string UserName, string DepartmentNo, string RoleNo, string Status) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<UserInfoDto>> GetUserRoleList(string UserName, string DepartmentNo, string RoleNo, string Status) |
| | | { |
| | | List<UserInfoDto> userdtolist = _userInforServer.GetUserRoleList(UserName, DepartmentNo, RoleNo, Status); |
| | | return Ok(new |
| | | { |
| | | data = userdtolist, |
| | | code = 0, |
| | | mes = "成功" |
| | | }); |
| | | return await _userInforServer.GetUserRoleList(UserName, DepartmentNo, RoleNo, Status); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="id">用户id</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetUserinfoListById(int id) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<SysUserInfor> GetUserinfoListById(int id) |
| | | { |
| | | SysUserInfor userinfo = _userInforServer.GetUserInfoById(id); |
| | | return Ok(new |
| | | { |
| | | data = userinfo, |
| | | code = 0, |
| | | msg = "成功" |
| | | }); |
| | | return await _userInforServer.GetUserInfoById(id); |
| | | } |
| | | |
| | | |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="System.Exception">捕获异常</exception> |
| | | [HttpPost] |
| | | public async Task<IActionResult> InsertUserinfo(UserInfoDto UserInfoDto) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | [UnitOfWork] |
| | | public async Task InsertUserinfo(UserInfoDto UserInfoDto) |
| | | { |
| | | //捕获异常 |
| | | try |
| | | await _userInforServer.InsertUserInfo(UserInfoDto); |
| | | await _operation.InsertOperation(new OperationInputVm() |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | UserInfoDto.CreateUser = uid; |
| | | int i = await _userInforServer.InsertUserInfo(UserInfoDto); |
| | | |
| | | //判断是否新增成功 |
| | | if (i == 0) |
| | | { |
| | | return Ok(new { data = i, code = 1, msg = "新增失败" }); |
| | | } |
| | | else if (i == 3) |
| | | { |
| | | return Ok(new { data = i, code = 3, msg = "用户名或登录名重复" }); |
| | | } |
| | | else |
| | | { |
| | | await _operation.InsertOperation("系统设置", "用户管理", UserInfoDto.UserNo, "添加", "添加用户信息 用户号:" + UserInfoDto.UserNo, uid); |
| | | return Ok(new { data = i, code = 0, msg = "新增成功" }); |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new System.Exception("新增用户异常", ex); |
| | | } |
| | | ParentName = "系统设置", |
| | | MenuName = "用户管理", |
| | | FkNo = UserInfoDto.UserNo, |
| | | TypeName = "添加", |
| | | Msg = "添加用户信息 用户号:" + UserInfoDto.UserNo |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="System.Exception">异常</exception> |
| | | [HttpGet] |
| | | public async Task<IActionResult> DeleteUserInfo(int userids) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | [UnitOfWork] |
| | | public async Task DeleteUserInfo(int userids) |
| | | { |
| | | //异常 |
| | | try |
| | | //获取用户信息 |
| | | SysUserInfor user = await _userInforServer.GetUserInfoById(userids); |
| | | await _userInforServer.DeleteUserinfo(user); |
| | | await _operation.InsertOperation(new OperationInputVm() |
| | | { |
| | | //获取用户信息 |
| | | SysUserInfor user = _userInforServer.GetUserInfoById(userids); |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | int i = await _userInforServer.DeleteUserinfo(user); |
| | | //判断是否删除成功 |
| | | if (i == 0) |
| | | { |
| | | return Ok(new { data = i, code = 1, msg = "删除失败" }); |
| | | } |
| | | else |
| | | { |
| | | await _operation.InsertOperation("系统设置", "用户管理", user.UserNo, "删除", "删除用户信息 用户号:" + user.UserNo, uid); |
| | | return Ok(new { data = i, code = 0, msg = "删除成功" }); |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new System.Exception("删除用户信息异常", ex); |
| | | } |
| | | ParentName = "系统设置", |
| | | MenuName = "用户管理", |
| | | FkNo = user.UserNo, |
| | | TypeName = "删除", |
| | | Msg = "删除用户信息 用户号:" + user.UserNo |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="System.Exception">捕获异常</exception> |
| | | [HttpPost] |
| | | public async Task<IActionResult> UpdateUserinfo(UserInfoDto userdto) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | [UnitOfWork] |
| | | public async Task UpdateUserinfo(UserInfoDto userdto) |
| | | { |
| | | //捕获异常 |
| | | try |
| | | await _userInforServer.UpdateUserinfo(userdto); |
| | | await _operation.InsertOperation(new OperationInputVm() |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | //userdto.UpdateUser = Convert.ToInt32(userId); |
| | | //更改人 |
| | | userdto.UpdateUser = uid; |
| | | |
| | | //编辑用户信息 |
| | | int i = await _userInforServer.UpdateUserinfo(userdto); |
| | | //判断是否编辑成功 |
| | | if (i == 0) |
| | | { |
| | | return Ok(new { data = i, code = 1, msg = "编辑失败" }); |
| | | } |
| | | else if (i == 3) |
| | | { |
| | | return Ok(new { data = i, code = 1, msg = "用户名或登录名重复" }); |
| | | } |
| | | else |
| | | { |
| | | await _operation.InsertOperation("系统设置", "用户管理", userdto.UserNo, "修改", "修改用户信息 用户号:" + userdto.UserNo, uid); |
| | | return Ok(new { data = i, code = 0, msg = "编辑成功" }); |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new System.Exception("编辑用户信息异常", ex); |
| | | } |
| | | ParentName = "系统设置", |
| | | MenuName = "用户管理", |
| | | FkNo = userdto.UserNo, |
| | | TypeName = "编辑", |
| | | Msg = "修改用户信息 用户号:" + userdto.UserNo |
| | | }); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 修改密码 |
| | | |
| | | /// <summary> |
| | | /// 修改密码 根据id获取用户原密码 |
| | | /// </summary> |
| | | /// <param name="PassWord">用户原密码</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public int GetUserUptPassById(string PassWord, int userId) |
| | | { |
| | | ////获取当前操作用户id |
| | | //var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | //int uid = Convert.ToInt32(userId); |
| | | |
| | | //根据用户id获取用户密码 |
| | | SysUserInfor user = _userInforServer.GetUserInfoById(userId); |
| | | //判断原密码是否正确 |
| | | if (user.PassWord == PassWord) |
| | | { |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | ///// <param name="userId">用户id</param> |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception">捕获异常</exception> |
| | | [HttpGet] |
| | | public async Task<IActionResult> UptUserPassWord(string pwdOld, string pwdNew, string pwdNewTwo/*, int userId*/) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task UptUserPassWord(string pwdOld, string pwdNew, string pwdNewTwo/*, int userId*/) |
| | | { |
| | | //捕获异常 |
| | | try |
| | | { |
| | | pwdOld = Md5Tools.CalcMd5(pwdOld); |
| | | pwdNew = Md5Tools.CalcMd5(pwdNew); |
| | | pwdNewTwo = Md5Tools.CalcMd5(pwdNewTwo); |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | //判断原密码是否正确 |
| | | int a = GetUserUptPassById(pwdOld, uid); |
| | | if (a == 1) |
| | | { |
| | | //修改密码 |
| | | int i = await _userInforServer.UptUserPassWord(pwdOld, pwdNew, pwdNewTwo, uid); |
| | | if (i == 0) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 1, |
| | | msg = "修改失败" |
| | | }); |
| | | } |
| | | //判断两次新密码是否一致 |
| | | else if (i == 3) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 0, |
| | | msg = "修改成功 请重新登录" |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 0, |
| | | msg = "修改成功 请重新登录" |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //错误 |
| | | return Ok(new |
| | | { |
| | | data = a, |
| | | code = 1, |
| | | msg = "原密码不正确" |
| | | }); |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new Exception("修改密码异常", ex); |
| | | } |
| | | pwdOld = Md5Tools.CalcMd5(pwdOld); |
| | | pwdNew = Md5Tools.CalcMd5(pwdNew); |
| | | pwdNewTwo = Md5Tools.CalcMd5(pwdNewTwo); |
| | | //获取当前操作用户id |
| | | SysUserInfor user = await _userInforServer.GetUserInfoById(_userManager.UserId); |
| | | if (user == null) |
| | | throw Oops.Bah("找不到用户信息"); |
| | | if (user.PassWord != pwdOld) |
| | | throw Oops.Bah("原密码不正确"); |
| | | //修改密码 |
| | | int i = await _userInforServer.UptUserPassWord(pwdNew, _userManager.UserId); |
| | | if (i <= 0) |
| | | throw Oops.Bah("修改密码失败"); |
| | | } |
| | | /// <summary> |
| | | /// x天后提醒用户修改密码 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult IsPassWordTime() |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<int> IsPassWordTime() |
| | | { |
| | | //捕获异常 |
| | | try |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | //判断原密码是否正确 |
| | | int a = _userInforServer.IsPassWordTime(uid); |
| | | return Ok(new |
| | | { |
| | | data = a, |
| | | code = 0, |
| | | msg = "修改失败" |
| | | }); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new Exception("修改密码异常", ex); |
| | | } |
| | | return await _userInforServer.IsPassWordTime(_userManager.UserId); |
| | | } |
| | | #endregion |
| | | |
| | |
| | | /// <param name="RoleName">角色名称</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetRolesList(string RoleNo, string RoleName) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<RoleDto>> GetRolesList(string RoleNo, string RoleName) |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | if (claimsIdentity == null) |
| | | { |
| | | throw new Exception("未获取到用户信息"); |
| | | } |
| | | string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | if (string.IsNullOrWhiteSpace(UserId)) |
| | | { |
| | | throw new Exception("未获取到用户信息"); |
| | | } |
| | | |
| | | //查询 |
| | | List<RoleDto> roles = _rolesServer.GetRoleList(RoleNo, RoleName, UserId); |
| | | //返回数据 |
| | | return Ok(new |
| | | { |
| | | data = roles, |
| | | code = 0, |
| | | msg = "获取成功" |
| | | }); |
| | | return await _rolesServer.GetRoleList(RoleNo, RoleName); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="roleid">角色id</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetRolesListById(int roleid) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<SysRoles> GetRolesListById(int roleid) |
| | | { |
| | | SysRoles role = _rolesServer.GetRoleInfoById(roleid); |
| | | return Ok(new |
| | | { |
| | | data = role, |
| | | code = 0, |
| | | msg = "获取成功" |
| | | }); |
| | | return await _rolesServer.GetRoleInfoById(roleid); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="System.Exception">捕获异常</exception> |
| | | [HttpPost] |
| | | public async Task<IActionResult> InsertRoleInfo(RoleDto roledto) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | [UnitOfWork] |
| | | public async Task InsertRoleInfo(RoleDto roledto) |
| | | { |
| | | //捕获异常 |
| | | try |
| | | await _rolesServer.InsertRoleInfo(roledto); |
| | | await _operation.InsertOperation(new OperationInputVm() |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | //创建人 |
| | | roledto.CreateUser = uid; |
| | | int i = await _rolesServer.InsertRoleInfo(roledto); |
| | | if (i == 0) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 1, |
| | | msg = "新增失败" |
| | | }); |
| | | } |
| | | else if (i == 3) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 3, |
| | | msg = "角色号必须唯一" |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | await _operation.InsertOperation("系统设置", "角色权限", roledto.RoleNo, "添加", "添加角色信息 角色号:" + roledto.RoleNo, uid); |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 0, |
| | | msg = "新增成功" |
| | | }); |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new System.Exception("角色新增异常", ex); |
| | | } |
| | | ParentName = "系统设置", |
| | | MenuName = "角色权限", |
| | | FkNo = roledto.RoleNo, |
| | | TypeName = "添加", |
| | | Msg = "添加角色信息 角色号:" + roledto.RoleNo |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="System.Exception"></exception> |
| | | [HttpGet] |
| | | public async Task<IActionResult> DeleteRoleInfo(int roleids) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | [UnitOfWork] |
| | | public async Task DeleteRoleInfo(int roleids) |
| | | { |
| | | //捕获异常 |
| | | try |
| | | //根据角色id获取角色信息 |
| | | SysRoles role = await _rolesServer.GetRoleInfoById(roleids); |
| | | await _rolesServer.DeleteRoleInfo(role); |
| | | await _operation.InsertOperation(new OperationInputVm() |
| | | { |
| | | //根据角色id获取角色信息 |
| | | SysRoles role = _rolesServer.GetRoleInfoById(roleids); |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | role.UpdateUser = uid; |
| | | int i = await _rolesServer.DeleteRoleInfo(role); |
| | | //判断是否删除成功 |
| | | if (i == 0) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 1, |
| | | msg = "删除失败" |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | await _operation.InsertOperation("系统设置", "角色权限", role.RoleNo, "删除", "删除角色信息 角色号:" + role.RoleNo, uid); |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 0, |
| | | msg = "删除成功" |
| | | }); |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new System.Exception("角色删除异常", ex); |
| | | } |
| | | ParentName = "系统设置", |
| | | MenuName = "角色权限", |
| | | FkNo = role.RoleNo, |
| | | TypeName = "删除", |
| | | Msg = "删除角色信息 角色号:" + role.RoleNo |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="System.Exception">捕获异常</exception> |
| | | [HttpPost] |
| | | public async Task<IActionResult> UpdateRolesInfo(SysRoles role) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | [UnitOfWork] |
| | | public async Task UpdateRolesInfo(SysRoles role) |
| | | { |
| | | //捕获异常 |
| | | try |
| | | await _rolesServer.UpdateRoleInfo(role); |
| | | await _operation.InsertOperation(new OperationInputVm() |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | int uid = Convert.ToInt32(userId); |
| | | //更改人 |
| | | role.UpdateUser = uid; |
| | | |
| | | int i = await _rolesServer.UpdateRoleInfo(role); |
| | | //判断是否编辑成功 |
| | | if (i == 0) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 1, |
| | | msg = "编辑失败" |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | await _operation.InsertOperation("系统设置", "角色权限", role.RoleNo, "修改", "修改角色信息 角色号:" + role.RoleNo, uid); |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | code = 0, |
| | | msg = "编辑成功" |
| | | }); |
| | | } |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new System.Exception("编辑角色异常", ex); |
| | | } |
| | | ParentName = "系统设置", |
| | | MenuName = "角色权限", |
| | | FkNo = role.RoleNo, |
| | | TypeName = "编辑", |
| | | Msg = "修改角色信息 角色号:" + role.RoleNo |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetRBACLists(int id) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<FunctionMenuDto>> GetRBACLists(int id) |
| | | { |
| | | //List<RoleRightDto> roleright = |
| | | var obj = _rBACServer.GetMenuByroleIdNew(id); |
| | | return Ok(new |
| | | { |
| | | data = obj, |
| | | code = 0, |
| | | msg = "成功" |
| | | }); |
| | | return await _rBACServer.GetMenuByroleIdNew(id); |
| | | } |
| | | |
| | | |
| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetRoleRightRBAC(int id, string MenuNo) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<FunctionMenuDto>> GetRoleRightRBAC(int id, string MenuNo) |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | if (claimsIdentity == null) |
| | | { |
| | | throw new Exception("未获取到用户信息"); |
| | | } |
| | | string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | if (string.IsNullOrWhiteSpace(UserId)) |
| | | { |
| | | throw new Exception("未获取到用户信息"); |
| | | } |
| | | |
| | | List<FunctionMenuDto> menudto = _rBACServer.GetRoleRightRBAC(MenuNo, UserId); |
| | | return Ok(new |
| | | { |
| | | data = menudto, |
| | | code = 0, |
| | | msg = "成功" |
| | | }); |
| | | return await _rBACServer.GetRoleRightRBAC(MenuNo, UserId); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetRoleRightLists(int id) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<RoleRightDto>> GetRoleRightLists(int id) |
| | | { |
| | | List<RoleRightDto> roleRightDtos = _rBACServer.GetRoleRightList(id); |
| | | return Ok(new |
| | | { |
| | | data = roleRightDtos, |
| | | code = 0, |
| | | msg = "成功" |
| | | }); |
| | | return await _rBACServer.GetRoleRightList(id); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetRoleRightList() |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<RoleRightDto>> GetRoleRightList() |
| | | { |
| | | try |
| | | { |
| | | //获取当前登录的用户ID |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | if (claimsIdentity == null) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | if (string.IsNullOrWhiteSpace(userId)) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | var roleRightDtos = _roleRightServer.GetRoleMenuList(int.Parse(userId)); |
| | | return Ok(new |
| | | { |
| | | data = roleRightDtos, |
| | | msg = "成功", |
| | | code = 0 |
| | | }); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return Ok(new { msg = e.Message, code = 0 }); |
| | | } |
| | | return await _roleRightServer.GetRoleMenuList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="id">角色权限id</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetRoleRightOneListById(int id) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<SysRoleRight>> GetRoleRightOneListById(int id) |
| | | { |
| | | List<SysRoleRight> roleRights = _roleRightServer.GetRoleRightOneListById(id); |
| | | return Ok(new |
| | | { |
| | | data = roleRights, |
| | | msg = "成功", |
| | | core = 0 |
| | | }); |
| | | return await _roleRightServer.GetRoleRightOneListById(id); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception">捕获异常</exception> |
| | | [HttpPost] |
| | | public async Task<IActionResult> InsertRoleRight(string MenuNo, int id) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | [UnitOfWork] |
| | | public async Task InsertRoleRight(string MenuNo, int id) |
| | | { |
| | | //捕获异常 |
| | | try |
| | | //根据Id获取角色号 |
| | | SysRoles roles = await _rolesServer.GetRoleInfoById(id); |
| | | //保存角色权限信息 |
| | | await _roleRightServer.InsertRoleRight(MenuNo, roles.RoleNo); |
| | | await _operation.InsertOperation(new OperationInputVm() |
| | | { |
| | | //获取当前操作用户id |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | |
| | | //根据Id获取角色号 |
| | | SysRoles roles = _rolesServer.GetRoleInfoById(id); |
| | | |
| | | //保存角色权限信息 |
| | | int i = await _roleRightServer.InsertRoleRight(MenuNo, roles.RoleNo, userId); |
| | | //判断是否新增成功 |
| | | if (i == 0) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | msg = "分配失败", |
| | | code = 1 |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | await _operation.InsertOperation("系统设置", "角色权限", roles.RoleNo, "修改", "分配角色权限 角色号:" + roles.RoleNo, Convert.ToInt32(userId)); |
| | | return Ok(new |
| | | { |
| | | data = i, |
| | | msg = "分配成功", |
| | | code = 0 |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | //抛出异常 |
| | | throw new Exception("新增角色权限信息异常", ex); |
| | | } |
| | | ParentName = "系统设置", |
| | | MenuName = "角色权限", |
| | | FkNo = roles.RoleNo, |
| | | TypeName = "编辑", |
| | | Msg = "分配角色权限 角色号:" + roles.RoleNo |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | matedto.CreateUser = uid; |
| | | //新增 |
| | | int i = await _mate.AddMate(matedto); |
| | | |
| | | |
| | | await _operation.InsertOperation("基础信息", "物料管理", matedto.SkuNo, "添加", "添加物料信息 物料号:" + matedto.SkuNo, uid); |
| | | return Ok(new { data = i, code = 0, msg = "成功" }); |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | //抛出异常 |
| | | return Ok(new { code = 1, msg = "新增物料异常"+ ex.Message }); |
| | | return Ok(new { code = 1, msg = "新增物料异常" + ex.Message }); |
| | | } |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | //抛出异 |
| | | return Ok(new { code = 1, msg = "编辑物料异常"+ex.Message }); |
| | | return Ok(new { code = 1, msg = "编辑物料异常" + ex.Message }); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | var bolls = _customerSvc.GetCustomerList(model.CustomerNo,model.CustomerName, model.Type, model.LinkMan, model.Phone, model.Page, model.Limit, out int count); |
| | | var bolls = _customerSvc.GetCustomerList(model.CustomerNo, model.CustomerName, model.Type, model.LinkMan, model.Phone, model.Page, model.Limit, out int count); |
| | | |
| | | return Ok(new { code = 0, count, msg = "客户信息", data = bolls }); |
| | | } |
| | |
| | | /// <summary> |
| | | /// 获取操作日志信息列表 |
| | | /// </summary> |
| | | /// <param name="menuName">菜单名称</param> |
| | | /// <param name="type">操作类型</param> |
| | | /// <param name="msg">操作内容</param> |
| | | /// <param name="menuNo">菜单号</param> |
| | | /// <param name="parentNo">模块号</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetSysOperationList(string menuName, string type, string msg, string menuNo, string parentNo) |
| | | [HttpPost] |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<SqlSugarPagedList<OperationDto>> GetSysOperationList(GetOperationVm model) |
| | | { |
| | | List<OperationDto> operation = _operation.GetSysOperationList(menuName, type, msg, menuNo, parentNo); |
| | | return Ok(new |
| | | { |
| | | data = operation, |
| | | code = 0, |
| | | msg = "成功" |
| | | }); |
| | | return await _operation.GetSysOperationList(model); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="dicName">字典名称</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetDicTypeList(string dicName) |
| | | [ServiceFilter(typeof(ApiResponseActionFilter))] |
| | | public async Task<List<SysDictionary>> GetDicTypeList(string dicName) |
| | | { |
| | | List<SysDictionary> diclist = _operation.GetDicTypeList(dicName); |
| | | return Ok(new |
| | | { |
| | | data = diclist, |
| | | code = 0, |
| | | msg = "成功" |
| | | }); |
| | | return await _operation.GetDicTypeList(dicName); |
| | | } |
| | | |
| | | #endregion |