ソースを参照

接口:公告总数量、公告当年月数据曲线

应县
北京泉江 1年前
コミット
3da0322a05
6個のファイルの変更124行の追加0行の削除
  1. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj
  2. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/BaseNoAuthentication.cs
  3. +64
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/Echarts/EchartsApi.cs
  4. +38
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsBLL.cs
  5. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsIBLL.cs
  6. +13
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj ファイルの表示

@@ -190,6 +190,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Bootstraper.cs" />
<Compile Include="Modules\Echarts\EchartsApi.cs" />
<Compile Include="Modules\EducationalAdministration\ArrangeExamTermApi.cs" />
<Compile Include="Modules\EducationalAdministration\ArrangeExamTermNewApi.cs" />
<Compile Include="Modules\SSOApi.cs" />


+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/BaseNoAuthentication.cs ファイルの表示

@@ -151,6 +151,10 @@ namespace Learun.Application.WebApi
}
#endregion

public Response Res(object data)
{
return Response.AsText(data.ToJson()).WithContentType("application/json");
}

#region 异常抓取


+ 64
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/Echarts/EchartsApi.cs ファイルの表示

@@ -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);
}

}
}

+ 38
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsBLL.cs ファイルの表示

@@ -170,6 +170,44 @@ namespace Learun.Application.OA
}
}

public int GetNewCount()
{
try
{
return newsService.GetNewSum();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

public Dictionary<int, int> GetMonthCount()
{
try
{
return newsService.GetNewMonthSum();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

#endregion
}
}

+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsIBLL.cs ファイルの表示

@@ -48,5 +48,9 @@ namespace Learun.Application.OA
#endregion

void ChangeStatusByProcessId(string parameterProcessId, int p1);

int GetNewCount();

Dictionary<int, int> GetMonthCount();
}
}

+ 13
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs ファイルの表示

@@ -11,6 +11,7 @@ using Nancy.Helpers;
using System.Configuration;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Linq;

namespace Learun.Application.OA
{
@@ -287,6 +288,18 @@ namespace Learun.Application.OA
}
}


public int GetNewSum()
{
return this.BaseRepository().FindList<NewsEntity>().Count();
}

public Dictionary<int,int> GetNewMonthSum()
{
var dt = new DateTime(DateTime.Now.Year, 1, 1);
var ls = this.BaseRepository().FindList<NewsEntity>(x=>x.F_CreateDate>=dt).Select(x => new { Year = x.F_CreateDate.Value.Year, Month = x.F_CreateDate.Value.Month }).GroupBy(x => new { x.Year, x.Month }).ToDictionary(x => x.Key.Month, a => a.Count());
return ls;
}
}

//public class Root


読み込み中…
キャンセル
保存