人民医院API

UserAccountController.cs 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using RMYY_CallCenter_Api.Utility;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. namespace RMYY_CallCenter_Api.Controllers.System
  9. {
  10. public class UserAccountController : BaseController
  11. {
  12. // GET: UserAccount
  13. //用户列表
  14. [HttpPost]
  15. public ActionResult GetList()
  16. {
  17. DataTable dt = new DataTable();
  18. string sql = string.Empty;
  19. string rolecode = Request.Params["rolecode"];
  20. string deptcode = Request.Params["deptcode"];
  21. string key = Request.Params["key"];
  22. string strpageindex = Request.Params["page"];
  23. int pageindex = 1;
  24. string strpagesize = Request.Params["pagesize"];
  25. int pagesize = 10;
  26. if (!string.IsNullOrWhiteSpace(deptcode))
  27. {
  28. sql += " and F_DeptCode='" + deptcode + "'";
  29. }
  30. if (!string.IsNullOrWhiteSpace(rolecode))
  31. {
  32. sql += " and F_RoleCode='" + rolecode + "'";
  33. }
  34. if (!string.IsNullOrWhiteSpace(key))
  35. {
  36. sql += " and (F_UserCode like '%{0}%' or F_UserName like '%{1}%')";
  37. }
  38. if (!string.IsNullOrWhiteSpace(strpageindex))
  39. {
  40. pageindex = Convert.ToInt32(strpageindex);
  41. }
  42. if (!string.IsNullOrWhiteSpace(strpagesize))
  43. {
  44. pagesize = Convert.ToInt32(strpagesize);
  45. }
  46. int recordCount = 0;
  47. dt = Bll.PagerBll.GetListPager(
  48. "T_Sys_UserAccount",
  49. "F_UserId",
  50. "*",
  51. sql,
  52. "ORDER BY F_UserId desc",
  53. pagesize,
  54. pageindex,
  55. true,
  56. out recordCount);
  57. var obj = new
  58. {
  59. rows = dt,
  60. total = recordCount
  61. };
  62. return Content(obj.ToJson());
  63. }
  64. /// <summary>
  65. /// 获取用户信息
  66. /// </summary>
  67. /// <param name="userId"></param>
  68. /// <param name="userCode"></param>
  69. /// <returns></returns>
  70. public ActionResult GetUser(int userId = 0, string userCode = "")
  71. {
  72. string sql = " 1=1 ";
  73. if (userId > 0)
  74. {
  75. sql += " and F_UserId=" + userId;
  76. }
  77. if (!string.IsNullOrWhiteSpace(userCode))
  78. {
  79. sql += " and F_UserCode='" + userCode + "'";
  80. }
  81. if (string.IsNullOrWhiteSpace(sql))
  82. return Error("获取失败");
  83. Model.T_Sys_UserAccount User = new Bll.T_Sys_UserAccount().GetModelList(sql).FirstOrDefault();
  84. return Success("获取成功", User);
  85. }
  86. }
  87. }