using learun.iapplication; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; namespace EC.Web.Areas.LR_OrganizationModule.Controllers { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2019.09.27 /// 描 述:部门模块控制器 /// [Area("LR_OrganizationModule")] public class DepartmentController : MvcControllerBase { private readonly DepartmentIBLL _departmentIBLL; private readonly CompanyIBLL _companyIBLL; public DepartmentController(DepartmentIBLL departmentIBLL, CompanyIBLL companyIBLL) { _departmentIBLL = departmentIBLL; _companyIBLL = companyIBLL; } #region 获取视图 /// /// 主页 /// /// [HttpGet] public IActionResult Index() { return View(); } /// /// 表单 /// /// [HttpGet] public IActionResult Form() { return View(); } #endregion 获取视图 #region 获取数据 /// /// 获取部门列表信息(根据公司Id) /// /// 公司Id /// 查询关键字 /// [HttpGet] [AjaxOnly] public async Task GetList(string companyId, string keyword) { var data = await _departmentIBLL.GetList(companyId, keyword); return Success(data); } /// /// 获取部门列表信息(根据公司Id 和 父级 id) /// /// 公司主键 /// 父级 id /// [HttpGet] [AjaxOnly] public async Task GetListByPid(string companyId, string pid) { var data = await _departmentIBLL.GetListByPid(companyId, pid); return Success(data); } /// /// 获取树形数据 /// /// 公司id /// 父级id /// [HttpGet] [AjaxOnly] public async Task GetTree(string companyId, string parentId) { if (string.IsNullOrEmpty(companyId)) { var companylist = await _companyIBLL.GetList(); var data = await _departmentIBLL.GetTree(companylist); return Success(data); } else { var data = await _departmentIBLL.GetTree(companyId, parentId); return Success(data); } } /// /// 获取部门实体数据 /// /// 部门主键 /// [HttpGet] [AjaxOnly] public async Task GetEntity(string departmentId) { var data = await _departmentIBLL.GetEntity(departmentId); return Success(data); } #endregion 获取数据 #region 提交数据 /// /// 保存表单数据 /// /// /// /// [HttpPost] [AjaxOnly] public async Task SaveForm(string keyValue, DepartmentEntity entity) { await _departmentIBLL.SaveEntity(keyValue, entity); return SuccessInfo("保存成功!"); } /// /// 删除表单数据 /// /// /// [HttpPost] [AjaxOnly] public async Task DeleteForm(string keyValue) { await _departmentIBLL.Delete(keyValue); return SuccessInfo("删除成功!"); } #endregion 提交数据 } }