SystemUserController.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using PMS.BusinessModels.SysManager;
  7. using PMS.Interface;
  8. using PMS.Interface.SysManager;
  9. using QWPlatform.SystemLibrary;
  10. using PMS.EntityModels.SysManager;
  11. using System.Data;
  12. using PMS.BusinessModels.Account;
  13. namespace PMS.WebUI.Controllers
  14. {
  15. /// <summary>
  16. /// 创 建 人:王海洋
  17. /// 创建日期:2018-12-10
  18. /// 功能描述:系统用户控制器
  19. /// </summary>
  20. public class SystemUserController : BaseController
  21. {
  22. IXTJSModel xtjs_model = InterfaceFactory.CreateBusinessInstance<IXTJSModel>();
  23. IXTZHModel xtzh_model = InterfaceFactory.CreateBusinessInstance<IXTZHModel>();
  24. IRoleAuthModel roleauth_model = InterfaceFactory.CreateBusinessInstance<IRoleAuthModel>();
  25. #region 人员账户
  26. // GET: SystemUser
  27. public ActionResult Index()
  28. {
  29. return View();
  30. }
  31. //Get 获取所有机构
  32. [HttpGet]
  33. public ActionResult GetOrgs()
  34. {
  35. //获取组织机构的JSOn
  36. var json = account_obj.GetOrgsDataGridJson();
  37. return Content(json, "application/json");
  38. }
  39. //Get:根据机构ID获取该机构下所有账户目录json
  40. [HttpGet]
  41. public ActionResult GetUserListByOrgId(string id, int page, int rows)
  42. {
  43. var json = account_obj.GetUserListByOrgId(id, page, rows);
  44. return Content(json, "application/json");
  45. }
  46. //将账户进行授权
  47. public ActionResult AuthRoleToAccount(int? id)
  48. {
  49. ViewBag.id = id;
  50. return View();
  51. }
  52. //POST:将用户授权相关角色ID
  53. [HttpPost]
  54. public ActionResult PostSaveAuthRoleToAccount(int? uid, string rids)
  55. {
  56. if (uid > 0)
  57. {
  58. bool r = account_obj.SaveAuthRoleToAccount(uid, rids);
  59. if (r)
  60. {
  61. return this.ResponseJson(System.Net.HttpStatusCode.OK, "授权成功", null);
  62. }
  63. }
  64. return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "没有用户ID", null);
  65. }
  66. //GET:根据人员账户获取已授权的角色
  67. [HttpGet]
  68. public ActionResult GetAccountRolesGridJson(int id)
  69. {
  70. var dt = account_obj.GetAccountRoles(id);
  71. var json = dt.ToEasyUIGridJson(0, null);
  72. return Content(json, "text/json");
  73. }
  74. //GET:返回数据权限的授权界面
  75. public ActionResult AuthDataToUser(int id)
  76. {
  77. ViewBag.id = id;
  78. return View();
  79. }
  80. //GET:获取所有渠道下的项目(数据授权时使用)
  81. [HttpGet]
  82. public ActionResult GetOrgProjects()
  83. {
  84. var treeJson = account_obj.GetOrgProjecgTree();
  85. return Content(treeJson, "text/json");
  86. }
  87. //POST 保存数据(用户数据授权)
  88. [HttpPost]
  89. public ActionResult PostSaveUserDataAuth(IEnumerable<account_authdata_model> models)
  90. {
  91. //保存授权数据
  92. bool r = account_obj.SaveAuthDataToAccount(models);
  93. if (r)
  94. {
  95. return this.ResponseJson(System.Net.HttpStatusCode.OK, "授权成功");
  96. }
  97. return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "授权失败");
  98. }
  99. /// <summary>
  100. /// 批量授权
  101. /// </summary>
  102. /// <param name="id"></param>
  103. /// <returns></returns>
  104. [HttpPost]
  105. public int BatchAuth(string id, IEnumerable<account_authdata_model> models)
  106. {
  107. //保存授权数据
  108. return account_obj.BatchAuth(id,models);
  109. }
  110. //GET:根据账户ID,获取该账户的数据授的授权列表
  111. [HttpGet]
  112. public ActionResult GetUserDataAuth(int id)
  113. {
  114. List<account_authdata_model> list = account_obj.GetAccountDataAuth(id);
  115. return this.ResponseJson(System.Net.HttpStatusCode.OK, "完成读取", list);
  116. }
  117. //系统账户弹出框 XtZHPopWindows(string id)
  118. public ActionResult XtZHPopWindows(int id)
  119. {
  120. ViewBag.id = id;
  121. return View();
  122. }
  123. /// <summary>
  124. /// 根据id查找用户信息
  125. /// </summary>
  126. /// <param name="ID"></param>
  127. /// <returns></returns>
  128. public ActionResult GetSystemUserInfo(int ID)
  129. {
  130. return this.ResponseJson(System.Net.HttpStatusCode.OK, "完成读取", xtzh_model.GetSystemUserInfo(ID));
  131. }
  132. /// <summary>
  133. /// 获取系统账户类型
  134. /// </summary>
  135. /// <returns></returns>
  136. public ActionResult XtZHLx()
  137. {
  138. string result = xtzh_model.XtZHLx();
  139. return Content(result, "text/json");
  140. }
  141. /// <summary>
  142. /// 获取系统账户公司
  143. /// </summary>
  144. /// <returns></returns>
  145. public ActionResult XtZHGs()
  146. {
  147. return Content(xtzh_model.XtZHGs(),"text/json");
  148. }
  149. /// <summary>
  150. /// 新增修改系统账户
  151. /// </summary>
  152. /// <param name="XtzhModel"></param>
  153. /// <returns></returns>
  154. public ActionResult XtZHEdit(XTZHModel XtzhModel)
  155. {
  156. int EditType=0;
  157. if (XtzhModel.ID!=null)
  158. {
  159. EditType = 1;
  160. }
  161. string result = xtzh_model.XtZHEdit(XtzhModel,EditType);
  162. string [] re= result.Split('|');
  163. if (re[0] == "1")
  164. {
  165. return this.ResponseJson(System.Net.HttpStatusCode.OK, re[1]);
  166. }
  167. else
  168. {
  169. return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, re[1]);
  170. }
  171. }
  172. /// <summary>
  173. /// 系统账户查询 return Content(dt, "application/json");
  174. /// </summary>
  175. /// <param name="search">条件</param>
  176. /// <param name="page">当前页码</param>
  177. /// <param name="rows">每页显示得行数</param>
  178. /// <returns></returns>
  179. public ActionResult XtZHSelect(string search, int page, int rows)
  180. {
  181. string result = xtzh_model.XtZHSelect(search, page, rows);
  182. return Content(result, "application/json");
  183. }
  184. /// <summary>
  185. /// 删除记录
  186. /// </summary>
  187. /// <returns></returns>
  188. public ActionResult XtZHDel(int id)
  189. {
  190. xtzh_model.XtZHDel(id);
  191. return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功");
  192. }
  193. /// <summary>
  194. /// 设置账户可以访问渠道下面所有项目
  195. /// </summary>
  196. /// <param name="id"></param>
  197. /// <param name="authorize">1是,0否</param>
  198. /// <returns></returns>
  199. public ActionResult UpdataAuthorize(int id,int authorize)
  200. {
  201. var state= xtzh_model.UpdataAuthorize(id, authorize);
  202. return this.ResponseJson(state? System.Net.HttpStatusCode.OK : System.Net.HttpStatusCode.InternalServerError, "操作成功");
  203. }
  204. /// <summary>
  205. /// 重置密码
  206. /// ID: 4
  207. // XM: "冉利"
  208. //ZH: "18315119271"
  209. /// </summary>
  210. /// <param name="ID">id</param>
  211. /// <param name="ZH">账户</param>
  212. /// <param name="XM">姓名</param>
  213. /// <returns></returns>
  214. public ActionResult XtZHMMPopWindows(int ID,string XM,string ZH)
  215. {
  216. ViewBag.id = ID;
  217. ViewBag.ZH = ZH;
  218. ViewBag.XM = XM;
  219. return View();
  220. }
  221. //保存修改得密码
  222. public ActionResult XGMm(int id,string MM, string ZH, string XM)
  223. {
  224. xtzh_model.XGMm(id, MM);
  225. return this.ResponseJson(System.Net.HttpStatusCode.OK, "重置成功");
  226. }
  227. /// <summary>
  228. /// 获取公司下的人员
  229. /// </summary>
  230. /// <param name="GSID"></param>
  231. /// <returns></returns>
  232. public ActionResult XtZHRY(string GSID)
  233. {
  234. return Content(xtzh_model.XtZHRY(GSID), "application/json");
  235. }
  236. #endregion
  237. #region 人员角色
  238. //获取人员角色主页
  239. public ActionResult RolesIndex()
  240. {
  241. return View();
  242. }
  243. //获取角色列表的json
  244. [HttpGet]
  245. public ActionResult GetRoleList(int page, int rows)
  246. {
  247. var json = account_obj.GetRolesList(page, rows);
  248. return Content(json, "application/json");
  249. }
  250. //获取角色列表的json
  251. [HttpGet]
  252. public ActionResult GetRolesForActiveList(int page, int rows)
  253. {
  254. var json = account_obj.GetRolesForActiveList(page, rows);
  255. return Content(json, "application/json");
  256. }
  257. //角色授权页面(传递角色ID)
  258. [HttpGet]
  259. public ActionResult RoleAuthorize(int id)
  260. {
  261. ViewBag.id = id;
  262. return View();
  263. }
  264. //POST,针对某个角色的授权信息
  265. //模块ID的最后一个节点为功能授权节点
  266. [HttpPost]
  267. public ActionResult PostRoleAuthorzie(int rid, string mids, string bids)
  268. {
  269. var r = account_obj.SaveRoleAuthorzie(rid, mids, bids);
  270. if (r)
  271. {
  272. return this.ResponseJson(System.Net.HttpStatusCode.OK, "授权成功");
  273. }
  274. return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "授权失败");
  275. }
  276. //GET:获取角色的权限信息(获取角色的模块信息,角色ID)
  277. [HttpGet]
  278. public ActionResult GetRoleAuthorzie(int id)
  279. {
  280. var json = account_obj.GetRoleAuthJson(id);
  281. return Content(json, "text/json");
  282. }
  283. //G用:根据角色ID及模块ID获取功能目录
  284. [HttpGet]
  285. public ActionResult GetRoleAuthorzieFuns(int roleid, int moduleid)
  286. {
  287. var json = account_obj.GetRoleAuthFunGridJson(roleid, moduleid);
  288. return Content(json, "text/json");
  289. }
  290. /// <summary>
  291. /// 判断是否是管理员
  292. /// </summary>
  293. /// <returns></returns>
  294. public ActionResult IsSuperAdmin()
  295. {
  296. UserInfo userinfo = this.GetCurrentUser();
  297. bool IsSuperAdmin = userinfo.IsSuperAdmin;
  298. if (IsSuperAdmin == true)
  299. {
  300. return this.ResponseJson(System.Net.HttpStatusCode.OK, "1");
  301. }
  302. else
  303. {
  304. return this.ResponseJson(System.Net.HttpStatusCode.Forbidden, "0");
  305. }
  306. }
  307. ///SystemUser/RolePopWindows 新增系统角色
  308. //修改系统角色/SystemUser/RolePopWindows?id=
  309. public ActionResult RolePopWindows(int id)
  310. {
  311. ViewBag.id = id;
  312. return View();
  313. }
  314. ////删除系统角色/SystemUser/RoleDel { 'id': row.ID, 'type': 0 };
  315. public ActionResult RoleDel(int id)
  316. {
  317. xtjs_model.RoleDel(id);
  318. return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功");
  319. }
  320. ///参数id查询系统角色信息SystemUser/GetSystemRoleInfo?id=' + ID,
  321. public ActionResult GetSystemRoleInfo(int id)
  322. {
  323. DataTable result = xtjs_model.GetSystemRoleInfo(id);
  324. return this.ResponseJson(System.Net.HttpStatusCode.OK, "读取成功", result);
  325. }
  326. // 提交表单信息到具体得页面 SystemUser/SaveRoleInfo
  327. public ActionResult SaveRoleInfo(XTJSModel model)
  328. {
  329. int type_in = 0;
  330. if (model.ID!=null)
  331. {
  332. type_in = 1;
  333. }
  334. string Result = xtjs_model.SaveRoleInfo(model, type_in);
  335. string[] Resultstring = Result.Split('1');
  336. return this.ResponseJson(System.Net.HttpStatusCode.OK, Resultstring[1]);
  337. }
  338. /// <summary>
  339. /// 判断输入的系统角色名是否重复
  340. /// 并给与提示
  341. /// </summary>
  342. /// <param name="Name"></param>
  343. /// <returns></returns>
  344. public string RoleNameCheck(string Name)
  345. {
  346. string result = xtjs_model.RoleNameCheck(Name);
  347. string[] re = result.Split('|');
  348. if (re[0] == "1")
  349. {
  350. return "true";
  351. }
  352. return "false";
  353. }
  354. /// <summary>
  355. /// 系统账户名称重复测试有问题
  356. /// </summary>
  357. /// <param name="name"></param>
  358. /// <returns></returns>
  359. public string UserNameCheck(string name)
  360. {
  361. string result= xtzh_model.UserNameCheck(name);
  362. string[] re = result.Split('|');
  363. if (re[0] == "1")
  364. {
  365. return "true";
  366. }
  367. return "false";
  368. }
  369. //where rownum = 1
  370. public ActionResult RoleXh()
  371. {
  372. string result = xtjs_model.RoleXh();
  373. return Content(result, "text/json");
  374. }
  375. //根据角色查询用户列表
  376. public ActionResult GetUserByRoleId(int rid,int rows,int page)
  377. {
  378. var json = account_obj.GetUserByRoleId(rid, rows, page);
  379. return Content(json, "text/json");
  380. }
  381. #endregion
  382. /// <summary>
  383. /// 系统角色权限的保存(暂时不能用)
  384. /// </summary>
  385. /// <param name="ids"></param>
  386. /// <returns></returns>
  387. public ActionResult SaveXtjsQx(string ids)
  388. {
  389. string result= roleauth_model.SaveXtjsQx(ids);
  390. string[] result1 = result.Split('|');
  391. if (result1[0] == "1")
  392. {
  393. return this.ResponseJson(System.Net.HttpStatusCode.OK, "成功");
  394. }
  395. else
  396. {
  397. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "失败");
  398. }
  399. }
  400. public ActionResult SelectPersonInfo(string Zh)
  401. {
  402. string result= xtzh_model.SelectPersonInfo(Zh);
  403. if (result=="")
  404. {
  405. return Content("", "text/json");
  406. }
  407. return Content(result, "text/json");
  408. }
  409. }
  410. }