地铁二期项目正式开始

QuickMsgsController.cs 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 YTSoft.BaseCallCenter.Model;
  10. using YTSoft.BaseCallCenter.MVCWeb.Models;
  11. /// <summary>
  12. /// 客服快捷回复
  13. /// </summary>
  14. namespace YTSoft.BaseCallCenter.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. #endregion
  45. [ActionName("GetListData")]
  46. public string GetListData(string key = "", int type = -1, int page = 0, int limit = 20)
  47. {
  48. string strWhere = " 1=1 ";
  49. if (!string.IsNullOrEmpty(key))
  50. {
  51. strWhere += string.Format(" and msg like '%{0}%'", key);
  52. }
  53. if (type != -1)
  54. {
  55. strWhere += string.Format(" and service_id {0}", type == 1 ? "!=0" : "=0");
  56. }
  57. DataTable dt = busQuickMsgs.GetListByPage(strWhere, "", (page - 1) * limit, limit).Tables[0];
  58. int count = busQuickMsgs.GetRecordCount(strWhere);
  59. return Success("成功", dt, count);
  60. }
  61. [ActionName("GetData")]
  62. public string GettData(int id = 0)
  63. {
  64. if (id == 0)
  65. return Error("请输入ID");
  66. Model.kf_quick_msgs model = busQuickMsgs.GetModel(id);
  67. return Success("成功", model, 1);
  68. }
  69. [ActionName("adddata")]
  70. public string AddData(string msg = "", int type = 0)
  71. {
  72. if (string.IsNullOrEmpty(msg))
  73. {
  74. return Error("请输入值msg");
  75. }
  76. if (type != 1 && type != 0)
  77. {
  78. return Error("请输入值type");
  79. }
  80. string strWhere = string.Format(" msg='{0}' and service_id{1} ", msg, type==1?"!=0":"=0");
  81. int count = busQuickMsgs.GetRecordCount(strWhere);
  82. if (count > 0)
  83. {
  84. return Error("已存在");
  85. }
  86. Model.kf_quick_msgs model = new kf_quick_msgs();
  87. model.service_id = type;
  88. model.msg = msg;
  89. model.rate = 0;
  90. if (busQuickMsgs.Add(model))
  91. {
  92. AddLog("kf_quick_msgs", model.id.ToString(),"添加消息","", model);
  93. return Success("成功", model, 1);
  94. }
  95. else
  96. return Error("失败");
  97. }
  98. [ActionName("editdata")]
  99. public string EditData(string msg = "",int id=0)
  100. {
  101. if (string.IsNullOrEmpty(msg))
  102. {
  103. return Error("请输入值msg");
  104. }
  105. if(id==0)
  106. return Error("请输入值id");
  107. Model.kf_quick_msgs model = busQuickMsgs.GetModel(id);
  108. string modeljson = JsonConvert.SerializeObject(model);
  109. model.msg = msg;
  110. if (busQuickMsgs.Update(model))
  111. {
  112. AddLog("kf_quick_msgs", model.id.ToString(), "修改消息", modeljson, model);
  113. return Success("成功", model, 1);
  114. }
  115. else
  116. return Error("失败");
  117. }
  118. [ActionName("deletedata")]
  119. public string DeleteData(int id = 0)
  120. {
  121. Model.kf_quick_msgs model = busQuickMsgs.GetModel(id);
  122. if (busQuickMsgs.Delete(id))
  123. {
  124. AddLog("kf_quick_msgs", model.id.ToString(), "删除消息", JsonConvert.SerializeObject(model), "");
  125. return Success("删除成功");
  126. }
  127. else
  128. return Error("失败");
  129. }
  130. }
  131. }