| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- using CallCenter.Utility;
- using CallCenterApi.Common;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers
- {
- public class ModuleInfoController : BaseController
- {
- // GET: ModuleInfo
- #region 菜单
- /// <summary>
- /// 获取菜单列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetModuleInfoList()
- {
- DataTable dt = new BLL.T_Sys_ModuleInfo().GetList(0, " F_IsDelete=0 ", " F_Sort").Tables[0];
- return Success("加载成功", dt);
- }
- /// <summary>
- /// 获取菜单列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetModuleInfoListById(int id = 0)
- {
- DataTable dt = new BLL.T_Sys_ModuleInfo().GetList(" isnull(F_ParentID,0)='" + id + "' and F_StateFlag=1 and F_IsDelete=0").Tables[0];
- return Success("列表加载成功", dt);
- }
- /// <summary>
- /// 获取菜单
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetModuleInfo()
- {
- int id = RequestString.GetInt("id", 0);
- Model.T_Sys_ModuleInfo dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
- return Success("获取信息成功", dModel);
- }
- /// <summary>
- /// 添加菜单
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- [Authority]
- public ActionResult AddModuleInfo()
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- int id = RequestString.GetInt("id", 0);
- int pid = RequestString.GetInt("pid", 0);
- int ismenu = RequestString.GetInt("ismenu", 0);
- int sort = RequestString.GetInt("sort", 0);
- string name = RequestString.GetFormString("name");
- string code = RequestString.GetFormString("code");
- string opturl = RequestString.GetFormString("opturl");
- string target = RequestString.GetFormString("target");
- Model.T_Sys_ModuleInfo dModel = new Model.T_Sys_ModuleInfo();
- if (id == 0)
- {
- var list = new BLL.T_Sys_ModuleInfo().GetModelList(" F_ParentID='" + pid + "' and F_ModuleName='" + name + "' ");
- if (list.Count > 0)
- {
- return Error("已经存在此菜单");
- }
- else
- {
- dModel.F_ParentID = pid;
- dModel.F_ModuleCode = code;
- dModel.F_OptUrl = opturl;
- dModel.F_Target = target;
- dModel.F_IsMenu = ismenu;
- dModel.F_Sort = sort;
- dModel.F_ModuleName = name;
- dModel.F_StateFlag = 1;
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = userModel.F_UserCode;
- dModel.F_CreateTime = DateTime.Now;
- long n = new BLL.T_Sys_ModuleInfo().Add(dModel);
- if (n > 0)
- return Success("添加成功", n);
- else
- return Error("添加失败");
- }
- }
- else
- {
- dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
- if (dModel != null)
- {
- var list = new BLL.T_Sys_ModuleInfo().GetModelList(" F_ParentID='" + pid + "' and F_ModuleName='" + name + "' and F_Id!='" + id + "' ");
- if (list.Count > 0)
- {
- return Error("已经存在此菜单");
- }
- else
- {
- dModel.F_ParentID = pid;
- dModel.F_ModuleCode = code;
- dModel.F_OptUrl = opturl;
- dModel.F_Target = target;
- dModel.F_IsMenu = ismenu;
- dModel.F_Sort = sort;
- dModel.F_ModuleName = name;
- dModel.F_LastModifyUser = userModel.F_UserCode;
- dModel.F_LastModifyTime = DateTime.Now;
- long n = new BLL.T_Sys_ModuleInfo().Add(dModel);
- if (new BLL.T_Sys_ModuleInfo().Update(dModel))
- return Success("修改成功");
- else
- return Error("修改失败");
- }
- }
- else
- {
- return Error("修改失败");
- }
- }
- }
- /// <summary>
- /// 删除菜单
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelModuleInfo(string[] ids)
- {
- if (ids == null || ids.Length <= 0)
- return Error("请选择要删除的菜单");
- var idStr = string.Join(",", ids);
- if (string.IsNullOrEmpty(idStr.Trim()))
- return Error("请选择要删除的菜单");
- if (new BLL.T_Sys_ModuleInfo().DeleteList(idStr))
- return Success("删除成功");
- return Error("删除失败");
- }
- /// <summary>
- /// 删除菜单和其下级菜单
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelModuleInfo(long id)
- {
- if (id > 0)
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- var model = new BLL.T_Sys_ModuleInfo().GetModel(id);
- if (DelModuleInfoByPId(id, userModel.F_UserCode))
- {
- var dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
- dModel.F_IsDelete = 1;
- dModel.F_DeleteUser = userModel.F_UserCode;
- dModel.F_DeleteTime = DateTime.Now;
- new BLL.T_Sys_ModuleInfo().Update(dModel);
- }
- return Success("删除成功");
- }
- else
- {
- return Error("删除失败");
- }
- }
- public bool DelModuleInfoByPId(long id,string code)
- {
- bool bl = true;
- var list = new BLL.T_Sys_ModuleInfo().GetModelList(" F_ParentID ='" + id + "'");
- foreach (var l in list)
- {
- if (DelModuleInfoByPId(l.F_Id, code))
- {
- var dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
- dModel.F_IsDelete = 1;
- dModel.F_DeleteUser = code;
- dModel.F_DeleteTime = DateTime.Now;
- new BLL.T_Sys_ModuleInfo().Update(dModel);
- }
- }
- return bl;
- }
- #endregion
- #region 菜单按钮
- /// <summary>
- /// 获取菜单按钮列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetModuleInfoButtonList()
- {
- DataTable dt = new BLL.T_Sys_ModuleInfoButton().GetList(0, " F_IsDelete=0 ", " F_Sort").Tables[0];
- return Success("加载成功", dt);
- }
- /// <summary>
- /// 获取菜单按钮列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetModuleInfoButtonListById(int id = 0)
- {
- DataTable dt = new BLL.T_Sys_ModuleInfoButton().GetList(" isnull(F_ModuleId,0)='" + id + "' and F_StateFlag=1 and F_IsDelete=0").Tables[0];
- return Success("列表加载成功", dt);
- }
- /// <summary>
- /// 获取菜单按钮
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetModuleInfoButton()
- {
- int id = RequestString.GetInt("id", 0);
- Model.T_Sys_ModuleInfoButton dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
- return Success("获取信息成功", dModel);
- }
- /// <summary>
- /// 添加菜单按钮
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- [Authority]
- public ActionResult AddModuleInfoButton()
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- int id = RequestString.GetInt("id", 0);
- long mid = RequestString.GetInt("mid", 0);
- int pid = RequestString.GetInt("pid", 0);
- int layer = RequestString.GetInt("layer", 0);
- int loction = RequestString.GetInt("loction", 0);
- int issplit = RequestString.GetInt("issplit", 0);
- int sort = RequestString.GetInt("sort", 0);
- string name = RequestString.GetFormString("name");
- string code = RequestString.GetFormString("code");
- string icon = RequestString.GetFormString("icon");
- string jsevent = RequestString.GetFormString("jsevent");
- string remark = RequestString.GetFormString("remark");
- Model.T_Sys_ModuleInfoButton dModel = new Model.T_Sys_ModuleInfoButton();
- if (id == 0)
- {
- var list = new BLL.T_Sys_ModuleInfoButton().GetModelList(" F_ModuleId='" + mid + "' and F_FullName='" + name + "' ");
- if (list.Count > 0)
- {
- return Error("已经存在此菜单按钮");
- }
- else
- {
- dModel.F_ModuleId = mid;
- dModel.F_ParentId = pid;
- dModel.F_EnCode = code;
- dModel.F_Icon = icon;
- dModel.F_JsEvent = jsevent;
- dModel.F_Layers = layer;
- dModel.F_Location = loction;
- dModel.F_Remark = remark;
- dModel.F_IsSplit = issplit;
- dModel.F_Sort = sort;
- dModel.F_FullName = name;
- dModel.F_StateFlag = 1;
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = userModel.F_UserCode;
- dModel.F_CreateTime = DateTime.Now;
- long n = new BLL.T_Sys_ModuleInfoButton().Add(dModel);
- if (n > 0)
- return Success("添加成功", n);
- else
- return Error("添加失败");
- }
- }
- else
- {
- dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
- if (dModel != null)
- {
- var list = new BLL.T_Sys_ModuleInfoButton().GetModelList(" F_ModuleId='" + id + "' and F_FullName='" + name + "' and F_Id!='" + id + "' ");
- if (list.Count > 0)
- {
- return Error("已经存在此菜单按钮");
- }
- else
- {
- dModel.F_ModuleId = mid;
- dModel.F_ParentId = pid;
- dModel.F_EnCode = code;
- dModel.F_Icon = icon;
- dModel.F_JsEvent = jsevent;
- dModel.F_Layers = layer;
- dModel.F_Location = loction;
- dModel.F_Remark = remark;
- dModel.F_IsSplit = issplit;
- dModel.F_Sort = sort;
- dModel.F_FullName = name;
- dModel.F_LastModifyUser = userModel.F_UserCode;
- dModel.F_LastModifyTime = DateTime.Now;
- long n = new BLL.T_Sys_ModuleInfoButton().Add(dModel);
- if (new BLL.T_Sys_ModuleInfoButton().Update(dModel))
- return Success("修改成功");
- else
- return Error("修改失败");
- }
- }
- else
- {
- return Error("修改失败");
- }
- }
- }
- /// <summary>
- /// 删除菜单按钮
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelModuleInfoButton(string[] ids)
- {
- if (ids == null || ids.Length <= 0)
- return Error("请选择要删除的菜单按钮");
- var idStr = string.Join(",", ids);
- if (string.IsNullOrEmpty(idStr.Trim()))
- return Error("请选择要删除的菜单按钮");
- if (new BLL.T_Sys_ModuleInfoButton().DeleteList(idStr))
- return Success("删除成功");
- return Error("删除失败");
- }
- /// <summary>
- /// 删除菜单按钮和其下级菜单按钮
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelModuleInfoButton(long id)
- {
- if (id > 0)
- {
- int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
- var model = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
- if (DelModuleInfoButtonByPId(id, userModel.F_UserCode))
- {
- var dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
- dModel.F_IsDelete = 1;
- dModel.F_DeleteUser = userModel.F_UserCode;
- dModel.F_DeleteTime = DateTime.Now;
- new BLL.T_Sys_ModuleInfoButton().Update(dModel);
- }
- return Success("删除成功");
- }
- else
- {
- return Error("删除失败");
- }
- }
- public bool DelModuleInfoButtonByPId(long id, string code)
- {
- bool bl = true;
- var list = new BLL.T_Sys_ModuleInfoButton().GetModelList(" F_ParentID ='" + id + "'");
- foreach (var l in list)
- {
- if (DelModuleInfoButtonByPId(l.F_Id, code))
- {
- var dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
- dModel.F_IsDelete = 1;
- dModel.F_DeleteUser = code;
- dModel.F_DeleteTime = DateTime.Now;
- new BLL.T_Sys_ModuleInfoButton().Update(dModel);
- }
- }
- return bl;
- }
- #endregion
- }
- }
|