最后修复最大深度问题

This commit is contained in:
橙子
2021-11-06 17:53:54 +08:00
parent 1066e54369
commit d5f7b4b01a
5 changed files with 18 additions and 7 deletions

View File

@@ -30,7 +30,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
private RabbitMQInvoker _rabbitMQInvoker; private RabbitMQInvoker _rabbitMQInvoker;
private CacheClientDB _cacheClientDB; private CacheClientDB _cacheClientDB;
private IRoleService _roleService; private IRoleService _roleService;
public AccountController(ILogger<UserController> logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker,CacheClientDB cacheClientDB, IRoleService roleService) private IHttpContextAccessor _httpContext;
public AccountController(ILogger<UserController> logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker,CacheClientDB cacheClientDB, IRoleService roleService, IHttpContextAccessor httpContext)
{ {
_logger = logger; _logger = logger;
_userService = userService; _userService = userService;
@@ -38,6 +39,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
_rabbitMQInvoker = rabbitMQInvoker; _rabbitMQInvoker = rabbitMQInvoker;
_cacheClientDB = cacheClientDB; _cacheClientDB = cacheClientDB;
_roleService = roleService; _roleService = roleService;
_httpContext = httpContext;
} }
@@ -94,6 +96,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
//设置默认头像 //设置默认头像
var setting = JsonHelper.StrToObj<SettingDto>(_cacheClientDB.Get<string>(RedisConst.key)); var setting = JsonHelper.StrToObj<SettingDto>(_cacheClientDB.Get<string>(RedisConst.key));
_user.icon = setting.InitIcon; _user.icon = setting.InitIcon;
_user.ip = _httpContext.HttpContext.Request.Headers["X-Real-IP"].FirstOrDefault();//通过上下文获取ip
//设置默认角色 //设置默认角色
if (string.IsNullOrEmpty(setting.InitRole)) if (string.IsNullOrEmpty(setting.InitRole))
{ {
@@ -117,6 +120,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpPost] [HttpPost]
public async Task<Result> SendSMS(string SMSAddress) public async Task<Result> SendSMS(string SMSAddress)
{ {
if (string.IsNullOrEmpty(SMSAddress))
{
return Result.Error("请输入电话号码");
}
SMSAddress = SMSAddress.Trim(); SMSAddress = SMSAddress.Trim();
if (!await _userService.PhoneIsExsit(SMSAddress)) if (!await _userService.PhoneIsExsit(SMSAddress))
{ {

View File

@@ -58,7 +58,7 @@ namespace Yi.Framework.Service
public async Task<List<menu>> GetTopMenuByUserId(int userId) public async Task<List<menu>> GetTopMenuByUserId(int userId)
{ {
var user_data = await _DbRead.Set<user>().Include(u => u.roles).ThenInclude(u => u.menus).FirstOrDefaultAsync(); var user_data = await _DbRead.Set<user>().Include(u => u.roles).ThenInclude(u => u.menus).Where(u=>u.id==userId).FirstOrDefaultAsync();
List<menu> menuList = new(); List<menu> menuList = new();
user_data.roles.ForEach(u => user_data.roles.ForEach(u =>
{ {

View File

@@ -16,7 +16,8 @@ namespace Yi.Framework.Service
public async Task<List<role>> GetRolesByUserId(int userId) public async Task<List<role>> GetRolesByUserId(int userId)
{ {
var user_data =await _Db.Set<user>().Include(u => u.roles).Where(u => u.id==userId).FirstOrDefaultAsync(); var user_data =await _Db.Set<user>().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; return roleList;
} }

View File

@@ -1,6 +1,7 @@
using Autofac; using Autofac;
using Autofac.Extras.DynamicProxy; using Autofac.Extras.DynamicProxy;
using Castle.DynamicProxy; using Castle.DynamicProxy;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -36,11 +37,11 @@ namespace Yi.Framework.WebCore.Utility
containerBuilder.RegisterType<DbContextFactory>().As<IDbContextFactory>().InstancePerDependency().EnableInterfaceInterceptors(); containerBuilder.RegisterType<DbContextFactory>().As<IDbContextFactory>().InstancePerDependency().EnableInterfaceInterceptors();
containerBuilder.RegisterType< HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance();
///反射注入服务层及接口层
///反射注入服务层及接口层
var assemblysServices = GetDll( "Yi.Framework.Service.dll"); var assemblysServices = GetDll( "Yi.Framework.Service.dll");
containerBuilder.RegisterAssemblyTypes(assemblysServices) containerBuilder.RegisterAssemblyTypes(assemblysServices)
.AsImplementedInterfaces() .AsImplementedInterfaces()

View File

@@ -57,7 +57,7 @@
</v-text-field> </v-text-field>
</v-col> </v-col>
<v-col cols="3"> <v-col cols="3">
<app-btn @click="sendSMS" class="mb-1 mt-1">验证码</app-btn> <v-btn color="secondary" @click="sendSMS" class="mb-1 mt-1" :disabled="is_en">验证码</v-btn>
</v-col> </v-col>
</v-row> </v-row>
<v-text-field <v-text-field
@@ -113,6 +113,7 @@ import accoutAPI from "../api/accountApi";
export default { export default {
methods: { methods: {
sendSMS() { sendSMS() {
this.is_en=true
accoutAPI.SendSMS(this.form.phone).then(resp=>{ accoutAPI.SendSMS(this.form.phone).then(resp=>{
if (resp.status) { if (resp.status) {
this.$dialog.notify.success(resp.msg, { this.$dialog.notify.success(resp.msg, {
@@ -171,6 +172,7 @@ export default {
], ],
isPasswordVisible: false, isPasswordVisible: false,
code: "", code: "",
is_en:false,
form: { form: {
phone: "", phone: "",
username: "", username: "",