更新控制器接口

This commit is contained in:
lzw
2021-10-15 17:50:56 +08:00
parent f3c2c3c0a9
commit 141987893e
16 changed files with 139 additions and 257 deletions

View File

@@ -8,6 +8,7 @@ using Yi.Framework.Common.Models;
using Yi.Framework.DTOModel;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.WebCore;
namespace Yi.Framework.ApiMicroservice.Controllers
{
@@ -16,9 +17,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public class MenuController : ControllerBase
{
private IMenuService _menuService;
public MenuController(IMenuService menuService)
private IUserService _userService;
public MenuController(IMenuService menuService, IUserService userService)
{
_menuService = menuService;
_userService =userService;
}
[HttpGet]
public async Task<Result> GetMenu()
@@ -70,7 +73,24 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <returns></returns>
[HttpPost]
public async Task<Result> SetMouldByMenu(IdDto<int> idDto)
{
{
if (await _menuService.SetMouldByMenu(idDto.id2,idDto.id1))
{
return Result.Success();
}
return Result.Error();
}
/// <summary>
/// 得到该用户有哪些菜单关联mould
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<Result> GetMenuByUser()
{
var _user = this.HttpContext.GetCurrentUserInfo();
var menuList= await _userService.GetMenusByUser(_user);
return Result.Success().SetData(menuList);
}
}
}

View File

@@ -85,15 +85,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
}
/// <summary>
/// 给个用户设置多个角色ids有用户id与 角色列表ids1对多
/// 给个用户设置多个角色ids有用户id与 角色列表ids对多,ids1用户,ids2为角色
/// </summary>
/// <param name="idsDto"></param>
/// <param name="idsListDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<Result> SetRoleByUser(IdsDto<int> idsDto)
public async Task<Result> SetRoleByUser(IdsListDto<int> idsListDto)
{
var _user = this.HttpContext.GetCurrentUserInfo();
await _userService.SetRolesByUserId(idsDto.ids, _user.id);
await _userService.SetRolesByUser(idsListDto.ids2, idsListDto.ids1);
return Result.Success();
}
}

View File

@@ -51,7 +51,12 @@ namespace Yi.Framework.Interface
/// <param name="roleIds"></param>
/// <param name="userId"></param>
/// <returns></returns>
Task<bool> SetRolesByUserId(List<int> roleIds,int userId);
Task<bool> SetRolesByUser(List<int> roleIds, List<int> userIds);
/// <summary>
/// email验证
/// </summary>
/// <param name="emailAddress"></param>
/// <returns></returns>
Task<bool> EmailIsExsit(string emailAddress);
}

View File

@@ -1 +0,0 @@


View File

@@ -1,34 +0,0 @@
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
Assembly assembly = Assembly.LoadFrom(System.IO.Path.Combine(solutionsPath, @"Yi.Framework.ApiMicroservice\bin\Debug\net5.0\Yi.Framework.Model.dll"));
Type[] ts = assembly.GetTypes();
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Model.Models;
namespace Yi.Framework.Interface
{
public partial class BaseContext :DbContext
{
<# foreach(string item in ts){
#>
public partial interface I<#=item #>Dal:IBaseDal<<#=item #>>
{
}
<# } #>
}
}

View File

@@ -8,35 +8,12 @@
<Compile Remove="T4Service.cs" />
</ItemGroup>
<ItemGroup>
<None Include="T4IService.cs">
<DependentUpon>T4IService.tt</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="T4IService.tt">
<LastGenOutput>T4IService.cs</LastGenOutput>
<Generator>TextTemplatingFileGenerator</Generator>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4IService.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>T4IService.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>

View File

@@ -1 +0,0 @@


View File

@@ -1,34 +0,0 @@
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
Assembly assembly = Assembly.LoadFrom(System.IO.Path.Combine(solutionsPath, @"Yi.Framework.ApiMicroservice\bin\Debug\net5.0\Yi.Framework.Model.dll"));
Type[] ts = assembly.GetTypes();
#>
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Model
{
public partial class BaseContext :DbContext
{
<# foreach(var item in ts){
#>
public DbSet<<#=item#>> <#=item#> { get; set; }
<# } #>
}
}

View File

