This commit is contained in:
不做码农
2021-09-27 08:06:09 +08:00
parent 48e14b4d4f
commit 40026f596f
53 changed files with 1306 additions and 312 deletions
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.System.Generate;
namespace ZR.Repository.System
{
public class GenTableRepository : BaseRepository<GenTable>
{
}
public class GenTableColumnRepository : BaseRepository<GenTableColumn>
{
/// <summary>
/// 根据表id批量删除表字段
/// </summary>
/// <param name="tableId"></param>
/// <returns></returns>
public int DeleteGenTableColumn(long[] tableId)
{
return Context.Deleteable<GenTableColumn>().Where(f => tableId.Contains(f.TableId)).ExecuteCommand();
}
/// <summary>
/// 根据表名删除字段
/// </summary>
/// <param name="tableName"></param>
/// <returns></returns>
public int DeleteGenTableColumnByTableName(string tableName)
{
return Context.Deleteable<GenTableColumn>().Where(f => f.TableName == tableName).ExecuteCommand();
}
/// <summary>
/// 获取表所有字段
/// </summary>
/// <param name="tableId"></param>
/// <returns></returns>
public List<GenTableColumn> GenTableColumns(long tableId)
{
return Context.Queryable<GenTableColumn>().Where(f => f.TableId == tableId).OrderBy(x => x.Sort).ToList();
}
/// <summary>
/// 插入表字段
/// </summary>
/// <param name="tableColumn"></param>
/// <returns></returns>
public int InsertGenTableColumn(List<GenTableColumn> tableColumn)
{
return Context.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
}
/// <summary>
/// 批量更新表字段
/// </summary>
/// <param name="tableColumn"></param>
/// <returns></returns>
public int UpdateGenTableColumn(List<GenTableColumn> tableColumn)
{
foreach (var item in tableColumn)
{
Context.Updateable<GenTableColumn>()
.Where(f => f.TableId == item.TableId)
.SetColumns(it => new GenTableColumn()
{
ColumnComment = item.ColumnComment,
CsharpField = item.CsharpField,
CsharpType = item.CsharpType,
IsQuery = item.IsQuery,
IsEdit = item.IsEdit,
IsInsert = item.IsInsert,
IsList = item.IsList,
QueryType = item.QueryType,
HtmlType = item.HtmlType,
IsRequired = item.IsRequired,
Sort = item.Sort,
Update_time = DateTime.Now,
DictType = item.DictType
})
.Where(f => f.ColumnId == item.ColumnId)
.ExecuteCommand();
}
return 1;
}
}
}
+3 -3
View File
@@ -8,7 +8,7 @@ namespace ZR.Repository.System
/// 部门管理
/// </summary>
[AppService(ServiceLifetime= LifeTime.Transient)]
public class SysDeptRepository : BaseRepository
public class SysDeptRepository : BaseRepository<SysDept>
{
/// <summary>
///
@@ -19,12 +19,12 @@ namespace ZR.Repository.System
{
string sql = "select * from sys_dept where find_in_set(@deptId, ancestors)";
return Db.SqlQueryable<SysDept>(sql).AddParameters(new { @deptId = deptId }).ToList();
return Context.SqlQueryable<SysDept>(sql).AddParameters(new { @deptId = deptId }).ToList();
}
public int UdateDeptChildren(SysDept dept)
{
return Db.Updateable(dept).UpdateColumns(it => new { it.Ancestors }).ExecuteCommand();
return Context.Updateable(dept).UpdateColumns(it => new { it.Ancestors }).ExecuteCommand();
}
}
}
@@ -9,7 +9,7 @@ namespace ZR.Repository.System
/// 字典数据
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysDictDataRepository : BaseRepository
public class SysDictDataRepository : BaseRepository<SysDictData>
{
/// <summary>
/// 字典类型数据搜索
@@ -18,7 +18,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysDictData> SelectDictDataList(SysDictData dictData)
{
return Db.Queryable<SysDictData>()
return Context.Queryable<SysDictData>()
.WhereIF(!string.IsNullOrEmpty(dictData.DictLabel), it => it.DictLabel.Contains(dictData.DictLabel))
.WhereIF(!string.IsNullOrEmpty(dictData.Status), it => it.Status == dictData.Status)
.WhereIF(!string.IsNullOrEmpty(dictData.DictType), it => it.DictType == dictData.DictType)
@@ -32,7 +32,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysDictData> SelectDictDataByType(string dictType)
{
return Db.Queryable<SysDictData>().Where(f => f.Status == "0" && f.DictType == dictType)
return Context.Queryable<SysDictData>().Where(f => f.Status == "0" && f.DictType == dictType)
.OrderBy(it => it.DictSort)
.ToList();
}
@@ -44,7 +44,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public long InsertDictData(SysDictData dict)
{
var result = Db.Insertable(dict).IgnoreColumns(it => new { dict.Update_by })
var result = Context.Insertable(dict).IgnoreColumns(it => new { dict.Update_by })
.ExecuteReturnIdentity();
return result;
}
@@ -56,7 +56,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public long UpdateDictData(SysDictData dict)
{
return Db.Updateable<SysDictData>()
return Context.Updateable<SysDictData>()
.SetColumns(t => new SysDictData()
{
Remark = dict.Remark,
@@ -76,7 +76,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteDictDataByIds(long[] dictCodes)
{
return Db.Deleteable<SysDictData>().In(dictCodes).ExecuteCommand();
return Context.Deleteable<SysDictData>().In(dictCodes).ExecuteCommand();
}
/// <summary>
@@ -88,7 +88,7 @@ namespace ZR.Repository.System
public int UpdateDictDataType(string old_dictType, string new_dictType)
{
//只更新DictType字段根据where条件
return Db.Updateable<SysDictData>()
return Context.Updateable<SysDictData>()
.SetColumns(t => new SysDictData() { DictType = new_dictType })
.Where(f => f.DictType == old_dictType)
.ExecuteCommand();
+4 -4
View File
@@ -10,7 +10,7 @@ namespace ZR.Repository.System
/// 字典
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysDictRepository : BaseRepository
public class SysDictRepository : BaseRepository<SysDictType>
{
/// <summary>
/// 查询字段类型列表
@@ -20,7 +20,7 @@ namespace ZR.Repository.System
public List<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager)
{
var totalNum = 0;
var list = Db
var list = Context
.Queryable<SysDictType>()
.WhereIF(!string.IsNullOrEmpty(dictType.DictName), it => it.DictName.Contains(dictType.DictName))
.WhereIF(!string.IsNullOrEmpty(dictType.Status), it => it.Status == dictType.Status)
@@ -37,7 +37,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteDictTypeByIds(long[] id)
{
return Db.Deleteable<SysDictType>().In(id).ExecuteCommand();
return Context.Deleteable<SysDictType>().In(id).ExecuteCommand();
}
/// <summary>
@@ -47,7 +47,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int UpdateDictType(SysDictType dictType)
{
return Db.Updateable(dictType).IgnoreColumns(it => new { dictType.Create_by }).ExecuteCommand();
return Context.Updateable(dictType).IgnoreColumns(it => new { dictType.Create_by }).ExecuteCommand();
}
}
}
@@ -8,7 +8,7 @@ using ZR.Model.System;
namespace ZR.Repository.System
{
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysLogininfoRepository : BaseRepository
public class SysLogininfoRepository : BaseRepository<SysLogininfor>
{
/// <summary>
/// 查询登录日志
@@ -19,7 +19,7 @@ namespace ZR.Repository.System
public List<SysLogininfor> GetLoginLog(SysLogininfor logininfoDto, PagerInfo pager)
{
int totalCount = 0;
var list = Db.Queryable<SysLogininfor>()
var list = Context.Queryable<SysLogininfor>()
.Where(it => it.loginTime >= logininfoDto.BeginTime && it.loginTime <= logininfoDto.EndTime)
.WhereIF(logininfoDto.ipaddr.IfNotEmpty(), f => f.ipaddr == logininfoDto.ipaddr)
.WhereIF(logininfoDto.userName.IfNotEmpty(), f => f.userName.Contains(logininfoDto.userName))
@@ -38,7 +38,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public void AddLoginInfo(SysLogininfor sysLogininfor)
{
int result = Db.Insertable(sysLogininfor)
int result = Context.Insertable(sysLogininfor)
.IgnoreColumns(it => new { it.Create_by, it.Create_time, it.Remark })
.ExecuteReturnIdentity();
}
@@ -50,7 +50,7 @@ namespace ZR.Repository.System
{
string sql = "truncate table sys_logininfor";
Db.Ado.ExecuteCommand(sql);
Context.Ado.ExecuteCommand(sql);
}
/// <summary>
@@ -60,7 +60,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteLogininforByIds(long[] ids)
{
return Db.Deleteable<SysLogininfor>().In(ids).ExecuteCommand();
return Context.Deleteable<SysLogininfor>().In(ids).ExecuteCommand();
}
/// <summary>
@@ -70,7 +70,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysUser Login(LoginBodyDto user)
{
return Db.Queryable<SysUser>().First(it => it.UserName == user.Username && it.Password == user.Password);
return Context.Queryable<SysUser>().First(it => it.UserName == user.Username && it.Password == user.Password);
}
/// <summary>
@@ -81,7 +81,8 @@ namespace ZR.Repository.System
/// <returns></returns>
public void UpdateLoginInfo(LoginBodyDto user, long userId)
{
Db.Updateable(new SysUser() { LoginIP = user.LoginIP, LoginDate = Db.GetDate(), UserId = userId })
var db = Context;
db.Updateable(new SysUser() { LoginIP = user.LoginIP, LoginDate = db.GetDate(), UserId = userId })
.UpdateColumns(it => new { it.LoginIP, it.LoginDate })
.ExecuteCommand();
}
+14 -13
View File
@@ -12,7 +12,7 @@ namespace ZR.Repository.System
/// 系统菜单
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysMenuRepository : BaseRepository
public class SysMenuRepository : BaseRepository<SysMenu>
{
/// <summary>
/// 获取所有菜单(菜单管理)
@@ -20,7 +20,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysMenu> SelectMenuList(SysMenu menu)
{
return Db.Queryable<SysMenu>()
return Context.Queryable<SysMenu>()
.WhereIF(!string.IsNullOrEmpty(menu.menuName), it => it.menuName.Contains(menu.menuName))
.WhereIF(!string.IsNullOrEmpty(menu.visible), it => it.visible == menu.visible)
.WhereIF(!string.IsNullOrEmpty(menu.status), it => it.status == menu.status)
@@ -36,7 +36,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysMenu> SelectMenuListByUserId(SysMenu sysMenu, long userId)
{
return Db.Queryable<SysMenu, SysRoleMenu, SysUserRole, SysRole>((menu, roleMenu, userRole, role) => new JoinQueryInfos(
return Context.Queryable<SysMenu, SysRoleMenu, SysUserRole, SysRole>((menu, roleMenu, userRole, role) => new JoinQueryInfos(
JoinType.Left, menu.menuId == roleMenu.Menu_id,
JoinType.Left, roleMenu.Role_id == userRole.RoleId,
JoinType.Left, userRole.RoleId == role.RoleId
@@ -60,7 +60,7 @@ namespace ZR.Repository.System
{
var menuTypes = new string[] { "M", "C" };
return Db.Queryable<SysMenu>()
return Context.Queryable<SysMenu>()
.Where(f => f.status == "0" && menuTypes.Contains(f.menuType))
.OrderBy(it => new { it.parentId, it.orderNum }).ToList();
}
@@ -73,7 +73,7 @@ namespace ZR.Repository.System
public List<SysMenu> SelectMenuTreeByRoleIds(List<long> roleIds)
{
var menuTypes = new string[] { "M", "C"};
return Db.Queryable<SysMenu, SysRoleMenu>((menu, roleMenu) => new JoinQueryInfos(
return Context.Queryable<SysMenu, SysRoleMenu>((menu, roleMenu) => new JoinQueryInfos(
JoinType.Left, menu.menuId == roleMenu.Menu_id
))
.Where((menu, roleMenu) => roleIds.Contains(roleMenu.Role_id) && menuTypes.Contains(menu.menuType) && menu.status == "0")
@@ -90,7 +90,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysMenu SelectMenuById(int menuId)
{
return Db.Queryable<SysMenu>().Where(it => it.menuId == menuId).Single();
return Context.Queryable<SysMenu>().Where(it => it.menuId == menuId).Single();
}
/// <summary>
@@ -100,6 +100,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int AddMenu(SysMenu menu)
{
var Db = Context;
menu.Create_time = Db.GetDate();
menu.menuId = Db.Insertable(menu).ExecuteReturnIdentity();
return 1;
@@ -112,7 +113,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int EditMenu(SysMenu menu)
{
return Db.Updateable(menu).ExecuteCommand();
return Context.Updateable(menu).ExecuteCommand();
}
/// <summary>
@@ -122,7 +123,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteMenuById(int menuId)
{
return Db.Deleteable<SysMenu>().Where(it => it.menuId == menuId).ExecuteCommand();
return Context.Deleteable<SysMenu>().Where(it => it.menuId == menuId).ExecuteCommand();
}
/// <summary>
@@ -132,7 +133,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int ChangeSortMenu(MenuDto menuDto)
{
var result = Db.Updateable(new SysMenu() { menuId = menuDto.MenuId, orderNum = menuDto.orderNum })
var result = Context.Updateable(new SysMenu() { menuId = menuDto.MenuId, orderNum = menuDto.orderNum })
.UpdateColumns(it => new { it.orderNum }).ExecuteCommand();
return result;
}
@@ -144,7 +145,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysMenu> SelectMenuPermsByUserId(long userId)
{
return Db.Queryable<SysMenu, SysRoleMenu, SysUserRole, SysRole>((m, rm, ur, r) => new JoinQueryInfos(
return Context.Queryable<SysMenu, SysRoleMenu, SysUserRole, SysRole>((m, rm, ur, r) => new JoinQueryInfos(
JoinType.Left, m.menuId == rm.Menu_id,
JoinType.Left, rm.Role_id == ur.RoleId,
JoinType.Left, ur.RoleId == r.RoleId
@@ -161,7 +162,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysMenu CheckMenuNameUnique(SysMenu menu)
{
return Db.Queryable<SysMenu>()
return Context.Queryable<SysMenu>()
.Where(it => it.menuName == menu.menuName && it.parentId == menu.parentId).Single();
}
@@ -172,7 +173,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int HasChildByMenuId(long menuId)
{
return Db.Queryable<SysMenu>().Where(it => it.parentId == menuId).Count();
return Context.Queryable<SysMenu>().Where(it => it.parentId == menuId).Count();
}
#region RoleMenu
@@ -184,7 +185,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int CheckMenuExistRole(long menuId)
{
return Db.Queryable<SysRoleMenu>().Where(it => it.Menu_id == menuId).Count();
return Context.Queryable<SysRoleMenu>().Where(it => it.Menu_id == menuId).Count();
}
#endregion
+6 -6
View File
@@ -8,7 +8,7 @@ using ZR.Model.System;
namespace ZR.Repository.System
{
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysOperLogRepository : BaseRepository
public class SysOperLogRepository : BaseRepository<SysOperLog>
{
/// <summary>
/// 查询操作日志
@@ -19,7 +19,7 @@ namespace ZR.Repository.System
public List<SysOperLog> GetSysOperLog(SysOperLogDto sysOper, PagerInfo pagerInfo)
{
int totalCount = 0;
var list = Db.Queryable<SysOperLog>()
var list = Context.Queryable<SysOperLog>()
.Where(it => it.operTime >= sysOper.BeginTime && it.operTime <= sysOper.EndTime)
.WhereIF(sysOper.Title.IfNotEmpty(), it => it.title.Contains(sysOper.Title))
.WhereIF(sysOper.operName.IfNotEmpty(), it => it.operName.Contains(sysOper.operName))
@@ -38,7 +38,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public void AddSysOperLog(SysOperLog sysOperLog)
{
Db.Insertable(sysOperLog).ExecuteCommandAsync();
Context.Insertable(sysOperLog).ExecuteCommandAsync();
}
/// <summary>
@@ -47,7 +47,7 @@ namespace ZR.Repository.System
public void ClearOperLog()
{
string sql = "truncate table sys_oper_log";
Db.Ado.ExecuteCommand(sql);
Context.Ado.ExecuteCommand(sql);
}
/// <summary>
@@ -57,7 +57,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteOperLogByIds(long[] operIds)
{
return Db.Deleteable<SysOperLog>().In(operIds).ExecuteCommand();
return Context.Deleteable<SysOperLog>().In(operIds).ExecuteCommand();
}
/// <summary>
@@ -67,7 +67,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysOperLog SelectOperLogById(long operId)
{
return Db.Queryable<SysOperLog>().InSingle(operId);
return Context.Queryable<SysOperLog>().InSingle(operId);
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.System;
namespace ZR.Repository.System
{
public class SysPostRepository : BaseRepository<SysPost>
{
}
}
+16 -16
View File
@@ -9,7 +9,7 @@ namespace ZR.Repository.System
/// 角色操作类
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysRoleRepository : BaseRepository
public class SysRoleRepository : BaseRepository<SysRole>
{
/// <summary>
/// 根据条件分页查询角色数据
@@ -17,7 +17,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysRole> SelectRoleList(SysRole sysRole)
{
return Db.Queryable<SysRole>()
return Context.Queryable<SysRole>()
.Where(role => role.DelFlag == "0")
.WhereIF(!string.IsNullOrEmpty(sysRole.RoleName), role => role.RoleName.Contains(sysRole.RoleName))
.WhereIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status)
@@ -33,7 +33,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysRole> SelectRolePermissionByUserId(long userId)
{
return Db.Queryable<SysRole>()
return Context.Queryable<SysRole>()
.Where(role => role.DelFlag == "0")
.Where(it => SqlFunc.Subqueryable<SysUserRole>().Where(s => s.UserId == userId).Any())
.OrderBy(role => role.RoleSort)
@@ -46,7 +46,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysRole> SelectRoleAll()
{
return Db.Queryable<SysRole>().OrderBy(it => it.RoleSort).ToList();
return Context.Queryable<SysRole>().OrderBy(it => it.RoleSort).ToList();
}
/// <summary>
@@ -56,7 +56,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysRole SelectRoleById(long roleId)
{
return Db.Queryable<SysRole>().InSingle(roleId);
return Context.Queryable<SysRole>().InSingle(roleId);
}
/// <summary>
@@ -66,7 +66,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteRoleByRoleIds(long[] roleId)
{
return Db.Deleteable<SysRole>().In(roleId).ExecuteCommand();
return Context.Deleteable<SysRole>().In(roleId).ExecuteCommand();
}
/// <summary>
@@ -76,7 +76,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysRole> SelectUserRoleListByUserId(long userId)
{
return Db.Queryable<SysUserRole, SysRole>((ur, r) => new SqlSugar.JoinQueryInfos(
return Context.Queryable<SysUserRole, SysRole>((ur, r) => new SqlSugar.JoinQueryInfos(
SqlSugar.JoinType.Left, ur.RoleId == r.RoleId
)).Where((ur, r) => ur.UserId == userId)
.Select((ur, r) => r).ToList();
@@ -91,7 +91,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysRoleMenu> SelectRoleMenuByRoleId(long roleId)
{
return Db.Queryable<SysRoleMenu>().Where(it => it.Role_id == roleId).ToList();
return Context.Queryable<SysRoleMenu>().Where(it => it.Role_id == roleId).ToList();
}
/// <summary>
@@ -101,7 +101,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int AddRoleMenu(List<SysRoleMenu> sysRoleMenus)
{
return Db.Insertable(sysRoleMenus).ExecuteCommand();
return Context.Insertable(sysRoleMenus).ExecuteCommand();
}
/// <summary>
@@ -111,7 +111,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteRoleMenuByRoleId(long roleId)
{
return Db.Deleteable<SysRoleMenu>().Where(it => it.Role_id == roleId).ExecuteCommand();
return Context.Deleteable<SysRoleMenu>().Where(it => it.Role_id == roleId).ExecuteCommand();
}
#endregion
@@ -123,8 +123,8 @@ namespace ZR.Repository.System
/// <returns></returns>
public long InsertRole(SysRole sysRole)
{
sysRole.Create_time = Db.GetDate();
return Db.Insertable(sysRole).ExecuteReturnBigIdentity();
sysRole.Create_time = Context.GetDate();
return Context.Insertable(sysRole).ExecuteReturnBigIdentity();
}
/// <summary>
@@ -134,7 +134,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int UpdateSysRole(SysRole sysRole)
{
var db = Db;
var db = Context;
sysRole.Update_time = db.GetDate();
return db.Updateable<SysRole>()
@@ -156,7 +156,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int UpdateRoleStatus(SysRole role)
{
return Db.Updateable(role).UpdateColumns(t => new { t.Status }).ExecuteCommand();
return Context.Updateable(role).UpdateColumns(t => new { t.Status }).ExecuteCommand();
}
/// <summary>
@@ -166,7 +166,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysRole CheckRoleKeyUnique(string roleKey)
{
return Db.Queryable<SysRole>().Where(it => it.RoleKey == roleKey).Single();
return Context.Queryable<SysRole>().Where(it => it.RoleKey == roleKey).Single();
}
/// <summary>
@@ -176,7 +176,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysRole CheckRoleNameUnique(string roleName)
{
return Db.Queryable<SysRole>().Where(it => it.RoleName == roleName).Single();
return Context.Queryable<SysRole>().Where(it => it.RoleName == roleName).Single();
}
}
}
@@ -9,7 +9,7 @@ namespace ZR.Repository.System
/// 用户岗位
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysUserPostRepository : BaseRepository
public class SysUserPostRepository : BaseRepository<SysUserPost>
{
/// <summary>
/// 获取用户岗位
@@ -18,7 +18,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysPost> SelectPostsByUserId(long userId)
{
return Db.Queryable<SysPost, SysUserPost>((p, up) => new JoinQueryInfos(
return Context.Queryable<SysPost, SysUserPost>((p, up) => new JoinQueryInfos(
JoinType.Left, up.PostId == p.PostId
)).Where((p, up) => up.UserId == userId)
.Select<SysPost>().ToList();
+10 -10
View File
@@ -10,7 +10,7 @@ namespace ZR.Repository.System
/// 用户管理
/// </summary>
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysUserRepository : BaseRepository
public class SysUserRepository : BaseRepository<SysUser>
{
/// <summary>
/// 根据条件分页查询用户列表
@@ -25,7 +25,7 @@ namespace ZR.Repository.System
left join sys_dept d on u.deptId = d.deptId
WHERE u.delFlag = '0' ";
int totalCount = 0;
var list = Db.SqlQueryable<SysUser>(sql)
var list = Context.SqlQueryable<SysUser>(sql)
.WhereIF(!string.IsNullOrEmpty(user.UserName), it => it.UserName.Contains(user.UserName))
.WhereIF(!string.IsNullOrEmpty(user.Status), it => it.Status == user.Status)
.WhereIF(user.BeginTime != DateTime.MinValue && user.BeginTime != null, it => it.Create_time >= user.BeginTime)
@@ -44,7 +44,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public SysUser SelectUserById(long userId)
{
return Db.Queryable<SysUser>().Where(f => f.UserId == userId).First();
return Context.Queryable<SysUser>().Where(f => f.UserId == userId).First();
}
/// <summary>
@@ -54,7 +54,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int CheckUserNameUnique(string userName)
{
return Db.Queryable<SysUser>().Where(it => it.UserName == userName).Count();
return Context.Queryable<SysUser>().Where(it => it.UserName == userName).Count();
}
/// <summary>
@@ -65,7 +65,7 @@ namespace ZR.Repository.System
public int AddUser(SysUser sysUser)
{
sysUser.Create_time = DateTime.Now;
return Db.Insertable(sysUser).ExecuteReturnIdentity();
return Context.Insertable(sysUser).ExecuteReturnIdentity();
}
/// <summary>
@@ -76,7 +76,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int ResetPwd(long userid, string password)
{
return Db.Updateable(new SysUser() { UserId = userid, Password = password })
return Context.Updateable(new SysUser() { UserId = userid, Password = password })
.UpdateColumns(it => new { it.Password }).ExecuteCommand();
}
@@ -87,7 +87,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int ChangeUserStatus(SysUser user)
{
return Db.Updateable(user).UpdateColumns(t => new { t.Status })
return Context.Updateable(user).UpdateColumns(t => new { t.Status })
.ExecuteCommand();
}
@@ -98,7 +98,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteUser(long userid)
{
return Db.Updateable(new SysUser() { UserId = userid, DelFlag = "2" })
return Context.Updateable(new SysUser() { UserId = userid, DelFlag = "2" })
.UpdateColumns(t => t.DelFlag)
.ExecuteCommand();
}
@@ -110,7 +110,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int UpdateUser(SysUser user)
{
return Db.Updateable(user)
return Context.Updateable(user)
//.SetColumns(t => new SysUser()
//{
// UserName = user.UserName,
@@ -136,7 +136,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int UpdatePhoto(SysUser user)
{
return Db.Updateable<SysUser>()
return Context.Updateable<SysUser>()
.SetColumns(t => new SysUser()
{
Avatar = user.Avatar
@@ -6,7 +6,7 @@ using ZR.Model.System;
namespace ZR.Repository.System
{
[AppService(ServiceLifetime = LifeTime.Transient)]
public class SysUserRoleRepository : BaseRepository
public class SysUserRoleRepository : BaseRepository<SysUserRole>
{
/// <summary>
/// 删除用户角色
@@ -15,7 +15,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteUserRoleByUserId(int userId)
{
return Db.Deleteable<SysUserRole>().Where(it => it.UserId == userId).ExecuteCommand();
return Context.Deleteable<SysUserRole>().Where(it => it.UserId == userId).ExecuteCommand();
}
/// <summary>
@@ -26,7 +26,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteRoleUserByUserIds(long roleId, List<long> userIds)
{
return Db.Deleteable<SysUserRole>().Where(it => it.RoleId == roleId && userIds.Contains(it.UserId))
return Context.Deleteable<SysUserRole>().Where(it => it.RoleId == roleId && userIds.Contains(it.UserId))
.ExecuteCommand();
}
@@ -37,7 +37,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int AddUserRole(List<SysUserRole> sysUsers)
{
return Db.Insertable(sysUsers).ExecuteCommand();
return Context.Insertable(sysUsers).ExecuteCommand();
}
/// <summary>
@@ -47,7 +47,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int DeleteUserRoleByRoleId(int roleId)
{
return Db.Deleteable<SysUserRole>().In(roleId).ExecuteCommand();
return Context.Deleteable<SysUserRole>().In(roleId).ExecuteCommand();
}
/// <summary>
@@ -57,7 +57,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public int CountUserRoleByRoleId(long roleId)
{
return Db.Queryable<SysUserRole>().Where(it => it.RoleId == roleId).Count();
return Context.Queryable<SysUserRole>().Where(it => it.RoleId == roleId).Count();
}
/// <summary>
@@ -67,7 +67,7 @@ namespace ZR.Repository.System
/// <returns></returns>
public List<SysUser> GetSysUsersByRoleId(long roleId)
{
return Db.Queryable<SysUserRole, SysUser>((t1, u) => new JoinQueryInfos(
return Context.Queryable<SysUserRole, SysUser>((t1, u) => new JoinQueryInfos(
JoinType.Left, t1.UserId == u.UserId))
.Where((t1, u) => t1.RoleId == roleId && u.DelFlag == "0")
.Select((t1, u) => u)