优化仓储、Service
This commit is contained in:
@@ -203,7 +203,10 @@ namespace ZR.Repository
|
||||
{
|
||||
return Context.Deleteable<T>().ExecuteCommand();
|
||||
}
|
||||
|
||||
public bool Truncate()
|
||||
{
|
||||
return Context.DbMaintenance.TruncateTable<T>();
|
||||
}
|
||||
#endregion delete
|
||||
|
||||
#region query
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace ZR.Repository
|
||||
int Delete(object[] obj);
|
||||
int Delete(object id);
|
||||
int DeleteTable();
|
||||
bool Truncate();
|
||||
|
||||
#endregion delete
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using Infrastructure.Attribute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章管理
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleRepository : BaseRepository<Article>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文章目录
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleCategoryRepository : BaseRepository<ArticleCategory>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,31 +4,6 @@ using ZR.Model.System;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门管理
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysDeptRepository : BaseRepository<SysDept>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="deptId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDept> SelectChildrenDeptById(long deptId)
|
||||
{
|
||||
string sql = "select * from sys_dept where find_in_set(@deptId, ancestors)";
|
||||
|
||||
return Context.SqlQueryable<SysDept>(sql).AddParameters(new { @deptId = deptId }).ToList();
|
||||
}
|
||||
|
||||
public int UdateDeptChildren(List<SysDept> dept)
|
||||
{
|
||||
return Context.Updateable(dept).WhereColumns(f => new { f.DeptId })
|
||||
.UpdateColumns(it => new { it.Ancestors }).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色部门
|
||||
/// </summary>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Model.Models;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件存储仓储
|
||||
///
|
||||
/// @author zz
|
||||
/// @date 2021-12-15
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysFileRepository : BaseRepository<SysFile>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
{
|
||||
@@ -161,5 +161,29 @@ namespace ZR.Repository.System
|
||||
})
|
||||
.Where(f => f.UserId == user.UserId).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
/// <param name="user">登录实体</param>
|
||||
/// <returns></returns>
|
||||
public SysUser Login(LoginBodyDto user)
|
||||
{
|
||||
return GetFirst(it => it.UserName == user.Username && it.Password == user.Password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改登录信息
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public void UpdateLoginInfo(LoginBodyDto user, long userId)
|
||||
{
|
||||
var db = Context;
|
||||
db.Updateable(new SysUser() { LoginIP = user.LoginIP, LoginDate = db.GetDate(), UserId = userId })
|
||||
.UpdateColumns(it => new { it.LoginIP, it.LoginDate })
|
||||
.ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,16 +11,6 @@ namespace ZR.Repository.System
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysUserRoleRepository : BaseRepository<SysUserRole>
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除用户角色
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteUserRoleByUserId(int userId)
|
||||
{
|
||||
return Context.Deleteable<SysUserRole>().Where(it => it.UserId == userId).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除角色对应用户
|
||||
/// </summary>
|
||||
@@ -33,36 +23,6 @@ namespace ZR.Repository.System
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加用户角色
|
||||
/// </summary>
|
||||
/// <param name="sysUsers"></param>
|
||||
/// <returns></returns>
|
||||
public int AddUserRole(List<SysUserRole> sysUsers)
|
||||
{
|
||||
return Context.Insertable(sysUsers).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色关联的用户
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteUserRoleByRoleId(int roleId)
|
||||
{
|
||||
return Context.Deleteable<SysUserRole>().In(roleId).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色分配个数
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public int CountUserRoleByRoleId(long roleId)
|
||||
{
|
||||
return Context.Queryable<SysUserRole>().Where(it => it.RoleId == roleId).Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户数据根据角色id
|
||||
/// </summary>
|
||||
|
||||
@@ -4,10 +4,25 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="System\CommonLangRepository.cs" />
|
||||
<Compile Remove="System\GenTableRepository.cs" />
|
||||
<Compile Remove="System\SysConfigRepository.cs" />
|
||||
<Compile Remove="System\SysDeptRepository.cs" />
|
||||
<Compile Remove="System\SysDictDataRepository.cs" />
|
||||
<Compile Remove="System\SysDictRepository.cs" />
|
||||
<Compile Remove="System\SysLogininfoRepository.cs" />
|
||||
<Compile Remove="System\SysNoticeRepository.cs" />
|
||||
<Compile Remove="System\SysOperLogRepository.cs" />
|
||||
<Compile Remove="System\SysPostRepository.cs" />
|
||||
<Compile Remove="System\SysTasksQzRepository.cs" />
|
||||
<Compile Remove="System\SysUserPostRepository.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
|
||||
|
||||
Reference in New Issue
Block a user