| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- using RMYY_CallCenter_Api.Utility;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace RMYY_CallCenter_Api.Controllers.CallTel
- {
- public class MobiledataController : BaseController
- {
- //获取号码归属地列表
- public ActionResult GetList(string strtelnum,int page = 1, int pagesize = 10)
- {
-
- string sql = " and F_IsDelete=0";
- DataTable dt = new DataTable();
- if (strtelnum != null && strtelnum.Trim() != "")
- {
- sql += " and (F_MobileNum= '" + strtelnum.Trim() + "' or F_ZipCode like '%" + strtelnum.Trim()
- + "%' or F_CityDes like '%" + strtelnum.Trim() + "%'or F_CardDes like '%" + strtelnum.Trim() + "%')";
- }
- int recordCount = 0;
- dt = Bll.PagerBll.GetListPager(
- "T_Sys_MobileData with(nolock)",
- "F_Id",
- "*",
- sql,
- "ORDER BY F_Id desc",
- pagesize,
- page,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
-
- }
- //获取详情
- public ActionResult GetMobiledata(int id)
- {
- return Success("获取号码归属地成功", new Bll.T_Sys_MobileData().GetModel(id));
- }
- //获取号码归属地
- public ActionResult GetMobiledataByNum(string mobileNum)
- {
- if (!string.IsNullOrEmpty(mobileNum))
- {
- Model.T_Sys_MobileData dModel = new Bll.T_Sys_MobileData().GetModelList(" F_MobileNum='" + mobileNum.Trim() + "' ").FirstOrDefault();
- if (dModel != null)
- {
- return Success("获取号码归属地成功", dModel);
- }
- else
- {
- return Error("获取号码归属地失败");
- }
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- //添加/编辑号码归属地
- public ActionResult AddMobiledata(string mobileNum, string zipCode, string cityDes, string cardDes, int id = 0)
- {
- Bll.T_Sys_MobileData dBLL = new Bll.T_Sys_MobileData();
- Model.T_Sys_MobileData dModel = new Model.T_Sys_MobileData();
- if (id != 0)
- {
- dModel = dBLL.GetModel(id);
- if (dModel != null)
- {
- if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
- {
- dModel.F_MobileNum = mobileNum.Trim();
- }
- if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
- {
- dModel.F_ZipCode = zipCode.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
- {
- dModel.F_CityDes = cityDes.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
- {
- dModel.F_CardDes = cardDes.Trim();
- }
- bool b = dBLL.Update(dModel);
- if (b)
- {
- return Success("编辑成功");
- }
- else
- {
- return Error("编辑失败");
- }
- }
- else
- {
- return Error("编辑失败");
- }
- }
- else
- {
- dModel = new Model.T_Sys_MobileData();
- if (!string.IsNullOrWhiteSpace(mobileNum.Trim()))
- {
- dModel.F_MobileNum = mobileNum.Trim();
- }
- if (!string.IsNullOrWhiteSpace(zipCode.Trim()))
- {
- dModel.F_ZipCode = zipCode.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cityDes.Trim()))
- {
- dModel.F_CityDes = cityDes.Trim();
- }
- if (!string.IsNullOrWhiteSpace(cardDes.Trim()))
- {
- dModel.F_CardDes = cardDes.Trim();
- }
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = User.F_UserCode;
- dModel.F_CreateTime = DateTime.Now;
- int n = dBLL.Add(dModel);
- if (n > 0)
- {
- return Success("添加成功", n);
- }
- else
- {
- return Error("添加失败");
- }
- }
- }
- //删除号码归属地记录
- public ActionResult DelMobiledata(string[] nums)
- {
- if (nums != null && nums.Length > 0)
- {
- string idd = " ";
- foreach (string str in nums)
- {
- idd += "'" + str + "',";
- }
- if (new Bll.T_Sys_MobileData().DeleteList(idd.TrimEnd(','), User.F_UserCode))
- {
- return Success("删除成功");
- }
- else
- return Error("删除失败");
- }
- else
- {
- return Error("请选择要删除的记录");
- }
- }
- }
- }
|