147 lines
4.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Learun.Application.Organization;
using Learun.Util;
using System.Web.Mvc;
namespace Learun.Application.Web.Areas.LR_OrganizationModule.Controllers
{
/// <summary>
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 Hexagon PPM
/// 创建人:研发部
/// 日 期2017.04.17
/// 描 述:部门管理
/// </summary>
public class DepartmentController : MvcControllerBase
{
private DepartmentIBLL departmentIBLL = new DepartmentBLL();
private CompanyIBLL companyIBLL = new CompanyBLL();
#region
/// <summary>
/// 主页
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult Index()
{
return View();
}
/// <summary>
/// 表单
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult Form()
{
return View();
}
#endregion
#region
/// <summary>
/// 获取部门列表信息(根据公司Id)
/// </summary>
/// <param name="companyId">公司Id</param>
/// <param name="keyWord">查询关键字</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetList(string companyId,string keyword)
{
//if (string.IsNullOrEmpty(companyId) && string.IsNullOrEmpty(keyword))
//{
// return Success(departmentIBLL.GetAllList());
//}
var data = departmentIBLL.GetList(companyId, keyword);
return Success(data);
}
/// <summary>
/// 获取树形数据
/// </summary>
/// <param name="companyId">公司id</param>
/// <param name="parentId">父级id</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetTree(string companyId, string parentId)
{
if (string.IsNullOrEmpty(companyId))
{
var companylist = companyIBLL.GetList();
var data = departmentIBLL.GetTree(companylist);
return Success(data);
}
else
{
var data = departmentIBLL.GetTree(companyId, parentId);
return Success(data);
}
}
/// <summary>
/// 获取部门实体数据
/// </summary>
/// <param name="companyId"></param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetEntity(string departmentId)
{
var data = departmentIBLL.GetEntity(departmentId);
return Success(data);
}
/// <summary>
/// 获取映射数据
/// </summary>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetMap(string ver)
{
var data = departmentIBLL.GetModelMap();
string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
if (md5 == ver)
{
return Success("no update");
}
else
{
var jsondata = new
{
data = data,
ver = md5
};
return Success(jsondata);
}
}
#endregion
#region
/// <summary>
/// 保存表单数据
/// </summary>
/// <param name="keyValue"></param>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, DepartmentEntity entity)
{
departmentIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
}
/// <summary>
/// 删除表单数据
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
departmentIBLL.VirtualDelete(keyValue);
return Success("删除成功!");
}
#endregion
}
}