IDbConnection con = Dal.AbsConnection.GetDbConnection();
[HttpGet]
[Route("api/Page")]
public IHttpActionResult Paging(int PageIndex=1)
{
var para = new DynamicParameters();
para.Add("@TableName", "DayWord d join DayType dt on d.Dtid = dt.Did");
para.Add("@FiledName", "*");
para.Add("@OrderFiled", "d.Id");
para.Add("@WhereStr", "");
para.Add("@PageIndex", PageIndex);
para.Add("@PageSize", 2);
para.Add("@TotalCount", 0, DbType.Int32, ParameterDirection.Output);
int total = 0;
var list = con.Query<AllProduct>("PagingSix", para, null, true, null, CommandType.StoredProcedure).ToList();
total = para.Get<int>("@TotalCount");
return Ok(new { data = list, totalCount = total });
}
[HttpGet]
[Route("api/Export")]
public void GetExport()
{
List<AllProduct> list = null;
string str = "select * from DayWord d join DayType dt on d.Dtid = dt.Did";
list = con.Query<AllProduct>(str).ToList();
//序列化
string sql = JsonConvert.SerializeObject(list);
//反序列化
DataTable dt = JsonConvert.DeserializeObject<DataTable>(sql);
ExcelHelper.ExportByWeb(dt, "日志信息", "dayWord.xls");
}
}