人民医院API

MobiledataController.cs 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.CallTel
  9. {
  10. public class MobiledataController : BaseController
  11. {
  12. //获取号码归属地列表
  13. public ActionResult GetList(string strtelnum,int page = 1, int pagesize = 10)
  14. {
  15. string sql = " and F_IsDelete=0";
  16. DataTable dt = new DataTable();
  17. if (strtelnum != null && strtelnum.Trim() != "")
  18. {
  19. sql += " and (F_MobileNum= '" + strtelnum.Trim() + "' or F_ZipCode like '%" + strtelnum.Trim()
  20. + "%' or F_CityDes like '%" + strtelnum.Trim() + "%'or F_CardDes like '%" + strtelnum.Trim() + "%')";
  21. }
  22. int recordCount = 0;
  23. dt = Bll.PagerBll.GetListPager(
  24. "T_Sys_MobileData with(nolock)",
  25. "F_Id",
  26. "*",
  27. sql,
  28. "ORDER BY F_Id desc",
  29. pagesize,
  30. page,
  31. true,
  32. out recordCount);
  33. var obj = new
  34. {
  35. state = "success",
  36. message = "成功",
  37. rows = dt,
  38. total = recordCount
  39. };
  40. return Content(obj.ToJson());
  41. }
  42. //获取详情
  43. public ActionResult GetMobiledata(int id)
  44. {
  45. return Success("获取号码归属地成功", new Bll.T_Sys_MobileData().GetModel(id));
  46. }
  47. //获取号码归属地
  48. public ActionResult GetMobiledataByNum(string mobileNum)
  49. {
  50. if (!string.IsNullOrEmpty(mobileNum))
  51. {
  52. Model.T_Sys_MobileData dModel = new Bll.T_Sys_MobileData().GetModelList(" F_MobileNum='" + mobileNum.Trim() + "' ").FirstOrDefault();
  53. if (dModel != null)
  54. {
  55. return Success("获取号码归属地成功", dModel);
  56. }
  57. else
  58. {
  59. return Error("获取号码归属地失败");
  60. }
  61. }
  62. else
  63. {
  64. return Error("获取参数失败");
  65. }
  66. }
  67. //添加/编辑号码归属地
  68. public ActionResult AddMobiledata(string mobileNum, string zipCode, string cityDes, string cardDes, int id = 0)
  69. {
  70. Bll.T_Sys_MobileData dBLL = new Bll.T_Sys_MobileData();
  71. Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
  72. if (id != 0)
  73. {
  74. dModel = dBLL.GetModel(id);
  75. if (dModel != null)
  76. {
  77. if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
  78. {
  79. dModel.F_MobileNum = mobileNum.Trim();
  80. }
  81. if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
  82. {
  83. dModel.F_ZipCode = zipCode.Trim();
  84. }
  85. if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
  86. {
  87. dModel.F_CityDes = cityDes.Trim();
  88. }
  89. if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
  90. {
  91. dModel.F_CardDes = cardDes.Trim();
  92. }
  93. bool b = dBLL.Update(dModel);
  94. if (b)
  95. {
  96. return Success("编辑成功");
  97. }
  98. else
  99. {
  100. return Error("编辑失败");
  101. }
  102. }
  103. else
  104. {
  105. return Error("编辑失败");
  106. }
  107. }
  108. else
  109. {
  110. dModel = new Model.T_Sys_MobileData();
  111. if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
  112. {
  113. dModel.F_MobileNum = mobileNum.Trim();
  114. }
  115. if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
  116. {
  117. dModel.F_ZipCode = zipCode.Trim();
  118. }
  119. if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
  120. {
  121. dModel.F_CityDes = cityDes.Trim();
  122. }
  123. if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
  124. {
  125. dModel.F_CardDes = cardDes.Trim();
  126. }
  127. dModel.F_IsDelete = 0;
  128. dModel.F_CreateUser = User.F_UserCode;
  129. dModel.F_CreateTime = DateTime.Now;
  130. int n = dBLL.Add(dModel);
  131. if (n > 0)
  132. {
  133. return Success("添加成功", n);
  134. }
  135. else
  136. {
  137. return Error("添加失败");
  138. }
  139. }
  140. }
  141. //删除号码归属地记录
  142. public ActionResult DelMobiledata(string[] nums)
  143. {
  144. if (nums != null && nums.Length > 0)
  145. {
  146. string idd = " ";
  147. foreach (string str in nums)
  148. {
  149. idd += "'" + str + "',";
  150. }
  151. if (new Bll.T_Sys_MobileData().DeleteList(idd.TrimEnd(','), User.F_UserCode))
  152. {
  153. return Success("删除成功");
  154. }
  155. else
  156. return Error("删除失败");
  157. }
  158. else
  159. {
  160. return Error("请选择要删除的记录");
  161. }
  162. }
  163. }
  164. }