县级监管平台

RoleInfoController.cs 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using CallCenterApi.Common;
  2. using CallCenterApi.Interface.Controllers.Base;
  3. using CallCenterApi.Interface.Models.Input;
  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. [Authority]
  13. public class RoleInfoController : BaseController
  14. {
  15. private BLL.T_Sys_RoleInfo roleInfoBLL = new BLL.T_Sys_RoleInfo();
  16. // 获取角色列表
  17. public ActionResult GetRoleList(int pageIndex = 1, int pageSize = 10, string code = "", string name = "", int isall = 0)
  18. {
  19. if (isall == 0)
  20. {
  21. DataTable dt = new DataTable();
  22. int recordCount = 0;
  23. dt = BLL.PagerBLL.GetListPager(
  24. "T_Sys_RoleInfo",
  25. "F_RoleId",
  26. "*",
  27. " and F_RoleName like '%" + name + "%' and F_RoleCode like '%" + code + "%' ",
  28. "",
  29. pageSize,
  30. pageIndex,
  31. true,
  32. out recordCount);
  33. var obj = new
  34. {
  35. rows = dt,
  36. total = recordCount
  37. };
  38. return Content(obj.ToJson());
  39. }
  40. else
  41. {
  42. return Success("获取角色信息成功", new BLL.T_Sys_RoleInfo().GetAllList().Tables[0]);
  43. }
  44. }
  45. //获取角色
  46. public ActionResult GetRole(int roleid = 0)
  47. {
  48. Model.T_Sys_RoleInfo dModel = roleInfoBLL.GetModel(roleid);
  49. if (dModel != null)
  50. return Success("获取角色信息成功", dModel);
  51. else
  52. return Error("获取角色信息失败");
  53. }
  54. //添加角色
  55. public ActionResult AddRole(RoleInput input)
  56. {
  57. Model.T_Sys_RoleInfo rModel = new Model.T_Sys_RoleInfo();
  58. rModel.F_RoleName = input.RoleName;
  59. rModel.F_Remark = input.RoleRemark;
  60. rModel.F_RoleCode = input.Code;
  61. if (roleInfoBLL.Add(rModel) > 0)
  62. return Success("添加成功");
  63. else
  64. return Success("添加失败");
  65. }
  66. //编辑角色
  67. public ActionResult EditRole(RoleInput input)
  68. {
  69. if (input.RoleId <= 0)
  70. return Error("请选择要编辑的角色");
  71. Model.T_Sys_RoleInfo rModel = roleInfoBLL.GetModel(input.RoleId);
  72. rModel.F_Remark = input.RoleRemark;
  73. rModel.F_RoleCode = input.Code;
  74. rModel.F_RoleName = input.RoleName;
  75. if (rModel == null)
  76. return Error("获取信息失败");
  77. if (roleInfoBLL.Update(rModel))
  78. return Success("编辑成功");
  79. else
  80. return Success("编辑失败");
  81. }
  82. //删除角色
  83. public ActionResult DelRole(int id = 0)
  84. {
  85. if (id <= 0)
  86. return Error("请选择角色");
  87. if (roleInfoBLL.Delete(id))
  88. return Success("删除成功");
  89. else
  90. return Error("删除失败");
  91. }
  92. }
  93. }