|
|
@@ -0,0 +1,64 @@ |
|
|
|
using Learun.Application.OA; |
|
|
|
using Learun.Util; |
|
|
|
using Nancy; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
namespace Learun.Application.WebApi.Modules.Echarts |
|
|
|
{ |
|
|
|
public class EchartsApi : BaseNoAuthentication |
|
|
|
{ |
|
|
|
|
|
|
|
private NewsIBLL newsIBLL = new NewsBLL(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EchartsApi() : base("/api/echarts/") |
|
|
|
{ |
|
|
|
Get["/notice/sum"] = NoticeSum; |
|
|
|
Get["/notice/monthsum"] = NoticeMonthSum; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 新闻数量 |
|
|
|
/// </summary> |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public Response NoticeSum(dynamic _) |
|
|
|
{ |
|
|
|
var sum = newsIBLL.GetNewCount(); |
|
|
|
var res = new { value = sum }; |
|
|
|
|
|
|
|
return Res(res); |
|
|
|
} |
|
|
|
|
|
|
|
public Response NoticeMonthSum(dynamic _) |
|
|
|
{ |
|
|
|
var dic = newsIBLL.GetMonthCount(); |
|
|
|
var m = 0; |
|
|
|
while (m<13) |
|
|
|
{ |
|
|
|
m++; |
|
|
|
if(!dic.ContainsKey(m)) |
|
|
|
{ |
|
|
|
dic.Add(m, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
var cate = new List<string>(); |
|
|
|
var data = new List<int>(); |
|
|
|
for (int i = 1; i < 13; i++) |
|
|
|
{ |
|
|
|
cate.Add($"{i}月"); |
|
|
|
data.Add(dic[i]); |
|
|
|
} |
|
|
|
|
|
|
|
var res = new { categories = cate, series = new List<object> { new { name = "公告", data = data } } }; |
|
|
|
return Res(res); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |