郑许地铁

QuickMsgsController.cs 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using ZXDT.CallCenter.Model;
  10. using ZXDT.CallCenter.MVCWeb.Models;
  11. /// <summary>
  12. /// 客服快捷回复
  13. /// </summary>
  14. namespace ZXDT.CallCenter.MVCWeb.Controllers
  15. {
  16. public class QuickMsgsController : BaseController
  17. {
  18. BLL.kf_quick_msgs busQuickMsgs = new BLL.kf_quick_msgs();
  19. #region 纯视图
  20. /// <summary>
  21. /// 回复列表
  22. /// </summary>
  23. /// <returns></returns>
  24. public ActionResult GetList()
  25. {
  26. return View();
  27. }
  28. /// <summary>
  29. /// 添加 视图
  30. /// </summary>
  31. /// <returns></returns>
  32. public ActionResult Add()
  33. {
  34. return View();
  35. }
  36. /// <summary>
  37. /// 修改 视图
  38. /// </summary>
  39. /// <returns></returns>
  40. public ActionResult Edit()
  41. {
  42. return View();
  43. }
  44. /// <summary>
  45. /// 历史记录
  46. /// </summary>
  47. /// <returns></returns>
  48. public ActionResult GetHistory()
  49. {
  50. return View();
  51. }
  52. #endregion
  53. [ActionName("GetListData")]
  54. public string GetListData(DateTime? NowDateTime,string key = "", int type = -1, int page = 0, int limit = 20)
  55. {
  56. string strWhere = string.Format(" service_id in (0,{0})", F_PId.ToInt32());
  57. if (!string.IsNullOrEmpty(key))
  58. {
  59. strWhere += string.Format(" and msg like '%{0}%'", key);
  60. }
  61. if (type != -1)
  62. {
  63. strWhere += string.Format(" and service_id {0}", type == 1 ? "!=0" : "=0");
  64. }
  65. DataTable dt = busQuickMsgs.GetListByPage(strWhere, " service_id asc, rate desc ", (page - 1) * limit, limit).Tables[0];
  66. int count = busQuickMsgs.GetRecordCount(strWhere);
  67. return Success("成功", dt, count);
  68. }
  69. [ActionName("GetData")]
  70. public string GettData(int id = 0)
  71. {
  72. if (id == 0)
  73. return Error("请输入ID");
  74. Model.kf_quick_msgs model = busQuickMsgs.GetModel(id);
  75. return Success("成功", model, 1);
  76. }
  77. [ActionName("adddata")]
  78. public string AddData(string msg = "", int type = 0,int rate=0)
  79. {
  80. if (string.IsNullOrEmpty(msg))
  81. {
  82. return Error("请输入值msg");
  83. }
  84. if (type != 1 && type != 0)
  85. {
  86. return Error("请输入值type");
  87. }
  88. string strWhere = string.Format(" msg='{0}' and service_id{1} ", msg, type==1 ?"="+F_PId.ToInt32():"=0");
  89. int count = busQuickMsgs.GetRecordCount(strWhere);
  90. if (count > 0)
  91. {
  92. return Error("已存在");
  93. }
  94. Model.kf_quick_msgs model = new kf_quick_msgs();
  95. model.service_id = type==0?0:F_PId.ToInt32();
  96. model.msg = msg;
  97. model.rate = rate;
  98. if (busQuickMsgs.Add(model))
  99. {
  100. AddLog("kf_quick_msgs", model.id.ToString(),"添加消息","", model);
  101. return Success("成功", model, 1);
  102. }
  103. else
  104. return Error("失败");
  105. }
  106. [ActionName("editdata")]
  107. public string EditData(string msg = "",int id=0,int rate=-1)
  108. {
  109. if (string.IsNullOrEmpty(msg))
  110. {
  111. return Error("请输入值msg");
  112. }
  113. if(id==0)
  114. return Error("请输入值id");
  115. Model.kf_quick_msgs model = busQuickMsgs.GetModel(id);
  116. string modeljson = JsonConvert.SerializeObject(model);
  117. model.msg = msg;
  118. if (rate >= 0)
  119. {
  120. model.rate = rate;
  121. }
  122. if (busQuickMsgs.Update(model))
  123. {
  124. AddLog("kf_quick_msgs", model.id.ToString(), "修改消息", modeljson, model);
  125. return Success("成功", model, 1);
  126. }
  127. else
  128. return Error("失败");
  129. }
  130. [ActionName("deletedata")]
  131. public string DeleteData(int id = 0)
  132. {
  133. Model.kf_quick_msgs model = busQuickMsgs.GetModel(id);
  134. if (busQuickMsgs.Delete(id))
  135. {
  136. AddLog("kf_quick_msgs", model.id.ToString(), "删除消息", JsonConvert.SerializeObject(model), "");
  137. return Success("删除成功");
  138. }
  139. else
  140. return Error("失败");
  141. }
  142. }
  143. }