using Nancy;
using Learun.Util;
using System.Collections.Generic;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Application.TwoDevelopment.LogisticsManagement;
using System;
using Learun.Application.WorkFlow;
namespace Learun.Application.WebApi
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2020-06-03 14:29
/// 描 述:系部数据
///
public class PurchaseOtherApplyApi : BaseApi
{
private Purchase_Other_ApplyIBLL PurchaseOtherIBLL = new Purchase_Other_ApplyBLL();
private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
///
/// 注册接口
///
public PurchaseOtherApplyApi()
: base("/learun/adms/PurchaseOtherapply")
{
Get["/pagelist"] = GetPageList;
Get["/form"] = GetForm;
Post["/delete"] = DeleteForm;
Post["/save"] = SaveForm;
Post["/submit"] = Submit;
Get["/shList"] = GetshList;
}
#region 获取数据
///
/// 获取页面显示列表分页数据
///
///
///
public Response GetPageList(dynamic _)
{
ReqPageParam parameter = this.GetReqData();
var data = PurchaseOtherIBLL.GetPageList(parameter.pagination, parameter.queryJson);
var jsonData = new
{
rows = data,
total = parameter.pagination.total,
page = parameter.pagination.page,
records = parameter.pagination.records
};
return Success(jsonData);
}
///
/// 获取表单数据
///
///
///
public Response GetForm(dynamic _)
{
string keyValue = this.GetReqData();
var Purchase_OtherData = PurchaseOtherIBLL.GetPurchase_Other_ApplyEntity(keyValue);
var Purchase_Other_DetailsData = PurchaseOtherIBLL.GetPurchase_Other_ApplydetailsList(Purchase_OtherData.Id);
var jsonData = new
{
Purchase_Other = Purchase_OtherData,
Purchase_Other_Details = Purchase_Other_DetailsData,
};
return Success(jsonData);
}
///
/// 获取页面显示列表数据
///
///
///
public Response GetshList(dynamic _)
{
Purchase_Other_ApplyEntity parameter = this.GetReqData();
var Purchase_OtherData = PurchaseOtherIBLL.GetEntityByProcessId(parameter.ProcessId);
var Purchase_Other_DetailsData = PurchaseOtherIBLL.GetPurchase_Other_ApplydetailsList(Purchase_OtherData.Id);
var jsonData = new
{
Purchase_Other = Purchase_OtherData,
Purchase_Other_Details = Purchase_Other_DetailsData,
};
return Success(jsonData);
}
#endregion
#region 提交数据
///
/// 删除实体数据
///
///
///
public Response DeleteForm(dynamic _)
{
string keyValue = this.GetReqData();
PurchaseOtherIBLL.DeleteEntity(keyValue);
return Success("删除成功!");
}
///
/// 保存实体数据(新增、修改)
///
///
///
public Response SaveForm(dynamic _)
{
//Purchase_OtherEntity entity = strEntity.ToObject();
//List purchase_Other_DetailsList = strpurchase_Other_DetailsList.ToObject>();
//Purchase_OtherIBLL.SaveEntity(keyValue, entity, purchase_Other_DetailsList);
ReqFormEntity parameter = this.GetReqData();
Purchase_Other_ApplyEntity entity = parameter.strEntity.ToObject();
List detailList = parameter.DetailList.ToObject>();
//var code = entity.EnCode;
if (detailList != null)
{
if (detailList.Count == 0)
{
return Fail("请添加明细");
}
}
string id=PurchaseOtherIBLL.SaveEntity(parameter.keyValue, entity, detailList);
var json = new
{
Id = id
};
return Success(json);
}
///
/// 提交
///
///
///
public Response Submit(dynamic _)
{
Purchase_Other_ApplyEntity parameter = this.GetReqData();
//string keyValue = this.GetReqData();
//var processId = Guid.NewGuid().ToString();
PurchaseOtherIBLL.ModifyStatus(parameter.Id, 1, parameter.ProcessId);
//UserInfo userInfo = LoginUserInfo.Get();
//nWFProcessIBLL.CreateFlow("1-2", processId, "", 1, "", userInfo);
return Success("提交成功!");
}
#endregion
#region 私有类
///
/// 表单实体类
///
private class ReqFormEntity
{
public string keyValue { get; set; }
public string strEntity { get; set; }
public string DetailList { get; set; }
}
#endregion
}
}