diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index be7c7a07..32d475a2 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -30,7 +30,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers private RabbitMQInvoker _rabbitMQInvoker; private CacheClientDB _cacheClientDB; private IRoleService _roleService; - public AccountController(ILogger logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker,CacheClientDB cacheClientDB, IRoleService roleService) + private IHttpContextAccessor _httpContext; + public AccountController(ILogger logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker,CacheClientDB cacheClientDB, IRoleService roleService, IHttpContextAccessor httpContext) { _logger = logger; _userService = userService; @@ -38,6 +39,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers _rabbitMQInvoker = rabbitMQInvoker; _cacheClientDB = cacheClientDB; _roleService = roleService; + _httpContext = httpContext; } @@ -94,6 +96,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers //设置默认头像 var setting = JsonHelper.StrToObj(_cacheClientDB.Get(RedisConst.key)); _user.icon = setting.InitIcon; + _user.ip = _httpContext.HttpContext.Request.Headers["X-Real-IP"].FirstOrDefault();//通过上下文获取ip //设置默认角色 if (string.IsNullOrEmpty(setting.InitRole)) { @@ -117,6 +120,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPost] public async Task SendSMS(string SMSAddress) { + if (string.IsNullOrEmpty(SMSAddress)) + { + return Result.Error("请输入电话号码"); + } SMSAddress = SMSAddress.Trim(); if (!await _userService.PhoneIsExsit(SMSAddress)) { diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework/Yi.Framework.Service/MenuService.cs index 3b05cfb5..7c885c35 100644 --- a/Yi.Framework/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework/Yi.Framework.Service/MenuService.cs @@ -58,7 +58,7 @@ namespace Yi.Framework.Service public async Task> GetTopMenuByUserId(int userId) { - var user_data = await _DbRead.Set().Include(u => u.roles).ThenInclude(u => u.menus).FirstOrDefaultAsync(); + var user_data = await _DbRead.Set().Include(u => u.roles).ThenInclude(u => u.menus).Where(u=>u.id==userId).FirstOrDefaultAsync(); List menuList = new(); user_data.roles.ForEach(u => { diff --git a/Yi.Framework/Yi.Framework.Service/RoleService.cs b/Yi.Framework/Yi.Framework.Service/RoleService.cs index 2ab3a56c..1461c1af 100644 --- a/Yi.Framework/Yi.Framework.Service/RoleService.cs +++ b/Yi.Framework/Yi.Framework.Service/RoleService.cs @@ -16,7 +16,8 @@ namespace Yi.Framework.Service public async Task> GetRolesByUserId(int userId) { var user_data =await _Db.Set().Include(u => u.roles).Where(u => u.id==userId).FirstOrDefaultAsync(); - var roleList = user_data.roles.Where(u=>u.is_delete==Normal).ToList(); + var roleList = user_data.roles.Where(u=>u.is_delete==Normal).ToList(); + roleList.ForEach(u => u.users = null); return roleList; } diff --git a/Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs b/Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs index 49e6c303..f39b0d8d 100644 --- a/Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs +++ b/Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs @@ -1,6 +1,7 @@ using Autofac; using Autofac.Extras.DynamicProxy; using Castle.DynamicProxy; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.EntityFrameworkCore; @@ -36,11 +37,11 @@ namespace Yi.Framework.WebCore.Utility containerBuilder.RegisterType().As().InstancePerDependency().EnableInterfaceInterceptors(); - - + containerBuilder.RegisterType< HttpContextAccessor>().As().SingleInstance(); -///反射注入服务层及接口层 + + ///反射注入服务层及接口层 var assemblysServices = GetDll( "Yi.Framework.Service.dll"); containerBuilder.RegisterAssemblyTypes(assemblysServices) .AsImplementedInterfaces() diff --git a/Yi.Vue/src/views/register.vue b/Yi.Vue/src/views/register.vue index 5a7afbc4..b1c159d9 100644 --- a/Yi.Vue/src/views/register.vue +++ b/Yi.Vue/src/views/register.vue @@ -57,7 +57,7 @@ - 验证码 + 验证码 { if (resp.status) { this.$dialog.notify.success(resp.msg, { @@ -171,6 +172,7 @@ export default { ], isPasswordVisible: false, code: "", + is_en:false, form: { phone: "", username: "",