县级监管平台

FunctionController.cs 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using CallCenterApi.Common;
  2. using CallCenterApi.Interface.Controllers.Base;
  3. using CallCenterApi.Interface.Models.Common;
  4. using CallCenterApi.Interface.Models.Input;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace CallCenterApi.Interface.Controllers
  13. {
  14. [Authority]
  15. public class FunctionController : BaseController
  16. {
  17. private BLL.T_Sys_Function functionBLL = new BLL.T_Sys_Function();
  18. /// <summary>
  19. /// 获取菜单列表
  20. /// </summary>
  21. /// <param name="filter"></param>
  22. /// <returns></returns>
  23. public ActionResult GetAllList()
  24. {
  25. DataTable dt = new DataTable();
  26. StringBuilder sql = new StringBuilder();
  27. dt = functionBLL.GetList(0, "1=1", "F_Sort asc").Tables[0];
  28. return Success("加载成功", dt);
  29. }
  30. /// <summary>
  31. /// 获取菜单列表
  32. /// </summary>
  33. /// <param name="filter"></param>
  34. /// <returns></returns>
  35. public ActionResult GetList()
  36. {
  37. DataTable dt = new DataTable();
  38. StringBuilder sql = new StringBuilder();
  39. int pid = RequestString.GetInt("pid", 0);
  40. string strpageindex = RequestString.GetQueryString("page");
  41. int pageindex = 1;
  42. string strpagesize = RequestString.GetQueryString("pagesize");
  43. int pagesize = 10;
  44. if (pid != 0)
  45. { sql.Append(" and f_parentid=" + pid); }
  46. if (strpageindex.Trim() != "")
  47. {
  48. pageindex = Convert.ToInt32(strpageindex);
  49. }
  50. if (strpagesize.Trim() != "")
  51. {
  52. pagesize = Convert.ToInt32(strpagesize);
  53. }
  54. var recordCount = 0;
  55. dt = BLL.PagerBLL.GetListPager(
  56. "T_Sys_Function",
  57. "F_FunctionId",
  58. "*",
  59. sql.ToString(),
  60. "ORDER BY F_Sort ",
  61. pagesize,
  62. pageindex,
  63. true,
  64. out recordCount);
  65. var obj = new
  66. {
  67. state = "success",
  68. message = "成功",
  69. rows = dt,
  70. total = recordCount
  71. };
  72. return Content(obj.ToJson());
  73. }
  74. /// <summary>
  75. /// 获取菜单信息
  76. /// </summary>
  77. /// <returns></returns>
  78. public ActionResult GetFunction()
  79. {
  80. DataTable dt = new DataTable();
  81. StringBuilder sql = new StringBuilder();
  82. int id = RequestString.GetInt("id", 0);
  83. var model = functionBLL.GetModel(id);
  84. return Success("加载成功", model);
  85. }
  86. /// <summary>
  87. /// 添加/编辑菜单
  88. /// </summary>
  89. /// <param name="input"></param>
  90. /// <returns></returns>
  91. [HttpPost]
  92. public ActionResult AddFunction()
  93. {
  94. int id = RequestString.GetInt("id", 0);
  95. int pid = RequestString.GetInt("pid", 0);
  96. string name = RequestString.GetFormString("name");
  97. string code = RequestString.GetFormString("code");
  98. int state = RequestString.GetInt("state", 0);
  99. int sort = RequestString.GetInt("sort", 0);
  100. string url = RequestString.GetFormString("url");
  101. string img = RequestString.GetFormString("img");
  102. string remark = RequestString.GetFormString("remark");
  103. Model.T_Sys_Function orderModel = new Model.T_Sys_Function();
  104. if (pid == 0) return Error("参数错误");
  105. if (pid != -1)
  106. {
  107. var model = functionBLL.GetModel(pid);
  108. if (model == null) return Error("父菜单不存在");
  109. }
  110. if (id == 0)
  111. {
  112. orderModel.F_ParentId = pid;
  113. orderModel.F_FunctionCode = code;
  114. orderModel.F_FunctionName = name;
  115. orderModel.F_OptUrl = url;
  116. orderModel.F_ImgUrl = img;
  117. orderModel.F_Sort = sort;
  118. orderModel.F_Remark = remark;
  119. orderModel.F_State = state;
  120. orderModel.F_Layer = 2;
  121. orderModel.F_flag = 0;
  122. if (pid < 0)
  123. {
  124. orderModel.F_Layer = 1;
  125. orderModel.F_flag = 1;
  126. }
  127. if (functionBLL.Add(orderModel) > 0)
  128. return Success("菜单添加成功");
  129. else
  130. return Error("菜单添加失败");
  131. }
  132. else
  133. {
  134. orderModel = functionBLL.GetModel(id);
  135. if (orderModel != null)
  136. {
  137. orderModel.F_ParentId = pid;
  138. orderModel.F_FunctionCode = code;
  139. orderModel.F_FunctionName = name;
  140. orderModel.F_OptUrl = url;
  141. orderModel.F_ImgUrl = img;
  142. orderModel.F_Sort = sort;
  143. orderModel.F_Remark = remark;
  144. orderModel.F_State = state;
  145. orderModel.F_Layer = 2;
  146. orderModel.F_flag = 0;
  147. if (pid < 0)
  148. {
  149. orderModel.F_Layer = 1;
  150. orderModel.F_flag = 1;
  151. }
  152. if (functionBLL.Update(orderModel))
  153. return Success("菜单修改成功");
  154. else
  155. return Error("菜单修改失败");
  156. }
  157. else
  158. {
  159. return Error("菜单修改失败");
  160. }
  161. }
  162. }
  163. /// <summary>
  164. /// 删除菜单
  165. /// </summary>
  166. /// <param name="ids"></param>
  167. /// <returns></returns>
  168. public ActionResult DelFunction(string[] ids)
  169. {
  170. if (ids != null && ids.Length > 0)
  171. {
  172. string idd = " ";
  173. foreach (string str in ids)
  174. {
  175. idd += str + ",";
  176. }
  177. if (new BLL.T_Sys_Function().DeleteList(idd.TrimEnd(',')))
  178. {
  179. return Success("删除成功");
  180. }
  181. else
  182. {
  183. return Error("删除失败");
  184. }
  185. }
  186. else
  187. {
  188. return Error("获取参数失败");
  189. }
  190. }
  191. }
  192. }