|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- using Learun.Application.Base.SystemModule;
- using Learun.Util;
- using System.Web.Mvc;
-
- namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.04.01
- /// 描 述:数据源管理
- /// </summary>
- public class DataSourceController : MvcControllerBase
- {
- DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
-
- #region 获取视图
- /// <summary>
- /// 管理页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 表单页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- /// <summary>
- /// 测试页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult TestForm()
- {
- return View();
- }
- /// <summary>
- /// 选择页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult SelectForm()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
- /// <summary>
- /// 获取分页数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="keyword">关键字</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string keyword)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = dataSourceIBLL.GetPageList(paginationobj, keyword);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records,
- };
- return JsonResult(jsonData);
- }
- /// <summary>
- /// 获取所有数据源数据列表
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetList()
- {
- var data = dataSourceIBLL.GetList();
- return JsonResult(data);
- }
- /// <summary>
- /// 获取所有数据源实体根据编号
- /// </summary>
- /// <param name="keyValue">编号</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetEntityByCode(string keyValue)
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- return Success("");
- }
- else
- {
- var data = dataSourceIBLL.GetEntityByCode(keyValue.Split(',')[0]);
- return JsonResult(data);
- }
-
- }
- /// <summary>
- /// 获取所有数据源实体根据编号
- /// </summary>
- /// <param name="keyValue">编号</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetNameByCode(string keyValue)
- {
- if (string.IsNullOrEmpty(keyValue))
- {
- return SuccessString("");
- }
- else
- {
- var data = dataSourceIBLL.GetEntityByCode(keyValue.Split(',')[0]);
- if (data != null)
- {
- return SuccessString(data.F_Name);
- }
- else
- {
- return SuccessString("");
- }
- }
-
- }
- #endregion
-
- #region 提交数据
- /// <summary>
- /// 保存表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, DataSourceEntity entity)
- {
- bool res = dataSourceIBLL.SaveEntity(keyValue, entity);
- if (res)
- {
- return Success("保存成功!");
- }
- else
- {
- return Fail("保存失败,编码重复!");
- }
- }
- /// <summary>
- /// 删除表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- dataSourceIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- #endregion
-
- #region 扩展方法
- /// <summary>
- /// 获取数据源数据
- /// </summary>
- /// <param name="code">数据源编号</param>
- /// <param name="strWhere">sql查询条件语句</param>
- /// <param name="queryJson">数据源请求条件字串</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetDataTable(string code, string strWhere, string queryJson)
- {
- var data = dataSourceIBLL.GetDataTable(code, strWhere, queryJson);
- return JsonResult(data);
- }
- /// <summary>
- /// 获取数据源数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="code">数据源编号</param>
- /// <param name="strWhere">sql查询条件语句</param>
- /// <param name="queryJson">数据源请求条件字串</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetDataTablePage(string pagination, string code, string strWhere, string queryJson)
- {
-
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = dataSourceIBLL.GetDataTable(code, paginationobj, strWhere, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records,
- };
- return JsonResult(jsonData);
- }
- /// <summary>
- /// 获取数据源列名
- /// </summary>
- /// <param name="code">数据源编码</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetDataColName(string code)
- {
- var data = dataSourceIBLL.GetDataColName(code);
- return JsonResult(data);
- }
-
- /// <summary>
- /// 获取数据源数据
- /// </summary>
- /// <param name="code">数据源编号</param>
- /// <param name="strWhere">sql查询条件语句</param>
- /// <param name="queryJson">数据源请求条件字串</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetMap(string code, string ver)
- {
- var data = dataSourceIBLL.GetDataTable(code, "");
-
- string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
- if (md5 == ver)
- {
- return Success("no update");
- }
- else
- {
- var jsondata = new
- {
- data = data,
- ver = md5
- };
- return JsonResult(jsondata);
- }
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetTree(string code, string parentId, string Id, string showId)
- {
- var data = dataSourceIBLL.GetTree(code, parentId, Id, showId);
- return JsonResult(data);
- }
- #endregion
- }
- }
|