优化分页统一返回
This commit is contained in:
parent
79b3c306f9
commit
8dc832cdbd
@ -4,6 +4,10 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Model\PagedInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspectCore.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
|
||||
|
||||
@ -19,7 +19,7 @@ using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System.Generate;
|
||||
using ZR.Model.Vo;
|
||||
using ZR.Service;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
@ -72,9 +72,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
public IActionResult FindListTable(string dbName, string tableName, PagerInfo pager)
|
||||
{
|
||||
List<DbTableInfo> list = _CodeGeneraterService.GetAllTables(dbName, tableName, pager);
|
||||
var vm = new VMPageResult<DbTableInfo>(list, pager);
|
||||
|
||||
return SUCCESS(vm);
|
||||
return SUCCESS(list.ToPage(pager));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -38,10 +38,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[HttpGet("list")]
|
||||
public IActionResult List([FromQuery] SysDictData dictData, [FromQuery] PagerInfo pagerInfo)
|
||||
{
|
||||
var list = SysDictDataService.SelectDictDataList(dictData);
|
||||
pagerInfo.TotalNum = list.Count;
|
||||
var vm = new VMPageResult<SysDictData>(list, pagerInfo);
|
||||
return SUCCESS(vm);
|
||||
var list = SysDictDataService.SelectDictDataList(dictData, pagerInfo);
|
||||
return SUCCESS(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -107,7 +105,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[HttpDelete("{dictCode}")]
|
||||
public IActionResult Remove(string dictCode)
|
||||
{
|
||||
long[] dictCodes = ZR.Common.Tools.SpitLongArrary(dictCode);
|
||||
long[] dictCodes = Common.Tools.SpitLongArrary(dictCode);
|
||||
|
||||
return SUCCESS(SysDictDataService.DeleteDictDataByIds(dictCodes));
|
||||
}
|
||||
|
||||
@ -38,8 +38,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
var list = SysDictService.SelectDictTypeList(dict, pagerInfo);
|
||||
|
||||
var vm = new VMPageResult<SysDictType>(list, pagerInfo);
|
||||
return SUCCESS(vm, TIME_FORMAT_FULL);
|
||||
return SUCCESS(list, TIME_FORMAT_FULL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -11,7 +11,7 @@ using System.IO;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.Vo;
|
||||
using ZR.Service;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.System
|
||||
@ -53,9 +53,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
var list = UserService.SelectUserList(user, pager);
|
||||
|
||||
var vm = new VMPageResult<SysUser>(list, pager);
|
||||
|
||||
return SUCCESS(vm, TIME_FORMAT_FULL);
|
||||
return SUCCESS(list.ToPage(pager), TIME_FORMAT_FULL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -38,9 +38,8 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
public IActionResult LoignLogList([FromQuery] SysLogininfor sysLogininfoDto, [FromQuery] PagerInfo pagerInfo)
|
||||
{
|
||||
var list = sysLoginService.GetLoginLog(sysLogininfoDto, pagerInfo);
|
||||
var vMPage = new VMPageResult<SysLogininfor>(list, pagerInfo);
|
||||
|
||||
return ToResponse(ToJson(vMPage.TotalNum, vMPage), TIME_FORMAT_FULL_2);
|
||||
return ToResponse(ToJson(list.Count, list.ToPage(pagerInfo)), TIME_FORMAT_FULL_2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -41,9 +41,8 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
PagerInfo pagerInfo = new PagerInfo(sysOperLog.pageNum);
|
||||
|
||||
var list = sysOperLogService.SelectOperLogList(sysOperLog, pagerInfo);
|
||||
var vMPage = new VMPageResult<SysOperLog>(list, pagerInfo);
|
||||
|
||||
return ToResponse(ToJson(vMPage.TotalNum, vMPage), TIME_FORMAT_FULL_2);
|
||||
return ToResponse(ToJson(list.TotalNum, list), TIME_FORMAT_FULL_2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,7 +83,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
public IActionResult Export([FromQuery] SysOperLogDto sysOperLog)
|
||||
{
|
||||
var list = sysOperLogService.SelectOperLogList(sysOperLog, new PagerInfo(1, 10000));
|
||||
string sFileName = ExportExcel(list, "operlog", "操作日志");
|
||||
string sFileName = ExportExcel(list.Result, "operlog", "操作日志");
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
|
||||
|
||||
@ -1,103 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ZRModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用json格式实体返回类
|
||||
/// Author by zhaorui
|
||||
/// </summary>
|
||||
public class ApiResult
|
||||
{
|
||||
public int Code { get; set; }
|
||||
public string Msg { get; set; }
|
||||
/// <summary>
|
||||
/// 如果data值为null,则忽略序列化将不会返回data字段
|
||||
/// </summary>
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
public object Data { get; set; }
|
||||
|
||||
public ApiResult()
|
||||
{
|
||||
Code = 0;
|
||||
Msg = "fail";
|
||||
}
|
||||
|
||||
public ApiResult OnSuccess()
|
||||
{
|
||||
Code = 100;
|
||||
Msg = "success";
|
||||
return this;
|
||||
}
|
||||
public ApiResult(int code, string msg, object data = null)
|
||||
{
|
||||
Code = code;
|
||||
Msg = msg;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public ApiResult OnSuccess(object data = null)
|
||||
{
|
||||
Code = (int)ResultCode.SUCCESS;
|
||||
Msg = "SUCCESS";
|
||||
Data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回成功消息
|
||||
/// </summary>
|
||||
/// <param name="data">数据对象</param>
|
||||
/// <returns>成功消息</returns>
|
||||
public static ApiResult Success(object data) { return new ApiResult(100, "success", data); }
|
||||
|
||||
/// <summary>
|
||||
/// 返回成功消息
|
||||
/// </summary>
|
||||
/// <param name="msg">返回内容</param>
|
||||
/// <returns>成功消息</returns>
|
||||
public static ApiResult Success(string msg) { return new ApiResult(100, msg, null); }
|
||||
|
||||
/// <summary>
|
||||
/// 返回成功消息
|
||||
/// </summary>
|
||||
/// <param name="msg">返回内容</param>
|
||||
/// <param name="data">数据对象</param>
|
||||
/// <returns>成功消息</returns>
|
||||
public static ApiResult Success(string msg, object data) { return new ApiResult(100, msg, data); }
|
||||
|
||||
/// <summary>
|
||||
/// 返回失败消息
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
public static ApiResult Error(int code, string msg) { return new ApiResult(code, msg); }
|
||||
|
||||
/// <summary>
|
||||
/// 返回失败消息
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
public static ApiResult Error(string msg) { return new ApiResult(200, msg); }
|
||||
|
||||
}
|
||||
public enum ResultCode
|
||||
{
|
||||
[Description("success")]
|
||||
SUCCESS = 100,
|
||||
[Description("参数错误")]
|
||||
PARAM_ERROR = 101,
|
||||
[Description("自定义错误")]
|
||||
CUSTOM_ERROR = 200,
|
||||
FAIL = 0,
|
||||
[Description("程序出错啦")]
|
||||
GLOBAL_ERROR = 104,
|
||||
[Description("请先绑定手机号")]
|
||||
NOBIND_PHONENUM = 102,
|
||||
[Description("授权失败")]
|
||||
OAUTH_FAIL = 201,
|
||||
[Description("未授权")]
|
||||
DENY = 401
|
||||
}
|
||||
}
|
||||
30
ZR.Model/Extensions/QueryableExtension.cs
Normal file
30
ZR.Model/Extensions/QueryableExtension.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 分页扩展
|
||||
/// </summary>
|
||||
public static class PageExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取列表
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public static PagedInfo<T> ToPage<T>(this List<T> source, PagerInfo parm)
|
||||
{
|
||||
var page = new PagedInfo<T>
|
||||
{
|
||||
TotalPage = parm.TotalPage,
|
||||
TotalNum = parm.TotalNum,
|
||||
PageSize = parm.PageSize,
|
||||
PageIndex = parm.PageNum,
|
||||
Result = source
|
||||
};
|
||||
return page;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
|
||||
namespace ZRModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取配置文件POCO实体类
|
||||
/// </summary>
|
||||
public class OptionsSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// 1、喵播 2、fireStar
|
||||
/// </summary>
|
||||
public int Platform { get; set; }
|
||||
public string AppName { get; set; }
|
||||
public string Redis { get; set; }
|
||||
public string Conn_Live { get; set; }
|
||||
public string Conn_Admin { get; set; }
|
||||
/// <summary>
|
||||
/// mongodb连接字符串
|
||||
/// </summary>
|
||||
public string Mongo_Conn { get; set; }
|
||||
public string Database { get; set; }
|
||||
|
||||
public LoggingOptions Logging { get; set; }
|
||||
public MailOptions MailOptions { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送邮件数据配置
|
||||
/// </summary>
|
||||
public class MailOptions
|
||||
{
|
||||
public string From { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Host { get; set; }
|
||||
public int Port { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
public class LoggingOptions
|
||||
{
|
||||
public LogLevelOptions LogLevel { get; set; }
|
||||
}
|
||||
public class LogLevelOptions
|
||||
{
|
||||
public string Default { get; set; }
|
||||
public string Ssytem { get; set; }
|
||||
public string Microsoft { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Infrastructure.Model
|
||||
namespace ZR.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 分页参数
|
||||
@ -20,34 +20,33 @@ namespace Infrastructure.Model
|
||||
/// <summary>
|
||||
/// 排序列
|
||||
/// </summary>
|
||||
//public string Sort { get; set; }
|
||||
public string Sort { get; set; }
|
||||
/// <summary>
|
||||
/// 排序类型
|
||||
/// </summary>
|
||||
//public string SortType { get; set; }
|
||||
public string SortType { get; set; }
|
||||
/// <summary>
|
||||
/// 总记录数
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
public int TotalNum { get; set; }
|
||||
/// <summary>
|
||||
/// 总页数
|
||||
/// </summary>
|
||||
//public int TotalPage
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (TotalCount > 0)
|
||||
// {
|
||||
// return TotalCount % this.PageSize == 0 ? TotalCount / this.PageSize : TotalCount / this.PageSize + 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
// set { }
|
||||
//}
|
||||
public int TotalPage { get; set; }
|
||||
public int TotalPage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TotalNum > 0)
|
||||
{
|
||||
return TotalNum % this.PageSize == 0 ? TotalNum / this.PageSize : TotalNum / this.PageSize + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
set { }
|
||||
}
|
||||
public List<T> Result { get; set; }
|
||||
|
||||
public PagedInfo()
|
||||
@ -59,8 +58,8 @@ namespace Infrastructure.Model
|
||||
{
|
||||
PageIndex = pageIndex;
|
||||
PageSize = pageSize;
|
||||
TotalCount = source.Count;
|
||||
TotalPage = (int)Math.Ceiling(TotalCount / (double)PageSize);//计算总页数
|
||||
TotalNum = source.Count;
|
||||
TotalPage = (int)Math.Ceiling(TotalNum / (double)PageSize);//计算总页数
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,9 +18,20 @@ namespace ZR.Model
|
||||
/// <summary>
|
||||
/// 总页码
|
||||
/// </summary>
|
||||
public int TotalPageNum { get; set; }
|
||||
/// <summary>
|
||||
/// 总页数
|
||||
/// </summary>
|
||||
public int TotalPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return TotalNum > 0 ? TotalNum % PageSize == 0 ? TotalNum / PageSize : TotalNum / PageSize + 1 : 0;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
public int PageSize { get => pageSize; set => pageSize = value; }
|
||||
|
||||
public string Sort { get; set; }
|
||||
public string OrderBy { get; set; }
|
||||
public PagerInfo()
|
||||
{
|
||||
PageNum = 1;
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace ZR.Model.Vo
|
||||
{
|
||||
public class VMPageResult<T> where T : new()
|
||||
{
|
||||
public int Page { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public long TotalNum { get; set; }
|
||||
//public int TotalPages { get; set; }
|
||||
public IList<T> Result { get; set; }
|
||||
public long EndPage { get; set; }
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
public DataTable Data { get; set; }
|
||||
|
||||
public VMPageResult()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 集合使用
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <param name="pagerInfo"></param>
|
||||
public VMPageResult(IList<T> result, PagerInfo pagerInfo)
|
||||
{
|
||||
this.Result = result;
|
||||
this.TotalNum = pagerInfo.TotalNum;
|
||||
this.PageSize = pagerInfo.PageSize;
|
||||
this.Page = pagerInfo.PageNum;
|
||||
//计算
|
||||
this.EndPage = pagerInfo.TotalNum % PageSize == 0 ? pagerInfo.TotalNum / PageSize : pagerInfo.TotalNum / PageSize + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// datable使用
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <param name="pagerInfo"></param>
|
||||
public VMPageResult(DataTable result, PagerInfo pagerInfo)
|
||||
{
|
||||
this.Data = result;
|
||||
this.TotalNum = pagerInfo.TotalNum;
|
||||
this.PageSize = pagerInfo.PageSize;
|
||||
this.Page = pagerInfo.PageNum;
|
||||
//计算
|
||||
this.EndPage = pagerInfo.TotalNum % PageSize == 0 ? pagerInfo.TotalNum / PageSize : pagerInfo.TotalNum / PageSize + 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,11 +4,6 @@
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="ApiResult.cs" />
|
||||
<Compile Remove="OptionsSetting.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.4.3" />
|
||||
@ -18,6 +13,7 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="Dto\" />
|
||||
<Folder Include="Enum\" />
|
||||
<Folder Include="Vo\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -391,13 +391,13 @@ namespace ZR.Repository
|
||||
public static PagedInfo<T> ToPage<T>(this ISugarQueryable<T> source, PagerInfo parm)
|
||||
{
|
||||
var page = new PagedInfo<T>();
|
||||
var total = source.Count();
|
||||
page.TotalCount = total;
|
||||
var total = 0;
|
||||
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);
|
||||
page.Result = source.OrderByIF(!string.IsNullOrEmpty(parm.Sort), $"{parm.OrderBy} {(parm.Sort == "desc" ? "desc" : "asc")}")
|
||||
.ToPageList(parm.PageNum, parm.PageSize, ref total);
|
||||
page.TotalNum = total;
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Model;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
@ -15,14 +18,15 @@ namespace ZR.Repository.System
|
||||
/// 字典类型数据搜索
|
||||
/// </summary>
|
||||
/// <param name="dictData"></param>
|
||||
/// <param name="pagerInfo"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictData> SelectDictDataList(SysDictData dictData)
|
||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo)
|
||||
{
|
||||
return Context.Queryable<SysDictData>()
|
||||
.WhereIF(!string.IsNullOrEmpty(dictData.DictLabel), it => it.DictLabel.Contains(dictData.DictLabel))
|
||||
.WhereIF(!string.IsNullOrEmpty(dictData.Status), it => it.Status == dictData.Status)
|
||||
.WhereIF(!string.IsNullOrEmpty(dictData.DictType), it => it.DictType == dictData.DictType)
|
||||
.ToList();
|
||||
var exp = Expressionable.Create<SysDictData>();
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictData.DictLabel), it => it.DictLabel.Contains(dictData.DictLabel));
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictData.Status), it => it.Status == dictData.Status);
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictData.DictType), it => it.DictType == dictData.DictType);
|
||||
return GetPages(exp.ToExpression(), pagerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using Infrastructure.Attribute;
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
@ -22,17 +22,14 @@ namespace ZR.Repository.System
|
||||
/// </summary>
|
||||
/// <param name="dictType">实体模型</param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager)
|
||||
public PagedInfo<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager)
|
||||
{
|
||||
var totalNum = 0;
|
||||
var list = Context
|
||||
.Queryable<SysDictType>()
|
||||
.WhereIF(!string.IsNullOrEmpty(dictType.DictName), it => it.DictName.Contains(dictType.DictName))
|
||||
.WhereIF(!string.IsNullOrEmpty(dictType.Status), it => it.Status == dictType.Status)
|
||||
.WhereIF(!string.IsNullOrEmpty(dictType.DictType), it => it.DictType == dictType.DictType)
|
||||
.ToPageList(pager.PageNum, pager.PageSize, ref totalNum);
|
||||
pager.TotalNum = totalNum;
|
||||
return list;
|
||||
var exp = Expressionable.Create<SysDictType>();
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictType.DictName), it => it.DictName.Contains(dictType.DictName));
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictType.Status), it => it.Status == dictType.Status);
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictType.DictType), it => it.DictType == dictType.DictType);
|
||||
|
||||
return GetPages(exp.ToExpression(), pager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -4,6 +4,8 @@ using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Model;
|
||||
|
||||
namespace ZR.Repository.System
|
||||
{
|
||||
@ -16,19 +18,16 @@ namespace ZR.Repository.System
|
||||
/// <param name="sysOper"></param>
|
||||
/// <param name="pagerInfo">分页数据</param>
|
||||
/// <returns></returns>
|
||||
public List<SysOperLog> GetSysOperLog(SysOperLogDto sysOper, PagerInfo pagerInfo)
|
||||
public PagedInfo<SysOperLog> GetSysOperLog(SysOperLogDto sysOper, PagerInfo pagerInfo)
|
||||
{
|
||||
int totalCount = 0;
|
||||
var list = Context.Queryable<SysOperLog>()
|
||||
.Where(it => it.operTime >= sysOper.BeginTime && it.operTime <= sysOper.EndTime)
|
||||
.WhereIF(sysOper.Title.IfNotEmpty(), it => it.title.Contains(sysOper.Title))
|
||||
.WhereIF(sysOper.operName.IfNotEmpty(), it => it.operName.Contains(sysOper.operName))
|
||||
.WhereIF(sysOper.BusinessType != -1, it =>it.businessType == sysOper.BusinessType)
|
||||
.WhereIF(sysOper.Status != -1, it => it.status == sysOper.Status)
|
||||
.OrderBy(it => it.OperId, SqlSugar.OrderByType.Desc)
|
||||
.ToPageList(pagerInfo.PageNum, pagerInfo.PageSize, ref totalCount);
|
||||
pagerInfo.TotalNum = totalCount;
|
||||
return list;
|
||||
var exp = Expressionable.Create<SysOperLog>();
|
||||
exp.And(it => it.operTime >= sysOper.BeginTime && it.operTime <= sysOper.EndTime);
|
||||
exp.AndIF(sysOper.Title.IfNotEmpty(), it => it.title.Contains(sysOper.Title));
|
||||
exp.AndIF(sysOper.operName.IfNotEmpty(), it => it.operName.Contains(sysOper.operName));
|
||||
exp.AndIF(sysOper.BusinessType != -1, it => it.businessType == sysOper.BusinessType);
|
||||
exp.AndIF(sysOper.Status != -1, it => it.status == sysOper.Status);
|
||||
|
||||
return GetPages(exp.ToExpression(), pagerInfo, x => x.OperId, OrderByType.Desc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
|
||||
using Infrastructure.Model;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Vo;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
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 PagedInfo<T> ToPage<T>(this ISugarQueryable<T> source, PagerInfo parm)
|
||||
{
|
||||
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,11 +1,10 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Model;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Generate;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
using Infrastructure.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Generate;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
using System;
|
||||
using Infrastructure.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysDictDataService
|
||||
{
|
||||
public List<SysDictData> SelectDictDataList(SysDictData dictData);
|
||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo);
|
||||
public List<SysDictData> SelectDictDataByType(string dictType);
|
||||
public SysDictData SelectDictDataById(long dictCode);
|
||||
public long InsertDictData(SysDictData dict);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
@ -11,7 +11,7 @@ namespace ZR.Service.System.IService
|
||||
public interface ISysDictService
|
||||
{
|
||||
public List<SysDictType> GetAll();
|
||||
public List<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager);
|
||||
public PagedInfo<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 校验字典类型称是否唯一
|
||||
|
||||
@ -3,6 +3,7 @@ using ZR.Model;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System;
|
||||
using Infrastructure.Model;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
@ -16,7 +17,7 @@ namespace ZR.Service.System.IService
|
||||
/// <param name="operLog">操作日志对象</param>
|
||||
/// <param name="pager"></param>
|
||||
/// <returns>操作日志集合</returns>
|
||||
public List<SysOperLog> SelectOperLogList(SysOperLogDto operLog, PagerInfo pager);
|
||||
public PagedInfo<SysOperLog> SelectOperLogList(SysOperLogDto operLog, PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 清空操作日志
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
using Infrastructure.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
@ -27,9 +29,9 @@ namespace ZR.Service.System
|
||||
/// </summary>
|
||||
/// <param name="dictData"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictData> SelectDictDataList(SysDictData dictData)
|
||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo)
|
||||
{
|
||||
return SysDictDataRepository.SelectDictDataList(dictData);
|
||||
return SysDictDataRepository.SelectDictDataList(dictData, pagerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
@ -33,7 +33,7 @@ namespace ZR.Service.System
|
||||
/// </summary>
|
||||
/// <param name="dictType">实体模型</param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager)
|
||||
public PagedInfo<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager)
|
||||
{
|
||||
return DictRepository.SelectDictTypeList(dictType, pager);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using ZR.Model.System;
|
||||
using ZR.Repository.System;
|
||||
using ZR.Service.System.IService;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
@ -37,7 +38,7 @@ namespace ZR.Service.System
|
||||
/// <param name="operLog">操作日志对象</param>
|
||||
/// <param name="pager"></param>
|
||||
/// <returns>操作日志集合</returns>
|
||||
public List<SysOperLog> SelectOperLogList(SysOperLogDto operLog, PagerInfo pager)
|
||||
public PagedInfo<SysOperLog> SelectOperLogList(SysOperLogDto operLog, PagerInfo pager)
|
||||
{
|
||||
operLog.BeginTime = DateTimeHelper.GetBeginTime(operLog.BeginTime, -1);
|
||||
operLog.EndTime = DateTimeHelper.GetBeginTime(operLog.EndTime, 1);
|
||||
|
||||
@ -28,7 +28,7 @@ service.interceptors.request.use(config => {
|
||||
//将token放到请求头发送给服务器,将tokenkey放在请求头中
|
||||
config.headers.Token = getToken();
|
||||
} else {
|
||||
console.log(config)
|
||||
// console.log(config)
|
||||
}
|
||||
return config;
|
||||
}, error => {
|
||||
|
||||
@ -204,7 +204,7 @@ export default {
|
||||
listGendemo(this.addDateRange(this.queryParams, this.timeRange)).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.dataList = res.data.result;
|
||||
this.total = res.data.totalCount;
|
||||
this.total = res.data.totalNum;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@ -291,7 +291,7 @@ export default {
|
||||
this.loading = true;
|
||||
queryTasks(this.queryParams).then((response) => {
|
||||
this.dataTasks = response.data.result;
|
||||
this.total = response.data.totalCount;
|
||||
this.total = response.data.totalNum;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
@ -161,7 +161,7 @@ export default {
|
||||
listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(
|
||||
(response) => {
|
||||
this.jobLogList = response.data.result;
|
||||
this.total = response.data.totalCount;
|
||||
this.total = response.data.totalNum;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
|
||||
@ -100,7 +100,7 @@ export default {
|
||||
listArticle(this.queryParams).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.dataList = res.data.result;
|
||||
this.total = res.data.totalCount;
|
||||
this.total = res.data.totalNum;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -170,7 +170,7 @@ export default {
|
||||
listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(
|
||||
(response) => {
|
||||
this.configList = response.data.result;
|
||||
this.total = response.data.totalCount;
|
||||
this.total = response.data.totalNum;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
|
||||
@ -160,7 +160,7 @@ export default {
|
||||
this.loading = true;
|
||||
listPost(this.queryParams).then((response) => {
|
||||
this.postList = response.data.result;
|
||||
this.total = response.data.totalCount;
|
||||
this.total = response.data.totalNum;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
@ -151,7 +151,7 @@ export default {
|
||||
|
||||
getGenTable(this.queryParams).then((res) => {
|
||||
this.tableData = res.data.result;
|
||||
this.total = res.data.totalCount;
|
||||
this.total = res.data.totalNum;
|
||||
this.tableloading = false;
|
||||
});
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user