|
- using Learun.Application.Organization;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using Learun.Util;
- using Learun.Util.Operat;
- using System.Linq;
- using System.Web.Mvc;
-
- namespace Learun.Application.Web.Areas.LR_OrganizationModule.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.03.09
- /// 描 述:公司管理
- /// </summary>
- public class CompanyController : MvcControllerBase
- {
- private CompanyIBLL companyIBLL = new CompanyBLL();
- private ArrangeLessonSyncIBLL arrangeLessonSyncIBLL = new ArrangeLessonSyncBLL();
-
- #region 获取视图
- /// <summary>
- /// 主页
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 表单
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
- /// <summary>
- /// 获取公司列表信息
- /// </summary>
- /// <param name="keyword">查询关键字</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetList(string keyword)
- {
- var data = companyIBLL.GetList(keyword);
- foreach (var item in data)
- {
- item.F_BriefIntroduction = WebHelper.HtmlDecode(item.F_BriefIntroduction);
- item.F_EnrollmentInformation = WebHelper.HtmlDecode(item.F_EnrollmentInformation);
- }
- return JsonResult(data);
- }
- /// <summary>
- /// 获取树形数据
- /// </summary>
- /// <param name="parentId">父级id</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetTree(string parentId)
- {
- var data = companyIBLL.GetTree(parentId);
- return JsonResult(data);
- }
- /// <summary>
- /// 获取映射数据
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetMap(string ver)
- {
- var data = companyIBLL.GetModelMap();
- 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);
- }
- }
- #endregion
-
- #region 提交数据
- /// <summary>
- /// 保存表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体数据</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- [ValidateInput(false)]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- CompanyEntity entity = strEntity.ToObject<CompanyEntity>();
- entity.SyncFlag = false;
- entity.F_BriefIntroduction = WebHelper.HtmlEncode(entity.F_BriefIntroduction);
- entity.F_EnrollmentInformation = WebHelper.HtmlEncode(entity.F_EnrollmentInformation);
- var list = companyIBLL.GetList();
- if (!string.IsNullOrEmpty(keyValue))
- {
- entity.SyncFlag = true;
- //判断排课同步数据是否存在:若存在,清除同步数据;
- var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
- if (arrangeLessonSyncList.Any())
- {
- arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
- }
- else
- {
- entity.SyncFlag = false;
- }
-
- list = list.Where(m => m.F_CompanyId != keyValue).ToList();
- }
- if (keyValue == entity.F_ParentId)
- {
- return Fail("操作失败,当前项不允许");
- }
-
- if (list.Any(a => a.F_FullName == entity.F_FullName))
- {
- return Fail("学校名称重复");
- }
-
- if (list.Any(a => a.F_EnCode == entity.F_EnCode))
- {
- return Fail("学校编码重复");
- }
-
- if (list.Any(a => a.F_ShortName == entity.F_ShortName))
- {
- return Fail("学校简称重复");
- }
- companyIBLL.SaveEntity(keyValue, entity);
- return Success("保存成功!", "公司信息", string.IsNullOrEmpty(keyValue) ? OperationType.Create : OperationType.Update, entity.F_CompanyId, entity.ToJson());
- }
- /// <summary>
- /// 删除表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- var list = companyIBLL.GetList().Where(x => x.F_ParentId == keyValue && x.F_EnabledMark == 1 && x.F_DeleteMark == 0);
- if (list.Count() > 0)
- {
- return Fail("删除失败!拥有下辖项不可直接删除");
- }
- else
- {
- companyIBLL.VirtualDelete(keyValue);
- return Success("删除成功!", "公司信息", OperationType.Delete, keyValue, "");
- }
- }
- #endregion
- }
- }
|