@@ -16,23 +16,8 @@
<ProjectReference Include="..\Yi.Framework.Common\Yi.Framework.Common.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="T4DaraContext.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>T4DaraContext.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4DaraContext.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>T4DaraContext.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>

View File

@@ -1 +0,0 @@


View File

@@ -1,15 +0,0 @@
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
Assembly assembly = Assembly.LoadFrom(System.IO.Path.Combine(solutionsPath, @"Yi.Framework.ApiMicroservice\bin\Debug\net5.0\Yi.Framework.Model.dll"));
Type[] ts = assembly.GetTypes();
#>

View File

@@ -85,17 +85,20 @@ namespace Yi.Framework.Service
return await AddAsync(_user);
}
public async Task<bool> SetRolesByUserId(List<int> roleIds, int userId)
public async Task<bool> SetRolesByUser(List<int> roleIds, List<int> userIds)
{
var user_data =await GetEntity(u => u.id ==userId &&u.is_delete == (short)Common.Enum.DelFlagEnum.Normal);
var user_data =await _Db.Set<user>().Include(u=>u.roles).Where(u =>userIds.Contains(u.id) &&u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync();
if (user_data == null)
{
return false;
}
var roleList = _Db.Set<role>().Where(u => roleIds.Contains(u.id)).ToList();
foreach(var item in user_data)
{
item.roles = roleList;
}
user_data.roles = roleList;
return await AddAsync(user_data);
return await UpdateListAsync(user_data);
}
}
}

View File

@@ -8,36 +8,13 @@
<Compile Remove="T4DaraContext.cs" />
</ItemGroup>
<ItemGroup>
<None Include="T4Service.cs">
<DependentUpon>T4Service.tt</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="T4Service.tt">
<LastGenOutput>T4Service.cs</LastGenOutput>
<Generator>TextTemplatingFileGenerator</Generator>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4Service.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>T4Service.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>

View File

@@ -11,6 +11,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Helper;
namespace Yi.Framework.WebCore.FilterExtend
{

View File

@@ -13,21 +13,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastru
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MicroServiceInstance", "MicroServiceInstance", "{026D2797-07D1-4BA5-8070-50CDE0258C59}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.DTOModel", "Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj", "{5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.DTOModel", "Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj", "{5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Interface", "Yi.Framework.Interface\Yi.Framework.Interface.csproj", "{5935EC64-7414-47D8-B934-E5896DD89E4E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Interface", "Yi.Framework.Interface\Yi.Framework.Interface.csproj", "{5935EC64-7414-47D8-B934-E5896DD89E4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Model", "Yi.Framework.Model\Yi.Framework.Model.csproj", "{F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Model", "Yi.Framework.Model\Yi.Framework.Model.csproj", "{F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Service", "Yi.Framework.Service\Yi.Framework.Service.csproj", "{C5E41276-A30F-4098-BA79-2E8920BBD02A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Service", "Yi.Framework.Service\Yi.Framework.Service.csproj", "{C5E41276-A30F-4098-BA79-2E8920BBD02A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Common", "Yi.Framework.Common\Yi.Framework.Common.csproj", "{4816AA7B-7222-4B3B-A178-C2A70713E9D1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Common", "Yi.Framework.Common\Yi.Framework.Common.csproj", "{4816AA7B-7222-4B3B-A178-C2A70713E9D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.Core", "Yi.Framework.Core\Yi.Framework.Core.csproj", "{07A80C17-E03E-475D-9BBF-98E3B1393652}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Core", "Yi.Framework.Core\Yi.Framework.Core.csproj", "{07A80C17-E03E-475D-9BBF-98E3B1393652}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.WebCore", "Yi.Framework.WebCore\Yi.Framework.WebCore.csproj", "{E4734315-158C-4D35-AF01-1122C22F2955}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.WebCore", "Yi.Framework.WebCore\Yi.Framework.WebCore.csproj", "{E4734315-158C-4D35-AF01-1122C22F2955}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.ApiMicroservice", "Yi.Framework.ApiMicroservice\Yi.Framework.ApiMicroservice.csproj", "{A95157D2-907F-411E-BA1D-A17F48C54A0E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.ApiMicroservice", "Yi.Framework.ApiMicroservice\Yi.Framework.ApiMicroservice.csproj", "{A95157D2-907F-411E-BA1D-A17F48C54A0E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution