using System.Linq;
using Learun.Application.Organization;
using System.Web.Mvc;
namespace Learun.Application.Web.Areas.LR_OrganizationModule.Controllers
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:陈彬彬
/// 日 期:2017.03.09
/// 描 述:岗位管理
///
public class PostController : MvcControllerBase
{
private PostIBLL postIBLL = new PostBLL();
private CompanyIBLL companyIBLL = new CompanyBLL();
#region 获取视图
///
/// 主页
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 表单
///
///
[HttpGet]
public ActionResult Form()
{
return View();
}
///
/// 岗位选择页面
///
///
[HttpGet]
public ActionResult SelectForm()
{
return View();
}
#endregion
#region 获取数据
///
/// 获取岗位列表信息
///
/// 查询关键字
///
[HttpGet]
[AjaxOnly]
public ActionResult GetList(string companyId, string keyword, string departmentId)
{
var data = postIBLL.GetList(companyId, keyword, departmentId);
return JsonResult(data);
}
///
/// 获取树形数据
///
/// 公司主键
///
[HttpGet]
[AjaxOnly]
public ActionResult GetTree(string companyId)
{
var data = postIBLL.GetTree(companyId);
return JsonResult(data);
}
[HttpGet]
[AjaxOnly]
public ActionResult GetAllTree(string companyId, string parentId)
{
if (string.IsNullOrEmpty(companyId))
{
var companylist = companyIBLL.GetList();
var data = postIBLL.GetAllTree(companylist);
return JsonResult(data);
}
else
{
var data = postIBLL.GetTree(companyId, parentId);
return JsonResult(data);
}
}
///
/// 获取岗位名称
///
/// 岗位主键
///
[HttpGet]
[AjaxOnly]
public ActionResult GetEntityName(string keyValue)
{
if (keyValue == "0")
{
return SuccessString("");
}
var data = postIBLL.GetEntity(keyValue);
return SuccessString(data.F_Name);
}
///
/// 获取岗位实体数据
///
/// 岗位主键
///
[HttpGet]
[AjaxOnly]
public ActionResult GetEntity(string keyValue)
{
var data = postIBLL.GetEntity(keyValue);
return JsonResult(data);
}
#endregion
#region 提交数据
///
/// 保存表单数据
///
/// 主键
/// 实体
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, PostEntity entity)
{
var list = postIBLL.GetList(entity.F_CompanyId);
if (list.Any(a => a.F_EnCode == entity.F_EnCode))
{
return Fail("岗位编号重复");
}
postIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
}
///
/// 删除表单数据
///
/// 主键
///
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
postIBLL.VirtualDelete(keyValue);
return Success("删除成功!");
}
#endregion
}
}