| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Common;
- using CallCenterApi.Interface.Models.Dto;
- using CallCenterApi.Interface.Models.Filter;
- using CallCenterApi.Interface.Models.Input;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers
- {
- //[Authority]
- public class ModuleInfoController : BaseController
- {
- private BLL.T_Sys_ModuleInfo moduleInfoBLL= new BLL.T_Sys_ModuleInfo();
-
- /// <summary>
- /// 返回树形下拉框 菜单数据
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetTreeList()
- {
- var ds_ModuleInfo = moduleInfoBLL.GetAllList();//DataSet
- List<Model.T_Sys_ModuleInfo> list_ModuleInfo = moduleInfoBLL.DataTableToList(ds_ModuleInfo.Tables[0]);
- list_ModuleInfo.Sort((x,y)=>x.F_Sort-y.F_Sort);//排序
- var treeList = new List<TreeModel>();
- foreach (var item in list_ModuleInfo)
- {
- TreeModel treeModel = new TreeModel();
- treeModel.id = item.F_ModuleId.ToString();
- treeModel.IconCls = item.F_ImgUrl;
- treeModel.text = item.F_ModuleName;
- treeModel.parentid = item.F_ParentID.ToString();
- treeList.Add(treeModel);
- }
- //return Content(treeList.ToJson());
- return Success("获取菜单树成功", treeList.TreeRecursion("0"));
- }
- [HttpGet]
- public ActionResult GetAllGrid(string keyword)
- {
- //TODO:计划使用缓存
- var ds_ModuleInfo = moduleInfoBLL.GetAllList();//DataSet 不在此处添加搜素条件,是因为计划改为缓存
- List<Model.T_Sys_ModuleInfo> list_ModuleInfo = moduleInfoBLL.DataTableToList(ds_ModuleInfo.Tables[0]);
- if (!string.IsNullOrEmpty(keyword))
- {
- list_ModuleInfo=list_ModuleInfo.TreeWhere(t => t.F_ModuleName.Contains(keyword), "F_ModuleId", "F_ParentID").ToList();
- }
- list_ModuleInfo.Sort((x, y) => x.F_Sort - y.F_Sort);//排序
- return Success("获取菜单", list_ModuleInfo);
-
- }
- /// <summary>
- /// 获取菜单实体
- /// </summary>
- /// <param name="mId"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetModule(int mId = 0)
- {
- var entity_ModuleInfo = moduleInfoBLL.GetModel(mId);
- if (entity_ModuleInfo != null)
- {
- return Success("加载菜单成功", new
- {
- name = entity_ModuleInfo.F_ModuleName,
- code = entity_ModuleInfo.F_ModuleCode,
- url = entity_ModuleInfo.F_OptUrl,
- enable = entity_ModuleInfo.F_StateFlag,
- remark = entity_ModuleInfo.F_Remark,
- sort = entity_ModuleInfo.F_Sort
- });
- }
- else
- {
- return Error("加载菜单失败");
- }
- }
-
- /// <summary>
- /// 添加菜单
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult AddModule(ModuleInfoDto input)
- {
- var entity_ModuleInfo = new Model.T_Sys_ModuleInfo();
- entity_ModuleInfo.F_ParentID = input.parentid;
- entity_ModuleInfo.F_ModuleName = input.name;
- entity_ModuleInfo.F_ModuleCode = input.code;
- entity_ModuleInfo.F_Remark = input.remark;
- entity_ModuleInfo.F_Sort = input.sort;
- entity_ModuleInfo.F_StateFlag = Convert.ToInt32(input.flag);
- entity_ModuleInfo.F_OptUrl = input.url;
- entity_ModuleInfo.F_CreateTime = DateTime.Now;
- entity_ModuleInfo.F_CreateUID = CurrentUser.UserData.F_UserId;
- entity_ModuleInfo.F_Button = "label label-warning pull - right lblcount "+ input.code;
-
- if (moduleInfoBLL.Add(entity_ModuleInfo) > 0)
- {
- return Success("菜单添加成功");
- }
- else
- {
- return Error("菜单添加失败,请重试!");
- }
- }
- /// <summary>
- /// 删除菜单
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelModule(string[] ids)
- {
- if (ids != null && ids.Length > 0)
- {
- string idd = " ";
- foreach (string str in ids)
- {
- idd += str + ",";
- }
- #region 判断子栏目是否存在
- var sql = "";
- sql += " F_StateFlag = 1 AND F_ParentID in (" + idd.TrimEnd(',') + ") ";
- var list = moduleInfoBLL.DataTableToList(moduleInfoBLL.GetList(sql).Tables[0]);
- if (list.Count > 0)
- return Error("操作失败:子栏目存在,不能删除");
- #endregion
- if (new BLL.T_Sys_ModuleInfo().DeleteList(idd.TrimEnd(',')))
- {
- return Success("删除成功");
- }
- else
- {
- return Error("删除失败,请重试!");
- }
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- /// <summary>
- /// 编辑菜单
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult EditModule(ModuleInfoDto input)
- {
- var entity_ModuleInfo = moduleInfoBLL.GetModel(input.id);
- if (entity_ModuleInfo != null)
- {
- entity_ModuleInfo.F_ParentID = input.parentid;
- entity_ModuleInfo.F_ModuleName = input.name;
- entity_ModuleInfo.F_ModuleCode = input.code;
- entity_ModuleInfo.F_Remark = input.remark;
- entity_ModuleInfo.F_Sort = input.sort;
- entity_ModuleInfo.F_StateFlag = Convert.ToInt32(input.flag);
- entity_ModuleInfo.F_OptUrl = input.url;
- entity_ModuleInfo.F_Button = "label label-warning pull - right lblcount " + input.code;
- if (moduleInfoBLL.Update(entity_ModuleInfo))
- {
- return Success("菜单修改成功");
- }
- else
- {
- return Error("菜单修改失败,请重试!");
- }
- }
- else
- {
- return Error("菜单对象获取失败");
- }
- }
- /// <summary>
- /// 获取菜单列表数据
- /// </summary>
- /// <param name="filter"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetList(FilterSysConfig filter)
- {
- var sql = "";
- if (!string.IsNullOrWhiteSpace(filter.Value))
- {
- sql += " and F_ParamValue like '%" + filter.Value + "%' ";
- }
- if (!string.IsNullOrWhiteSpace(filter.Code))
- {
- sql += " and F_ParamCode like '%" + filter.Code + "%' ";
- }
- int recordCount = 0;
- Model.PageData<Model.T_Sys_SystemConfig> pageModel = new Model.PageData<Model.T_Sys_SystemConfig>();
- var dt = BLL.PagerBLL.GetListPager(
- "T_Sys_SystemConfig",
- "F_ParamId",
- "*",
- sql,
- "ORDER BY F_ParamId desc",
- filter.PageSize,
- filter.PageIndex,
- true,
- out recordCount);
- var obj = new
- {
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
-
-
- }
- }
- }
|