优化接口、仓储层
This commit is contained in:
parent
40026f596f
commit
56a04bbf73
@ -22,7 +22,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
return Content(jsonStr, "application/json");
|
return Content(jsonStr, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IActionResult ToRespose(ResultCode resultCode, object data = null)
|
protected IActionResult ToResponse(ResultCode resultCode, object data = null)
|
||||||
{
|
{
|
||||||
string jsonStr = GetJsonStr(GetApiResult(resultCode, data), "");
|
string jsonStr = GetJsonStr(GetApiResult(resultCode, data), "");
|
||||||
return Content(jsonStr, "application/json");
|
return Content(jsonStr, "application/json");
|
||||||
@ -34,13 +34,13 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
/// <param name="apiResult"></param>
|
/// <param name="apiResult"></param>
|
||||||
/// <param name="timeFormatStr"></param>
|
/// <param name="timeFormatStr"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected IActionResult OutputJson(ApiResult apiResult, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
|
protected IActionResult ToResponse(ApiResult apiResult, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
|
||||||
{
|
{
|
||||||
string jsonStr = GetJsonStr(apiResult, timeFormatStr);
|
string jsonStr = GetJsonStr(apiResult, timeFormatStr);
|
||||||
|
|
||||||
return Content(jsonStr, "application/json");
|
return Content(jsonStr, "application/json");
|
||||||
}
|
}
|
||||||
protected IActionResult OutputJson(long rows, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
|
protected IActionResult ToResponse(long rows, string timeFormatStr = "yyyy-MM-dd HH:mm:ss")
|
||||||
{
|
{
|
||||||
string jsonStr = GetJsonStr(ToJson(rows), timeFormatStr);
|
string jsonStr = GetJsonStr(ToJson(rows), timeFormatStr);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
|
|
||||||
protected IActionResult CustomError(ResultCode resultCode, string msg = "")
|
protected IActionResult CustomError(ResultCode resultCode, string msg = "")
|
||||||
{
|
{
|
||||||
return OutputJson(GetApiResult(resultCode, msg));
|
return ToResponse(GetApiResult(resultCode, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -196,7 +196,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ToRespose(ResultCode.FAIL);
|
return ToResponse(ResultCode.FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -147,7 +147,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
{
|
{
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"删除失败Id 不能为空"));
|
return ToResponse(ApiResult.Error($"删除失败Id 不能为空"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除文章
|
// 删除文章
|
||||||
|
|||||||
@ -97,10 +97,10 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(DeptService.CheckDeptNameUnique(dept)))
|
if (UserConstants.NOT_UNIQUE.Equals(DeptService.CheckDeptNameUnique(dept)))
|
||||||
{
|
{
|
||||||
return OutputJson(GetApiResult(ResultCode.CUSTOM_ERROR, $"新增部门{dept.DeptName}失败,部门名称已存在"));
|
return ToResponse(GetApiResult(ResultCode.CUSTOM_ERROR, $"新增部门{dept.DeptName}失败,部门名称已存在"));
|
||||||
}
|
}
|
||||||
dept.Create_by = User.Identity.Name;
|
dept.Create_by = User.Identity.Name;
|
||||||
return OutputJson(ToJson(DeptService.InsertDept(dept)));
|
return ToResponse(ToJson(DeptService.InsertDept(dept)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -115,14 +115,14 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(DeptService.CheckDeptNameUnique(dept)))
|
if (UserConstants.NOT_UNIQUE.Equals(DeptService.CheckDeptNameUnique(dept)))
|
||||||
{
|
{
|
||||||
return OutputJson(GetApiResult(ResultCode.CUSTOM_ERROR, $"修改部门{dept.DeptName}失败,部门名称已存在"));
|
return ToResponse(GetApiResult(ResultCode.CUSTOM_ERROR, $"修改部门{dept.DeptName}失败,部门名称已存在"));
|
||||||
}
|
}
|
||||||
else if (dept.ParentId.Equals(dept.DeptId))
|
else if (dept.ParentId.Equals(dept.DeptId))
|
||||||
{
|
{
|
||||||
return OutputJson(GetApiResult(ResultCode.CUSTOM_ERROR, $"修改部门{dept.DeptName}失败,上级部门不能是自己"));
|
return ToResponse(GetApiResult(ResultCode.CUSTOM_ERROR, $"修改部门{dept.DeptName}失败,上级部门不能是自己"));
|
||||||
}
|
}
|
||||||
dept.Update_by = User.Identity.Name;
|
dept.Update_by = User.Identity.Name;
|
||||||
return OutputJson(ToJson(DeptService.UpdateDept(dept)));
|
return ToResponse(ToJson(DeptService.UpdateDept(dept)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -134,13 +134,13 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[Log(Title = "部门管理", BusinessType = BusinessType.DELETE)]
|
[Log(Title = "部门管理", BusinessType = BusinessType.DELETE)]
|
||||||
public IActionResult Remove(long deptId)
|
public IActionResult Remove(long deptId)
|
||||||
{
|
{
|
||||||
if (DeptService.GetCount(it => it.ParentId == deptId && it.DelFlag == "0") > 0)
|
if (DeptService.Queryable().Count(it => it.ParentId == deptId && it.DelFlag == "0") > 0)
|
||||||
{
|
{
|
||||||
return OutputJson(GetApiResult(ResultCode.CUSTOM_ERROR, $"存在下级部门,不允许删除"));
|
return ToResponse(GetApiResult(ResultCode.CUSTOM_ERROR, $"存在下级部门,不允许删除"));
|
||||||
}
|
}
|
||||||
if (UserService.GetCount(it => it.DeptId == deptId && it.DelFlag == "0") > 0)
|
if (DeptService.Queryable().Count(it => it.DeptId == deptId && it.DelFlag == "0") > 0)
|
||||||
{
|
{
|
||||||
return OutputJson(GetApiResult(ResultCode.CUSTOM_ERROR, $"部门存在用户,不允许删除"));
|
return ToResponse(GetApiResult(ResultCode.CUSTOM_ERROR, $"部门存在用户,不允许删除"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS(DeptService.Delete(deptId));
|
return SUCCESS(DeptService.Delete(deptId));
|
||||||
|
|||||||
@ -51,7 +51,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[ActionPermissionFilter(Permission = "system:dict:query")]
|
[ActionPermissionFilter(Permission = "system:dict:query")]
|
||||||
public IActionResult GetInfo(long dictId = 0)
|
public IActionResult GetInfo(long dictId = 0)
|
||||||
{
|
{
|
||||||
return SUCCESS(SysDictService(f => f.DictId == dictId));
|
return SUCCESS(SysDictService.GetInfo(dictId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -66,7 +66,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(SysDictService.CheckDictTypeUnique(dict)))
|
if (UserConstants.NOT_UNIQUE.Equals(SysDictService.CheckDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"新增字典'{dict.DictName}'失败,字典类型已存在"));
|
return ToResponse(ApiResult.Error($"新增字典'{dict.DictName}'失败,字典类型已存在"));
|
||||||
}
|
}
|
||||||
//设置添加人
|
//设置添加人
|
||||||
dict.Create_by = HttpContext.User.Identity.Name;
|
dict.Create_by = HttpContext.User.Identity.Name;
|
||||||
@ -87,7 +87,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(SysDictService.CheckDictTypeUnique(dict)))
|
if (UserConstants.NOT_UNIQUE.Equals(SysDictService.CheckDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"修改字典'{dict.DictName}'失败,字典类型已存在"));
|
return ToResponse(ApiResult.Error($"修改字典'{dict.DictName}'失败,字典类型已存在"));
|
||||||
}
|
}
|
||||||
//设置添加人
|
//设置添加人
|
||||||
dict.Update_by = HttpContext.User.Identity.Name;
|
dict.Update_by = HttpContext.User.Identity.Name;
|
||||||
|
|||||||
@ -125,7 +125,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
long uid = HttpContext.GetUId();
|
long uid = HttpContext.GetUId();
|
||||||
var menus = sysMenuService.SelectMenuTreeByUserId(uid);
|
var menus = sysMenuService.SelectMenuTreeByUserId(uid);
|
||||||
|
|
||||||
return OutputJson(ToJson(1, sysMenuService.BuildMenus(menus)));
|
return ToResponse(ToJson(1, sysMenuService.BuildMenus(menus)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -94,23 +94,23 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[ActionPermissionFilter(Permission = "system:menu:edit")]
|
[ActionPermissionFilter(Permission = "system:menu:edit")]
|
||||||
public IActionResult MenuEdit([FromBody] SysMenu MenuDto)
|
public IActionResult MenuEdit([FromBody] SysMenu MenuDto)
|
||||||
{
|
{
|
||||||
if (MenuDto == null) { return OutputJson(ApiResult.Error(101, "请求参数错误")); }
|
if (MenuDto == null) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
//if (UserConstants.NOT_UNIQUE.Equals(sysMenuService.CheckMenuNameUnique(MenuDto)))
|
//if (UserConstants.NOT_UNIQUE.Equals(sysMenuService.CheckMenuNameUnique(MenuDto)))
|
||||||
//{
|
//{
|
||||||
// return OutputJson(ApiResult.Error($"修改菜单'{MenuDto.menuName}'失败,菜单名称已存在"));
|
// return ToResponse(ApiResult.Error($"修改菜单'{MenuDto.menuName}'失败,菜单名称已存在"));
|
||||||
//}
|
//}
|
||||||
if (UserConstants.YES_FRAME.Equals(MenuDto.isFrame) && !MenuDto.path.StartsWith("http"))
|
if (UserConstants.YES_FRAME.Equals(MenuDto.isFrame) && !MenuDto.path.StartsWith("http"))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"修改菜单'{MenuDto.menuName}'失败,地址必须以http(s)://开头"));
|
return ToResponse(ApiResult.Error($"修改菜单'{MenuDto.menuName}'失败,地址必须以http(s)://开头"));
|
||||||
}
|
}
|
||||||
if (MenuDto.menuId.Equals(MenuDto.parentId))
|
if (MenuDto.menuId.Equals(MenuDto.parentId))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"修改菜单'{MenuDto.menuName}'失败,上级菜单不能选择自己"));
|
return ToResponse(ApiResult.Error($"修改菜单'{MenuDto.menuName}'失败,上级菜单不能选择自己"));
|
||||||
}
|
}
|
||||||
MenuDto.Update_by = User.Identity.Name;
|
MenuDto.Update_by = User.Identity.Name;
|
||||||
int result = sysMenuService.EditMenu(MenuDto);
|
int result = sysMenuService.EditMenu(MenuDto);
|
||||||
|
|
||||||
return OutputJson(result);
|
return ToResponse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -123,20 +123,20 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[ActionPermissionFilter(Permission = "system:menu:add")]
|
[ActionPermissionFilter(Permission = "system:menu:add")]
|
||||||
public IActionResult MenuAdd([FromBody] SysMenu MenuDto)
|
public IActionResult MenuAdd([FromBody] SysMenu MenuDto)
|
||||||
{
|
{
|
||||||
if (MenuDto == null) { return OutputJson(ApiResult.Error(101, "请求参数错误")); }
|
if (MenuDto == null) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(sysMenuService.CheckMenuNameUnique(MenuDto)))
|
if (UserConstants.NOT_UNIQUE.Equals(sysMenuService.CheckMenuNameUnique(MenuDto)))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"新增菜单'{MenuDto.menuName}'失败,菜单名称已存在"));
|
return ToResponse(ApiResult.Error($"新增菜单'{MenuDto.menuName}'失败,菜单名称已存在"));
|
||||||
}
|
}
|
||||||
if (UserConstants.YES_FRAME.Equals(MenuDto.isFrame) && !MenuDto.path.StartsWith("http"))
|
if (UserConstants.YES_FRAME.Equals(MenuDto.isFrame) && !MenuDto.path.StartsWith("http"))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"新增菜单'{MenuDto.menuName}'失败,地址必须以http(s)://开头"));
|
return ToResponse(ApiResult.Error($"新增菜单'{MenuDto.menuName}'失败,地址必须以http(s)://开头"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuDto.Create_by = User.Identity.Name;
|
MenuDto.Create_by = User.Identity.Name;
|
||||||
int result = sysMenuService.AddMenu(MenuDto);
|
int result = sysMenuService.AddMenu(MenuDto);
|
||||||
|
|
||||||
return OutputJson(result);
|
return ToResponse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -159,7 +159,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
}
|
}
|
||||||
int result = sysMenuService.DeleteMenuById(menuId);
|
int result = sysMenuService.DeleteMenuById(menuId);
|
||||||
|
|
||||||
return OutputJson(result);
|
return ToResponse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -172,10 +172,10 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[Log(Title = "保存排序", BusinessType = BusinessType.UPDATE)]
|
[Log(Title = "保存排序", BusinessType = BusinessType.UPDATE)]
|
||||||
public IActionResult ChangeSort([FromBody] MenuDto MenuDto)
|
public IActionResult ChangeSort([FromBody] MenuDto MenuDto)
|
||||||
{
|
{
|
||||||
if (MenuDto == null) { return OutputJson(ApiResult.Error(101, "请求参数错误")); }
|
if (MenuDto == null) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
|
|
||||||
int result = sysMenuService.ChangeSortMenu(MenuDto);
|
int result = sysMenuService.ChangeSortMenu(MenuDto);
|
||||||
return OutputJson(result);
|
return ToResponse(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
//开始拼装查询条件
|
//开始拼装查询条件
|
||||||
var predicate = Expressionable.Create<SysPost>();
|
var predicate = Expressionable.Create<SysPost>();
|
||||||
predicate = predicate.AndIF(post.Status.IfNotEmpty(), it => it.Status == post.Status);
|
predicate = predicate.AndIF(post.Status.IfNotEmpty(), it => it.Status == post.Status);
|
||||||
var list = PostService.GetPages(predicate.ToExpression(), pagerInfo);
|
var list = PostService.GetPages(predicate.ToExpression(), pagerInfo, s => new { s.PostSort });
|
||||||
|
|
||||||
return SUCCESS(list);
|
return SUCCESS(list);
|
||||||
}
|
}
|
||||||
@ -71,8 +71,9 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在");
|
throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.Update_by = User.Identity.Name;
|
|
||||||
return OutputJson(ToJson(PostService.Add(post)));
|
post.Create_by = User.Identity.Name;
|
||||||
|
return ToResponse(ToJson(PostService.Add(post)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -94,7 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在");
|
throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.Update_by = User.Identity.Name;
|
post.Update_by = User.Identity.Name;
|
||||||
return OutputJson(ToJson(PostService.Update(post)));
|
return ToResponse(ToJson(PostService.Update(post) ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -107,7 +108,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[Log(Title = "岗位删除", BusinessType = BusinessType.DELETE)]
|
[Log(Title = "岗位删除", BusinessType = BusinessType.DELETE)]
|
||||||
public IActionResult Delete(int id = 0)
|
public IActionResult Delete(int id = 0)
|
||||||
{
|
{
|
||||||
return OutputJson(ToJson(PostService.Delete(id)));
|
return ToResponse(ToJson(PostService.Delete(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -84,7 +84,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
user.Update_time = DateTime.Now;
|
user.Update_time = DateTime.Now;
|
||||||
|
|
||||||
int result = UserService.ChangeUser(user);
|
int result = UserService.ChangeUser(user);
|
||||||
return OutputJson(result);
|
return ToResponse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -103,11 +103,11 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
string newMd5 = NETCore.Encrypt.EncryptProvider.Md5(newPassword);
|
string newMd5 = NETCore.Encrypt.EncryptProvider.Md5(newPassword);
|
||||||
if (user.Password != oldMd5)
|
if (user.Password != oldMd5)
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error("修改密码失败,旧密码错误"));
|
return ToResponse(ApiResult.Error("修改密码失败,旧密码错误"));
|
||||||
}
|
}
|
||||||
if (user.Password == newMd5)
|
if (user.Password == newMd5)
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error("新密码不能和旧密码相同"));
|
return ToResponse(ApiResult.Error("新密码不能和旧密码相同"));
|
||||||
}
|
}
|
||||||
if (UserService.ResetPwd(loginUser.UserId, newMd5) > 0)
|
if (UserService.ResetPwd(loginUser.UserId, newMd5) > 0)
|
||||||
{
|
{
|
||||||
@ -116,7 +116,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
return SUCCESS(1);
|
return SUCCESS(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OutputJson(ApiResult.Error("修改密码异常,请联系管理员"));
|
return ToResponse(ApiResult.Error("修改密码异常,请联系管理员"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -69,17 +69,17 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[Route("edit")]
|
[Route("edit")]
|
||||||
public IActionResult RoleAdd([FromBody] SysRole sysRoleDto)
|
public IActionResult RoleAdd([FromBody] SysRole sysRoleDto)
|
||||||
{
|
{
|
||||||
if (sysRoleDto == null) return OutputJson(ApiResult.Error(101, "请求参数错误"));
|
if (sysRoleDto == null) return ToResponse(ApiResult.Error(101, "请求参数错误"));
|
||||||
|
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(sysRoleService.CheckRoleKeyUnique(sysRoleDto)))
|
if (UserConstants.NOT_UNIQUE.Equals(sysRoleService.CheckRoleKeyUnique(sysRoleDto)))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error((int)ResultCode.CUSTOM_ERROR, $"新增角色'{sysRoleDto.RoleName}'失败,角色权限已存在"));
|
return ToResponse(ApiResult.Error((int)ResultCode.CUSTOM_ERROR, $"新增角色'{sysRoleDto.RoleName}'失败,角色权限已存在"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sysRoleDto.Create_by = User.Identity.Name;
|
sysRoleDto.Create_by = User.Identity.Name;
|
||||||
long roleId = sysRoleService.InsertRole(sysRoleDto);
|
long roleId = sysRoleService.InsertRole(sysRoleDto);
|
||||||
|
|
||||||
return OutputJson(ToJson(roleId));
|
return ToResponse(ToJson(roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -95,7 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
if (sysRoleDto == null || sysRoleDto.RoleId <= 0 || string.IsNullOrEmpty(sysRoleDto.RoleKey))
|
if (sysRoleDto == null || sysRoleDto.RoleId <= 0 || string.IsNullOrEmpty(sysRoleDto.RoleKey))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error(101, "请求参数错误"));
|
return ToResponse(ApiResult.Error(101, "请求参数错误"));
|
||||||
}
|
}
|
||||||
sysRoleService.CheckRoleAllowed(sysRoleDto);
|
sysRoleService.CheckRoleAllowed(sysRoleDto);
|
||||||
var info = sysRoleService.SelectRoleById(sysRoleDto.RoleId);
|
var info = sysRoleService.SelectRoleById(sysRoleDto.RoleId);
|
||||||
@ -103,7 +103,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(sysRoleService.CheckRoleKeyUnique(sysRoleDto)))
|
if (UserConstants.NOT_UNIQUE.Equals(sysRoleService.CheckRoleKeyUnique(sysRoleDto)))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"编辑角色'{sysRoleDto.RoleName}'失败,角色权限已存在"));
|
return ToResponse(ApiResult.Error($"编辑角色'{sysRoleDto.RoleName}'失败,角色权限已存在"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
|
|
||||||
return SUCCESS(upResult);
|
return SUCCESS(upResult);
|
||||||
}
|
}
|
||||||
return OutputJson(ApiResult.Error($"修改角色'{sysRoleDto.RoleName}'失败,请联系管理员"));
|
return ToResponse(ApiResult.Error($"修改角色'{sysRoleDto.RoleName}'失败,请联系管理员"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -128,7 +128,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[Log(Title = "角色管理", BusinessType = BusinessType.UPDATE)]
|
[Log(Title = "角色管理", BusinessType = BusinessType.UPDATE)]
|
||||||
public IActionResult DataScope([FromBody] SysRole sysRoleDto)
|
public IActionResult DataScope([FromBody] SysRole sysRoleDto)
|
||||||
{
|
{
|
||||||
if (sysRoleDto == null || sysRoleDto.RoleId <= 0) return OutputJson(ApiResult.Error(101, "请求参数错误"));
|
if (sysRoleDto == null || sysRoleDto.RoleId <= 0) return ToResponse(ApiResult.Error(101, "请求参数错误"));
|
||||||
|
|
||||||
sysRoleDto.Create_by = HttpContextExtension.GetName(HttpContext);
|
sysRoleDto.Create_by = HttpContextExtension.GetName(HttpContext);
|
||||||
//删除角色菜单
|
//删除角色菜单
|
||||||
@ -151,7 +151,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
long[] roleIds = Tools.SpitLongArrary(roleId);
|
long[] roleIds = Tools.SpitLongArrary(roleId);
|
||||||
int result = sysRoleService.DeleteRoleByRoleId(roleIds);
|
int result = sysRoleService.DeleteRoleByRoleId(roleIds);
|
||||||
|
|
||||||
return OutputJson(ToJson(result));
|
return ToResponse(ToJson(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -166,7 +166,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
{
|
{
|
||||||
int result = sysRoleService.UpdateRoleStatus(roleDto);
|
int result = sysRoleService.UpdateRoleStatus(roleDto);
|
||||||
|
|
||||||
return OutputJson(ToJson(result));
|
return ToResponse(ToJson(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
dic.Add("roleIds", RoleService.SelectUserRoles(userId));
|
dic.Add("roleIds", RoleService.SelectUserRoles(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return OutputJson(ApiResult.Success(dic));
|
return ToResponse(ApiResult.Success(dic));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -88,16 +88,16 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[ActionPermissionFilter(Permission = "system:user:add")]
|
[ActionPermissionFilter(Permission = "system:user:add")]
|
||||||
public IActionResult AddUser([FromBody] SysUser user)
|
public IActionResult AddUser([FromBody] SysUser user)
|
||||||
{
|
{
|
||||||
if (user == null) { return OutputJson(ApiResult.Error(101, "请求参数错误")); }
|
if (user == null) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
if (UserConstants.NOT_UNIQUE.Equals(UserService.CheckUserNameUnique(user.UserName)))
|
if (UserConstants.NOT_UNIQUE.Equals(UserService.CheckUserNameUnique(user.UserName)))
|
||||||
{
|
{
|
||||||
return OutputJson(ApiResult.Error($"新增用户 '{user.UserName}'失败,登录账号已存在"));
|
return ToResponse(ApiResult.Error($"新增用户 '{user.UserName}'失败,登录账号已存在"));
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Create_by = User.Identity.Name;
|
user.Create_by = User.Identity.Name;
|
||||||
user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
|
user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
|
||||||
|
|
||||||
return OutputJson(UserService.InsertUser(user));
|
return ToResponse(UserService.InsertUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -110,12 +110,12 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[ActionPermissionFilter(Permission = "system:user:edit")]
|
[ActionPermissionFilter(Permission = "system:user:edit")]
|
||||||
public IActionResult UpdateUser([FromBody] SysUser user)
|
public IActionResult UpdateUser([FromBody] SysUser user)
|
||||||
{
|
{
|
||||||
if (user == null || user.UserId <= 0) { return OutputJson(ApiResult.Error(101, "请求参数错误")); }
|
if (user == null || user.UserId <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
|
|
||||||
user.Update_by = User.Identity.Name;
|
user.Update_by = User.Identity.Name;
|
||||||
int upResult = UserService.UpdateUser(user);
|
int upResult = UserService.UpdateUser(user);
|
||||||
|
|
||||||
return OutputJson(upResult);
|
return ToResponse(upResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -128,10 +128,10 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[ActionPermissionFilter(Permission = "system:user:update")]
|
[ActionPermissionFilter(Permission = "system:user:update")]
|
||||||
public IActionResult ChangeStatus([FromBody] SysUser user)
|
public IActionResult ChangeStatus([FromBody] SysUser user)
|
||||||
{
|
{
|
||||||
if (user == null) { return OutputJson(ApiResult.Error(101, "请求参数错误")); }
|
if (user == null) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
|
|
||||||
int result = UserService.ChangeUserStatus(user);
|
int result = UserService.ChangeUserStatus(user);
|
||||||
return OutputJson(ToJson(result));
|
return ToResponse(ToJson(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -144,11 +144,11 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
[ActionPermissionFilter(Permission = "system:user:remove")]
|
[ActionPermissionFilter(Permission = "system:user:remove")]
|
||||||
public IActionResult Remove(int userid = 0)
|
public IActionResult Remove(int userid = 0)
|
||||||
{
|
{
|
||||||
if (userid <= 0) { return OutputJson(ApiResult.Error(101, "请求参数错误")); }
|
if (userid <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
|
|
||||||
int result = UserService.DeleteUser(userid);
|
int result = UserService.DeleteUser(userid);
|
||||||
|
|
||||||
return OutputJson(ToJson(result));
|
return ToResponse(ToJson(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -164,7 +164,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
sysUser.Password = NETCore.Encrypt.EncryptProvider.Md5(sysUser.Password);
|
sysUser.Password = NETCore.Encrypt.EncryptProvider.Md5(sysUser.Password);
|
||||||
|
|
||||||
int result = UserService.ResetPwd(sysUser.UserId, sysUser.Password);
|
int result = UserService.ResetPwd(sysUser.UserId, sysUser.Password);
|
||||||
return OutputJson(ToJson(result));
|
return ToResponse(ToJson(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -142,7 +142,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
Update_by = User.Identity.Name,
|
Update_by = User.Identity.Name,
|
||||||
Update_time = DateTime.Now
|
Update_time = DateTime.Now
|
||||||
});
|
});
|
||||||
if (response > 0)
|
if (response)
|
||||||
{
|
{
|
||||||
//先暂停原先的任务
|
//先暂停原先的任务
|
||||||
var respon = await _schedulerServer.UpdateTaskScheduleAsync(tasksQz, tasksQz.JobGroup);
|
var respon = await _schedulerServer.UpdateTaskScheduleAsync(tasksQz, tasksQz.JobGroup);
|
||||||
@ -177,7 +177,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
{
|
{
|
||||||
_tasksQzService.Delete(id);
|
_tasksQzService.Delete(id);
|
||||||
}
|
}
|
||||||
return OutputJson(taskResult);
|
return ToResponse(taskResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -208,7 +208,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
_tasksQzService.Update(tasksQz);
|
_tasksQzService.Update(tasksQz);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OutputJson(taskResult);
|
return ToResponse(taskResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -239,7 +239,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
_tasksQzService.Update(tasksQz);
|
_tasksQzService.Update(tasksQz);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OutputJson(taskResult);
|
return ToResponse(taskResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -264,7 +264,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
//_tasksQzService.Update(tasksQz);
|
//_tasksQzService.Update(tasksQz);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OutputJson(taskResult);
|
return ToResponse(taskResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
|
|
||||||
int result = tasksLogService.Delete(jobIdArr);
|
int result = tasksLogService.Delete(jobIdArr);
|
||||||
|
|
||||||
return OutputJson(ToJson(result, result));
|
return ToResponse(ToJson(result, result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
|||||||
var list = sysLoginService.GetLoginLog(sysLogininfoDto, pagerInfo);
|
var list = sysLoginService.GetLoginLog(sysLogininfoDto, pagerInfo);
|
||||||
var vMPage = new VMPageResult<SysLogininfor>(list, pagerInfo);
|
var vMPage = new VMPageResult<SysLogininfor>(list, pagerInfo);
|
||||||
|
|
||||||
return OutputJson(ToJson(vMPage.TotalNum, vMPage), TIME_FORMAT_FULL_2);
|
return ToResponse(ToJson(vMPage.TotalNum, vMPage), TIME_FORMAT_FULL_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
|||||||
var list = sysOperLogService.SelectOperLogList(sysOperLog, pagerInfo);
|
var list = sysOperLogService.SelectOperLogList(sysOperLog, pagerInfo);
|
||||||
var vMPage = new VMPageResult<SysOperLog>(list, pagerInfo);
|
var vMPage = new VMPageResult<SysOperLog>(list, pagerInfo);
|
||||||
|
|
||||||
return OutputJson(ToJson(vMPage.TotalNum, vMPage), TIME_FORMAT_FULL_2);
|
return ToResponse(ToJson(vMPage.TotalNum, vMPage), TIME_FORMAT_FULL_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
string accessPath = $"{OptionsSetting.Upload.UploadUrl}/{finalFilePath.Replace("wwwroot", "").Replace("\\", "/")}";
|
string accessPath = $"{OptionsSetting.Upload.UploadUrl}/{finalFilePath.Replace("wwwroot", "").Replace("\\", "/")}";
|
||||||
return OutputJson(ToJson(1, accessPath));
|
return ToResponse(ToJson(1, accessPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
public IActionResult DeleteGendemo(string ids)
|
public IActionResult DeleteGendemo(string ids)
|
||||||
{
|
{
|
||||||
int[] idsArr = Tools.SpitIntArrary(ids);
|
int[] idsArr = Tools.SpitIntArrary(ids);
|
||||||
if (idsArr.Length <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||||
|
|
||||||
var response = _GendemoService.Delete(idsArr);
|
var response = _GendemoService.Delete(idsArr);
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ namespace ZR.Admin.WebApi.Extensions
|
|||||||
//var _tasksQzService2 = (ISysTasksQzService)services.GetRequiredService(typeof(SysTasksQzService));
|
//var _tasksQzService2 = (ISysTasksQzService)services.GetRequiredService(typeof(SysTasksQzService));
|
||||||
ITaskSchedulerServer _schedulerServer = App.GetRequiredService<ITaskSchedulerServer>();
|
ITaskSchedulerServer _schedulerServer = App.GetRequiredService<ITaskSchedulerServer>();
|
||||||
|
|
||||||
var tasks = _tasksQzService.GetWhere(m => m.IsStart);
|
var tasks = _tasksQzService.QueryableToList(m => m.IsStart);
|
||||||
|
|
||||||
//程序启动后注册所有定时任务
|
//程序启动后注册所有定时任务
|
||||||
foreach (var task in tasks)
|
foreach (var task in tasks)
|
||||||
|
|||||||
@ -127,7 +127,7 @@ namespace {ApiControllerNamespace}.Controllers
|
|||||||
public IActionResult Delete{ModelName}(string ids)
|
public IActionResult Delete{ModelName}(string ids)
|
||||||
{
|
{
|
||||||
int[] idsArr = Tools.SpitIntArrary(ids);
|
int[] idsArr = Tools.SpitIntArrary(ids);
|
||||||
if (idsArr.Length <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||||
|
|
||||||
var response = _{ModelName}Service.Delete(idsArr);
|
var response = _{ModelName}Service.Delete(idsArr);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
|
using Infrastructure.Model;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -6,6 +7,7 @@ using System.Dynamic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ZR.Model;
|
||||||
|
|
||||||
namespace ZR.Repository
|
namespace ZR.Repository
|
||||||
{
|
{
|
||||||
@ -58,28 +60,41 @@ namespace ZR.Repository
|
|||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
};
|
};
|
||||||
|
|
||||||
base.Context = Db.GetConnection(configId);//根据类传入的ConfigId自动选择
|
Context = Db.GetConnection(configId);//根据类传入的ConfigId自动选择
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region add
|
#region add
|
||||||
|
/// <summary>
|
||||||
|
/// 插入指定列使用
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <param name="iClumns"></param>
|
||||||
|
/// <param name="ignoreNull"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
public int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||||
{
|
{
|
||||||
return base.Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand();
|
return Context.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand();
|
||||||
}
|
}
|
||||||
public int Insert(T t, bool IgnoreNullColumn = true)
|
/// <summary>
|
||||||
|
/// 插入实体
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="t"></param>
|
||||||
|
/// <param name="IgnoreNullColumn">默认忽略null列</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Add(T t)
|
||||||
{
|
{
|
||||||
return base.Context.Insertable(t).IgnoreColumns(IgnoreNullColumn).ExecuteCommand();
|
return Context.Insertable(t).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int InsertIgnoreNullColumn(T t)
|
public int InsertIgnoreNullColumn(T t)
|
||||||
{
|
{
|
||||||
return base.Context.Insertable(t).IgnoreColumns(true).ExecuteCommand();
|
return Context.Insertable(t).IgnoreColumns(true).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int InsertIgnoreNullColumn(T t, params string[] columns)
|
public int InsertIgnoreNullColumn(T t, params string[] columns)
|
||||||
{
|
{
|
||||||
return base.Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand();
|
return Context.Insertable(t).IgnoreColumns(columns).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public int Insert(SqlSugarClient client, T t)
|
//public int Insert(SqlSugarClient client, T t)
|
||||||
@ -237,9 +252,9 @@ namespace ZR.Repository
|
|||||||
|
|
||||||
#region delete
|
#region delete
|
||||||
|
|
||||||
public bool Delete(Expression<Func<T, bool>> expression)
|
public bool DeleteExp(Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
return base.Context.Deleteable<T>().Where(expression).ExecuteCommand() > 0;
|
return Context.Deleteable<T>().Where(expression).ExecuteCommand() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public bool Delete<PkType>(PkType[] primaryKeyValues)
|
//public bool Delete<PkType>(PkType[] primaryKeyValues)
|
||||||
@ -247,47 +262,46 @@ namespace ZR.Repository
|
|||||||
// return base.Context.Deleteable<T>().In(primaryKeyValues).ExecuteCommand() > 0;
|
// return base.Context.Deleteable<T>().In(primaryKeyValues).ExecuteCommand() > 0;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public bool Delete(object[] obj)
|
public int Delete(object[] obj)
|
||||||
{
|
{
|
||||||
return base.Context.Deleteable<T>().In(obj).ExecuteCommand() > 0;
|
return Context.Deleteable<T>().In(obj).ExecuteCommand();
|
||||||
}
|
}
|
||||||
public bool Delete(object id)
|
public int Delete(object id)
|
||||||
{
|
{
|
||||||
return base.Context.Deleteable<T>(id).ExecuteCommand() > 0;
|
return Context.Deleteable<T>(id).ExecuteCommand();
|
||||||
}
|
}
|
||||||
public bool Delete()
|
public bool DeleteTable()
|
||||||
{
|
{
|
||||||
return base.Context.Deleteable<T>().ExecuteCommand() > 0;
|
return Context.Deleteable<T>().ExecuteCommand() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion delete
|
#endregion delete
|
||||||
|
|
||||||
#region query
|
#region query
|
||||||
|
|
||||||
public bool IsAny(Expression<Func<T, bool>> expression)
|
public bool Any(Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
//base.Context.Queryable<T>().Any();
|
return Context.Queryable<T>().Where(expression).Any();
|
||||||
return base.Context.Queryable<T>().Where(expression).Any();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISugarQueryable<T> Queryable()
|
public ISugarQueryable<T> Queryable()
|
||||||
{
|
{
|
||||||
return base.Context.Queryable<T>();
|
return Context.Queryable<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName)
|
public ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName)
|
||||||
{
|
{
|
||||||
return base.Context.Queryable(tableName, shortName);
|
return Context.Queryable(tableName, shortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> QueryableToList(Expression<Func<T, bool>> expression)
|
public List<T> QueryableToList(Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
return base.Context.Queryable<T>().Where(expression).ToList();
|
return Context.Queryable<T>().Where(expression).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression)
|
public Task<List<T>> QueryableToListAsync(Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
return base.Context.Queryable<T>().Where(expression).ToListAsync();
|
return Context.Queryable<T>().Where(expression).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||||
@ -296,32 +310,27 @@ namespace ZR.Repository
|
|||||||
// return query.JilToJson();
|
// return query.JilToJson();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public T QueryableToEntity(Expression<Func<T, bool>> expression)
|
|
||||||
{
|
|
||||||
return base.Context.Queryable<T>().Where(expression).First();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<T> QueryableToList(string tableName)
|
public List<T> QueryableToList(string tableName)
|
||||||
{
|
{
|
||||||
return base.Context.Queryable<T>(tableName).ToList();
|
return Context.Queryable<T>(tableName).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> QueryableToList(string tableName, Expression<Func<T, bool>> expression)
|
public List<T> QueryableToList(string tableName, Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
return base.Context.Queryable<T>(tableName).Where(expression).ToList();
|
return Context.Queryable<T>(tableName).Where(expression).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10)
|
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10)
|
||||||
{
|
{
|
||||||
int totalNumber = 0;
|
int totalNumber = 0;
|
||||||
var list = base.Context.Queryable<T>().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber);
|
var list = Context.Queryable<T>().Where(expression).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||||
return (list, totalNumber);
|
return (list, totalNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10)
|
public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, string order, int pageIndex = 0, int pageSize = 10)
|
||||||
{
|
{
|
||||||
int totalNumber = 0;
|
int totalNumber = 0;
|
||||||
var list = base.Context.Queryable<T>().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber);
|
var list = Context.Queryable<T>().Where(expression).OrderBy(order).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||||
return (list, totalNumber);
|
return (list, totalNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,38 +340,19 @@ namespace ZR.Repository
|
|||||||
|
|
||||||
if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase))
|
if (orderBy.Equals("DESC", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var list = base.Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||||
return (list, totalNumber);
|
return (list, totalNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var list = base.Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
var list = Context.Queryable<T>().Where(expression).OrderBy(orderFiled, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||||
return (list, totalNumber);
|
return (list, totalNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public (List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, Bootstrap.BootstrapParams bootstrap)
|
|
||||||
//{
|
|
||||||
// int totalNumber = 0;
|
|
||||||
// if (bootstrap.offset != 0)
|
|
||||||
// {
|
|
||||||
// bootstrap.offset = bootstrap.offset / bootstrap.limit + 1;
|
|
||||||
// }
|
|
||||||
// if (bootstrap.order.Equals("DESC", StringComparison.OrdinalIgnoreCase))
|
|
||||||
// {
|
|
||||||
// var list = base.Context.Queryable<T>().Where(expression).OrderBy(bootstrap.sort).ToPageList(bootstrap.offset, bootstrap.limit, ref totalNumber);
|
|
||||||
// return (list, totalNumber);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// var list = base.Context.Queryable<T>().Where(expression).OrderBy(bootstrap.sort).ToPageList(bootstrap.offset, bootstrap.limit, ref totalNumber);
|
|
||||||
// return (list, totalNumber);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public List<T> SqlQueryToList(string sql, object obj = null)
|
public List<T> SqlQueryToList(string sql, object obj = null)
|
||||||
{
|
{
|
||||||
return base.Context.Ado.SqlQuery<T>(sql, obj);
|
return Context.Ado.SqlQuery<T>(sql, obj);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得一条数据
|
/// 获得一条数据
|
||||||
@ -383,15 +373,32 @@ namespace ZR.Repository
|
|||||||
{
|
{
|
||||||
return Context.Queryable<T>().InSingle(pkValue);
|
return Context.Queryable<T>().InSingle(pkValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得一条数据
|
/// 根据条件查询分页数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm">string</param>
|
/// <param name="where"></param>
|
||||||
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T GetFirst(string parm)
|
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm)
|
||||||
{
|
{
|
||||||
return Context.Queryable<T>().Where(parm).First();
|
var source = Context.Queryable<T>().Where(where);
|
||||||
|
|
||||||
|
return source.ToPage(parm);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc")
|
||||||
|
{
|
||||||
|
var source = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc);
|
||||||
|
|
||||||
|
return source.ToPage(parm);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查询所有数据(无分页,请慎用)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
|
||||||
|
{
|
||||||
|
return Context.Queryable<T>().WithCacheIF(useCache, cacheSecond).ToList();
|
||||||
}
|
}
|
||||||
#endregion query
|
#endregion query
|
||||||
|
|
||||||
@ -423,9 +430,33 @@ namespace ZR.Repository
|
|||||||
// return result;
|
// return result;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
//public string QueryableToJson(string select, Expression<Func<T, bool>> expressionWhere)
|
||||||
|
//{
|
||||||
|
// throw new NotImplementedException();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class QueryableExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 读取列表
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static PagedInfo<T> ToPage<T>(this ISugarQueryable<T> source, PagerInfo parm)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var page = new PagedInfo<T>();
|
||||||
|
var total = source.Count();
|
||||||
|
page.TotalCount = total;
|
||||||
|
page.PageSize = parm.PageSize;
|
||||||
|
page.PageIndex = parm.PageNum;
|
||||||
|
|
||||||
|
//page.DataSource = source.OrderByIF(!string.IsNullOrEmpty(parm.Sort), $"{parm.OrderBy} {(parm.Sort == "descending" ? "desc" : "asc")}").ToPageList(parm.PageNum, parm.PageSize);
|
||||||
|
page.Result = source.ToPageList(parm.PageNum, parm.PageSize);
|
||||||
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,50 +0,0 @@
|
|||||||
using Infrastructure;
|
|
||||||
using SqlSugar;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace ZR.Repository.DbProvider
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// SqlSugar ORM
|
|
||||||
/// </summary>
|
|
||||||
public class SugarDbContext
|
|
||||||
{
|
|
||||||
public SqlSugarClient Db; //用来处理事务多表查询和复杂的操作
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 使用SugarSql获取连接对象
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public SugarDbContext()
|
|
||||||
{
|
|
||||||
string connStr = ConfigUtils.Instance.GetConnectionStrings(OptionsSetting.ConnAdmin);
|
|
||||||
int dbType = ConfigUtils.Instance.GetAppConfig<int>(OptionsSetting.ConnDbType);
|
|
||||||
|
|
||||||
Db = new SqlSugarClient(new List<ConnectionConfig>()
|
|
||||||
{
|
|
||||||
new ConnectionConfig(){
|
|
||||||
ConnectionString = connStr,
|
|
||||||
DbType = (DbType)dbType,
|
|
||||||
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样
|
|
||||||
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
|
|
||||||
ConfigId = 0
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
////调式代码 用来打印SQL
|
|
||||||
//Db.Aop.OnLogExecuting = (sql, pars) =>
|
|
||||||
//{
|
|
||||||
// Console.BackgroundColor = ConsoleColor.Yellow;
|
|
||||||
// Console.WriteLine("【SQL语句】" + sql.ToLower() + "\r\n" + Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
|
||||||
//};
|
|
||||||
////出错打印日志
|
|
||||||
//Db.Aop.OnError = (e) =>
|
|
||||||
//{
|
|
||||||
// Console.WriteLine($"[执行Sql出错]{e.Message},SQL={e.Sql}");
|
|
||||||
// Console.WriteLine();
|
|
||||||
//};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using SqlSugar;
|
using Infrastructure.Model;
|
||||||
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -7,6 +8,7 @@ using System.Linq;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ZR.Model;
|
||||||
|
|
||||||
namespace ZR.Repository
|
namespace ZR.Repository
|
||||||
{
|
{
|
||||||
@ -14,7 +16,7 @@ namespace ZR.Repository
|
|||||||
{
|
{
|
||||||
#region add
|
#region add
|
||||||
int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
|
||||||
int Insert(T t, bool IgnoreNullColumn = true);
|
int Add(T t);
|
||||||
|
|
||||||
int InsertIgnoreNullColumn(T t);
|
int InsertIgnoreNullColumn(T t);
|
||||||
|
|
||||||
@ -87,21 +89,30 @@ namespace ZR.Repository
|
|||||||
|
|
||||||
#region delete
|
#region delete
|
||||||
|
|
||||||
bool Delete(Expression<Func<T, bool>> expression);
|
bool DeleteExp(Expression<Func<T, bool>> expression);
|
||||||
|
|
||||||
//bool Delete<PkType>(PkType[] primaryKeyValues);
|
//bool Delete<PkType>(PkType[] primaryKeyValues);
|
||||||
|
int Delete(object[] obj);
|
||||||
bool Delete(object[] obj);
|
int Delete(object id);
|
||||||
bool Delete(object id);
|
bool DeleteTable();
|
||||||
bool Delete();
|
|
||||||
|
|
||||||
#endregion delete
|
#endregion delete
|
||||||
|
|
||||||
#region query
|
#region query
|
||||||
|
/// <summary>
|
||||||
|
/// 根据条件查询分页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="where"></param>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm);
|
||||||
|
|
||||||
bool IsAny(Expression<Func<T, bool>> expression);
|
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc");
|
||||||
|
|
||||||
|
bool Any(Expression<Func<T, bool>> expression);
|
||||||
|
|
||||||
ISugarQueryable<T> Queryable();
|
ISugarQueryable<T> Queryable();
|
||||||
|
List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
|
||||||
|
|
||||||
//ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
|
//ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
|
||||||
|
|
||||||
@ -115,8 +126,6 @@ namespace ZR.Repository
|
|||||||
|
|
||||||
List<T> QueryableToList(string tableName);
|
List<T> QueryableToList(string tableName);
|
||||||
|
|
||||||
T QueryableToEntity(Expression<Func<T, bool>> expression);
|
|
||||||
|
|
||||||
List<T> QueryableToList(string tableName, Expression<Func<T, bool>> expression);
|
List<T> QueryableToList(string tableName, Expression<Func<T, bool>> expression);
|
||||||
|
|
||||||
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
|
(List<T>, int) QueryableToPage(Expression<Func<T, bool>> expression, int pageIndex = 0, int pageSize = 10);
|
||||||
@ -141,7 +150,7 @@ namespace ZR.Repository
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm">string</param>
|
/// <param name="parm">string</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
T GetFirst(string parm);
|
//T GetFirst(string parm);
|
||||||
|
|
||||||
#endregion query
|
#endregion query
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
using AspectCore.DynamicProxy;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ZR.Repository.DbProvider;
|
|
||||||
|
|
||||||
namespace ZR.Repository.Interceptor
|
|
||||||
{
|
|
||||||
|
|
||||||
public class SqlLogInterceptorAttribute : AbstractInterceptorAttribute
|
|
||||||
{
|
|
||||||
public override Task Invoke(AspectContext context, AspectDelegate next)
|
|
||||||
{
|
|
||||||
global::System.Console.WriteLine("");
|
|
||||||
return next(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
using Infrastructure.Attribute;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using ZR.Repository.DbProvider;
|
|
||||||
|
|
||||||
namespace ZR.Repository.System
|
|
||||||
{
|
|
||||||
public class BaseRepository : SugarDbContext
|
|
||||||
{
|
|
||||||
protected void PrintLog()
|
|
||||||
{
|
|
||||||
//调式代码 用来打印SQL
|
|
||||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
|
||||||
{
|
|
||||||
Console.WriteLine("【SQL语句】" + sql.ToLower() + "\r\n" + Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Infrastructure.Attribute;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -7,11 +8,12 @@ using ZR.Model.System.Generate;
|
|||||||
|
|
||||||
namespace ZR.Repository.System
|
namespace ZR.Repository.System
|
||||||
{
|
{
|
||||||
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
public class GenTableRepository : BaseRepository<GenTable>
|
public class GenTableRepository : BaseRepository<GenTable>
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
public class GenTableColumnRepository : BaseRepository<GenTableColumn>
|
public class GenTableColumnRepository : BaseRepository<GenTableColumn>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -44,8 +44,7 @@ namespace ZR.Repository.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public long InsertDictData(SysDictData dict)
|
public long InsertDictData(SysDictData dict)
|
||||||
{
|
{
|
||||||
var result = Context.Insertable(dict).IgnoreColumns(it => new { dict.Update_by })
|
var result = InsertReturnBigIdentity(dict);
|
||||||
.ExecuteReturnIdentity();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ namespace ZR.Repository.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int DeleteDictDataByIds(long[] dictCodes)
|
public int DeleteDictDataByIds(long[] dictCodes)
|
||||||
{
|
{
|
||||||
return Context.Deleteable<SysDictData>().In(dictCodes).ExecuteCommand();
|
return Delete(dictCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Infrastructure.Attribute;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -7,6 +8,7 @@ using ZR.Model.System;
|
|||||||
|
|
||||||
namespace ZR.Repository.System
|
namespace ZR.Repository.System
|
||||||
{
|
{
|
||||||
|
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysPostRepository : BaseRepository<SysPost>
|
public class SysPostRepository : BaseRepository<SysPost>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,4 @@
|
|||||||
using Infrastructure.Attribute;
|
using ZR.Repository;
|
||||||
using Infrastructure.Model;
|
|
||||||
using SqlSugar;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using ZR.Model;
|
|
||||||
using ZR.Repository;
|
|
||||||
using ZR.Repository.DbProvider;
|
|
||||||
|
|
||||||
namespace ZR.Service
|
namespace ZR.Service
|
||||||
{
|
{
|
||||||
@ -14,318 +6,284 @@ namespace ZR.Service
|
|||||||
/// 基础服务定义
|
/// 基础服务定义
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public class BaseService<T> : BaseRepository<T> where T : class,new()//, IBaseService<T> where T : class, new()
|
public class BaseService<T> : BaseRepository<T>, IBaseService<T> where T : class, new()
|
||||||
{
|
{
|
||||||
//private readonly IBaseRepository<T> BaseRepository;
|
//#region 添加操作
|
||||||
//public BaseService(IBaseRepository<T> baseRepository)
|
|
||||||
//{
|
|
||||||
// BaseRepository = baseRepository;
|
|
||||||
//}
|
|
||||||
|
|
||||||
#region 事务
|
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 启用事务
|
///// 添加一条数据
|
||||||
///// </summary>
|
///// </summary>
|
||||||
//public void BeginTran()
|
///// <param name="parm">T</param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public int Add(T parm)
|
||||||
//{
|
//{
|
||||||
// Context.Ado.BeginTran();
|
// return Add(parm);// Context.Insertable(parm).RemoveDataCache().ExecuteCommand();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 提交事务
|
///// 添加
|
||||||
///// </summary>
|
///// </summary>
|
||||||
//public void CommitTran()
|
///// <param name="parm"></param>
|
||||||
//{
|
///// <param name="iClumns">插入列</param>
|
||||||
// Context.Ado.CommitTran();
|
///// <param name="ignoreNull">忽略null列</param>
|
||||||
//}
|
///// <returns></returns>
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 回滚事务
|
|
||||||
///// </summary>
|
|
||||||
//public void RollbackTran()
|
|
||||||
//{
|
|
||||||
// Context.Ado.RollbackTran();
|
|
||||||
//}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 添加操作
|
|
||||||
/// <summary>
|
|
||||||
/// 添加一条数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm">T</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int Add(T parm)
|
|
||||||
{
|
|
||||||
return base.Add(parm);// Context.Insertable(parm).RemoveDataCache().ExecuteCommand();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm"></param>
|
|
||||||
/// <param name="iClumns">插入列</param>
|
|
||||||
/// <param name="ignoreNull">忽略null列</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
//public int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
//public int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
|
||||||
//{
|
//{
|
||||||
// return Add(parm);
|
// return Add(parm);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 批量添加数据
|
///// 批量添加数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">List<T></param>
|
///// <param name="parm">List<T></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
public int Add(List<T> parm)
|
//public int Add(List<T> parm)
|
||||||
{
|
//{
|
||||||
return Context.Insertable(parm).RemoveDataCache().ExecuteCommand();
|
// return 1;// Context.Insertable(parm).RemoveDataCache().ExecuteCommand();
|
||||||
}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 添加或更新数据,不推荐使用了
|
///// 添加或更新数据,不推荐使用了
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">List<T></param>
|
///// <param name="parm">List<T></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
public T Saveable(T parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null)
|
//public T Saveable(T parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null)
|
||||||
{
|
//{
|
||||||
var command = Context.Saveable(parm);
|
// var command = Context.Saveable(parm);
|
||||||
|
|
||||||
if (uClumns != null)
|
// if (uClumns != null)
|
||||||
{
|
// {
|
||||||
command = command.UpdateIgnoreColumns(uClumns);
|
// command = command.UpdateIgnoreColumns(uClumns);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (iColumns != null)
|
// if (iColumns != null)
|
||||||
{
|
// {
|
||||||
command = command.InsertIgnoreColumns(iColumns);
|
// command = command.InsertIgnoreColumns(iColumns);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return command.ExecuteReturnEntity();
|
// return command.ExecuteReturnEntity();
|
||||||
}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 批量添加或更新数据
|
///// 批量添加或更新数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">List<T></param>
|
///// <param name="parm">List<T></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
public List<T> Saveable(List<T> parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null)
|
//public List<T> Saveable(List<T> parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null)
|
||||||
{
|
//{
|
||||||
var command = Context.Saveable(parm);
|
// var command = Context.Saveable(parm);
|
||||||
|
|
||||||
if (uClumns != null)
|
// if (uClumns != null)
|
||||||
{
|
// {
|
||||||
command = command.UpdateIgnoreColumns(uClumns);
|
// command = command.UpdateIgnoreColumns(uClumns);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (iColumns != null)
|
// if (iColumns != null)
|
||||||
{
|
// {
|
||||||
command = command.InsertIgnoreColumns(iColumns);
|
// command = command.InsertIgnoreColumns(iColumns);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return command.ExecuteReturnList();
|
// return command.ExecuteReturnList();
|
||||||
}
|
//}
|
||||||
#endregion
|
//#endregion
|
||||||
|
|
||||||
#region 查询操作
|
//#region 查询操作
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件查询数据是否存在
|
///// 根据条件查询数据是否存在
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
///// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
//public bool Any(Expression<Func<T, bool>> where)
|
//public bool Any(Expression<Func<T, bool>> where)
|
||||||
//{
|
//{
|
||||||
// return base.Context.Any(where);
|
// return true;// base.Context.Any(where);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件合计字段
|
///// 根据条件合计字段
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
///// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
public TResult Sum<TResult>(Expression<Func<T, bool>> where, Expression<Func<T, TResult>> field)
|
//public TResult Sum<TResult>(Expression<Func<T, bool>> where, Expression<Func<T, TResult>> field)
|
||||||
{
|
|
||||||
return base.Context.Queryable<T>().Where(where).Sum(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据主值查询单条数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pkValue">主键值</param>
|
|
||||||
/// <returns>泛型实体</returns>
|
|
||||||
//public T GetId(object pkValue)
|
|
||||||
//{
|
//{
|
||||||
// return base.Context.Queryable<T>().InSingle(pkValue);
|
// return base.Context.Queryable<T>().Where(where).Sum(field);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据主键查询多条数据
|
///// 根据主值查询单条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="ids"></param>
|
///// <param name="pkValue">主键值</param>
|
||||||
/// <returns></returns>
|
///// <returns>泛型实体</returns>
|
||||||
public List<T> GetIn(object[] ids)
|
////public T GetId(object pkValue)
|
||||||
{
|
////{
|
||||||
return Context.Queryable<T>().In(ids).ToList();
|
//// return base.Context.Queryable<T>().InSingle(pkValue);
|
||||||
}
|
////}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件取条数
|
///// 根据主键查询多条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
///// <param name="ids"></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
public int GetCount(Expression<Func<T, bool>> where)
|
//public List<T> GetIn(object[] ids)
|
||||||
{
|
|
||||||
return Context.Queryable<T>().Count(where);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询所有数据(无分页,请慎用)
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
|
|
||||||
{
|
|
||||||
return Context.Queryable<T>().WithCacheIF(useCache, cacheSecond).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获得一条数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="where">Expression<Func<T, bool>></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T GetFirst2(Expression<Func<T, bool>> where)
|
|
||||||
{
|
|
||||||
return base.GetFirst(where);// Context.Queryable<T>().Where(where).First();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获得一条数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm">string</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
//public T GetFirst(string parm)
|
|
||||||
//{
|
//{
|
||||||
// return Context.Queryable<T>().Where(parm).First();
|
// return Context.Queryable<T>().In(ids).ToList();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件查询分页数据
|
///// 根据条件取条数
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where"></param>
|
///// <param name="where">条件表达式树</param>
|
||||||
/// <param name="parm"></param>
|
///// <returns></returns>
|
||||||
/// <returns></returns>
|
//public int GetCount(Expression<Func<T, bool>> where)
|
||||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm)
|
//{
|
||||||
{
|
// return Context.Queryable<T>().Count(where);
|
||||||
var source = Context.Queryable<T>().Where(where);
|
|
||||||
|
|
||||||
return source.ToPage(parm);
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc")
|
///// <summary>
|
||||||
{
|
///// 查询所有数据(无分页,请慎用)
|
||||||
var source = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc);
|
///// </summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
|
||||||
|
//{
|
||||||
|
// return Context.Queryable<T>().WithCacheIF(useCache, cacheSecond).ToList();
|
||||||
|
//}
|
||||||
|
|
||||||
return source.ToPage(parm);
|
///// <summary>
|
||||||
}
|
///// 获得一条数据
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="where">Expression<Func<T, bool>></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public T GetFirst2(Expression<Func<T, bool>> where)
|
||||||
|
//{
|
||||||
|
// return base.GetFirst(where);// Context.Queryable<T>().Where(where).First();
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 获得一条数据
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="parm">string</param>
|
||||||
|
///// <returns></returns>
|
||||||
|
////public T GetFirst(string parm)
|
||||||
|
////{
|
||||||
|
//// return Context.Queryable<T>().Where(parm).First();
|
||||||
|
////}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 根据条件查询分页数据
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="where"></param>
|
||||||
|
///// <param name="parm"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm)
|
||||||
|
//{
|
||||||
|
// var source = Context.Queryable<T>().Where(where);
|
||||||
|
|
||||||
|
// return source.ToPage(parm);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc")
|
||||||
|
//{
|
||||||
|
// var source = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc);
|
||||||
|
|
||||||
|
// return source.ToPage(parm);
|
||||||
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据条件查询数据
|
/// 根据条件查询数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
/// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<T> GetWhere(Expression<Func<T, bool>> where, bool useCache = false, int cacheSecond = 3600)
|
// public List<T> GetWhere(Expression<Func<T, bool>> where, bool useCache = false, int cacheSecond = 3600)
|
||||||
{
|
// {
|
||||||
var query = Context.Queryable<T>().Where(where).WithCacheIF(useCache, cacheSecond);
|
// var query = Context.Queryable<T>().Where(where).WithCacheIF(useCache, cacheSecond);
|
||||||
return query.ToList();
|
// return query.ToList();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 根据条件查询数据
|
///// 根据条件查询数据
|
||||||
/// </summary>
|
|
||||||
/// <param name="where">条件表达式树</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<T> GetWhere(Expression<Func<T, bool>> where, Expression<Func<T, object>> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600)
|
|
||||||
{
|
|
||||||
var query = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc).WithCacheIF(useCache, cacheSecond);
|
|
||||||
return query.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 修改操作
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 修改一条数据
|
|
||||||
///// </summary>
|
///// </summary>
|
||||||
///// <param name="parm">T</param>
|
///// <param name="where">条件表达式树</param>
|
||||||
///// <returns></returns>
|
///// <returns></returns>
|
||||||
//public int Update(T parm)
|
// public List<T> GetWhere(Expression<Func<T, bool>> where, Expression<Func<T, object>> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600)
|
||||||
|
// {
|
||||||
|
// var query = Context.Queryable<T>().Where(where).OrderByIF(orderEnum == "Asc", order, OrderByType.Asc).OrderByIF(orderEnum == "Desc", order, OrderByType.Desc).WithCacheIF(useCache, cacheSecond);
|
||||||
|
// return query.ToList();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
//#region 修改操作
|
||||||
|
|
||||||
|
/////// <summary>
|
||||||
|
/////// 修改一条数据
|
||||||
|
/////// </summary>
|
||||||
|
/////// <param name="parm">T</param>
|
||||||
|
/////// <returns></returns>
|
||||||
|
////public int Update(T parm)
|
||||||
|
////{
|
||||||
|
//// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand();
|
||||||
|
////}
|
||||||
|
|
||||||
|
/////// <summary>
|
||||||
|
/////// 批量修改
|
||||||
|
/////// </summary>
|
||||||
|
/////// <param name="parm">T</param>
|
||||||
|
/////// <returns></returns>
|
||||||
|
////public int Update(List<T> parm)
|
||||||
|
////{
|
||||||
|
//// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand();
|
||||||
|
////}
|
||||||
|
|
||||||
|
/////// <summary>
|
||||||
|
/////// 按查询条件更新
|
||||||
|
/////// </summary>
|
||||||
|
/////// <param name="where"></param>
|
||||||
|
/////// <param name="columns"></param>
|
||||||
|
/////// <returns></returns>
|
||||||
|
////public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||||
|
////{
|
||||||
|
//// return Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand();
|
||||||
|
////}
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region 删除操作
|
||||||
|
|
||||||
|
/////// <summary>
|
||||||
|
/////// 删除一条或多条数据
|
||||||
|
/////// </summary>
|
||||||
|
/////// <param name="parm">string</param>
|
||||||
|
/////// <returns></returns>
|
||||||
|
////public int Delete(object id)
|
||||||
|
////{
|
||||||
|
//// return Context.Deleteable<T>(id).RemoveDataCache().ExecuteCommand();
|
||||||
|
////}
|
||||||
|
|
||||||
|
/////// <summary>
|
||||||
|
/////// 删除一条或多条数据
|
||||||
|
/////// </summary>
|
||||||
|
/////// <param name="parm">string</param>
|
||||||
|
/////// <returns></returns>
|
||||||
|
////public int Delete(object[] ids)
|
||||||
|
////{
|
||||||
|
//// return Context.Deleteable<T>().In(ids).RemoveDataCache().ExecuteCommand();
|
||||||
|
////}
|
||||||
|
|
||||||
|
/////// <summary>
|
||||||
|
/////// 根据条件删除一条或多条数据
|
||||||
|
/////// </summary>
|
||||||
|
/////// <param name="where">过滤条件</param>
|
||||||
|
/////// <returns></returns>
|
||||||
|
////public int Delete(Expression<Func<T, bool>> where)
|
||||||
|
////{
|
||||||
|
//// return Context.Deleteable<T>().Where(where).RemoveDataCache().ExecuteCommand();
|
||||||
|
////}
|
||||||
|
|
||||||
|
//public int DeleteTable()
|
||||||
//{
|
//{
|
||||||
// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand();
|
// return Context.Deleteable<T>().RemoveDataCache().ExecuteCommand();
|
||||||
//}
|
//}
|
||||||
|
//#endregion
|
||||||
///// <summary>
|
|
||||||
///// 批量修改
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="parm">T</param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public int Update(List<T> parm)
|
|
||||||
//{
|
|
||||||
// return Context.Updateable(parm).RemoveDataCache().ExecuteCommand();
|
|
||||||
//}
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 按查询条件更新
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="where"></param>
|
|
||||||
///// <param name="columns"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
|
||||||
//{
|
|
||||||
// return Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand();
|
|
||||||
//}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 删除操作
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 删除一条或多条数据
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="parm">string</param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public int Delete(object id)
|
|
||||||
//{
|
|
||||||
// return Context.Deleteable<T>(id).RemoveDataCache().ExecuteCommand();
|
|
||||||
//}
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 删除一条或多条数据
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="parm">string</param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public int Delete(object[] ids)
|
|
||||||
//{
|
|
||||||
// return Context.Deleteable<T>().In(ids).RemoveDataCache().ExecuteCommand();
|
|
||||||
//}
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 根据条件删除一条或多条数据
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="where">过滤条件</param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public int Delete(Expression<Func<T, bool>> where)
|
|
||||||
//{
|
|
||||||
// return Context.Deleteable<T>().Where(where).RemoveDataCache().ExecuteCommand();
|
|
||||||
//}
|
|
||||||
|
|
||||||
public int DeleteTable()
|
|
||||||
{
|
|
||||||
return Context.Deleteable<T>().RemoveDataCache().ExecuteCommand();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,31 +11,6 @@ namespace ZR.Service
|
|||||||
{
|
{
|
||||||
public static class QueryableExtension
|
public static class QueryableExtension
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 读取列表
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <param name="pageIndex"></param>
|
|
||||||
/// <param name="pageSize"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
//public static async Task<PagedInfo<T>> ToPageAsync<T>(this ISugarQueryable<T> source, PageParm parm)
|
|
||||||
//{
|
|
||||||
// var page = new PagedInfo<T>();
|
|
||||||
// var total = await source.CountAsync();
|
|
||||||
// page.TotalCount = total;
|
|
||||||
// page.TotalPages = total / parm.PageSize;
|
|
||||||
|
|
||||||
// if (total % parm.PageSize > 0)
|
|
||||||
// page.TotalPages++;
|
|
||||||
|
|
||||||
// page.PageSize = parm.PageSize;
|
|
||||||
// page.PageIndex = parm.PageIndex;
|
|
||||||
|
|
||||||
// page.DataSource = await source.OrderByIF(!string.IsNullOrEmpty(parm.Sort), $"{parm.OrderBy} {(parm.Sort == "descending" ? "desc" : "asc")}").ToPageListAsync(parm.PageIndex, parm.PageSize);
|
|
||||||
// return page;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 读取列表
|
/// 读取列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -49,11 +24,6 @@ namespace ZR.Service
|
|||||||
var page = new PagedInfo<T>();
|
var page = new PagedInfo<T>();
|
||||||
var total = source.Count();
|
var total = source.Count();
|
||||||
page.TotalCount = total;
|
page.TotalCount = total;
|
||||||
//page.TotalPage = total / parm.PageSize;
|
|
||||||
|
|
||||||
//if (total % parm.PageSize > 0)
|
|
||||||
// page.TotalPages++;
|
|
||||||
|
|
||||||
page.PageSize = parm.PageSize;
|
page.PageSize = parm.PageSize;
|
||||||
page.PageIndex = parm.PageNum;
|
page.PageIndex = parm.PageNum;
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using SqlSugar;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using ZR.Repository;
|
||||||
|
|
||||||
namespace ZR.Service
|
namespace ZR.Service
|
||||||
{
|
{
|
||||||
@ -10,221 +11,199 @@ namespace ZR.Service
|
|||||||
/// 基础服务定义
|
/// 基础服务定义
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public interface IBaseService<T> where T : class
|
public interface IBaseService<T> : IBaseRepository<T> where T : class, new()
|
||||||
{
|
{
|
||||||
|
|
||||||
#region 事务
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 启用事务
|
|
||||||
///// </summary>
|
|
||||||
//void BeginTran();
|
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 提交事务
|
|
||||||
///// </summary>
|
|
||||||
//void CommitTran();
|
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 回滚事务
|
|
||||||
///// </summary>
|
|
||||||
//void RollbackTran();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 添加操作
|
#region 添加操作
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一条数据
|
/// 添加一条数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
int Add(T parm);
|
//int Add(T parm);
|
||||||
|
|
||||||
int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = false);
|
//int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = false);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 批量添加数据
|
///// 批量添加数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">List<T></param>
|
///// <param name="parm">List<T></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int Add(List<T> parm);
|
//int Add(List<T> parm);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 添加或更新数据
|
///// 添加或更新数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm"><T></param>
|
///// <param name="parm"><T></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
T Saveable(T parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null);
|
//T Saveable(T parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 批量添加或更新数据
|
///// 批量添加或更新数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">List<T></param>
|
///// <param name="parm">List<T></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
List<T> Saveable(List<T> parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null);
|
//List<T> Saveable(List<T> parm, Expression<Func<T, object>> uClumns = null, Expression<Func<T, object>> iColumns = null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
//#endregion
|
||||||
|
|
||||||
#region 查询操作
|
//#region 查询操作
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件查询数据是否存在
|
///// 根据条件查询数据是否存在
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
///// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
bool Any(Expression<Func<T, bool>> where);
|
//bool Any(Expression<Func<T, bool>> where);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件合计字段
|
///// 根据条件合计字段
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
///// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
TResult Sum<TResult>(Expression<Func<T, bool>> where, Expression<Func<T, TResult>> field);
|
//TResult Sum<TResult>(Expression<Func<T, bool>> where, Expression<Func<T, TResult>> field);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据主值查询单条数据
|
///// 根据主值查询单条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="pkValue">主键值</param>
|
///// <param name="pkValue">主键值</param>
|
||||||
/// <returns>泛型实体</returns>
|
///// <returns>泛型实体</returns>
|
||||||
T GetId(object pkValue);
|
//T GetId(object pkValue);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据主键查询多条数据
|
///// 根据主键查询多条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="ids"></param>
|
///// <param name="ids"></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
List<T> GetIn(object[] ids);
|
//List<T> GetIn(object[] ids);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件取条数
|
///// 根据条件取条数
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
///// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int GetCount(Expression<Func<T, bool>> where);
|
//int GetCount(Expression<Func<T, bool>> where);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 查询所有数据(无分页,请慎用)
|
///// 查询所有数据(无分页,请慎用)
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
|
//List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 获得一条数据
|
///// 获得一条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">Expression<Func<T, bool>></param>
|
///// <param name="where">Expression<Func<T, bool>></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
T GetFirst(Expression<Func<T, bool>> where);
|
//T GetFirst(Expression<Func<T, bool>> where);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 获得一条数据
|
///// 获得一条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">string</param>
|
///// <param name="parm">string</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
T GetFirst(string parm);
|
//T GetFirst(string parm);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件查询分页数据
|
///// 根据条件查询分页数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where"></param>
|
///// <param name="where"></param>
|
||||||
/// <param name="parm"></param>
|
///// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, Model.PagerInfo parm);
|
//PagedInfo<T> GetPages(Expression<Func<T, bool>> where, Model.PagerInfo parm);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件查询分页
|
///// 根据条件查询分页
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where"></param>
|
///// <param name="where"></param>
|
||||||
/// <param name="parm"></param>
|
///// <param name="parm"></param>
|
||||||
/// <param name="order"></param>
|
///// <param name="order"></param>
|
||||||
/// <param name="orderEnum"></param>
|
///// <param name="orderEnum"></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
PagedInfo<T> GetPages(Expression<Func<T, bool>> where, Model.PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc");
|
//PagedInfo<T> GetPages(Expression<Func<T, bool>> where, Model.PagerInfo parm, Expression<Func<T, object>> order, string orderEnum = "Asc");
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件查询数据
|
///// 根据条件查询数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
///// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
List<T> GetWhere(Expression<Func<T, bool>> where, bool useCache = false, int cacheSecond = 3600);
|
////List<T> GetWhere(Expression<Func<T, bool>> where, bool useCache = false, int cacheSecond = 3600);
|
||||||
|
|
||||||
/// <summary>
|
/////// <summary>
|
||||||
/// 根据条件查询数据
|
/////// 根据条件查询数据
|
||||||
/// </summary>
|
/////// </summary>
|
||||||
/// <param name="where">条件表达式树</param>
|
/////// <param name="where">条件表达式树</param>
|
||||||
/// <returns></returns>
|
/////// <returns></returns>
|
||||||
List<T> GetWhere(Expression<Func<T, bool>> where, Expression<Func<T, object>> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600);
|
////List<T> GetWhere(Expression<Func<T, bool>> where, Expression<Func<T, object>> order, string orderEnum = "Asc", bool useCache = false, int cacheSecond = 3600);
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
//#endregion
|
||||||
|
|
||||||
#region 修改操作
|
//#region 修改操作
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 修改一条数据
|
///// 修改一条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">T</param>
|
///// <param name="parm">T</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int Update(T parm);
|
//int Update(T parm);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 批量修改
|
///// 批量修改
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">T</param>
|
///// <param name="parm">T</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int Update(List<T> parm);
|
//int Update(List<T> parm);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 按查询条件更新
|
///// 按查询条件更新
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where"></param>
|
///// <param name="where"></param>
|
||||||
/// <param name="columns"></param>
|
///// <param name="columns"></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
//int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
//#endregion
|
||||||
|
|
||||||
#region 删除操作
|
//#region 删除操作
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 删除一条或多条数据
|
///// 删除一条或多条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">string</param>
|
///// <param name="parm">string</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int Delete(object id);
|
//int Delete(object id);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 删除一条或多条数据
|
///// 删除一条或多条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="parm">string</param>
|
///// <param name="parm">string</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int Delete(object[] ids);
|
//int Delete(object[] ids);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 根据条件删除一条或多条数据
|
///// 根据条件删除一条或多条数据
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="where">过滤条件</param>
|
///// <param name="where">过滤条件</param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int Delete(Expression<Func<T, bool>> where);
|
//int Delete(Expression<Func<T, bool>> where);
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 清空表
|
///// 清空表
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
int DeleteTable();
|
//int DeleteTable();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace ZR.Service.System
|
|||||||
/// 文章目录
|
/// 文章目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class ArticleCategoryService : IArticleCategoryService
|
public class ArticleCategoryService : BaseService<ArticleCategory>, IArticleCategoryService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建前端所需要树结构
|
/// 构建前端所需要树结构
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace ZR.Service.System
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(IArticleService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(IArticleService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class ArticleService : IArticleService
|
public class ArticleService : BaseService<Article>, IArticleService
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,11 +67,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));
|
||||||
|
|
||||||
(List<GenTable>, int) ts = GenTableRepository.QueryableToPage(predicate.ToExpression(), pagerInfo.PageNum, pagerInfo.PageSize);
|
return GenTableRepository.GetPages(predicate.ToExpression(), pagerInfo);
|
||||||
|
|
||||||
PagedInfo<GenTable> pagedInfo = new(ts.Item1, pagerInfo.PageNum, pagerInfo.PageSize);
|
|
||||||
pagedInfo.TotalCount = ts.Item2;
|
|
||||||
return pagedInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using ZR.Model.System;
|
|||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface IArticleCategoryService //: IBaseService<ArticleCategory>
|
public interface IArticleCategoryService : IBaseService<ArticleCategory>
|
||||||
{
|
{
|
||||||
List<ArticleCategory> BuildCategoryTree(List<ArticleCategory> categories);
|
List<ArticleCategory> BuildCategoryTree(List<ArticleCategory> categories);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using ZR.Model.System;
|
|||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface IArticleService //: IBaseService<Article>
|
public interface IArticleService : IBaseService<Article>
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,15 +6,15 @@ using ZR.Model.Vo.System;
|
|||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface ISysDeptService //: IBaseService<SysDept>
|
public interface ISysDeptService : IBaseService<SysDept>
|
||||||
{
|
{
|
||||||
public List<SysDept> GetSysDepts(SysDept dept);
|
List<SysDept> GetSysDepts(SysDept dept);
|
||||||
public string CheckDeptNameUnique(SysDept dept);
|
string CheckDeptNameUnique(SysDept dept);
|
||||||
public int InsertDept(SysDept dept);
|
int InsertDept(SysDept dept);
|
||||||
public int UpdateDept(SysDept dept);
|
int UpdateDept(SysDept dept);
|
||||||
public void UpdateDeptChildren(long deptId, string newAncestors, string oldAncestors);
|
void UpdateDeptChildren(long deptId, string newAncestors, string oldAncestors);
|
||||||
public List<SysDept> GetChildrenDepts(List<SysDept> depts, long deptId);
|
List<SysDept> GetChildrenDepts(List<SysDept> depts, long deptId);
|
||||||
public List<SysDept> BuildDeptTree(List<SysDept> depts);
|
List<SysDept> BuildDeptTree(List<SysDept> depts);
|
||||||
public List<TreeSelectVo> BuildDeptTreeSelect(List<SysDept> depts);
|
List<TreeSelectVo> BuildDeptTreeSelect(List<SysDept> depts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace ZR.Service.System.IService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISysDictService : IBaseService<SysDictType>
|
public interface ISysDictService
|
||||||
{
|
{
|
||||||
public List<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager);
|
public List<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager);
|
||||||
|
|
||||||
@ -39,5 +39,12 @@ namespace ZR.Service.System.IService
|
|||||||
/// <param name="sysDictType"></param>
|
/// <param name="sysDictType"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int UpdateDictType(SysDictType sysDictType);
|
public int UpdateDictType(SysDictType sysDictType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取字典信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dictId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
SysDictType GetInfo(long dictId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ using ZR.Repository;
|
|||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface ISysPostService: IBaseRepository<SysPost>
|
public interface ISysPostService : IBaseService<SysPost>
|
||||||
{
|
{
|
||||||
string CheckPostNameUnique(SysPost sysPost);
|
string CheckPostNameUnique(SysPost sysPost);
|
||||||
string CheckPostCodeUnique(SysPost sysPost);
|
string CheckPostCodeUnique(SysPost sysPost);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using ZR.Repository;
|
|||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface ISysTasksLogService: IBaseRepository<SysTasksLog>
|
public interface ISysTasksLogService : IBaseService<SysTasksLog>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录任务执行日志
|
/// 记录任务执行日志
|
||||||
|
|||||||
@ -7,8 +7,8 @@ using ZR.Model.System;
|
|||||||
|
|
||||||
namespace ZR.Service.System.IService
|
namespace ZR.Service.System.IService
|
||||||
{
|
{
|
||||||
public interface ISysTasksQzService
|
public interface ISysTasksQzService : IBaseService<SysTasksQz>
|
||||||
{
|
{
|
||||||
SysTasksQz GetId(object id);
|
//SysTasksQz GetId(object id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ namespace ZR.Service.System
|
|||||||
/// 部门管理
|
/// 部门管理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(ISysDeptService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysDeptService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysDeptService :ISysDeptService
|
public class SysDeptService : BaseService<SysDept>, ISysDeptService
|
||||||
{
|
{
|
||||||
public SysDeptRepository DeptRepository;
|
public SysDeptRepository DeptRepository;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ namespace ZR.Service.System
|
|||||||
}
|
}
|
||||||
|
|
||||||
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
|
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
|
||||||
return DeptRepository.Insert(dept, true);
|
return DeptRepository.Add(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -86,8 +86,8 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int UpdateDept(SysDept dept)
|
public int UpdateDept(SysDept dept)
|
||||||
{
|
{
|
||||||
SysDept newParentDept = DeptRepository.GetSingle(it => it.ParentId == dept.ParentId);
|
SysDept newParentDept = DeptRepository.GetFirst(it => it.ParentId == dept.ParentId);
|
||||||
SysDept oldDept = DeptRepository.GetSingle(m => m.DeptId == dept.DeptId);
|
SysDept oldDept = DeptRepository.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;
|
||||||
@ -129,12 +129,10 @@ namespace ZR.Service.System
|
|||||||
foreach (var child in children)
|
foreach (var child in children)
|
||||||
{
|
{
|
||||||
child.Ancestors = child.Ancestors.Replace(oldAncestors, newAncestors);
|
child.Ancestors = child.Ancestors.Replace(oldAncestors, newAncestors);
|
||||||
|
}
|
||||||
if (child.DeptId.Equals(deptId))
|
if (children.Count > 0)
|
||||||
{
|
{
|
||||||
//TODO Saveable(child, it => new { it.Ancestors });
|
//DeptRepository.UdateDeptChildren(child);
|
||||||
//DeptRepository.UdateDeptChildren(child);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace ZR.Service.System
|
|||||||
public List<SysDictData> SelectDictDataByType(string dictType)
|
public List<SysDictData> SelectDictDataByType(string dictType)
|
||||||
{
|
{
|
||||||
string CK = $"SelectDictDataByType_{dictType}";
|
string CK = $"SelectDictDataByType_{dictType}";
|
||||||
if (!(CacheHelper.GetCache(CK) is List<SysDictData> list))
|
if (CacheHelper.GetCache(CK) is not List<SysDictData> list)
|
||||||
{
|
{
|
||||||
list = SysDictDataRepository.SelectDictDataByType(dictType);
|
list = SysDictDataRepository.SelectDictDataByType(dictType);
|
||||||
CacheHelper.SetCache(CK, list, 30);
|
CacheHelper.SetCache(CK, list, 30);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace ZR.Service.System
|
|||||||
/// 字典类型
|
/// 字典类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysDictService : BaseService<SysDictType>, ISysDictService
|
public class SysDictService : ISysDictService
|
||||||
{
|
{
|
||||||
private SysDictRepository DictRepository;
|
private SysDictRepository DictRepository;
|
||||||
private SysDictDataRepository DictDataRepository;
|
private SysDictDataRepository DictDataRepository;
|
||||||
@ -79,7 +79,7 @@ namespace ZR.Service.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public long InsertDictType(SysDictType sysDictType)
|
public long InsertDictType(SysDictType sysDictType)
|
||||||
{
|
{
|
||||||
return DictRepository.InsertReturnEntity(sysDictType).DictId;
|
return DictRepository.InsertReturnBigIdentity(sysDictType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -97,5 +97,15 @@ namespace ZR.Service.System
|
|||||||
}
|
}
|
||||||
return DictRepository.UpdateDictType(sysDictType);
|
return DictRepository.UpdateDictType(sysDictType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取字典信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dictId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SysDictType GetInfo(long dictId)
|
||||||
|
{
|
||||||
|
return DictRepository.GetFirst(f => f.DictId == dictId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace ZR.Service.System
|
|||||||
/// 岗位管理
|
/// 岗位管理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(ISysPostService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysPostService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysPostService : BaseRepository<SysPost>, ISysPostService
|
public class SysPostService : BaseService<SysPost>, ISysPostService
|
||||||
{
|
{
|
||||||
public SysPostRepository PostRepository;
|
public SysPostRepository PostRepository;
|
||||||
public SysPostService(SysPostRepository postRepository)
|
public SysPostService(SysPostRepository postRepository)
|
||||||
|
|||||||
@ -28,7 +28,7 @@ namespace ZR.Service.System
|
|||||||
logModel.CreateTime = DateTime.Now;
|
logModel.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
Insert(logModel, true);
|
Add(logModel);
|
||||||
return logModel;
|
return logModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ using ZR.Service.System.IService;
|
|||||||
namespace ZR.Service.System
|
namespace ZR.Service.System
|
||||||
{
|
{
|
||||||
[AppService(ServiceType = typeof(ISysTasksQzService), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(ISysTasksQzService), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class SysTasksQzService : ISysTasksQzService
|
public class SysTasksQzService : BaseService<SysTasksQz>, ISysTasksQzService
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
<el-table v-loading="loading" :data="deptList" row-key="deptId" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
<el-table v-loading="loading" :data="deptList" row-key="deptId" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||||
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
|
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
|
||||||
|
<el-table-column prop="leader" label="负责人" width="100"></el-table-column>
|
||||||
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
|
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
|
||||||
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
|
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<name>ZR.Admin.WebApi</name>
|
<name>ZR.Admin.WebApi</name>
|
||||||
</assembly>
|
</assembly>
|
||||||
<members>
|
<members>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.BaseController.OutputJson(Infrastructure.Model.ApiResult,System.String)">
|
<member name="M:ZR.Admin.WebApi.Controllers.BaseController.ToResponse(Infrastructure.Model.ApiResult,System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
json输出带时间格式的
|
json输出带时间格式的
|
||||||
</summary>
|
</summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user