|
|
@@ -0,0 +1,116 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Web; |
|
|
|
using Learun.Application.TwoDevelopment.EducationalAdministration; |
|
|
|
using Learun.Util; |
|
|
|
using Nancy; |
|
|
|
|
|
|
|
namespace Learun.Application.WebApi.Modules |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
/// 通讯录 |
|
|
|
/// </summary> |
|
|
|
public class AddressBookApi : BaseApi |
|
|
|
{ |
|
|
|
public AddressBookApi() |
|
|
|
: base("/Learun/adms/PersonnelManagement/AddressBook") |
|
|
|
{ |
|
|
|
Get["/pagelist"] = GetPageList; |
|
|
|
Get["/list"] = GetList; |
|
|
|
Get["/form"] = GetForm; |
|
|
|
Post["/delete"] = DeleteForm; |
|
|
|
Post["/save"] = SaveForm; |
|
|
|
} |
|
|
|
|
|
|
|
private AddressBookIBLL addressBookIBLL = new AddressBookBLL(); |
|
|
|
|
|
|
|
#region 获取数据 |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 获取页面显示列表分页数据 |
|
|
|
/// <summary> |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public Response GetPageList(dynamic _) |
|
|
|
{ |
|
|
|
ReqPageParam parameter = this.GetReqData<ReqPageParam>(); |
|
|
|
var data = addressBookIBLL.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); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 获取页面显示列表数据 |
|
|
|
/// <summary> |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public Response GetList(dynamic _) |
|
|
|
{ |
|
|
|
string queryJson = this.GetReqData(); |
|
|
|
var data = addressBookIBLL.GetList(queryJson); |
|
|
|
return Success(data); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 获取表单数据 |
|
|
|
/// <summary> |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public Response GetForm(dynamic _) |
|
|
|
{ |
|
|
|
string keyValue = this.GetReqData(); |
|
|
|
var ClassWorkData = addressBookIBLL.GetEntity(keyValue); |
|
|
|
var jsonData = new |
|
|
|
{ |
|
|
|
ClassWork = ClassWorkData, |
|
|
|
}; |
|
|
|
return Success(jsonData); |
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 提交数据 |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 删除实体数据 |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <summary> |
|
|
|
/// <returns></returns> |
|
|
|
public Response DeleteForm(dynamic _) |
|
|
|
{ |
|
|
|
string keyValue = this.GetReqData(); |
|
|
|
addressBookIBLL.DeleteEntity(keyValue); |
|
|
|
return Success("删除成功!"); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 保存实体数据(新增、修改) |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <summary> |
|
|
|
/// <returns></returns> |
|
|
|
public Response SaveForm(dynamic _) |
|
|
|
{ |
|
|
|
ReqFormEntity parameter = this.GetReqData<ReqFormEntity>(); |
|
|
|
AddressBookEntity entity = parameter.strEntity.ToObject<AddressBookEntity>(); |
|
|
|
addressBookIBLL.SaveEntity(parameter.keyValue, entity); |
|
|
|
return Success("保存成功!"); |
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 私有类 |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 表单实体类 |
|
|
|
/// <summary> |
|
|
|
private class ReqFormEntity |
|
|
|
{ |
|
|
|
public string keyValue { get; set; } |
|
|
|
public string strEntity { get; set; } |
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|
} |