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.

146 lines
3.2 KiB

3 years ago
using System.Collections.Generic;
using EC.App.AutoWeight.Driver;
using learun.util;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace EC.Web.Areas.AutoWeight.Controllers
{
/// <summary>
/// 汽车衡
/// Copyright (c) 2019-present 汽车衡
/// 创建人:lxc
/// 日 期: 2020-11-10 21:47:57
/// 描 述: 驾驶员 aw_driver
/// </summary>
[Area("AutoWeight")]
public class DriverController : MvcControllerBase
{
private readonly DriverIBll _bll;
public DriverController(DriverIBll 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 获取数据
/// <summary>
/// 获取表单数据
/// </summary>
/// <param name="keyValue">主键</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetForm(string keyValue)
{
var driverEntity = await _bll.GetEntity(keyValue);
var jsonData = new
{
driverEntity
};
return Success(jsonData);
}
/// <summary>
/// 获取主表aw_driver的所有列表数据
/// </summary>
/// <param name="queryJson">查询参数,json字串</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetList(string queryJson)
{
var list = await _bll.GetList(queryJson);
return Success(list);
}
/// <summary>
/// 获取主表aw_driver的分页列表数据
/// </summary>
/// <param name="pagination">分页参数</param>
/// <param name="queryJson">查询参数,json字串</param>
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetPageList(string pagination, string queryJson)
{
var pageObj = pagination.ToObject<Pagination>();
var queryParam = queryJson.ToJObject();
var list = (!queryParam["SupplierId"].IsEmpty()) ? await _bll.GetPageList(pageObj, queryParam) : new List<DriverEntity>();
var jsonData = new
{
rows = list,
pageObj.total,
pageObj.page,
pageObj.records
};
return Success(jsonData);
}
[HttpGet]
[AjaxOnly]
public async Task<IActionResult> GetTree(int? supplierId)
{
var data = await _bll.GetTree(supplierId);
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_driver实体数据</param>
/// <returns></returns>
[HttpPost]
[AjaxOnly]
public async Task<IActionResult> SaveForm(string keyValue, DriverEntity entity)
{
var res = await _bll.SaveEntity(keyValue, entity);
return Success("保存成功!", res);
}
#endregion 提交数据
}
}