12345市长热线标准版-后端

ModuleInfoController.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. namespace CallCenterApi.Interface.Controllers
  11. {
  12. public class ModuleInfoController : BaseController
  13. {
  14. // GET: ModuleInfo
  15. #region 菜单
  16. /// <summary>
  17. /// 获取菜单列表
  18. /// </summary>
  19. /// <returns></returns>
  20. [Authority]
  21. public ActionResult GetModuleInfoList()
  22. {
  23. DataTable dt = new BLL.T_Sys_ModuleInfo().GetList(0, " F_IsDelete=0 ", " F_Sort").Tables[0];
  24. return Success("加载成功", dt);
  25. }
  26. /// <summary>
  27. /// 获取菜单列表
  28. /// </summary>
  29. /// <returns></returns>
  30. [Authority]
  31. public ActionResult GetModuleInfoListById(int id = 0)
  32. {
  33. DataTable dt = new BLL.T_Sys_ModuleInfo().GetList(" isnull(F_ParentID,0)='" + id + "' and F_StateFlag=1 and F_IsDelete=0").Tables[0];
  34. return Success("列表加载成功", dt);
  35. }
  36. /// <summary>
  37. /// 获取菜单
  38. /// </summary>
  39. /// <returns></returns>
  40. [Authority]
  41. public ActionResult GetModuleInfo()
  42. {
  43. int id = RequestString.GetInt("id", 0);
  44. Model.T_Sys_ModuleInfo dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
  45. return Success("获取信息成功", dModel);
  46. }
  47. /// <summary>
  48. /// 添加菜单
  49. /// </summary>
  50. /// <param name="input"></param>
  51. /// <returns></returns>
  52. [HttpPost]
  53. [Authority]
  54. public ActionResult AddModuleInfo()
  55. {
  56. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  57. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  58. int id = RequestString.GetInt("id", 0);
  59. int pid = RequestString.GetInt("pid", 0);
  60. int ismenu = RequestString.GetInt("ismenu", 0);
  61. int sort = RequestString.GetInt("sort", 0);
  62. string name = RequestString.GetFormString("name");
  63. string code = RequestString.GetFormString("code");
  64. string opturl = RequestString.GetFormString("opturl");
  65. string target = RequestString.GetFormString("target");
  66. Model.T_Sys_ModuleInfo dModel = new Model.T_Sys_ModuleInfo();
  67. if (id == 0)
  68. {
  69. var list = new BLL.T_Sys_ModuleInfo().GetModelList(" F_ParentID='" + pid + "' and F_ModuleName='" + name + "' ");
  70. if (list.Count > 0)
  71. {
  72. return Error("已经存在此菜单");
  73. }
  74. else
  75. {
  76. dModel.F_ParentID = pid;
  77. dModel.F_ModuleCode = code;
  78. dModel.F_OptUrl = opturl;
  79. dModel.F_Target = target;
  80. dModel.F_IsMenu = ismenu;
  81. dModel.F_Sort = sort;
  82. dModel.F_ModuleName = name;
  83. dModel.F_StateFlag = 1;
  84. dModel.F_IsDelete = 0;
  85. dModel.F_CreateUser = userModel.F_UserCode;
  86. dModel.F_CreateTime = DateTime.Now;
  87. long n = new BLL.T_Sys_ModuleInfo().Add(dModel);
  88. if (n > 0)
  89. return Success("添加成功", n);
  90. else
  91. return Error("添加失败");
  92. }
  93. }
  94. else
  95. {
  96. dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
  97. if (dModel != null)
  98. {
  99. var list = new BLL.T_Sys_ModuleInfo().GetModelList(" F_ParentID='" + pid + "' and F_ModuleName='" + name + "' and F_Id!='" + id + "' ");
  100. if (list.Count > 0)
  101. {
  102. return Error("已经存在此菜单");
  103. }
  104. else
  105. {
  106. dModel.F_ParentID = pid;
  107. dModel.F_ModuleCode = code;
  108. dModel.F_OptUrl = opturl;
  109. dModel.F_Target = target;
  110. dModel.F_IsMenu = ismenu;
  111. dModel.F_Sort = sort;
  112. dModel.F_ModuleName = name;
  113. dModel.F_LastModifyUser = userModel.F_UserCode;
  114. dModel.F_LastModifyTime = DateTime.Now;
  115. long n = new BLL.T_Sys_ModuleInfo().Add(dModel);
  116. if (new BLL.T_Sys_ModuleInfo().Update(dModel))
  117. return Success("修改成功");
  118. else
  119. return Error("修改失败");
  120. }
  121. }
  122. else
  123. {
  124. return Error("修改失败");
  125. }
  126. }
  127. }
  128. /// <summary>
  129. /// 删除菜单
  130. /// </summary>
  131. /// <param name="ids"></param>
  132. /// <returns></returns>
  133. [Authority]
  134. public ActionResult DelModuleInfo(string[] ids)
  135. {
  136. if (ids == null || ids.Length <= 0)
  137. return Error("请选择要删除的菜单");
  138. var idStr = string.Join(",", ids);
  139. if (string.IsNullOrEmpty(idStr.Trim()))
  140. return Error("请选择要删除的菜单");
  141. if (new BLL.T_Sys_ModuleInfo().DeleteList(idStr))
  142. return Success("删除成功");
  143. return Error("删除失败");
  144. }
  145. /// <summary>
  146. /// 删除菜单和其下级菜单
  147. /// </summary>
  148. /// <param name="ids"></param>
  149. /// <returns></returns>
  150. [Authority]
  151. public ActionResult DelModuleInfo(long id)
  152. {
  153. if (id > 0)
  154. {
  155. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  156. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  157. var model = new BLL.T_Sys_ModuleInfo().GetModel(id);
  158. if (DelModuleInfoByPId(id, userModel.F_UserCode))
  159. {
  160. var dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
  161. dModel.F_IsDelete = 1;
  162. dModel.F_DeleteUser = userModel.F_UserCode;
  163. dModel.F_DeleteTime = DateTime.Now;
  164. new BLL.T_Sys_ModuleInfo().Update(dModel);
  165. }
  166. return Success("删除成功");
  167. }
  168. else
  169. {
  170. return Error("删除失败");
  171. }
  172. }
  173. public bool DelModuleInfoByPId(long id,string code)
  174. {
  175. bool bl = true;
  176. var list = new BLL.T_Sys_ModuleInfo().GetModelList(" F_ParentID ='" + id + "'");
  177. foreach (var l in list)
  178. {
  179. if (DelModuleInfoByPId(l.F_Id, code))
  180. {
  181. var dModel = new BLL.T_Sys_ModuleInfo().GetModel(id);
  182. dModel.F_IsDelete = 1;
  183. dModel.F_DeleteUser = code;
  184. dModel.F_DeleteTime = DateTime.Now;
  185. new BLL.T_Sys_ModuleInfo().Update(dModel);
  186. }
  187. }
  188. return bl;
  189. }
  190. #endregion
  191. #region 菜单按钮
  192. /// <summary>
  193. /// 获取菜单按钮列表
  194. /// </summary>
  195. /// <returns></returns>
  196. [Authority]
  197. public ActionResult GetModuleInfoButtonList()
  198. {
  199. DataTable dt = new BLL.T_Sys_ModuleInfoButton().GetList(0, " F_IsDelete=0 ", " F_Sort").Tables[0];
  200. return Success("加载成功", dt);
  201. }
  202. /// <summary>
  203. /// 获取菜单按钮列表
  204. /// </summary>
  205. /// <returns></returns>
  206. [Authority]
  207. public ActionResult GetModuleInfoButtonListById(int id = 0)
  208. {
  209. DataTable dt = new BLL.T_Sys_ModuleInfoButton().GetList(" isnull(F_ModuleId,0)='" + id + "' and F_StateFlag=1 and F_IsDelete=0").Tables[0];
  210. return Success("列表加载成功", dt);
  211. }
  212. /// <summary>
  213. /// 获取菜单按钮
  214. /// </summary>
  215. /// <returns></returns>
  216. [Authority]
  217. public ActionResult GetModuleInfoButton()
  218. {
  219. int id = RequestString.GetInt("id", 0);
  220. Model.T_Sys_ModuleInfoButton dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
  221. return Success("获取信息成功", dModel);
  222. }
  223. /// <summary>
  224. /// 添加菜单按钮
  225. /// </summary>
  226. /// <param name="input"></param>
  227. /// <returns></returns>
  228. [HttpPost]
  229. [Authority]
  230. public ActionResult AddModuleInfoButton()
  231. {
  232. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  233. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  234. int id = RequestString.GetInt("id", 0);
  235. long mid = RequestString.GetInt("mid", 0);
  236. int pid = RequestString.GetInt("pid", 0);
  237. int layer = RequestString.GetInt("layer", 0);
  238. int loction = RequestString.GetInt("loction", 0);
  239. int issplit = RequestString.GetInt("issplit", 0);
  240. int sort = RequestString.GetInt("sort", 0);
  241. string name = RequestString.GetFormString("name");
  242. string code = RequestString.GetFormString("code");
  243. string icon = RequestString.GetFormString("icon");
  244. string jsevent = RequestString.GetFormString("jsevent");
  245. string remark = RequestString.GetFormString("remark");
  246. Model.T_Sys_ModuleInfoButton dModel = new Model.T_Sys_ModuleInfoButton();
  247. if (id == 0)
  248. {
  249. var list = new BLL.T_Sys_ModuleInfoButton().GetModelList(" F_ModuleId='" + mid + "' and F_FullName='" + name + "' ");
  250. if (list.Count > 0)
  251. {
  252. return Error("已经存在此菜单按钮");
  253. }
  254. else
  255. {
  256. dModel.F_ModuleId = mid;
  257. dModel.F_ParentId = pid;
  258. dModel.F_EnCode = code;
  259. dModel.F_Icon = icon;
  260. dModel.F_JsEvent = jsevent;
  261. dModel.F_Layers = layer;
  262. dModel.F_Location = loction;
  263. dModel.F_Remark = remark;
  264. dModel.F_IsSplit = issplit;
  265. dModel.F_Sort = sort;
  266. dModel.F_FullName = name;
  267. dModel.F_StateFlag = 1;
  268. dModel.F_IsDelete = 0;
  269. dModel.F_CreateUser = userModel.F_UserCode;
  270. dModel.F_CreateTime = DateTime.Now;
  271. long n = new BLL.T_Sys_ModuleInfoButton().Add(dModel);
  272. if (n > 0)
  273. return Success("添加成功", n);
  274. else
  275. return Error("添加失败");
  276. }
  277. }
  278. else
  279. {
  280. dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
  281. if (dModel != null)
  282. {
  283. var list = new BLL.T_Sys_ModuleInfoButton().GetModelList(" F_ModuleId='" + id + "' and F_FullName='" + name + "' and F_Id!='" + id + "' ");
  284. if (list.Count > 0)
  285. {
  286. return Error("已经存在此菜单按钮");
  287. }
  288. else
  289. {
  290. dModel.F_ModuleId = mid;
  291. dModel.F_ParentId = pid;
  292. dModel.F_EnCode = code;
  293. dModel.F_Icon = icon;
  294. dModel.F_JsEvent = jsevent;
  295. dModel.F_Layers = layer;
  296. dModel.F_Location = loction;
  297. dModel.F_Remark = remark;
  298. dModel.F_IsSplit = issplit;
  299. dModel.F_Sort = sort;
  300. dModel.F_FullName = name;
  301. dModel.F_LastModifyUser = userModel.F_UserCode;
  302. dModel.F_LastModifyTime = DateTime.Now;
  303. long n = new BLL.T_Sys_ModuleInfoButton().Add(dModel);
  304. if (new BLL.T_Sys_ModuleInfoButton().Update(dModel))
  305. return Success("修改成功");
  306. else
  307. return Error("修改失败");
  308. }
  309. }
  310. else
  311. {
  312. return Error("修改失败");
  313. }
  314. }
  315. }
  316. /// <summary>
  317. /// 删除菜单按钮
  318. /// </summary>
  319. /// <param name="ids"></param>
  320. /// <returns></returns>
  321. [Authority]
  322. public ActionResult DelModuleInfoButton(string[] ids)
  323. {
  324. if (ids == null || ids.Length <= 0)
  325. return Error("请选择要删除的菜单按钮");
  326. var idStr = string.Join(",", ids);
  327. if (string.IsNullOrEmpty(idStr.Trim()))
  328. return Error("请选择要删除的菜单按钮");
  329. if (new BLL.T_Sys_ModuleInfoButton().DeleteList(idStr))
  330. return Success("删除成功");
  331. return Error("删除失败");
  332. }
  333. /// <summary>
  334. /// 删除菜单按钮和其下级菜单按钮
  335. /// </summary>
  336. /// <param name="ids"></param>
  337. /// <returns></returns>
  338. [Authority]
  339. public ActionResult DelModuleInfoButton(long id)
  340. {
  341. if (id > 0)
  342. {
  343. int userId = Utils.StrToInt(User.UserData["F_UserID"], 0);
  344. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  345. var model = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
  346. if (DelModuleInfoButtonByPId(id, userModel.F_UserCode))
  347. {
  348. var dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
  349. dModel.F_IsDelete = 1;
  350. dModel.F_DeleteUser = userModel.F_UserCode;
  351. dModel.F_DeleteTime = DateTime.Now;
  352. new BLL.T_Sys_ModuleInfoButton().Update(dModel);
  353. }
  354. return Success("删除成功");
  355. }
  356. else
  357. {
  358. return Error("删除失败");
  359. }
  360. }
  361. public bool DelModuleInfoButtonByPId(long id, string code)
  362. {
  363. bool bl = true;
  364. var list = new BLL.T_Sys_ModuleInfoButton().GetModelList(" F_ParentID ='" + id + "'");
  365. foreach (var l in list)
  366. {
  367. if (DelModuleInfoButtonByPId(l.F_Id, code))
  368. {
  369. var dModel = new BLL.T_Sys_ModuleInfoButton().GetModel(id);
  370. dModel.F_IsDelete = 1;
  371. dModel.F_DeleteUser = code;
  372. dModel.F_DeleteTime = DateTime.Now;
  373. new BLL.T_Sys_ModuleInfoButton().Update(dModel);
  374. }
  375. }
  376. return bl;
  377. }
  378. #endregion
  379. }
  380. }