|
- using Nancy;
- using Learun.Util;
- using System.Collections.Generic;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using System.Linq;
- using Learun.Application.Organization;
- using System;
-
- namespace Learun.Application.WebApi
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-06-17 16:28
- /// 描 述:日志发送
- /// </summary>
- public class JournalApi : BaseApi
- {
- private JournalSendIBLL journalIBLL = new JournalSendBLL();
- private JournalReceiveIBLL journalReceiveIBLL = new JournalReceiveBLL();
- private UserIBLL userIBLL = new UserBLL();
-
- /// <summary>
- /// 注册接口
- /// <summary>
- public JournalApi()
- : base("/Learun/adms/EducationalAdministration/Journal")
- {
- Get["/pagelist"] = GetPageList;
- Get["/list"] = GetList;
- Get["/form"] = GetForm;
- Post["/delete"] = DeleteForm;
- Post["/save"] = SaveForm;
- Post["/saveDraft"] = SaveDraft;
- Post["/savePt"] = SavePt;
- Post["/send"] = Send;
-
- }
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = journalIBLL.GetPageList(parameter.pagination, parameter.queryJson);
- if (data != null)
- {
- foreach (var item in data)
- {
- item.JContent = WebHelper.HtmlDecode(item.JContent);
- }
- }
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = data.Count()
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetList(dynamic _)
- {
- string queryJson = this.GetReqData();
- var data = journalIBLL.GetList(queryJson);
- var result = data.ToList().Where(a => a.JSenderId == userInfo.userId || a.JReceiveId.Contains(userInfo.userId));
- return Success(result);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- var JournalSendData = journalIBLL.GetJournalSendEntityNoHtml(keyValue);
- if (JournalSendData != null)
- {
- JournalSendData.JContent = WebHelper.HtmlDecode(JournalSendData.JContent);
- }
- var jsonData = new
- {
- JournalSend = JournalSendData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response DeleteForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- journalIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- JournalSendEntity entity = parameter.strEntity.ToObject<JournalSendEntity>();
- var userInfo = LoginUserInfo.Get();
- entity.JSenderId = userInfo.userId;
- entity.JSender = userInfo.realName;
- entity.JReceive = userIBLL.GetEntityByUserId(entity.JReceiveId).F_RealName;
- entity.JIsSend = true;
- entity.JSendTime = DateTime.Now;
- journalIBLL.SaveEntity(this.userInfo, parameter.keyValue, entity);
-
-
- var receiveEntity = new JournalReceiveEntity();
- receiveEntity.JContent = entity.JContent;
- receiveEntity.JReceive = entity.JReceive;
- receiveEntity.JReceiveId = entity.JReceiveId;
- receiveEntity.JSender = entity.JSender;
- receiveEntity.JSenderId = entity.JSenderId;
- receiveEntity.JSendTime = entity.JSendTime;
- receiveEntity.JTitle = entity.JTitle;
- receiveEntity.JTypeId = entity.JTypeId;
- receiveEntity.JIsRead = false;
-
- journalReceiveIBLL.SaveEntity("", receiveEntity);
- return Success("保存成功!");
- }
-
- public Response SaveDraft(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- JournalSendEntity entity = parameter.strEntity.ToObject<JournalSendEntity>();
- var userInfo = LoginUserInfo.Get();
- entity.JSenderId = userInfo.userId;
- entity.JSender = userInfo.realName;
- entity.JReceive = userIBLL.GetEntityByUserId(entity.JReceiveId).F_RealName;
- entity.JIsSend = false;
- entity.JSendTime = DateTime.Now;
- journalIBLL.SaveEntity(this.userInfo, parameter.keyValue, entity);
-
- return Success("保存成功!");
- }
- public Response SavePt(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- JournalSendEntity entity = parameter.strEntity.ToObject<JournalSendEntity>();
- var userInfo = LoginUserInfo.Get();
- //entity.JContent = WebHelper.HtmlDecode(entity.JContent);
- entity.JSenderId = userInfo.userId;
- entity.JSender = userInfo.realName;
- entity.JIsSend = false;
- entity.JSendTime = DateTime.Now;
- journalIBLL.SaveEntity(parameter.keyValue, entity);
-
- return Success("保存成功!");
- }
-
- public Response Send(dynamic _)
- {
- string keyValue = this.GetReqData();
- journalIBLL.Send(keyValue);
- return Success("发送成功!");
- }
- #endregion
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- }
- #endregion
-
- }
- }
|