提交.Net6版本
This commit is contained in:
87
Yi.Framework.Net5/Yi.Framework.Interface/IBaseService.cs
Normal file
87
Yi.Framework.Net5/Yi.Framework.Interface/IBaseService.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Interface
|
||||
{
|
||||
public interface IBaseService<T> where T : class, new()
|
||||
{
|
||||
#region
|
||||
//通过id得到实体
|
||||
#endregion
|
||||
Task<T> GetEntityById(int id);
|
||||
|
||||
#region
|
||||
//通过表达式得到实体
|
||||
#endregion
|
||||
Task<T> GetEntity(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
#region
|
||||
//得到全部实体
|
||||
#endregion
|
||||
Task<IEnumerable<T>> GetAllEntitiesAsync();
|
||||
|
||||
#region
|
||||
//通过表达式得到实体
|
||||
#endregion
|
||||
Task<IEnumerable<T>> GetEntitiesAsync(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
#region
|
||||
//通过表达式得到实体,分页版本
|
||||
#endregion
|
||||
Task<int> GetCountAsync(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
#region
|
||||
//通过表达式统计数量
|
||||
#endregion
|
||||
IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda);
|
||||
|
||||
#region
|
||||
//通过表达式分组
|
||||
#endregion
|
||||
Task<Tuple<IEnumerable<T>, int>> GetPageEntities<S>(int pageSize, int pageIndex, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc);
|
||||
|
||||
#region
|
||||
//添加实体
|
||||
#endregion
|
||||
Task<bool> AddAsync(T entity);
|
||||
|
||||
#region
|
||||
//添加多个实体
|
||||
#endregion
|
||||
Task<bool> AddAsync(IEnumerable<T> entities);
|
||||
|
||||
#region
|
||||
//更新实体
|
||||
#endregion
|
||||
Task<bool> UpdateAsync(T entity);
|
||||
|
||||
#region
|
||||
//更新多个实体
|
||||
#endregion
|
||||
Task<bool> UpdateListAsync(IEnumerable<T> entities);
|
||||
|
||||
#region
|
||||
//更新实体部分属性
|
||||
#endregion
|
||||
Task<bool> DeleteAsync(T entity);
|
||||
|
||||
#region
|
||||
//删除实体
|
||||
#endregion
|
||||
Task<bool> DeleteAsync(int id);
|
||||
|
||||
#region
|
||||
//通过id删除实体
|
||||
#endregion
|
||||
Task<bool> DeleteAsync(IEnumerable<int> ids);
|
||||
|
||||
#region
|
||||
//通过id列表删除多个实体
|
||||
#endregion
|
||||
Task<bool> DeleteAsync(Expression<Func<T, bool>> where);
|
||||
}
|
||||
}
|
||||
43
Yi.Framework.Net5/Yi.Framework.Interface/IMenuService.cs
Normal file
43
Yi.Framework.Net5/Yi.Framework.Interface/IMenuService.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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 interface IMenuService:IBaseService<menu>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取所有菜单,关联接口
|
||||
/// 这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<menu> GetMenuInMould();
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// 现在,top菜单只允许为一个
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddTopMenu(menu _menu);
|
||||
/// <summary>
|
||||
/// 给一个菜单设置一个接口,Id1为菜单id,Id2为接口id
|
||||
/// 用于给菜单设置接口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<menu> SetMouldByMenu(int id1, int id2);
|
||||
/// <summary>
|
||||
/// 给一个菜单添加子节点(注意:添加,不是覆盖)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<menu> AddChildrenMenu(int menu_id, menu _children);
|
||||
/// <summary>
|
||||
/// 获取用户的目录菜单,不包含接口
|
||||
/// 用于账户信息页面,显示这个用户有哪些菜单,需要并列
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<menu>> GetTopMenusByTopMenuIds(List<int> menuIds);
|
||||
Task<List<menu>> GetTopMenuByUserId(int userId);
|
||||
}
|
||||
}
|
||||
22
Yi.Framework.Net5/Yi.Framework.Interface/IMouldService.cs
Normal file
22
Yi.Framework.Net5/Yi.Framework.Interface/IMouldService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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 interface IMouldService : IBaseService<mould>
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到该接口属于哪个菜单的
|
||||
/// </summary>
|
||||
/// <param name="_mould"></param>
|
||||
/// <returns></returns>
|
||||
Task<menu> GetMenuByMould(mould _mould);
|
||||
|
||||
}
|
||||
}
|
||||
47
Yi.Framework.Net5/Yi.Framework.Interface/IRoleService.cs
Normal file
47
Yi.Framework.Net5/Yi.Framework.Interface/IRoleService.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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 interface IRoleService:IBaseService<role>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取该角色的所有菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<menu>> GetMenusByRole(int roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 给多个角色设置多个菜单
|
||||
/// </summary>
|
||||
/// <param name="menuIds"></param>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SetMenusByRolesId(List<int> menuIds, List<int> roleIds);
|
||||
/// <summary>
|
||||
/// 获取多个用户的菜单,并列,不包含子菜单
|
||||
/// </summary>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<menu>> GetMenusByRoleId(List<int> roleIds);
|
||||
/// <summary>
|
||||
/// 获取用户的角色
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<role>> GetRolesByUserId(int userId);
|
||||
/// <summary>
|
||||
/// 获取该角色的top菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<menu>> GetTopMenusByRoleId(int roleId);
|
||||
|
||||
}
|
||||
}
|
||||
71
Yi.Framework.Net5/Yi.Framework.Interface/IUserService.cs
Normal file
71
Yi.Framework.Net5/Yi.Framework.Interface/IUserService.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
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 interface IUserService:IBaseService<user>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 登录,传入_user需包含用户名与密码/角色
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<user> Login(user _user);
|
||||
|
||||
/// <summary>
|
||||
/// 注册,需要检测是否用户名重复
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<bool> Register(user _user);
|
||||
/// <summary>
|
||||
/// 给多个用户设置多个角色
|
||||
/// </summary>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <param name="userIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SetRoleByUser(List<int> roleIds, List<int> userIds);
|
||||
/// <summary>
|
||||
/// 通过id获取用户信息,关联角色、菜单、子菜单、接口
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<user> GetUserById(int userId);
|
||||
/// <summary>
|
||||
/// email验证
|
||||
/// </summary>
|
||||
/// <param name="emailAddress"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> EmailIsExsit(string emailAddress);
|
||||
|
||||
/// <summary>
|
||||
/// sms验证
|
||||
/// </summary>
|
||||
/// <param name="smsAddress"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> PhoneIsExsit(string smsAddress);
|
||||
|
||||
/// <summary>
|
||||
/// 通过用户id,得到该用户的所有信息,关联角色
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<user> GetUserInRolesByHttpUser(int userId);
|
||||
/// <summary>
|
||||
/// 通过http获取用户id,得到该用户所有的菜单(递归的那种),把所有children为[]的值全部过滤成null,不要绑定mould
|
||||
/// </summary>
|
||||
/// <param name="allMenuIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<menu> GetMenuByHttpUser(List<int> allMenuIds);
|
||||
/// <summary>
|
||||
/// 根据路由获取菜单
|
||||
/// </summary>
|
||||
/// <param name="router"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<menu>> GetAxiosByRouter(string router,int userId, List<int> menuIds);
|
||||
|
||||
}
|
||||
}
|
||||
40
Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.cs
Normal file
40
Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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 interface IMenuService:IBaseService<menu>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<menu>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
|
||||
public partial interface IMouldService:IBaseService<mould>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<mould>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
|
||||
public partial interface IRoleService:IBaseService<role>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<role>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
|
||||
public partial interface IUserService:IBaseService<user>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<user>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
|
||||
public partial interface IVisitService:IBaseService<visit>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<visit>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
}
|
||||
43
Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.tt
Normal file
43
Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.tt
Normal file
@@ -0,0 +1,43 @@
|
||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.IO" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#
|
||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
||||
string dirPath= Path.Combine(solutionsPath,@"Yi.Framework.Model\Models\");
|
||||
DirectoryInfo dir = new DirectoryInfo(dirPath);
|
||||
FileInfo[] finfo = dir.GetFiles();
|
||||
string filenames = string.Empty;
|
||||
List<string> filenameList = new List<string>();
|
||||
for (int i = 0; i < finfo.Length; i++)
|
||||
{
|
||||
filenames = finfo[i].Name ;
|
||||
string[] fname=filenames.Split('.');
|
||||
filenameList.Add(fname[0]);
|
||||
}
|
||||
|
||||
|
||||
#>
|
||||
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
|
||||
{
|
||||
<# foreach(string k in filenameList){
|
||||
string fn= k.Substring(0,1).ToUpper()+k.Substring(1);
|
||||
#>
|
||||
|
||||
public partial interface I<#= fn #>Service:IBaseService<<#= k #>>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<<#= k #>>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
<# } #>
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="T4Service.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,42 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="T4Service.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="T4Iservice.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>T4Iservice.tt</DependentUpon>
|
||||
</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>
|
||||
Reference in New Issue
Block a user