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.

134 lines
2.8 KiB

3 years ago
using EC.App.AutoWeight.Site;
using learun.util;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace EC.Web.Areas.AutoWeight.Controllers
{
[Area("AutoWeight")]
public class SiteController : MvcControllerBase
{
private readonly SiteIBll _bll;
public SiteController(SiteIBll bll)
{
_bll = bll;
}
#region 视图功能
/// <summary>
/// 视图
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Index()
{
return View();
}
/// <summary>
/// 视图
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Form()
{
return View();
}
#endregion 视图功能
#region 获取数据
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetForm(string keyValue)
{
var driverEntity = await _bll.GetEntity(keyValue);
var jsonData = new
{
driverEntity
};
return Success(jsonData);
}
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetList(string queryJson)
{
var queryParam = queryJson.ToJObject();
if (queryParam["CompanyId"].IsEmpty())
queryParam["CompanyId"] = CurrentUser().Result.F_CompanyId;
var list = await _bll.GetList(queryParam);
return Success(list);
}
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetPageList(string pagination, string queryJson)
{
var pageObj = pagination.ToObject<Pagination>();
var queryParam = queryJson.ToJObject();
if (queryParam["CompanyId"].IsEmpty())
queryParam["CompanyId"] = CurrentUser().Result.F_CompanyId;
var list = await _bll.GetPageList(pageObj, queryParam);
var jsonData = new
{
rows = list,
pageObj.total,
pageObj.page,
pageObj.records
};
return Success(jsonData);
}
/// <summary>
/// 获取树形数据
/// </summary>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetTree(string companyId)
{
if (companyId == null) throw new ArgumentNullException(nameof(companyId));
var data = await _bll.GetTree(companyId);
return this.Success(data);
}
#endregion 获取数据
#region 提交数据
/// <summary>
/// 删除表单数据
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public async Task<IActionResult> DeleteForm(string keyValue)
{
await _bll.Delete(keyValue);
return SuccessInfo("删除成功!");
}
/// <summary>
/// 新增,更新
/// </summary>
/// <param name="keyValue">主键值</param>
/// <param name="entity">aw_auth实体数据</param>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public async Task<IActionResult> SaveForm(string keyValue, SiteEntity entity)
{
var res = await _bll.SaveEntity(keyValue, entity);
return Success("保存成功!", res);
}
#endregion 提交数据
}
}