public async Task <IActionResult> DeleteRoleInfo(string roleId) { // var res = _EFCoreService.DeleteRoleInfo(roleId); var roleInfo = await _roleInfoService.QueryById(roleId); var res = await _roleInfoService.Delete(roleInfo); return(new JsonResult(new Result { Data = res, Msg = $"删除角色{(res ? "成功" : "失败")}", Status = res ? 200 : 204 })); }
public async Task <IActionResult> GetJwt(DTO_UserInfo userInfo) { var data = await _userInfoService.QueryByWhereAsync(o => o.Name == userInfo.UserName && o.Pwd == userInfo.PassWord); if (data != null) { //获取角色ID var userRole = await _userRoleService.QueryByWhereAsync(o => o.UserId == data.UserId); var roleIds = userRole.RoleId.Split(',').ToList(); StringBuilder sb = new StringBuilder(); foreach (var item in roleIds) { var role = await _roleInfoService.QueryById(item); sb.Append(role.Role); sb.Append(","); } var roles = sb.ToString().TrimEnd(','); //从数据库获取 角色和api _jwtRequirement.jwtUserRoleInofs = _EFCoreService.GetAllRoleMenu(); var jwtTokenModle = new JwtTokenModel(); jwtTokenModle.Uid = data.UserId; jwtTokenModle.Roles = roles; var token = JwtHelper.IssueJwt(jwtTokenModle); //记录登录日志 LogHelper.Info($"{("用户" + data.Name + "于" + System.DateTime.Now + "登录成功")}"); return(new JsonResult(new Result { Data = token, Msg = "获取Token成功", Status = 200 })); } else { //记录登录日志 LogHelper.Info($"{("账号" + userInfo.UserName + "于" + System.DateTime.Now + "登录失败")}"); return(new JsonResult(new Result { Data = null, Msg = "获取Token失败", Status = 204 })); } }