using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; using YTSoft.BaseCallCenter.Model; using YTSoft.BaseCallCenter.MVCWeb.Models; /// /// 客服快捷回复 /// namespace YTSoft.BaseCallCenter.MVCWeb.Controllers { public class QuickMsgsController : BaseController { BLL.kf_quick_msgs busQuickMsgs = new BLL.kf_quick_msgs(); #region 纯视图 /// /// 回复列表 /// /// public ActionResult GetList() { return View(); } /// /// 添加 视图 /// /// public ActionResult Add() { return View(); } /// /// 修改 视图 /// /// public ActionResult Edit() { return View(); } #endregion [ActionName("GetListData")] public string GetListData(string key = "", int type = -1, int page = 0, int limit = 20) { string strWhere = " 1=1 "; if (!string.IsNullOrEmpty(key)) { strWhere += string.Format(" and msg like '%{0}%'", key); } if (type != -1) { strWhere += string.Format(" and service_id {0}", type == 1 ? "!=0" : "=0"); } DataTable dt = busQuickMsgs.GetListByPage(strWhere, "", (page - 1) * limit, limit).Tables[0]; int count = busQuickMsgs.GetRecordCount(strWhere); return Success("成功", dt, count); } [ActionName("GetData")] public string GettData(int id = 0) { if (id == 0) return Error("请输入ID"); Model.kf_quick_msgs model = busQuickMsgs.GetModel(id); return Success("成功", model, 1); } [ActionName("adddata")] public string AddData(string msg = "", int type = 0) { if (string.IsNullOrEmpty(msg)) { return Error("请输入值msg"); } if (type != 1 && type != 0) { return Error("请输入值type"); } string strWhere = string.Format(" msg='{0}' and service_id{1} ", msg, type==1?"!=0":"=0"); int count = busQuickMsgs.GetRecordCount(strWhere); if (count > 0) { return Error("已存在"); } Model.kf_quick_msgs model = new kf_quick_msgs(); model.service_id = type; model.msg = msg; model.rate = 0; if (busQuickMsgs.Add(model)) { AddLog("kf_quick_msgs", model.id.ToString(),"添加消息","", model); return Success("成功", model, 1); } else return Error("失败"); } [ActionName("editdata")] public string EditData(string msg = "",int id=0) { if (string.IsNullOrEmpty(msg)) { return Error("请输入值msg"); } if(id==0) return Error("请输入值id"); Model.kf_quick_msgs model = busQuickMsgs.GetModel(id); string modeljson = JsonConvert.SerializeObject(model); model.msg = msg; if (busQuickMsgs.Update(model)) { AddLog("kf_quick_msgs", model.id.ToString(), "修改消息", modeljson, model); return Success("成功", model, 1); } else return Error("失败"); } [ActionName("deletedata")] public string DeleteData(int id = 0) { Model.kf_quick_msgs model = busQuickMsgs.GetModel(id); if (busQuickMsgs.Delete(id)) { AddLog("kf_quick_msgs", model.id.ToString(), "删除消息", JsonConvert.SerializeObject(model), ""); return Success("删除成功"); } else return Error("失败"); } } }