You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

174 lines
3.8 KiB

using learun.iapplication;
using learun.util;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace EC.Web.Areas.LR_OrganizationModule.Controllers
{
/// <summary>
/// 版 本 EasyCode EC管理后台
/// Copyright (c) 2019-present EC管理有限公司
/// 创建人:tobin
/// 日 期:2019.09.27
/// 描 述:公司模块控制器
/// </summary>
[Area("LR_OrganizationModule")]
public class CompanyController : MvcControllerBase
{
private readonly CompanyIBLL _companyIBLL;
public CompanyController(CompanyIBLL companyIBLL)
{
_companyIBLL = companyIBLL;
}
#region 视图功能
/// <summary>
/// 主页面
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Index()
{
return View();
}
/// <summary>
/// 表单页
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Form()
{
return View();
}
#endregion 视图功能
#region 获取数据
/// <summary>
/// 获取公司列表信息
/// </summary>
/// <param name="keyword">查询关键字</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetList(string keyword)
{
var data = await _companyIBLL.GetList(keyword);
return Success(data);
}
/// <summary>
/// 获取公司列表信息
/// </summary>
/// <param name="pid">父级id</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetListByPId(string pid)
{
var data = await _companyIBLL.GetListByPId(pid);
return Success(data);
}
/// <summary>
/// 获取树形数据
/// </summary>
/// <param name="parentId">父级id</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetTree(string parentId)
{
var data = await _companyIBLL.GetTree(parentId);
return Success(data);
}
/// <summary>
/// 获取公司实体数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetEntity(string keyValue)
{
var data = await _companyIBLL.GetEntity(keyValue);
return Success(data);
}
#endregion 获取数据
#region 2
/// <summary>
/// 获取公司列表信息
/// </summary>
/// <param name="queryJson">查询关键字</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetList2(string queryJson)
{
var queryParam = queryJson.ToJObject();
if (queryParam["CompanyId"].IsEmpty())
queryParam["CompanyId"] = CurrentUser().Result.F_CompanyId;
var data = await _companyIBLL.GetList2(queryParam);
return Success(data);
}
/// <summary>
/// 获取树形数据
/// </summary>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetTree2()
{
var user = CurrentUser().Result;
var data = await _companyIBLL.GetTree2(user.F_CompanyId);
return Success(data);
}
#endregion 2
#region 提交数据
/// <summary>
/// 保存表单数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <param name="entity">实体数据</param>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public async Task<IActionResult> SaveForm(string keyValue, CompanyEntity entity)
{
if (string.IsNullOrEmpty(entity.F_ParentId))
{
entity.F_ParentId = CurrentUser().Result.F_CompanyId;
}
await _companyIBLL.SaveEntity(keyValue, entity);
return SuccessInfo("保存成功!");
}
/// <summary>
/// 删除表单数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public async Task<IActionResult> DeleteForm(string keyValue)
{
await _companyIBLL.Delete(keyValue);
return SuccessInfo("删除成功!");
}
#endregion 提交数据
}
}