优化仓储、Service
This commit is contained in:
parent
918e0b092d
commit
241fe55633
@ -203,7 +203,10 @@ namespace ZR.Repository
|
|||||||
{
|
{
|
||||||
return Context.Deleteable<T>().ExecuteCommand();
|
return Context.Deleteable<T>().ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
public bool Truncate()
|
||||||
|
{
|
||||||
|
return Context.DbMaintenance.TruncateTable<T>();
|
||||||
|
}
|
||||||
#endregion delete
|
#endregion delete
|
||||||
|
|
||||||
#region query
|
#region query
|
||||||
|
|||||||
@ -50,6 +50,7 @@ namespace ZR.Repository
|
|||||||
int Delete(object[] obj);
|
int Delete(object[] obj);
|
||||||
int Delete(object id);
|
int Delete(object id);
|
||||||
int DeleteTable();
|
int DeleteTable();
|
||||||
|
bool Truncate();
|
||||||
|
|
||||||
#endregion delete
|
#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
|
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>
|
||||||
/// 角色部门
|
/// 角色部门
|
||||||
/// </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 Infrastructure.Extensions;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
|
using ZR.Model.System.Dto;
|
||||||
|
|
||||||
namespace ZR.Repository.System
|
namespace ZR.Repository.System
|
||||||
{
|
{
|
||||||
@ -161,5 +161,29 @@ namespace ZR.Repository.System
|
|||||||
})
|
})
|
||||||
.Where(f => f.UserId == user.UserId).ExecuteCommand();
|
.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)]
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysUserRoleRepository : BaseRepository<SysUserRole>
|
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>
|
||||||
/// 批量删除角色对应用户
|
/// 批量删除角色对应用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,36 +23,6 @@ namespace ZR.Repository.System
|
|||||||
.ExecuteCommand();
|
.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>
|
/// <summary>
|
||||||
/// 获取用户数据根据角色id
|
/// 获取用户数据根据角色id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -4,10 +4,25 @@
|
|||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
<Compile Remove="System\CommonLangRepository.cs" />
|
||||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
<Compile Remove="System\GenTableRepository.cs" />
|
||||||
</ItemGroup>
|
<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>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using SqlSugar.IOC;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.Dto;
|
using ZR.Model.Dto;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Repository;
|
using ZR.Repository;
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -18,12 +15,6 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class ArticleCategoryService : BaseService<ArticleCategory>, IArticleCategoryService
|
public class ArticleCategoryService : BaseService<ArticleCategory>, IArticleCategoryService
|
||||||
{
|
{
|
||||||
private readonly ArticleCategoryRepository _ArticleCategoryRepository;
|
|
||||||
public ArticleCategoryService(ArticleCategoryRepository repository)
|
|
||||||
{
|
|
||||||
_ArticleCategoryRepository = repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询文章目录列表
|
/// 查询文章目录列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -35,8 +26,7 @@ namespace ZR.Service.System
|
|||||||
var predicate = Expressionable.Create<ArticleCategory>();
|
var predicate = Expressionable.Create<ArticleCategory>();
|
||||||
|
|
||||||
//搜索条件查询语法参考Sqlsugar
|
//搜索条件查询语法参考Sqlsugar
|
||||||
var response = _ArticleCategoryRepository
|
var response = Queryable()
|
||||||
.Queryable()
|
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.ToPage(parm);
|
.ToPage(parm);
|
||||||
|
|
||||||
@ -55,7 +45,7 @@ namespace ZR.Service.System
|
|||||||
|
|
||||||
//搜索条件查询语法参考Sqlsugar
|
//搜索条件查询语法参考Sqlsugar
|
||||||
|
|
||||||
var response = _ArticleCategoryRepository.Queryable().Where(predicate.ToExpression())
|
var response = Queryable().Where(predicate.ToExpression())
|
||||||
.ToTree(it => it.Children, it => it.ParentId, 0);
|
.ToTree(it => it.Children, it => it.ParentId, 0);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@ -68,7 +58,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int AddArticleCategory(ArticleCategory parm)
|
public int AddArticleCategory(ArticleCategory parm)
|
||||||
{
|
{
|
||||||
var response = _ArticleCategoryRepository.Insert(parm, it => new
|
var response = Insert(parm, it => new
|
||||||
{
|
{
|
||||||
it.Name,
|
it.Name,
|
||||||
it.CreateTime,
|
it.CreateTime,
|
||||||
|
|||||||
@ -20,12 +20,6 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ICommonLangService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ICommonLangService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class CommonLangService : BaseService<CommonLang>, ICommonLangService
|
public class CommonLangService : BaseService<CommonLang>, ICommonLangService
|
||||||
{
|
{
|
||||||
private readonly CommonLangRepository _CommonLangrepository;
|
|
||||||
public CommonLangService(CommonLangRepository repository)
|
|
||||||
{
|
|
||||||
_CommonLangrepository = repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 业务逻辑代码
|
#region 业务逻辑代码
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -42,8 +36,7 @@ namespace ZR.Service.System
|
|||||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
||||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
||||||
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
|
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
|
||||||
var response = _CommonLangrepository
|
var response = Queryable()
|
||||||
.Queryable()
|
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.ToPage(parm);
|
.ToPage(parm);
|
||||||
return response;
|
return response;
|
||||||
@ -63,8 +56,7 @@ namespace ZR.Service.System
|
|||||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
||||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
||||||
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
|
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
|
||||||
var response = _CommonLangrepository
|
var response = Queryable()
|
||||||
.Queryable()
|
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.ToPivotList(it => it.LangCode, it => it.LangKey, it => it.Max(f => f.LangName));
|
.ToPivotList(it => it.LangCode, it => it.LangKey, it => it.Max(f => f.LangName));
|
||||||
return response;
|
return response;
|
||||||
@ -78,8 +70,7 @@ namespace ZR.Service.System
|
|||||||
//搜索条件查询语法参考Sqlsugar
|
//搜索条件查询语法参考Sqlsugar
|
||||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
||||||
//predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
//predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
||||||
var response = _CommonLangrepository
|
var response = Queryable()
|
||||||
.Queryable()
|
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.ToList();
|
.ToList();
|
||||||
return response;
|
return response;
|
||||||
@ -98,7 +89,7 @@ namespace ZR.Service.System
|
|||||||
LangName = item.LangName,
|
LangName = item.LangName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var storage = _CommonLangrepository.Storageable(langs)
|
var storage = Storageable(langs)
|
||||||
.WhereColumns(it => new { it.LangKey, it.LangCode })
|
.WhereColumns(it => new { it.LangKey, it.LangCode })
|
||||||
.ToStorage();
|
.ToStorage();
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ZR.Common;
|
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System.Generate;
|
using ZR.Model.System.Generate;
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -19,12 +16,10 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(IGenTableService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(IGenTableService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class GenTableService : BaseService<GenTable>, IGenTableService
|
public class GenTableService : BaseService<GenTable>, IGenTableService
|
||||||
{
|
{
|
||||||
private GenTableRepository GenTableRepository;
|
|
||||||
private IGenTableColumnService GenTableColumnService;
|
private IGenTableColumnService GenTableColumnService;
|
||||||
public GenTableService(IGenTableColumnService genTableColumnService, GenTableRepository genTableRepository)
|
public GenTableService(IGenTableColumnService genTableColumnService)
|
||||||
{
|
{
|
||||||
GenTableColumnService = genTableColumnService;
|
GenTableColumnService = genTableColumnService;
|
||||||
GenTableRepository = genTableRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -34,7 +29,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteGenTableByIds(long[] tableIds)
|
public int DeleteGenTableByIds(long[] tableIds)
|
||||||
{
|
{
|
||||||
GenTableRepository.Delete(f => tableIds.Contains(f.TableId));
|
Delete(f => tableIds.Contains(f.TableId));
|
||||||
return GenTableColumnService.DeleteGenTableColumn(tableIds);
|
return GenTableColumnService.DeleteGenTableColumn(tableIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +40,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteGenTableByTbName(string tableName)
|
public int DeleteGenTableByTbName(string tableName)
|
||||||
{
|
{
|
||||||
return GenTableRepository.Delete(f => f.TableName == tableName) ? 1 : 0;
|
return Delete(f => f.TableName == tableName) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -55,10 +50,10 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public GenTable GetGenTableInfo(long tableId)
|
public GenTable GetGenTableInfo(long tableId)
|
||||||
{
|
{
|
||||||
var info = GenTableRepository.GetId(tableId);
|
var info = GetId(tableId);
|
||||||
if (info != null && !info.SubTableName.IsEmpty())
|
if (info != null && !info.SubTableName.IsEmpty())
|
||||||
{
|
{
|
||||||
info.SubTable = GenTableRepository.Queryable().Where(f => f.TableName == info.SubTableName).First();
|
info.SubTable = Queryable().Where(f => f.TableName == info.SubTableName).First();
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -69,7 +64,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<GenTable> GetGenTableAll()
|
public List<GenTable> GetGenTableAll()
|
||||||
{
|
{
|
||||||
return GenTableRepository.GetAll();
|
return GetAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -83,7 +78,7 @@ namespace ZR.Service.System
|
|||||||
var predicate = Expressionable.Create<GenTable>();
|
var predicate = Expressionable.Create<GenTable>();
|
||||||
predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
|
predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
|
||||||
|
|
||||||
return GenTableRepository.GetPages(predicate.ToExpression(), pagerInfo, x => x.TableId, OrderByType.Desc);
|
return GetPages(predicate.ToExpression(), pagerInfo, x => x.TableId, OrderByType.Desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -98,7 +93,7 @@ namespace ZR.Service.System
|
|||||||
//DeleteGenTableByIds(new long[] { table.TableId });
|
//DeleteGenTableByIds(new long[] { table.TableId });
|
||||||
DeleteGenTableByTbName(table.TableName);
|
DeleteGenTableByTbName(table.TableName);
|
||||||
|
|
||||||
return GenTableRepository.Context.Insertable(table).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnIdentity();
|
return Insertable(table).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -113,7 +108,7 @@ namespace ZR.Service.System
|
|||||||
|
|
||||||
public int UpdateGenTable(GenTable genTable)
|
public int UpdateGenTable(GenTable genTable)
|
||||||
{
|
{
|
||||||
var db = GenTableRepository.Context;
|
var db = Context;
|
||||||
genTable.Update_time = db.GetDate();
|
genTable.Update_time = db.GetDate();
|
||||||
return db.Updateable(genTable).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
return db.Updateable(genTable).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||||
}
|
}
|
||||||
@ -154,12 +149,6 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(IGenTableColumnService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(IGenTableColumnService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class GenTableColumnService : BaseService<GenTableColumn>, IGenTableColumnService
|
public class GenTableColumnService : BaseService<GenTableColumn>, IGenTableColumnService
|
||||||
{
|
{
|
||||||
|
|
||||||
private GenTableColumnRepository GetTableColumnRepository;
|
|
||||||
public GenTableColumnService(GenTableColumnRepository genTableColumnRepository)
|
|
||||||
{
|
|
||||||
GetTableColumnRepository = genTableColumnRepository;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除表字段
|
/// 删除表字段
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -167,8 +156,9 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteGenTableColumn(long tableId)
|
public int DeleteGenTableColumn(long tableId)
|
||||||
{
|
{
|
||||||
return GetTableColumnRepository.DeleteGenTableColumn(new long[] { tableId });
|
return Deleteable().Where(f => new long[] { tableId }.Contains(f.TableId)).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据表id批量删除表字段
|
/// 根据表id批量删除表字段
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -176,7 +166,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteGenTableColumn(long[] tableId)
|
public int DeleteGenTableColumn(long[] tableId)
|
||||||
{
|
{
|
||||||
return GetTableColumnRepository.DeleteGenTableColumn(tableId);
|
return Deleteable().Where(f => tableId.Contains(f.TableId)).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -186,7 +176,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteGenTableColumnByTableName(string tableName)
|
public int DeleteGenTableColumnByTableName(string tableName)
|
||||||
{
|
{
|
||||||
return GetTableColumnRepository.DeleteGenTableColumnByTableName(tableName);
|
return Deleteable().Where(f => f.TableName == tableName).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -196,7 +186,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<GenTableColumn> GenTableColumns(long tableId)
|
public List<GenTableColumn> GenTableColumns(long tableId)
|
||||||
{
|
{
|
||||||
return GetTableColumnRepository.GenTableColumns(tableId);
|
return Queryable().Where(f => f.TableId == tableId).OrderBy(x => x.Sort).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -206,7 +196,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int InsertGenTableColumn(List<GenTableColumn> tableColumn)
|
public int InsertGenTableColumn(List<GenTableColumn> tableColumn)
|
||||||
{
|
{
|
||||||
return GetTableColumnRepository.InsertGenTableColumn(tableColumn);
|
return Context.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -216,7 +206,28 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int UpdateGenTableColumn(List<GenTableColumn> tableColumn)
|
public int UpdateGenTableColumn(List<GenTableColumn> tableColumn)
|
||||||
{
|
{
|
||||||
return GetTableColumnRepository.UpdateGenTableColumn(tableColumn);
|
return Context.Updateable(tableColumn)
|
||||||
|
.WhereColumns(it => new { it.ColumnId, it.TableId })
|
||||||
|
.UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.ColumnComment,
|
||||||
|
it.CsharpField,
|
||||||
|
it.CsharpType,
|
||||||
|
it.IsQuery,
|
||||||
|
it.IsEdit,
|
||||||
|
it.IsInsert,
|
||||||
|
it.IsList,
|
||||||
|
it.QueryType,
|
||||||
|
it.HtmlType,
|
||||||
|
it.IsRequired,
|
||||||
|
it.Sort,
|
||||||
|
it.Update_time,
|
||||||
|
it.DictType,
|
||||||
|
it.Update_by,
|
||||||
|
it.Remark,
|
||||||
|
it.IsSort
|
||||||
|
})
|
||||||
|
.ExecuteCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Model.System.Vo;
|
using ZR.Model.System.Vo;
|
||||||
|
using ZR.Repository;
|
||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
@ -22,4 +21,9 @@ namespace ZR.Service.System.IService
|
|||||||
bool DeleteRoleDeptByRoleId(long roleId);
|
bool DeleteRoleDeptByRoleId(long roleId);
|
||||||
int InsertRoleDepts(SysRole role);
|
int InsertRoleDepts(SysRole role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ISysRoleDeptService : IBaseService<SysRoleDept>
|
||||||
|
{
|
||||||
|
List<SysRoleDept> SelectRoleDeptByRoleId(long roleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
using Infrastructure.Model;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface ISysDictDataService
|
public interface ISysDictDataService : IBaseService<SysDictData>
|
||||||
{
|
{
|
||||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo);
|
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo);
|
||||||
public List<SysDictData> SelectDictDataByType(string dictType);
|
public List<SysDictData> SelectDictDataByType(string dictType);
|
||||||
@ -16,5 +13,7 @@ namespace ZR.Service.System.IService
|
|||||||
public long InsertDictData(SysDictData dict);
|
public long InsertDictData(SysDictData dict);
|
||||||
public long UpdateDictData(SysDictData dict);
|
public long UpdateDictData(SysDictData dict);
|
||||||
public int DeleteDictDataByIds(long[] dictCodes);
|
public int DeleteDictDataByIds(long[] dictCodes);
|
||||||
|
int UpdateDictDataType(string old_dictType, string new_dictType);
|
||||||
|
List<SysDictData> SelectDictDataByCustomSql(SysDictType sysDictType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System.Dto;
|
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
|
using ZR.Model.System.Dto;
|
||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface ISysUserRoleService
|
public interface ISysUserRoleService : IBaseService<SysUserRole>
|
||||||
{
|
{
|
||||||
public int CountUserRoleByRoleId(long roleId);
|
public int CountUserRoleByRoleId(long roleId);
|
||||||
|
|
||||||
@ -31,7 +27,7 @@ namespace ZR.Service.System.IService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加用户角色
|
/// 添加用户角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sysRoleMenus"></param>
|
/// <param name="sysUsers"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int AddUserRole(List<SysUserRole> sysUsers);
|
public int AddUserRole(List<SysUserRole> sysUsers);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Repository;
|
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
{
|
{
|
||||||
@ -10,17 +9,11 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysConfigService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysConfigService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysConfigService : BaseService<SysConfig>, ISysConfigService
|
public class SysConfigService : BaseService<SysConfig>, ISysConfigService
|
||||||
{
|
{
|
||||||
private readonly SysConfigRepository _SysConfigrepository;
|
|
||||||
public SysConfigService(SysConfigRepository repository)
|
|
||||||
{
|
|
||||||
_SysConfigrepository = repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 业务逻辑代码
|
#region 业务逻辑代码
|
||||||
|
|
||||||
public SysConfig GetSysConfigByKey(string key)
|
public SysConfig GetSysConfigByKey(string key)
|
||||||
{
|
{
|
||||||
return _SysConfigrepository.Queryable().First(f => f.ConfigKey == key);
|
return Queryable().First(f => f.ConfigKey == key);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -20,11 +20,9 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysDeptService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysDeptService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysDeptService : BaseService<SysDept>, ISysDeptService
|
public class SysDeptService : BaseService<SysDept>, ISysDeptService
|
||||||
{
|
{
|
||||||
public SysDeptRepository DeptRepository;
|
public ISysRoleDeptService RoleDeptRepository;
|
||||||
public SysRoleDeptRepository RoleDeptRepository;
|
public SysDeptService(ISysRoleDeptService roleDeptRepository)
|
||||||
public SysDeptService(SysDeptRepository deptRepository, SysRoleDeptRepository roleDeptRepository)
|
|
||||||
{
|
{
|
||||||
DeptRepository = deptRepository;
|
|
||||||
RoleDeptRepository = roleDeptRepository;
|
RoleDeptRepository = roleDeptRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +39,7 @@ namespace ZR.Service.System
|
|||||||
predicate = predicate.AndIF(dept.DeptName.IfNotEmpty(), it => it.DeptName.Contains(dept.DeptName));
|
predicate = predicate.AndIF(dept.DeptName.IfNotEmpty(), it => it.DeptName.Contains(dept.DeptName));
|
||||||
predicate = predicate.AndIF(dept.Status.IfNotEmpty(), it => it.Status == dept.Status);
|
predicate = predicate.AndIF(dept.Status.IfNotEmpty(), it => it.Status == dept.Status);
|
||||||
|
|
||||||
var response = DeptRepository.GetList(predicate.ToExpression());
|
var response = GetList(predicate.ToExpression());
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -54,7 +52,7 @@ namespace ZR.Service.System
|
|||||||
public string CheckDeptNameUnique(SysDept dept)
|
public string CheckDeptNameUnique(SysDept dept)
|
||||||
{
|
{
|
||||||
long deptId = dept.DeptId == 0 ? -1L : dept.DeptId;
|
long deptId = dept.DeptId == 0 ? -1L : dept.DeptId;
|
||||||
SysDept info = DeptRepository.GetFirst(it => it.DeptName == dept.DeptName && it.ParentId == dept.ParentId);
|
SysDept info = GetFirst(it => it.DeptName == dept.DeptName && it.ParentId == dept.ParentId);
|
||||||
if (info != null && info.DeptId != deptId)
|
if (info != null && info.DeptId != deptId)
|
||||||
{
|
{
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
@ -69,7 +67,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int InsertDept(SysDept dept)
|
public int InsertDept(SysDept dept)
|
||||||
{
|
{
|
||||||
SysDept info = DeptRepository.GetFirst(it => it.DeptId == dept.ParentId);
|
SysDept info = GetFirst(it => it.DeptId == dept.ParentId);
|
||||||
//如果父节点不为正常状态,则不允许新增子节点
|
//如果父节点不为正常状态,则不允许新增子节点
|
||||||
if (info != null && !UserConstants.DEPT_NORMAL.Equals(info?.Status))
|
if (info != null && !UserConstants.DEPT_NORMAL.Equals(info?.Status))
|
||||||
{
|
{
|
||||||
@ -80,7 +78,7 @@ namespace ZR.Service.System
|
|||||||
{
|
{
|
||||||
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
|
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
|
||||||
}
|
}
|
||||||
return DeptRepository.Add(dept);
|
return Add(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -90,8 +88,8 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int UpdateDept(SysDept dept)
|
public int UpdateDept(SysDept dept)
|
||||||
{
|
{
|
||||||
SysDept newParentDept = DeptRepository.GetFirst(it => it.DeptId == dept.ParentId);
|
SysDept newParentDept = GetFirst(it => it.DeptId == dept.ParentId);
|
||||||
SysDept oldDept = DeptRepository.GetFirst(m => m.DeptId == dept.DeptId);
|
SysDept oldDept = GetFirst(m => m.DeptId == dept.DeptId);
|
||||||
if (newParentDept != null && oldDept != null)
|
if (newParentDept != null && oldDept != null)
|
||||||
{
|
{
|
||||||
string newAncestors = newParentDept.Ancestors + "," + newParentDept.DeptId;
|
string newAncestors = newParentDept.Ancestors + "," + newParentDept.DeptId;
|
||||||
@ -99,7 +97,7 @@ namespace ZR.Service.System
|
|||||||
dept.Ancestors = newAncestors;
|
dept.Ancestors = newAncestors;
|
||||||
UpdateDeptChildren(dept.DeptId, newAncestors, oldAncestors);
|
UpdateDeptChildren(dept.DeptId, newAncestors, oldAncestors);
|
||||||
}
|
}
|
||||||
int result = DeptRepository.Context.Updateable(dept).ExecuteCommand();
|
int result = Context.Updateable(dept).ExecuteCommand();
|
||||||
if (UserConstants.DEPT_NORMAL.Equals(dept.Status) && dept.Ancestors.IfNotEmpty()
|
if (UserConstants.DEPT_NORMAL.Equals(dept.Status) && dept.Ancestors.IfNotEmpty()
|
||||||
&& !"0".Equals(dept.Ancestors))
|
&& !"0".Equals(dept.Ancestors))
|
||||||
{
|
{
|
||||||
@ -119,7 +117,7 @@ namespace ZR.Service.System
|
|||||||
dept.Status = "0";
|
dept.Status = "0";
|
||||||
dept.Update_time = DateTime.Now;
|
dept.Update_time = DateTime.Now;
|
||||||
|
|
||||||
DeptRepository.Update(dept, it => new { it.Update_by, it.Update_time, it.Status }, f => depts.Contains(f.DeptId));
|
Update(dept, it => new { it.Update_by, it.Update_time, it.Status }, f => depts.Contains(f.DeptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -140,7 +138,8 @@ namespace ZR.Service.System
|
|||||||
}
|
}
|
||||||
if (children.Any())
|
if (children.Any())
|
||||||
{
|
{
|
||||||
DeptRepository.UdateDeptChildren(children);
|
Context.Updateable(children).WhereColumns(f => new { f.DeptId })
|
||||||
|
.UpdateColumns(it => new { it.Ancestors }).ExecuteCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,4 +284,16 @@ namespace ZR.Service.System
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 角色部门
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceType = typeof(ISysRoleDeptService), ServiceLifetime = LifeTime.Transient)]
|
||||||
|
public class SysRoleDeptService : BaseService<SysRoleDept>, ISysRoleDeptService
|
||||||
|
{
|
||||||
|
public List<SysRoleDept> SelectRoleDeptByRoleId(long roleId)
|
||||||
|
{
|
||||||
|
return GetList(it => it.RoleId == roleId).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Model;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Linq;
|
||||||
using ZR.Common;
|
using ZR.Common;
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -17,21 +16,20 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysDictDataService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysDictDataService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysDictDataService : BaseService<SysDictData>, ISysDictDataService
|
public class SysDictDataService : BaseService<SysDictData>, ISysDictDataService
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly SysDictDataRepository SysDictDataRepository;
|
|
||||||
public SysDictDataService(SysDictDataRepository sysDictDataRepository)
|
|
||||||
{
|
|
||||||
SysDictDataRepository = sysDictDataRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询字典数据
|
/// 查询字典数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dictData"></param>
|
/// <param name="dictData"></param>
|
||||||
|
/// <param name="pagerInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo)
|
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo)
|
||||||
{
|
{
|
||||||
return SysDictDataRepository.SelectDictDataList(dictData, pagerInfo);
|
//return SysDictDataRepository.SelectDictDataList(dictData, pagerInfo);
|
||||||
|
var exp = Expressionable.Create<SysDictData>();
|
||||||
|
exp.AndIF(!string.IsNullOrEmpty(dictData.DictLabel), it => it.DictLabel.Contains(dictData.DictLabel));
|
||||||
|
exp.AndIF(!string.IsNullOrEmpty(dictData.Status), it => it.Status == dictData.Status);
|
||||||
|
exp.AndIF(!string.IsNullOrEmpty(dictData.DictType), it => it.DictType == dictData.DictType);
|
||||||
|
return GetPages(exp.ToExpression(), pagerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -44,7 +42,9 @@ namespace ZR.Service.System
|
|||||||
string CK = $"SelectDictDataByType_{dictType}";
|
string CK = $"SelectDictDataByType_{dictType}";
|
||||||
if (CacheHelper.GetCache(CK) is not List<SysDictData> list)
|
if (CacheHelper.GetCache(CK) is not List<SysDictData> list)
|
||||||
{
|
{
|
||||||
list = SysDictDataRepository.SelectDictDataByType(dictType);
|
list = Queryable().Where(f => f.Status == "0" && f.DictType == dictType)
|
||||||
|
.OrderBy(it => it.DictSort)
|
||||||
|
.ToList();
|
||||||
CacheHelper.SetCache(CK, list, 30);
|
CacheHelper.SetCache(CK, list, 30);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -54,7 +54,9 @@ namespace ZR.Service.System
|
|||||||
string CK = $"SelectDictDataByTypes_{dictTypes}";
|
string CK = $"SelectDictDataByTypes_{dictTypes}";
|
||||||
if (CacheHelper.GetCache(CK) is not List<SysDictData> list)
|
if (CacheHelper.GetCache(CK) is not List<SysDictData> list)
|
||||||
{
|
{
|
||||||
list = SysDictDataRepository.SelectDictDataByTypes(dictTypes);
|
list = Queryable().Where(f => f.Status == "0" && dictTypes.Contains(f.DictType))
|
||||||
|
.OrderBy(it => it.DictSort)
|
||||||
|
.ToList();
|
||||||
//CacheHelper.SetCache(CK, list, 30);
|
//CacheHelper.SetCache(CK, list, 30);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -69,7 +71,7 @@ namespace ZR.Service.System
|
|||||||
string CK = $"SelectDictDataByCode_{dictCode}";
|
string CK = $"SelectDictDataByCode_{dictCode}";
|
||||||
if (CacheHelper.GetCache(CK) is not SysDictData list)
|
if (CacheHelper.GetCache(CK) is not SysDictData list)
|
||||||
{
|
{
|
||||||
list = SysDictDataRepository.GetFirst(f => f.DictCode == dictCode);
|
list = GetFirst(f => f.DictCode == dictCode);
|
||||||
CacheHelper.SetCache(CK, list, 5);
|
CacheHelper.SetCache(CK, list, 5);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -82,7 +84,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public long InsertDictData(SysDictData dict)
|
public long InsertDictData(SysDictData dict)
|
||||||
{
|
{
|
||||||
return SysDictDataRepository.InsertDictData(dict);
|
return Insertable(dict).ExecuteReturnBigIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -92,7 +94,19 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public long UpdateDictData(SysDictData dict)
|
public long UpdateDictData(SysDictData dict)
|
||||||
{
|
{
|
||||||
var result = SysDictDataRepository.UpdateDictData(dict);
|
var result = Updateable(dict)
|
||||||
|
.SetColumns(t => new SysDictData()
|
||||||
|
{
|
||||||
|
Remark = dict.Remark,
|
||||||
|
Update_time = DateTime.Now,
|
||||||
|
DictSort = dict.DictSort,
|
||||||
|
DictLabel = dict.DictLabel,
|
||||||
|
DictValue = dict.DictValue,
|
||||||
|
Status = dict.Status,
|
||||||
|
CssClass = dict.CssClass,
|
||||||
|
ListClass = dict.ListClass
|
||||||
|
})
|
||||||
|
.Where(f => f.DictCode == dict.DictCode).ExecuteCommand();
|
||||||
CacheHelper.Remove($"SelectDictDataByCode_{dict.DictCode}");
|
CacheHelper.Remove($"SelectDictDataByCode_{dict.DictCode}");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -104,7 +118,32 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteDictDataByIds(long[] dictCodes)
|
public int DeleteDictDataByIds(long[] dictCodes)
|
||||||
{
|
{
|
||||||
return SysDictDataRepository.DeleteDictDataByIds(dictCodes);
|
return Delete(dictCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步修改字典类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="old_dictType">旧字典类型</param>
|
||||||
|
/// <param name="new_dictType">新字典类型</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int UpdateDictDataType(string old_dictType, string new_dictType)
|
||||||
|
{
|
||||||
|
//只更新DictType字段根据where条件
|
||||||
|
return Context.Updateable<SysDictData>()
|
||||||
|
.SetColumns(t => new SysDictData() { DictType = new_dictType })
|
||||||
|
.Where(f => f.DictType == old_dictType)
|
||||||
|
.ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据字典类型查询自定义sql
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sysDictType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysDictData> SelectDictDataByCustomSql(SysDictType sysDictType)
|
||||||
|
{
|
||||||
|
return Context.Ado.SqlQuery<SysDictData>(sysDictType?.CustomSql).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -16,27 +15,32 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysDictService : BaseService<SysDictType>, ISysDictService
|
public class SysDictService : BaseService<SysDictType>, ISysDictService
|
||||||
{
|
{
|
||||||
private SysDictRepository DictRepository;
|
private ISysDictDataService DictDataService;
|
||||||
private SysDictDataRepository DictDataRepository;
|
|
||||||
|
|
||||||
public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository)
|
public SysDictService(ISysDictDataService dictDataRepository)
|
||||||
{
|
{
|
||||||
this.DictRepository = sysDictRepository;
|
this.DictDataService = dictDataRepository;
|
||||||
this.DictDataRepository = dictDataRepository;
|
|
||||||
}
|
}
|
||||||
public List<SysDictType> GetAll()
|
public List<SysDictType> GetAll()
|
||||||
{
|
{
|
||||||
return DictRepository.GetAll();
|
return Queryable().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询字段类型列表
|
/// 查询字段类型列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dictType">实体模型</param>
|
/// <param name="dictType">实体模型</param>
|
||||||
|
/// <param name="pager"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public PagedInfo<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager)
|
public PagedInfo<SysDictType> SelectDictTypeList(SysDictType dictType, PagerInfo pager)
|
||||||
{
|
{
|
||||||
return DictRepository.SelectDictTypeList(dictType, pager);
|
var exp = Expressionable.Create<SysDictType>();
|
||||||
|
exp.AndIF(!string.IsNullOrEmpty(dictType.DictName), it => it.DictName.Contains(dictType.DictName));
|
||||||
|
exp.AndIF(!string.IsNullOrEmpty(dictType.Status), it => it.Status == dictType.Status);
|
||||||
|
exp.AndIF(!string.IsNullOrEmpty(dictType.DictType), it => it.DictType.Contains(dictType.DictType));
|
||||||
|
exp.AndIF(!string.IsNullOrEmpty(dictType.Type), it => it.Type.Equals(dictType.Type));
|
||||||
|
|
||||||
|
return GetPages(exp.ToExpression(), pager, f => f.DictId, OrderByType.Desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,7 +50,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string CheckDictTypeUnique(SysDictType dictType)
|
public string CheckDictTypeUnique(SysDictType dictType)
|
||||||
{
|
{
|
||||||
SysDictType sysDictType = DictRepository.GetFirst(f => f.DictType == dictType.DictType);
|
SysDictType sysDictType = GetFirst(f => f.DictType == dictType.DictType);
|
||||||
if (sysDictType != null && sysDictType.DictId != dictType.DictId)
|
if (sysDictType != null && sysDictType.DictId != dictType.DictId)
|
||||||
{
|
{
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
@ -57,19 +61,19 @@ namespace ZR.Service.System
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量删除字典数据信息
|
/// 批量删除字典数据信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="dictIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteDictTypeByIds(long[] dictIds)
|
public int DeleteDictTypeByIds(long[] dictIds)
|
||||||
{
|
{
|
||||||
foreach (var dictId in dictIds)
|
foreach (var dictId in dictIds)
|
||||||
{
|
{
|
||||||
SysDictType dictType = DictRepository.GetFirst(x => x.DictId == dictId);
|
SysDictType dictType = GetFirst(x => x.DictId == dictId);
|
||||||
if (DictDataRepository.Count(f => f.DictType == dictType.DictType) > 0)
|
if (DictDataService.Count(f => f.DictType == dictType.DictType) > 0)
|
||||||
{
|
{
|
||||||
throw new CustomException($"{dictType.DictName}已分配,不能删除");
|
throw new CustomException($"{dictType.DictName}已分配,不能删除");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int count = DictRepository.DeleteDictTypeByIds(dictIds);
|
int count = Context.Deleteable<SysDictType>().In(dictIds).ExecuteCommand();
|
||||||
//if (count > 0)
|
//if (count > 0)
|
||||||
//{
|
//{
|
||||||
// DictUtils.clearDictCache();
|
// DictUtils.clearDictCache();
|
||||||
@ -84,7 +88,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public long InsertDictType(SysDictType sysDictType)
|
public long InsertDictType(SysDictType sysDictType)
|
||||||
{
|
{
|
||||||
return DictRepository.InsertReturnBigIdentity(sysDictType);
|
return InsertReturnBigIdentity(sysDictType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -94,13 +98,13 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int UpdateDictType(SysDictType sysDictType)
|
public int UpdateDictType(SysDictType sysDictType)
|
||||||
{
|
{
|
||||||
SysDictType oldDict = DictRepository.GetFirst(x => x.DictId == sysDictType.DictId);
|
SysDictType oldDict = GetFirst(x => x.DictId == sysDictType.DictId);
|
||||||
if (sysDictType.DictType != oldDict.DictType)
|
if (sysDictType.DictType != oldDict.DictType)
|
||||||
{
|
{
|
||||||
//同步修改 dict_data表里面的DictType值
|
//同步修改 dict_data表里面的DictType值
|
||||||
DictDataRepository.UpdateDictDataType(oldDict.DictType, sysDictType.DictType);
|
DictDataService.UpdateDictDataType(oldDict.DictType, sysDictType.DictType);
|
||||||
}
|
}
|
||||||
return DictRepository.UpdateDictType(sysDictType);
|
return Context.Updateable(sysDictType).IgnoreColumns(it => new { sysDictType.Create_by }).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -110,7 +114,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public SysDictType GetInfo(long dictId)
|
public SysDictType GetInfo(long dictId)
|
||||||
{
|
{
|
||||||
return DictRepository.GetFirst(f => f.DictId == dictId);
|
return GetFirst(f => f.DictId == dictId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -120,13 +124,13 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<SysDictData> SelectDictDataByCustomSql(string dictType)
|
public List<SysDictData> SelectDictDataByCustomSql(string dictType)
|
||||||
{
|
{
|
||||||
var dictInfo = DictRepository.Queryable()
|
var dictInfo = Queryable()
|
||||||
.Where(f => f.DictType == dictType).First();
|
.Where(f => f.DictType == dictType).First();
|
||||||
if (dictInfo == null || !dictInfo.CustomSql.StartsWith("select", StringComparison.OrdinalIgnoreCase))
|
if (dictInfo == null || !dictInfo.CustomSql.StartsWith("select", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return DictDataRepository.SelectDictDataByCustomSql(dictInfo);
|
return DictDataService.SelectDictDataByCustomSql(dictInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
|
using Infrastructure.Extensions;
|
||||||
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using ZR.Common;
|
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System.Dto;
|
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
|
using ZR.Model.System.Dto;
|
||||||
|
using ZR.Repository;
|
||||||
using ZR.Repository.System;
|
using ZR.Repository.System;
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
@ -17,11 +18,11 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysLoginService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysLoginService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysLoginService: BaseService<SysLogininfor>, ISysLoginService
|
public class SysLoginService: BaseService<SysLogininfor>, ISysLoginService
|
||||||
{
|
{
|
||||||
private SysLogininfoRepository SysLogininfoRepository;
|
private readonly SysUserRepository SysUserRepository;
|
||||||
|
|
||||||
public SysLoginService(SysLogininfoRepository sysLogininfo)
|
public SysLoginService(SysUserRepository sysUserRepository)
|
||||||
{
|
{
|
||||||
SysLogininfoRepository = sysLogininfo;
|
SysUserRepository = sysUserRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -34,7 +35,7 @@ namespace ZR.Service.System
|
|||||||
//密码md5
|
//密码md5
|
||||||
loginBody.Password = NETCore.Encrypt.EncryptProvider.Md5(loginBody.Password);
|
loginBody.Password = NETCore.Encrypt.EncryptProvider.Md5(loginBody.Password);
|
||||||
|
|
||||||
SysUser user = SysLogininfoRepository.Login(loginBody);
|
SysUser user = SysUserRepository.Login(loginBody);
|
||||||
logininfor.UserName = loginBody.Username;
|
logininfor.UserName = loginBody.Username;
|
||||||
logininfor.Status = "1";
|
logininfor.Status = "1";
|
||||||
logininfor.LoginTime = DateTime.Now;
|
logininfor.LoginTime = DateTime.Now;
|
||||||
@ -55,11 +56,10 @@ namespace ZR.Service.System
|
|||||||
logininfor.Status = "0";
|
logininfor.Status = "0";
|
||||||
logininfor.Msg = "登录成功";
|
logininfor.Msg = "登录成功";
|
||||||
AddLoginInfo(logininfor);
|
AddLoginInfo(logininfor);
|
||||||
SysLogininfoRepository.UpdateLoginInfo(loginBody, user.UserId);
|
SysUserRepository.UpdateLoginInfo(loginBody, user.UserId);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询操作日志
|
/// 查询操作日志
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -71,8 +71,15 @@ namespace ZR.Service.System
|
|||||||
logininfoDto.BeginTime = DateTimeHelper.GetBeginTime(logininfoDto.BeginTime, -1);
|
logininfoDto.BeginTime = DateTimeHelper.GetBeginTime(logininfoDto.BeginTime, -1);
|
||||||
logininfoDto.EndTime = DateTimeHelper.GetBeginTime(logininfoDto.EndTime, 1);
|
logininfoDto.EndTime = DateTimeHelper.GetBeginTime(logininfoDto.EndTime, 1);
|
||||||
|
|
||||||
var list = SysLogininfoRepository.GetLoginLog(logininfoDto, pager);
|
var exp = Expressionable.Create<SysLogininfor>();
|
||||||
return list;
|
exp.And(it => it.LoginTime >= logininfoDto.BeginTime && it.LoginTime <= logininfoDto.EndTime);
|
||||||
|
exp.AndIF(logininfoDto.Ipaddr.IfNotEmpty(), f => f.Ipaddr == logininfoDto.Ipaddr);
|
||||||
|
exp.AndIF(logininfoDto.UserName.IfNotEmpty(), f => f.UserName.Contains(logininfoDto.UserName));
|
||||||
|
exp.AndIF(logininfoDto.Status.IfNotEmpty(), f => f.Status == logininfoDto.Status);
|
||||||
|
var query = Queryable().Where(exp.ToExpression())
|
||||||
|
.OrderBy(it => it.InfoId, OrderByType.Desc);
|
||||||
|
|
||||||
|
return query.ToPage(pager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -82,7 +89,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void AddLoginInfo(SysLogininfor sysLogininfor)
|
public void AddLoginInfo(SysLogininfor sysLogininfor)
|
||||||
{
|
{
|
||||||
SysLogininfoRepository.AddLoginInfo(sysLogininfor);
|
Insert(sysLogininfor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -90,7 +97,7 @@ namespace ZR.Service.System
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void TruncateLogininfo()
|
public void TruncateLogininfo()
|
||||||
{
|
{
|
||||||
SysLogininfoRepository.TruncateLogininfo();
|
Truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -100,7 +107,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteLogininforByIds(long[] ids)
|
public int DeleteLogininforByIds(long[] ids)
|
||||||
{
|
{
|
||||||
return SysLogininfoRepository.DeleteLogininforByIds(ids);
|
return Delete(ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using ZR.Model.Models;
|
using ZR.Model.Models;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Repository;
|
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -19,12 +16,6 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysNoticeService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysNoticeService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysNoticeService : BaseService<SysNotice>, ISysNoticeService
|
public class SysNoticeService : BaseService<SysNotice>, ISysNoticeService
|
||||||
{
|
{
|
||||||
private readonly SysNoticeRepository _SysNoticerepository;
|
|
||||||
public SysNoticeService(SysNoticeRepository repository)
|
|
||||||
{
|
|
||||||
_SysNoticerepository = repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 业务逻辑代码
|
#region 业务逻辑代码
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -38,7 +29,7 @@ namespace ZR.Service.System
|
|||||||
|
|
||||||
//搜索条件查询语法参考Sqlsugar
|
//搜索条件查询语法参考Sqlsugar
|
||||||
predicate = predicate.And(m => m.Status == "0");
|
predicate = predicate.And(m => m.Status == "0");
|
||||||
return _SysNoticerepository.GetList(predicate.ToExpression());
|
return GetList(predicate.ToExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
|
using Infrastructure.Extensions;
|
||||||
|
using SqlSugar;
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Model.System.Dto;
|
using ZR.Model.System.Dto;
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -14,13 +15,6 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysOperLogService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysOperLogService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysOperLogService : BaseService<SysOperLog>, ISysOperLogService
|
public class SysOperLogService : BaseService<SysOperLog>, ISysOperLogService
|
||||||
{
|
{
|
||||||
public SysOperLogRepository sysOperLogRepository;
|
|
||||||
|
|
||||||
public SysOperLogService(SysOperLogRepository sysOperLog)
|
|
||||||
{
|
|
||||||
sysOperLogRepository = sysOperLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增操作日志操作
|
/// 新增操作日志操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,28 +25,34 @@ namespace ZR.Service.System
|
|||||||
{
|
{
|
||||||
operLog.OperParam = operLog.OperParam[..1000];
|
operLog.OperParam = operLog.OperParam[..1000];
|
||||||
}
|
}
|
||||||
sysOperLogRepository.AddSysOperLog(operLog);
|
//sysOperLogRepository.AddSysOperLog(operLog);
|
||||||
|
Insert(operLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询系统操作日志集合
|
/// 查询系统操作日志集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="operLog">操作日志对象</param>
|
/// <param name="sysOper">操作日志对象</param>
|
||||||
/// <param name="pager"></param>
|
/// <param name="pager"></param>
|
||||||
/// <returns>操作日志集合</returns>
|
/// <returns>操作日志集合</returns>
|
||||||
public PagedInfo<SysOperLog> SelectOperLogList(SysOperLogDto operLog, PagerInfo pager)
|
public PagedInfo<SysOperLog> SelectOperLogList(SysOperLogDto sysOper, PagerInfo pager)
|
||||||
{
|
{
|
||||||
operLog.BeginTime = DateTimeHelper.GetBeginTime(operLog.BeginTime, -1);
|
sysOper.BeginTime = DateTimeHelper.GetBeginTime(sysOper.BeginTime, -1);
|
||||||
operLog.EndTime = DateTimeHelper.GetBeginTime(operLog.EndTime, 1);
|
sysOper.EndTime = DateTimeHelper.GetBeginTime(sysOper.EndTime, 1);
|
||||||
|
|
||||||
bool isDemoMode = AppSettings.GetAppConfig("DemoMode", false);
|
bool isDemoMode = AppSettings.GetAppConfig("DemoMode", false);
|
||||||
if (isDemoMode)
|
if (isDemoMode)
|
||||||
{
|
{
|
||||||
return new PagedInfo<SysOperLog>();
|
return new PagedInfo<SysOperLog>();
|
||||||
}
|
}
|
||||||
var list = sysOperLogRepository.GetSysOperLog(operLog, pager);
|
var exp = Expressionable.Create<SysOperLog>();
|
||||||
|
exp.And(it => it.OperTime >= sysOper.BeginTime && it.OperTime <= sysOper.EndTime);
|
||||||
|
exp.AndIF(sysOper.Title.IfNotEmpty(), it => it.Title.Contains(sysOper.Title));
|
||||||
|
exp.AndIF(sysOper.operName.IfNotEmpty(), it => it.OperName.Contains(sysOper.operName));
|
||||||
|
exp.AndIF(sysOper.BusinessType != -1, it => it.BusinessType == sysOper.BusinessType);
|
||||||
|
exp.AndIF(sysOper.Status != -1, it => it.Status == sysOper.Status);
|
||||||
|
|
||||||
return list;
|
return GetPages(exp.ToExpression(), pager, x => x.OperId, OrderByType.Desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -60,7 +60,7 @@ namespace ZR.Service.System
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void CleanOperLog()
|
public void CleanOperLog()
|
||||||
{
|
{
|
||||||
sysOperLogRepository.ClearOperLog();
|
Truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -70,7 +70,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns>结果</returns>
|
/// <returns>结果</returns>
|
||||||
public int DeleteOperLogByIds(long[] operIds)
|
public int DeleteOperLogByIds(long[] operIds)
|
||||||
{
|
{
|
||||||
return sysOperLogRepository.DeleteOperLogByIds(operIds);
|
return Context.Deleteable<SysOperLog>().In(operIds).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -80,7 +80,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns>操作日志对象</returns>
|
/// <returns>操作日志对象</returns>
|
||||||
public SysOperLog SelectOperLogById(long operId)
|
public SysOperLog SelectOperLogById(long operId)
|
||||||
{
|
{
|
||||||
return sysOperLogRepository.SelectOperLogById(operId);
|
return GetById(operId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,6 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Repository;
|
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -15,12 +11,6 @@ namespace ZR.Service.System
|
|||||||
[AppService(ServiceType = typeof(ISysPostService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysPostService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysPostService : BaseService<SysPost>, ISysPostService
|
public class SysPostService : BaseService<SysPost>, ISysPostService
|
||||||
{
|
{
|
||||||
public SysPostRepository PostRepository;
|
|
||||||
public SysPostService(SysPostRepository postRepository)
|
|
||||||
{
|
|
||||||
PostRepository = postRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 校验岗位编码是否唯一
|
/// 校验岗位编码是否唯一
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -28,7 +18,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string CheckPostCodeUnique(SysPost post)
|
public string CheckPostCodeUnique(SysPost post)
|
||||||
{
|
{
|
||||||
SysPost info = PostRepository.GetFirst(it => it.PostCode.Equals(post.PostCode));
|
SysPost info = GetFirst(it => it.PostCode.Equals(post.PostCode));
|
||||||
if (info != null && info.PostId != post.PostId)
|
if (info != null && info.PostId != post.PostId)
|
||||||
{
|
{
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
@ -43,7 +33,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string CheckPostNameUnique(SysPost post)
|
public string CheckPostNameUnique(SysPost post)
|
||||||
{
|
{
|
||||||
SysPost info = PostRepository.GetFirst(it => it.PostName.Equals(post.PostName));
|
SysPost info = GetFirst(it => it.PostName.Equals(post.PostName));
|
||||||
if (info != null && info.PostId != post.PostId)
|
if (info != null && info.PostId != post.PostId)
|
||||||
{
|
{
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
@ -53,7 +43,7 @@ namespace ZR.Service.System
|
|||||||
|
|
||||||
public List<SysPost> GetAll()
|
public List<SysPost> GetAll()
|
||||||
{
|
{
|
||||||
return PostRepository.GetAll();
|
return GetAll(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,6 @@ namespace ZR.Service
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询所有角色
|
/// 查询所有角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="role"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<SysRole> SelectRoleAll()
|
public List<SysRole> SelectRoleAll()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using System;
|
using SqlSugar;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
using ZR.Repository.System;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
@ -13,14 +11,8 @@ namespace ZR.Service.System
|
|||||||
/// 用户岗位
|
/// 用户岗位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(ISysUserPostService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysUserPostService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysUserPostService : ISysUserPostService
|
public class SysUserPostService : BaseService<SysUserPost>, ISysUserPostService
|
||||||
{
|
{
|
||||||
private SysUserPostRepository UserPostRepository;
|
|
||||||
public SysUserPostService(SysUserPostRepository userPostRepository)
|
|
||||||
{
|
|
||||||
UserPostRepository = userPostRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增用户岗位信息
|
/// 新增用户岗位信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,7 +25,7 @@ namespace ZR.Service.System
|
|||||||
{
|
{
|
||||||
list.Add(new SysUserPost() { PostId = item, UserId = user.UserId });
|
list.Add(new SysUserPost() { PostId = item, UserId = user.UserId });
|
||||||
}
|
}
|
||||||
UserPostRepository.Insert(list);
|
Insert(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +36,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<long> GetUserPostsByUserId(long userId)
|
public List<long> GetUserPostsByUserId(long userId)
|
||||||
{
|
{
|
||||||
var list = UserPostRepository.GetList(f => f.UserId == userId);
|
var list = GetList(f => f.UserId == userId);
|
||||||
return list.Select(x => x.PostId).ToList();
|
return list.Select(x => x.PostId).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,13 +47,26 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetPostsStrByUserId(long userId)
|
public string GetPostsStrByUserId(long userId)
|
||||||
{
|
{
|
||||||
var list = UserPostRepository.SelectPostsByUserId(userId);
|
var list = SelectPostsByUserId(userId);
|
||||||
return string.Join(',', list.Select(x => x.PostName));
|
return string.Join(',', list.Select(x => x.PostName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(long userId)
|
public bool Delete(long userId)
|
||||||
{
|
{
|
||||||
return UserPostRepository.Delete(x => x.UserId == userId);
|
return Delete(x => x.UserId == userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户岗位
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysPost> SelectPostsByUserId(long userId)
|
||||||
|
{
|
||||||
|
return Context.Queryable<SysPost, SysUserPost>((p, up) => new JoinQueryInfos(
|
||||||
|
JoinType.Left, up.PostId == p.PostId
|
||||||
|
)).Where((p, up) => up.UserId == userId)
|
||||||
|
.Select<SysPost>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.System.Dto;
|
|
||||||
using ZR.Model.System;
|
using ZR.Model.System;
|
||||||
|
using ZR.Model.System.Dto;
|
||||||
using ZR.Repository.System;
|
using ZR.Repository.System;
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
@ -14,7 +12,7 @@ namespace ZR.Service.System
|
|||||||
/// 用户角色
|
/// 用户角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(ISysUserRoleService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysUserRoleService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysUserRoleService : ISysUserRoleService
|
public class SysUserRoleService : BaseService<SysUserRole>, ISysUserRoleService
|
||||||
{
|
{
|
||||||
public SysUserRoleRepository SysUserRoleRepository;
|
public SysUserRoleRepository SysUserRoleRepository;
|
||||||
|
|
||||||
@ -23,7 +21,6 @@ namespace ZR.Service.System
|
|||||||
SysUserRoleRepository = sysUserRoleRepository;
|
SysUserRoleRepository = sysUserRoleRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过角色ID查询角色使用数量
|
/// 通过角色ID查询角色使用数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,7 +28,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int CountUserRoleByRoleId(long roleId)
|
public int CountUserRoleByRoleId(long roleId)
|
||||||
{
|
{
|
||||||
return SysUserRoleRepository.CountUserRoleByRoleId(roleId);
|
return Count(it => it.RoleId == roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -41,7 +38,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteUserRoleByUserId(int userId)
|
public int DeleteUserRoleByUserId(int userId)
|
||||||
{
|
{
|
||||||
return SysUserRoleRepository.DeleteUserRoleByUserId(userId);
|
return Deleteable().Where(it => it.UserId == userId).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -58,11 +55,11 @@ namespace ZR.Service.System
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加用户角色
|
/// 添加用户角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sysRoleMenus"></param>
|
/// <param name="sysUserRoles"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int AddUserRole(List<SysUserRole> sysUsers)
|
public int AddUserRole(List<SysUserRole> sysUserRoles)
|
||||||
{
|
{
|
||||||
return SysUserRoleRepository.AddUserRole(sysUsers);
|
return Insert(sysUserRoles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -102,7 +99,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int InsertUserRole(SysUser user)
|
public int InsertUserRole(SysUser user)
|
||||||
{
|
{
|
||||||
List<SysUserRole> userRoles = new List<SysUserRole>();
|
List<SysUserRole> userRoles = new();
|
||||||
foreach (var item in user.RoleIds)
|
foreach (var item in user.RoleIds)
|
||||||
{
|
{
|
||||||
userRoles.Add(new SysUserRole() { RoleId = item, UserId = user.UserId });
|
userRoles.Add(new SysUserRole() { RoleId = item, UserId = user.UserId });
|
||||||
@ -114,8 +111,7 @@ namespace ZR.Service.System
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增加角色用户
|
/// 新增加角色用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId">角色id</param>
|
/// <param name="roleUsersCreateDto"></param>
|
||||||
/// <param name="userids">用户ids</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int InsertRoleUser(RoleUsersCreateDto roleUsersCreateDto)
|
public int InsertRoleUser(RoleUsersCreateDto roleUsersCreateDto)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user